LayoutLib: don't render when shader's local matrix is set to 0 scale.
Change-Id: I7726d87f3dd0475ac662f535a08c6435b8b9ed1f
This commit is contained in:
@ -73,6 +73,14 @@ public abstract class Shader_Delegate {
|
||||
public abstract boolean isSupported();
|
||||
public abstract String getSupportMessage();
|
||||
|
||||
public boolean isValid() {
|
||||
if (mLocalMatrix != null && mLocalMatrix.getAffineTransform().getDeterminant() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---- native methods ----
|
||||
|
||||
@LayoutlibDelegate
|
||||
@ -126,5 +134,4 @@ public abstract class Shader_Delegate {
|
||||
|
||||
return new java.awt.geom.AffineTransform();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -603,6 +603,7 @@ public class GcSnapshot {
|
||||
createCustomGraphics(originalGraphics, paint, compositeOnly, forceSrcMode) :
|
||||
(Graphics2D) originalGraphics.create();
|
||||
|
||||
if (configuredGraphics2D != null) {
|
||||
try {
|
||||
drawable.draw(configuredGraphics2D, paint);
|
||||
} finally {
|
||||
@ -610,6 +611,7 @@ public class GcSnapshot {
|
||||
configuredGraphics2D.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private GcSnapshot doRestore() {
|
||||
if (mPrevious != null) {
|
||||
@ -680,11 +682,13 @@ public class GcSnapshot {
|
||||
Graphics2D g = createCustomGraphics(baseGfx, mLocalLayerPaint,
|
||||
true /*alphaOnly*/, false /*forceSrcMode*/);
|
||||
|
||||
if (g != null) {
|
||||
g.drawImage(mLocalLayer.getImage(),
|
||||
mLayerBounds.left, mLayerBounds.top, mLayerBounds.right, mLayerBounds.bottom,
|
||||
mLayerBounds.left, mLayerBounds.top, mLayerBounds.right, mLayerBounds.bottom,
|
||||
null);
|
||||
g.dispose();
|
||||
}
|
||||
|
||||
baseGfx.dispose();
|
||||
}
|
||||
@ -714,12 +718,18 @@ public class GcSnapshot {
|
||||
Shader_Delegate shaderDelegate = paint.getShader();
|
||||
if (shaderDelegate != null) {
|
||||
if (shaderDelegate.isSupported()) {
|
||||
// shader could have a local matrix that's not valid (for instance 0 scaling).
|
||||
if (shaderDelegate.isValid()) {
|
||||
java.awt.Paint shaderPaint = shaderDelegate.getJavaPaint();
|
||||
assert shaderPaint != null;
|
||||
if (shaderPaint != null) {
|
||||
g.setPaint(shaderPaint);
|
||||
customShader = true;
|
||||
}
|
||||
} else {
|
||||
g.dispose();
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
Bridge.getLog().fidelityWarning(LayoutLog.TAG_SHADER,
|
||||
shaderDelegate.getSupportMessage(),
|
||||
@ -742,7 +752,7 @@ public class GcSnapshot {
|
||||
|
||||
if (forceSrcMode) {
|
||||
g.setComposite(AlphaComposite.getInstance(
|
||||
AlphaComposite.SRC, (float) alpha / 255.f));
|
||||
AlphaComposite.SRC, alpha / 255.f));
|
||||
} else {
|
||||
boolean customXfermode = false;
|
||||
Xfermode_Delegate xfermodeDelegate = paint.getXfermode();
|
||||
@ -766,7 +776,7 @@ public class GcSnapshot {
|
||||
// that will handle the alpha.
|
||||
if (customXfermode == false && alpha != 0xFF) {
|
||||
g.setComposite(AlphaComposite.getInstance(
|
||||
AlphaComposite.SRC_OVER, (float) alpha / 255.f));
|
||||
AlphaComposite.SRC_OVER, alpha / 255.f));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user