diff options
author | Derek Sollenberger <djsollen@google.com> | 2013-05-08 10:59:47 -0400 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2013-05-08 10:59:47 -0400 |
commit | 3bd9a6dc6b30ed0ce40ca9087ca0f4b1ca789100 (patch) | |
tree | 248c2e767a1674ddb2ec2cdf8f2e3e49c5b3ee36 /graphics | |
parent | d28653df6580b76559374580764aa2e86d6c2f48 (diff) | |
download | frameworks_base-3bd9a6dc6b30ed0ce40ca9087ca0f4b1ca789100.zip frameworks_base-3bd9a6dc6b30ed0ce40ca9087ca0f4b1ca789100.tar.gz frameworks_base-3bd9a6dc6b30ed0ce40ca9087ca0f4b1ca789100.tar.bz2 |
Fix error where clips/matrices are incorrectly transferred.
In these cases the caller passes in a NULL bitmap and expects it
to clear the canvas state. This change preserves that behavior.
bug: 8738494
Change-Id: I7ebf6a74bab3c2822849a3404de3828fec8d3084
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/Canvas.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java index cc7f23f..79bf54b 100644 --- a/graphics/java/android/graphics/Canvas.java +++ b/graphics/java/android/graphics/Canvas.java @@ -146,11 +146,13 @@ public class Canvas { * Replace existing canvas while ensuring that the swap has occurred before * the previous native canvas is unreferenced. */ - private void safeCanvasSwap(int nativeCanvas) { + private void safeCanvasSwap(int nativeCanvas, boolean copyState) { final int oldCanvas = mNativeCanvas; mNativeCanvas = nativeCanvas; mFinalizer.mNativeCanvas = nativeCanvas; - copyNativeCanvasState(oldCanvas, mNativeCanvas); + if (copyState) { + copyNativeCanvasState(oldCanvas, mNativeCanvas); + } finalizer(oldCanvas); } @@ -180,9 +182,10 @@ public class Canvas { } /** - * Specify a bitmap for the canvas to draw into. As a side-effect, the - * canvas' target density is updated to match that of the bitmap while all - * other state such as the layers, filters, matrix, and clip are reset. + * Specify a bitmap for the canvas to draw into. All canvas state such as + * layers, filters, and the save/restore stack are reset with the exception + * of the current matrix and clip stack. Additionally, as a side-effect + * the canvas' target density is updated to match that of the bitmap. * * @param bitmap Specifies a mutable bitmap for the canvas to draw into. * @see #setDensity(int) @@ -194,7 +197,7 @@ public class Canvas { } if (bitmap == null) { - safeCanvasSwap(initRaster(0)); + safeCanvasSwap(initRaster(0), false); mDensity = Bitmap.DENSITY_NONE; } else { if (!bitmap.isMutable()) { @@ -202,7 +205,7 @@ public class Canvas { } throwIfRecycled(bitmap); - safeCanvasSwap(initRaster(bitmap.ni())); + safeCanvasSwap(initRaster(bitmap.ni()), true); mDensity = bitmap.mDensity; } |