Loading tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java +8 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -101,5 +109,4 @@ public abstract class Shader_Delegate { return new java.awt.geom.AffineTransform(); } } tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java +28 −18 Original line number Diff line number Diff line Loading @@ -609,6 +609,7 @@ public class GcSnapshot { createCustomGraphics(originalGraphics, paint, compositeOnly, forceSrcMode) : (Graphics2D) originalGraphics.create(); if (configuredGraphics2D != null) { try { drawable.draw(configuredGraphics2D, paint); layer.change(); Loading @@ -617,6 +618,7 @@ public class GcSnapshot { configuredGraphics2D.dispose(); } } } private GcSnapshot doRestore() { if (mPrevious != null) { Loading Loading @@ -687,11 +689,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(); } Loading Loading @@ -721,12 +725,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(), Loading @@ -749,7 +759,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(); Loading @@ -773,7 +783,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)); } } Loading Loading
tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java +8 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -101,5 +109,4 @@ public abstract class Shader_Delegate { return new java.awt.geom.AffineTransform(); } }
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java +28 −18 Original line number Diff line number Diff line Loading @@ -609,6 +609,7 @@ public class GcSnapshot { createCustomGraphics(originalGraphics, paint, compositeOnly, forceSrcMode) : (Graphics2D) originalGraphics.create(); if (configuredGraphics2D != null) { try { drawable.draw(configuredGraphics2D, paint); layer.change(); Loading @@ -617,6 +618,7 @@ public class GcSnapshot { configuredGraphics2D.dispose(); } } } private GcSnapshot doRestore() { if (mPrevious != null) { Loading Loading @@ -687,11 +689,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(); } Loading Loading @@ -721,12 +725,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(), Loading @@ -749,7 +759,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(); Loading @@ -773,7 +783,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)); } } Loading