Merge 59aad78e
from master. do not merge.
LayoutLib: don't render when shader's local matrix is set to 0 scale. Change-Id: I02c0ddd856026357f468dcc8b81e0520470118de
This commit is contained in:
@ -73,6 +73,14 @@ public abstract class Shader_Delegate {
|
|||||||
public abstract boolean isSupported();
|
public abstract boolean isSupported();
|
||||||
public abstract String getSupportMessage();
|
public abstract String getSupportMessage();
|
||||||
|
|
||||||
|
public boolean isValid() {
|
||||||
|
if (mLocalMatrix != null && mLocalMatrix.getAffineTransform().getDeterminant() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// ---- native methods ----
|
// ---- native methods ----
|
||||||
|
|
||||||
@LayoutlibDelegate
|
@LayoutlibDelegate
|
||||||
@ -101,5 +109,4 @@ public abstract class Shader_Delegate {
|
|||||||
|
|
||||||
return new java.awt.geom.AffineTransform();
|
return new java.awt.geom.AffineTransform();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -609,6 +609,7 @@ public class GcSnapshot {
|
|||||||
createCustomGraphics(originalGraphics, paint, compositeOnly, forceSrcMode) :
|
createCustomGraphics(originalGraphics, paint, compositeOnly, forceSrcMode) :
|
||||||
(Graphics2D) originalGraphics.create();
|
(Graphics2D) originalGraphics.create();
|
||||||
|
|
||||||
|
if (configuredGraphics2D != null) {
|
||||||
try {
|
try {
|
||||||
drawable.draw(configuredGraphics2D, paint);
|
drawable.draw(configuredGraphics2D, paint);
|
||||||
layer.change();
|
layer.change();
|
||||||
@ -617,6 +618,7 @@ public class GcSnapshot {
|
|||||||
configuredGraphics2D.dispose();
|
configuredGraphics2D.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private GcSnapshot doRestore() {
|
private GcSnapshot doRestore() {
|
||||||
if (mPrevious != null) {
|
if (mPrevious != null) {
|
||||||
@ -687,11 +689,13 @@ public class GcSnapshot {
|
|||||||
Graphics2D g = createCustomGraphics(baseGfx, mLocalLayerPaint,
|
Graphics2D g = createCustomGraphics(baseGfx, mLocalLayerPaint,
|
||||||
true /*alphaOnly*/, false /*forceSrcMode*/);
|
true /*alphaOnly*/, false /*forceSrcMode*/);
|
||||||
|
|
||||||
|
if (g != null) {
|
||||||
g.drawImage(mLocalLayer.getImage(),
|
g.drawImage(mLocalLayer.getImage(),
|
||||||
mLayerBounds.left, mLayerBounds.top, mLayerBounds.right, mLayerBounds.bottom,
|
mLayerBounds.left, mLayerBounds.top, mLayerBounds.right, mLayerBounds.bottom,
|
||||||
mLayerBounds.left, mLayerBounds.top, mLayerBounds.right, mLayerBounds.bottom,
|
mLayerBounds.left, mLayerBounds.top, mLayerBounds.right, mLayerBounds.bottom,
|
||||||
null);
|
null);
|
||||||
g.dispose();
|
g.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
baseGfx.dispose();
|
baseGfx.dispose();
|
||||||
}
|
}
|
||||||
@ -721,12 +725,18 @@ public class GcSnapshot {
|
|||||||
Shader_Delegate shaderDelegate = paint.getShader();
|
Shader_Delegate shaderDelegate = paint.getShader();
|
||||||
if (shaderDelegate != null) {
|
if (shaderDelegate != null) {
|
||||||
if (shaderDelegate.isSupported()) {
|
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();
|
java.awt.Paint shaderPaint = shaderDelegate.getJavaPaint();
|
||||||
assert shaderPaint != null;
|
assert shaderPaint != null;
|
||||||
if (shaderPaint != null) {
|
if (shaderPaint != null) {
|
||||||
g.setPaint(shaderPaint);
|
g.setPaint(shaderPaint);
|
||||||
customShader = true;
|
customShader = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
g.dispose();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Bridge.getLog().fidelityWarning(LayoutLog.TAG_SHADER,
|
Bridge.getLog().fidelityWarning(LayoutLog.TAG_SHADER,
|
||||||
shaderDelegate.getSupportMessage(),
|
shaderDelegate.getSupportMessage(),
|
||||||
@ -749,7 +759,7 @@ public class GcSnapshot {
|
|||||||
|
|
||||||
if (forceSrcMode) {
|
if (forceSrcMode) {
|
||||||
g.setComposite(AlphaComposite.getInstance(
|
g.setComposite(AlphaComposite.getInstance(
|
||||||
AlphaComposite.SRC, (float) alpha / 255.f));
|
AlphaComposite.SRC, alpha / 255.f));
|
||||||
} else {
|
} else {
|
||||||
boolean customXfermode = false;
|
boolean customXfermode = false;
|
||||||
Xfermode_Delegate xfermodeDelegate = paint.getXfermode();
|
Xfermode_Delegate xfermodeDelegate = paint.getXfermode();
|
||||||
@ -773,7 +783,7 @@ public class GcSnapshot {
|
|||||||
// that will handle the alpha.
|
// that will handle the alpha.
|
||||||
if (customXfermode == false && alpha != 0xFF) {
|
if (customXfermode == false && alpha != 0xFF) {
|
||||||
g.setComposite(AlphaComposite.getInstance(
|
g.setComposite(AlphaComposite.getInstance(
|
||||||
AlphaComposite.SRC_OVER, (float) alpha / 255.f));
|
AlphaComposite.SRC_OVER, alpha / 255.f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user