Removed shade drawing optimization
Why?
- This optimization has caused many glitches, it easy to break and
we've done so a few times (technical debt.)
- It's unclear if not calling glClear() is still an optimization.
Most graphics cards actually expect a glClear and are optimized
to discard old frame buffers when the method is invoked
Change-Id: If1bb9b8bf4c907ca907dc1205ad05dabfefeba1b
Fixes: 113286511
Test: manual
Test: shalac@ is keeping an eye on the performance dashboard
(cherry picked from commit 90a38dd7f7b7c6dbbd31eafb8afeab90858f6aa6)
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 19492a0..11bd392 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -79,13 +79,6 @@
<!-- Show camera affordance on Keyguard -->
<bool name="config_keyguardShowCameraAffordance">false</bool>
- <!-- Whether we should use SRC drawing mode when drawing the scrim behind. If this flag is set,
- we change the canvas opacity so libhwui doesn't call glClear on our surface, and then we
- draw the scrim with SRC to overwrite the whole buffer, which saves us a layer of overdraw.
- However, SRC performs poorly on some devices, where it is more efficient to
- glClear + SRC_OVER, in which case this flag should be disabled. -->
- <bool name="config_status_bar_scrim_behind_use_src">true</bool>
-
<!-- The length of the vibration when the notification pops open. -->
<integer name="one_finger_pop_duration_ms">10</integer>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java
index eaa4c6d..3bc4342 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java
@@ -53,11 +53,8 @@
private static final String TAG = "ScrimView";
private final ColorExtractor.GradientColors mColors;
private int mDensity;
- private boolean mDrawAsSrc;
private float mViewAlpha = 1.0f;
private ValueAnimator mAlphaAnimator;
- private Rect mExcludedRect = new Rect();
- private boolean mHasExcludedArea;
private Drawable mDrawable;
private PorterDuffColorFilter mColorFilter;
private int mTintColor;
@@ -137,59 +134,8 @@
@Override
protected void onDraw(Canvas canvas) {
- if (mDrawAsSrc || mDrawable.getAlpha() > 0) {
- if (!mHasExcludedArea) {
- mDrawable.draw(canvas);
- } else {
- if (mExcludedRect.top > 0) {
- canvas.save();
- canvas.clipRect(0, 0, getWidth(), mExcludedRect.top);
- mDrawable.draw(canvas);
- canvas.restore();
- }
- if (mExcludedRect.left > 0) {
- canvas.save();
- canvas.clipRect(0, mExcludedRect.top, mExcludedRect.left,
- mExcludedRect.bottom);
- mDrawable.draw(canvas);
- canvas.restore();
- }
- if (mExcludedRect.right < getWidth()) {
- canvas.save();
- canvas.clipRect(mExcludedRect.right, mExcludedRect.top, getWidth(),
- mExcludedRect.bottom);
- mDrawable.draw(canvas);
- canvas.restore();
- }
- if (mExcludedRect.bottom < getHeight()) {
- canvas.save();
- canvas.clipRect(0, mExcludedRect.bottom, getWidth(), getHeight());
- mDrawable.draw(canvas);
- canvas.restore();
- }
- // We also need to draw the rounded corners of the background
- canvas.save();
- canvas.clipRect(mExcludedRect.left, mExcludedRect.top,
- mExcludedRect.left + mCornerRadius, mExcludedRect.top + mCornerRadius);
- mDrawable.draw(canvas);
- canvas.restore();
- canvas.save();
- canvas.clipRect(mExcludedRect.right - mCornerRadius, mExcludedRect.top,
- mExcludedRect.right, mExcludedRect.top + mCornerRadius);
- mDrawable.draw(canvas);
- canvas.restore();
- canvas.save();
- canvas.clipRect(mExcludedRect.left, mExcludedRect.bottom - mCornerRadius,
- mExcludedRect.left + mCornerRadius, mExcludedRect.bottom);
- mDrawable.draw(canvas);
- canvas.restore();
- canvas.save();
- canvas.clipRect(mExcludedRect.right - mCornerRadius,
- mExcludedRect.bottom - mCornerRadius,
- mExcludedRect.right, mExcludedRect.bottom);
- mDrawable.draw(canvas);
- canvas.restore();
- }
+ if (mDrawable.getAlpha() > 0) {
+ mDrawable.draw(canvas);
}
}
@@ -198,7 +144,6 @@
mDrawable.setCallback(this);
mDrawable.setBounds(getLeft(), getTop(), getRight(), getBottom());
mDrawable.setAlpha((int) (255 * mViewAlpha));
- setDrawAsSrc(mDrawAsSrc);
updateScreenSize();
invalidate();
}
@@ -211,12 +156,6 @@
}
}
- public void setDrawAsSrc(boolean asSrc) {
- mDrawAsSrc = asSrc;
- PorterDuff.Mode mode = asSrc ? PorterDuff.Mode.SRC : PorterDuff.Mode.SRC_OVER;
- mDrawable.setXfermode(new PorterDuffXfermode(mode));
- }
-
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
@@ -328,22 +267,6 @@
return mViewAlpha;
}
- public void setExcludedArea(Rect area) {
- if (area == null) {
- mHasExcludedArea = false;
- invalidate();
- return;
- }
-
- int left = Math.max(area.left, 0);
- int top = Math.max(area.top, 0);
- int right = Math.min(area.right, getWidth());
- int bottom = Math.min(area.bottom, getHeight());
- mExcludedRect.set(left, top, right, bottom);
- mHasExcludedArea = left < right && top < bottom;
- invalidate();
- }
-
public void setChangeRunnable(Runnable changeRunnable) {
mChangeRunnable = changeRunnable;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index 4f554b6..1883aa7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -394,9 +394,6 @@
};
private PorterDuffXfermode mSrcMode = new PorterDuffXfermode(PorterDuff.Mode.SRC);
private boolean mPulsing;
- private boolean mDrawBackgroundAsSrc;
- private boolean mFadingOut;
- private boolean mParentNotFullyVisible;
private boolean mGroupExpandedForMeasure;
private boolean mScrollable;
private View mForcedScroll;
@@ -789,21 +786,6 @@
R.dimen.heads_up_status_bar_padding);
}
- public void setDrawBackgroundAsSrc(boolean asSrc) {
- mDrawBackgroundAsSrc = asSrc;
- updateSrcDrawing();
- }
-
- private void updateSrcDrawing() {
- if (!mShouldDrawNotificationBackground) {
- return;
- }
-
- mBackgroundPaint.setXfermode(mDrawBackgroundAsSrc && !mFadingOut && !mParentNotFullyVisible
- ? mSrcMode : null);
- invalidate();
- }
-
private void notifyHeightChangeListener(ExpandableView view) {
notifyHeightChangeListener(view, false /* needsAnimation */);
}
@@ -1128,7 +1110,6 @@
&& !mHeadsUpAnimatingAway;
if (mIsClipped != clipped) {
mIsClipped = clipped;
- updateFadingState();
}
if (animatingClipping) {
@@ -2447,7 +2428,7 @@
startBackgroundAnimation();
} else {
mCurrentBounds.set(mBackgroundBounds);
- applyCurrentBackgroundBounds();
+ invalidate();
}
} else {
abortBackgroundAnimators();
@@ -2575,25 +2556,11 @@
private void setBackgroundTop(int top) {
mCurrentBounds.top = top;
- applyCurrentBackgroundBounds();
+ invalidate();
}
public void setBackgroundBottom(int bottom) {
mCurrentBounds.bottom = bottom;
- applyCurrentBackgroundBounds();
- }
-
- private void applyCurrentBackgroundBounds() {
- // If the background of the notification is not being drawn, then there is no need to
- // exclude an area in the scrim. Rather, the scrim's color should serve as the background.
- if (!mShouldDrawNotificationBackground) {
- return;
- }
-
- final boolean awake = mInterpolatedDarkAmount != 0 || mAmbientState.isDark();
- mScrimController.setExcludedBackgroundArea(
- mFadingOut || mParentNotFullyVisible || awake || mIsClipped ? null
- : mCurrentBounds);
invalidate();
}
@@ -4176,7 +4143,6 @@
updateBackground();
}
requestChildrenUpdate();
- applyCurrentBackgroundBounds();
updateWillNotDraw();
notifyHeightChangeListener(mShelf);
}
@@ -4650,35 +4616,6 @@
}
}
- public void setFadingOut(boolean fadingOut) {
- if (fadingOut != mFadingOut) {
- mFadingOut = fadingOut;
- updateFadingState();
- }
- }
-
- public void setParentNotFullyVisible(boolean parentNotFullyVisible) {
- if (mScrimController == null) {
- // we're not set up yet.
- return;
- }
- if (parentNotFullyVisible != mParentNotFullyVisible) {
- mParentNotFullyVisible = parentNotFullyVisible;
- updateFadingState();
- }
- }
-
- private void updateFadingState() {
- applyCurrentBackgroundBounds();
- updateSrcDrawing();
- }
-
- @Override
- public void setAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha) {
- super.setAlpha(alpha);
- setFadingOut(alpha != 1.0f);
- }
-
public void setQsExpanded(boolean qsExpanded) {
mQsExpanded = qsExpanded;
updateAlgorithmLayoutMinHeight();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 33ddfde..e5e5d40 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -2668,32 +2668,6 @@
setLaunchingAffordance(false);
}
- @Override
- public void setAlpha(float alpha) {
- super.setAlpha(alpha);
- updateFullyVisibleState(false /* forceNotFullyVisible */);
- }
-
- /**
- * Must be called before starting a ViewPropertyAnimator alpha animation because those
- * do NOT call setAlpha and therefore don't properly update the fullyVisibleState.
- */
- public void notifyStartFading() {
- updateFullyVisibleState(true /* forceNotFullyVisible */);
- }
-
- @Override
- public void setVisibility(int visibility) {
- super.setVisibility(visibility);
- updateFullyVisibleState(false /* forceNotFullyVisible */);
- }
-
- private void updateFullyVisibleState(boolean forceNotFullyVisible) {
- mNotificationStackScroller.setParentNotFullyVisible(forceNotFullyVisible
- || getAlpha() != 1.0f
- || getVisibility() != VISIBLE);
- }
-
/**
* Set whether we are currently launching an affordance. This is currently only set when
* launched via a camera gesture.
@@ -2992,10 +2966,6 @@
mNotificationStackScroller.setActivatedChild(o);
}
- public void setParentNotFullyVisible(boolean parent) {
- mNotificationStackScroller.setParentNotFullyVisible(parent);
- }
-
public void runAfterAnimationFinished(Runnable r) {
mNotificationStackScroller.runAfterAnimationFinished(r);
}
@@ -3020,8 +2990,4 @@
mNotificationStackScroller.setScrimController(scrimController);
updateShowEmptyShadeView();
}
-
- public void setDrawBackgroundAsSrc(boolean asSrc) {
- mNotificationStackScroller.setDrawBackgroundAsSrc(asSrc);
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
index 0c361ce..e3a7b75 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -685,10 +685,6 @@
return scrim.getTag(TAG_KEY_ANIM) != null;
}
- public void setDrawBehindAsSrc(boolean asSrc) {
- mScrimBehind.setDrawAsSrc(asSrc);
- }
-
@VisibleForTesting
void setOnAnimationFinished(Runnable onAnimationFinished) {
mOnAnimationFinished = onAnimationFinished;
@@ -800,10 +796,6 @@
return Handler.getMain();
}
- public void setExcludedBackgroundArea(Rect area) {
- mScrimBehind.setExcludedArea(area);
- }
-
public int getBackgroundColor() {
int color = mLockColors.getMainColor();
return Color.argb((int) (mScrimBehind.getViewAlpha() * Color.alpha(color)),
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 9beaa10..7ec4db2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -328,14 +328,6 @@
/** If true, the lockscreen will show a distinct wallpaper */
private static final boolean ENABLE_LOCKSCREEN_WALLPAPER = true;
- /**
- * Never let the alpha become zero for surfaces that draw with SRC - otherwise the RenderNode
- * won't draw anything and uninitialized memory will show through
- * if mScrimSrcModeEnabled. Note that 0.001 is rounded down to 0 in
- * libhwui.
- */
- private static final float SRC_MIN_ALPHA = 0.002f;
-
static {
boolean onlyCoreApps;
try {
@@ -485,7 +477,6 @@
protected boolean mDozing;
private boolean mDozingRequested;
- protected boolean mScrimSrcModeEnabled;
protected BackDropView mBackdrop;
protected ImageView mBackdropFront, mBackdropBack;
@@ -652,7 +643,6 @@
mVibrateOnOpening = mContext.getResources().getBoolean(
R.bool.config_vibrateOnIconAnimation);
mVibratorHelper = Dependency.get(VibratorHelper.class);
- mScrimSrcModeEnabled = res.getBoolean(R.bool.config_status_bar_scrim_behind_use_src);
DateTimeView.setReceiverHandler(Dependency.get(Dependency.TIME_TICK_HANDLER));
putComponent(StatusBar.class, this);
@@ -948,15 +938,6 @@
}
}, DozeParameters.getInstance(mContext),
mContext.getSystemService(AlarmManager.class));
- if (mScrimSrcModeEnabled) {
- Runnable runnable = () -> {
- boolean asSrc = mBackdrop.getVisibility() != View.VISIBLE;
- mScrimController.setDrawBehindAsSrc(asSrc);
- mNotificationPanel.setDrawBackgroundAsSrc(asSrc);
- };
- mBackdrop.setOnVisibilityChangedRunnable(runnable);
- runnable.run();
- }
mNotificationPanel.initDependencies(this, mGroupManager, mNotificationShelf,
mHeadsUpManager, mNotificationIconAreaController, mScrimController);
mDozeScrimController = new DozeScrimController(mScrimController, context,
@@ -1483,7 +1464,7 @@
if (mBackdrop.getVisibility() != View.VISIBLE) {
mBackdrop.setVisibility(View.VISIBLE);
if (allowEnterAnimation) {
- mBackdrop.setAlpha(SRC_MIN_ALPHA);
+ mBackdrop.setAlpha(0);
mBackdrop.animate().alpha(1f);
} else {
mBackdrop.animate().cancel();
@@ -1501,9 +1482,6 @@
mBackdropBack.getDrawable().getConstantState()
.newDrawable(mBackdropFront.getResources()).mutate();
mBackdropFront.setImageDrawable(drawable);
- if (mScrimSrcModeEnabled) {
- mBackdropFront.getDrawable().mutate().setXfermode(mSrcOverXferMode);
- }
mBackdropFront.setAlpha(1f);
mBackdropFront.setVisibility(View.VISIBLE);
} else {
@@ -1518,9 +1496,6 @@
} else {
mBackdropBack.setImageDrawable(artworkDrawable);
}
- if (mScrimSrcModeEnabled) {
- mBackdropBack.getDrawable().mutate().setXfermode(mSrcXferMode);
- }
if (mBackdropFront.getVisibility() == View.VISIBLE) {
if (DEBUG_MEDIA) {
@@ -1553,7 +1528,7 @@
} else {
mStatusBarWindowController.setBackdropShowing(false);
mBackdrop.animate()
- .alpha(SRC_MIN_ALPHA)
+ .alpha(0)
.setInterpolator(Interpolators.ACCELERATE_DECELERATE)
.setDuration(300)
.setStartDelay(0)
@@ -1765,10 +1740,6 @@
return mMediaManager.getMediaNotificationKey();
}
- public boolean isScrimSrcModeEnabled() {
- return mScrimSrcModeEnabled;
- }
-
/**
* To be called when there's a state change in StatusBarKeyguardViewManager.
*/
@@ -3410,7 +3381,6 @@
updateScrimController();
updateMediaMetaData(false, true);
mNotificationPanel.setAlpha(1);
- mNotificationPanel.setParentNotFullyVisible(true);
mNotificationPanel.animate()
.alpha(0)
.setStartDelay(FADE_KEYGUARD_START_DELAY)
@@ -3432,7 +3402,6 @@
* fading.
*/
public void fadeKeyguardWhilePulsing() {
- mNotificationPanel.notifyStartFading();
mNotificationPanel.animate()
.alpha(0f)
.setStartDelay(0)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
index 98f1a36..45b32c7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
@@ -227,20 +227,7 @@
@Override
protected void onAttachedToWindow () {
super.onAttachedToWindow();
-
- // We need to ensure that our window doesn't suffer from overdraw which would normally
- // occur if our window is translucent. Since we are drawing the whole window anyway with
- // the scrim, we don't need the window to be cleared in the beginning.
- if (mService.isScrimSrcModeEnabled()) {
- IBinder windowToken = getWindowToken();
- WindowManager.LayoutParams lp = (WindowManager.LayoutParams) getLayoutParams();
- lp.token = windowToken;
- setLayoutParams(lp);
- WindowManagerGlobal.getInstance().changeCanvasOpacity(windowToken, true);
- setWillNotDraw(false);
- } else {
- setWillNotDraw(!DEBUG);
- }
+ setWillNotDraw(!DEBUG);
}
@Override
@@ -394,26 +381,6 @@
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
- if (mService.isScrimSrcModeEnabled()) {
- // We need to ensure that our window is always drawn fully even when we have paddings,
- // since we simulate it to be opaque.
- int paddedBottom = getHeight() - getPaddingBottom();
- int paddedRight = getWidth() - getPaddingRight();
- if (getPaddingTop() != 0) {
- canvas.drawRect(0, 0, getWidth(), getPaddingTop(), mTransparentSrcPaint);
- }
- if (getPaddingBottom() != 0) {
- canvas.drawRect(0, paddedBottom, getWidth(), getHeight(), mTransparentSrcPaint);
- }
- if (getPaddingLeft() != 0) {
- canvas.drawRect(0, getPaddingTop(), getPaddingLeft(), paddedBottom,
- mTransparentSrcPaint);
- }
- if (getPaddingRight() != 0) {
- canvas.drawRect(paddedRight, getPaddingTop(), getWidth(), paddedBottom,
- mTransparentSrcPaint);
- }
- }
if (DEBUG) {
Paint pt = new Paint();
pt.setColor(0x80FFFF00);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/ScrimViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/ScrimViewTest.java
index 42dad11..c2611e4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/ScrimViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/ScrimViewTest.java
@@ -92,15 +92,6 @@
}
@Test
- public void testOnDraw_ExcludeRectDrawable() {
- mView.setExcludedArea(new Rect(10, 10, 20, 20));
- Canvas canvas = mock(Canvas.class);
- mView.onDraw(canvas);
- // One time for each rect side
- verify(canvas, times(8)).clipRect(anyInt(), anyInt(), anyInt(), anyInt());
- }
-
- @Test
public void setTint_set() {
int tint = Color.BLUE;
mView.setTint(tint);