OSDN Git Service

Turn off AA while notification expanding animation is running
authorStan Iliev <stani@google.com>
Tue, 6 Feb 2018 21:22:01 +0000 (16:22 -0500)
committerStan Iliev <stani@google.com>
Wed, 7 Feb 2018 19:27:52 +0000 (19:27 +0000)
Turn off AA from GriadientDrawable, while drawing with SRC
transfer mode. This CL speeds up drawing by avoiding intermediate
texture buffer in skia.

Bug:72804165
Test: Measured performance with systrace on opening a notifiation.
Change-Id: Icc69de90d81e8b1c4492f97722f72e7440d9acac

graphics/java/android/graphics/drawable/GradientDrawable.java
packages/SystemUI/src/com/android/systemui/statusbar/NotificationBackgroundView.java

index f5a6f49..8b5114c 100644 (file)
@@ -825,6 +825,14 @@ public class GradientDrawable extends Drawable {
         mFillPaint.setXfermode(mode);
     }
 
+    /**
+     * @param aa to draw this drawable with
+     * @hide
+     */
+    public void setAntiAlias(boolean aa) {
+        mFillPaint.setAntiAlias(aa);
+    }
+
     private void buildPathIfDirty() {
         final GradientState st = mGradientState;
         if (mPathIsDirty) {
index d6beb7f..ab89a52 100644 (file)
@@ -249,6 +249,9 @@ public class NotificationBackgroundView extends View {
                     (GradientDrawable) ((LayerDrawable) mBackground).getDrawable(0);
             gradientDrawable.setXfermode(
                     running ? new PorterDuffXfermode(PorterDuff.Mode.SRC) : null);
+            // Speed optimization: disable AA if transfer mode is not SRC_OVER. AA is not easy to
+            // spot during animation anyways.
+            gradientDrawable.setAntiAlias(!running);
         }
         if (!mExpandAnimationRunning) {
             setDrawableAlpha(mDrawableAlpha);