From 03b3e236a058b878ec467918610df8f94e83301c Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Tue, 12 Mar 2019 10:15:46 -0400 Subject: Restore Paint#nSetColor(@ColorInt) Bug: 127580253 Test: CtsGraphicsTestCases Perf: systrace Restored with a partial revert of "Add Paint#get(ShadowLayer)ColorLong" (commit 6ee411010ea270351d495bf357fc294304286a70). The original CL combined the @ColorInt and @ColorLong version for simplicity, but required doing extra work for the @ColorInt version. Separating them back out speeds it up at the cost of more code. Using systrace I see the following stats: Duration: (w/o this change) (w/ this change) avg: 0.020 ms 0.001 ms max: 9.141 ms 0.072 ms min: 0.005 ms 0.001 ms std: 0.074 ms 0.001 ms This change shows a significant speed improvement. It does not do the same for setShadowLayer, which is likely used less frequently. Change-Id: I9021864fcad7d0149b93674f09339f805c272994 --- graphics/java/android/graphics/Paint.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'graphics/java') diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java index 452f7c93f8aa..966e171a9c04 100644 --- a/graphics/java/android/graphics/Paint.java +++ b/graphics/java/android/graphics/Paint.java @@ -1048,7 +1048,8 @@ public class Paint { * @param color The new color (including alpha) to set in the paint. */ public void setColor(@ColorInt int color) { - setColor(Color.pack(color)); + nSetColor(mNativePaint, color); + mColor = Color.pack(color); } /** @@ -3192,6 +3193,8 @@ public class Paint { private static native void nSetColor(long paintPtr, long colorSpaceHandle, float r, float g, float b, float a); @CriticalNative + private static native void nSetColor(long paintPtr, @ColorInt int color); + @CriticalNative private static native void nSetStrikeThruText(long paintPtr, boolean strikeThruText); @CriticalNative private static native boolean nIsElegantTextHeight(long paintPtr); -- cgit v1.2.3-59-g8ed1b