Loading tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java +4 −1 Original line number Diff line number Diff line Loading @@ -86,11 +86,14 @@ public class BridgeRenderSession extends RenderSession { } @Override public Result render(long timeout) { public Result render(long timeout, boolean forceMeasure) { try { Bridge.prepareThread(); mLastResult = mSession.acquire(timeout); if (mLastResult.isSuccess()) { if (forceMeasure) { mSession.invalidateRenderingSize(); } mLastResult = mSession.render(false /*freshRender*/); } } finally { Loading tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java +17 −2 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Composite; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.Shape; import java.awt.geom.AffineTransform; Loading Loading @@ -615,8 +616,22 @@ public class GcSnapshot { return; } int width = layer.getImage().getWidth(); int height = layer.getImage().getHeight(); int width; int height; Rectangle clipBounds = originalGraphics.getClipBounds(); if (clipBounds != null) { if (clipBounds.width == 0 || clipBounds.height == 0) { // Clip is 0 so no need to paint anything. return; } // If we have clipBounds available, use them as they will always be // smaller than the full layer size. width = clipBounds.width; height = clipBounds.height; } else { width = layer.getImage().getWidth(); height = layer.getImage().getHeight(); } // Create a temporary image to which the color filter will be applied. BufferedImage image = new BufferedImage(width, height, Loading tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +15 −4 Original line number Diff line number Diff line Loading @@ -554,7 +554,14 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { // draw the views // create the BufferedImage into which the layout will be rendered. boolean newImage = false; if (newRenderSize || mCanvas == null) { // When disableBitmapCaching is true, we do not reuse mImage and // we create a new one in every render. // This is useful when mImage is just a wrapper of Graphics2D so // it doesn't get cached. boolean disableBitmapCaching = Boolean.TRUE.equals(params.getFlag( RenderParamsFlags.FLAG_KEY_DISABLE_BITMAP_CACHING)); if (newRenderSize || mCanvas == null || disableBitmapCaching) { if (params.getImageFactory() != null) { mImage = params.getImageFactory().getImage( mMeasuredScreenWidth, Loading @@ -581,8 +588,12 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { Bitmap bitmap = Bitmap_Delegate.createBitmap(mImage, true /*isMutable*/, hardwareConfig.getDensity()); if (mCanvas == null) { // create a Canvas around the Android bitmap mCanvas = new Canvas(bitmap); } else { mCanvas.setBitmap(bitmap); } mCanvas.setDensity(hardwareConfig.getDensity().getDpiValue()); } Loading Loading @@ -1631,7 +1642,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { return null; } private void invalidateRenderingSize() { public void invalidateRenderingSize() { mMeasuredScreenWidth = mMeasuredScreenHeight = -1; } Loading Loading
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java +4 −1 Original line number Diff line number Diff line Loading @@ -86,11 +86,14 @@ public class BridgeRenderSession extends RenderSession { } @Override public Result render(long timeout) { public Result render(long timeout, boolean forceMeasure) { try { Bridge.prepareThread(); mLastResult = mSession.acquire(timeout); if (mLastResult.isSuccess()) { if (forceMeasure) { mSession.invalidateRenderingSize(); } mLastResult = mSession.render(false /*freshRender*/); } } finally { Loading
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java +17 −2 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Composite; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.Shape; import java.awt.geom.AffineTransform; Loading Loading @@ -615,8 +616,22 @@ public class GcSnapshot { return; } int width = layer.getImage().getWidth(); int height = layer.getImage().getHeight(); int width; int height; Rectangle clipBounds = originalGraphics.getClipBounds(); if (clipBounds != null) { if (clipBounds.width == 0 || clipBounds.height == 0) { // Clip is 0 so no need to paint anything. return; } // If we have clipBounds available, use them as they will always be // smaller than the full layer size. width = clipBounds.width; height = clipBounds.height; } else { width = layer.getImage().getWidth(); height = layer.getImage().getHeight(); } // Create a temporary image to which the color filter will be applied. BufferedImage image = new BufferedImage(width, height, Loading
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +15 −4 Original line number Diff line number Diff line Loading @@ -554,7 +554,14 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { // draw the views // create the BufferedImage into which the layout will be rendered. boolean newImage = false; if (newRenderSize || mCanvas == null) { // When disableBitmapCaching is true, we do not reuse mImage and // we create a new one in every render. // This is useful when mImage is just a wrapper of Graphics2D so // it doesn't get cached. boolean disableBitmapCaching = Boolean.TRUE.equals(params.getFlag( RenderParamsFlags.FLAG_KEY_DISABLE_BITMAP_CACHING)); if (newRenderSize || mCanvas == null || disableBitmapCaching) { if (params.getImageFactory() != null) { mImage = params.getImageFactory().getImage( mMeasuredScreenWidth, Loading @@ -581,8 +588,12 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { Bitmap bitmap = Bitmap_Delegate.createBitmap(mImage, true /*isMutable*/, hardwareConfig.getDensity()); if (mCanvas == null) { // create a Canvas around the Android bitmap mCanvas = new Canvas(bitmap); } else { mCanvas.setBitmap(bitmap); } mCanvas.setDensity(hardwareConfig.getDensity().getDpiValue()); } Loading Loading @@ -1631,7 +1642,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { return null; } private void invalidateRenderingSize() { public void invalidateRenderingSize() { mMeasuredScreenWidth = mMeasuredScreenHeight = -1; } Loading