From d192911e95e054948790c6e189a7da0d6e1a5b1d Mon Sep 17 00:00:00 2001 From: Stan Iliev Date: Tue, 6 Feb 2018 16:22:01 -0500 Subject: [PATCH] Turn off AA while notification expanding animation is running 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 --- .../java/android/graphics/drawable/GradientDrawable.java | 8 ++++++++ .../systemui/statusbar/NotificationBackgroundView.java | 3 +++ 2 files changed, 11 insertions(+) diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java index f5a6f4910b1b2..8b5114c505818 100644 --- a/graphics/java/android/graphics/drawable/GradientDrawable.java +++ b/graphics/java/android/graphics/drawable/GradientDrawable.java @@ -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) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationBackgroundView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationBackgroundView.java index d6beb7fb26993..ab89a5287cdbf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationBackgroundView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationBackgroundView.java @@ -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);