diff options
author | Derek Sollenberger <djsollen@google.com> | 2014-03-31 13:52:39 -0400 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2014-05-07 09:36:04 -0400 |
commit | c29a0a4664a4b9871fadd668b632469a0db240b9 (patch) | |
tree | 33e324bd3698bf9c100f998389694e4baeefaa57 /graphics | |
parent | ae84e20b2a0cb77223d40f55c71011d3ae8c71c7 (diff) | |
download | frameworks_base-c29a0a4664a4b9871fadd668b632469a0db240b9.zip frameworks_base-c29a0a4664a4b9871fadd668b632469a0db240b9.tar.gz frameworks_base-c29a0a4664a4b9871fadd668b632469a0db240b9.tar.bz2 |
Avoid caching shadow properties in Java & HWUI.
bug: 10650594
Change-Id: I6f57df002710bb0567ed7e53fc0bfe96cfd504b8
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/Paint.java | 59 | ||||
-rw-r--r-- | graphics/java/android/graphics/drawable/ShapeDrawable.java | 2 |
2 files changed, 17 insertions, 44 deletions
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java index 1e1128e..457b3ea 100644 --- a/graphics/java/android/graphics/Paint.java +++ b/graphics/java/android/graphics/Paint.java @@ -55,27 +55,6 @@ public class Paint { /** * @hide */ - public boolean hasShadow; - /** - * @hide - */ - public float shadowDx; - /** - * @hide - */ - public float shadowDy; - /** - * @hide - */ - public float shadowRadius; - /** - * @hide - */ - public int shadowColor; - - /** - * @hide - */ public int mBidiFlags = BIDI_DEFAULT_LTR; static final Style[] sStyleArray = { @@ -492,12 +471,6 @@ public class Paint { mCompatScaling = 1; mInvCompatScaling = 1; - hasShadow = false; - shadowDx = 0; - shadowDy = 0; - shadowRadius = 0; - shadowColor = 0; - mBidiFlags = BIDI_DEFAULT_LTR; setTextLocale(Locale.getDefault()); setElegantTextHeight(false); @@ -538,12 +511,6 @@ public class Paint { mCompatScaling = paint.mCompatScaling; mInvCompatScaling = paint.mInvCompatScaling; - hasShadow = paint.hasShadow; - shadowDx = paint.shadowDx; - shadowDy = paint.shadowDy; - shadowRadius = paint.shadowRadius; - shadowColor = paint.shadowColor; - mBidiFlags = paint.mBidiFlags; mLocale = paint.mLocale; } @@ -1135,22 +1102,24 @@ public class Paint { * layer is removed. */ public void setShadowLayer(float radius, float dx, float dy, int color) { - hasShadow = radius > 0.0f; - shadowRadius = radius; - shadowDx = dx; - shadowDy = dy; - shadowColor = color; - nSetShadowLayer(radius, dx, dy, color); + native_setShadowLayer(mNativePaint, radius, dx, dy, color); } - - private native void nSetShadowLayer(float radius, float dx, float dy, int color); /** * Clear the shadow layer. */ public void clearShadowLayer() { - hasShadow = false; - nSetShadowLayer(0, 0, 0, 0); + setShadowLayer(0, 0, 0, 0); + } + + /** + * Checks if the paint has a shadow layer attached + * + * @return true if the paint has a shadow layer attached and false otherwise + * @hide + */ + public boolean hasShadowLayer() { + return native_hasShadowLayer(mNativePaint); } /** @@ -2295,4 +2264,8 @@ public class Paint { private static native void nativeGetCharArrayBounds(long nativePaint, char[] text, int index, int count, int bidiFlags, Rect bounds); private static native void finalizer(long nativePaint); + + private static native void native_setShadowLayer(long native_object, + float radius, float dx, float dy, int color); + private static native boolean native_hasShadowLayer(long native_object); } diff --git a/graphics/java/android/graphics/drawable/ShapeDrawable.java b/graphics/java/android/graphics/drawable/ShapeDrawable.java index 61b1b85..99ab4dd 100644 --- a/graphics/java/android/graphics/drawable/ShapeDrawable.java +++ b/graphics/java/android/graphics/drawable/ShapeDrawable.java @@ -237,7 +237,7 @@ public class ShapeDrawable extends Drawable { paint.setAlpha(modulateAlpha(prevAlpha, state.mAlpha)); // only draw shape if it may affect output - if (paint.getAlpha() != 0 || paint.getXfermode() != null || paint.hasShadow) { + if (paint.getAlpha() != 0 || paint.getXfermode() != null || paint.hasShadowLayer()) { final boolean clearColorFilter; if (mTintFilter != null && paint.getColorFilter() == null) { paint.setColorFilter(mTintFilter); |