am 1bde0f0e: am c0350c7c: am 5b002995: am 79107083: Merge "Add option to enable scrim SRC optimization" into lmp-dev
* commit '1bde0f0e69a352bec42b469e144d2c4cdd09df0f': Add option to enable scrim SRC optimization
This commit is contained in:
@@ -81,6 +81,13 @@
|
|||||||
<!-- Show camera affordance on Keyguard -->
|
<!-- Show camera affordance on Keyguard -->
|
||||||
<bool name="config_keyguardShowCameraAffordance">true</bool>
|
<bool name="config_keyguardShowCameraAffordance">true</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. -->
|
<!-- The length of the vibration when the notification pops open. -->
|
||||||
<integer name="one_finger_pop_duration_ms">10</integer>
|
<integer name="one_finger_pop_duration_ms">10</integer>
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class ScrimView extends View
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
if (mDrawAsSrc || !mIsEmpty) {
|
if (mDrawAsSrc || (!mIsEmpty && mViewAlpha > 0f)) {
|
||||||
PorterDuff.Mode mode = mDrawAsSrc ? PorterDuff.Mode.SRC : PorterDuff.Mode.SRC_OVER;
|
PorterDuff.Mode mode = mDrawAsSrc ? PorterDuff.Mode.SRC : PorterDuff.Mode.SRC_OVER;
|
||||||
int color = mScrimColor;
|
int color = mScrimColor;
|
||||||
color = Color.argb((int) (Color.alpha(color) * mViewAlpha), Color.red(color),
|
color = Color.argb((int) (Color.alpha(color) * mViewAlpha), Color.red(color),
|
||||||
|
|||||||
@@ -430,6 +430,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
private boolean mVisible;
|
private boolean mVisible;
|
||||||
private boolean mWaitingForKeyguardExit;
|
private boolean mWaitingForKeyguardExit;
|
||||||
private boolean mDozing;
|
private boolean mDozing;
|
||||||
|
private boolean mScrimSrcModeEnabled;
|
||||||
|
|
||||||
private Interpolator mLinearOutSlowIn;
|
private Interpolator mLinearOutSlowIn;
|
||||||
private Interpolator mLinearInterpolator = new LinearInterpolator();
|
private Interpolator mLinearInterpolator = new LinearInterpolator();
|
||||||
@@ -569,6 +570,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
|
mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
|
||||||
.getDefaultDisplay();
|
.getDefaultDisplay();
|
||||||
updateDisplaySize();
|
updateDisplaySize();
|
||||||
|
mScrimSrcModeEnabled = mContext.getResources().getBoolean(
|
||||||
|
R.bool.config_status_bar_scrim_behind_use_src);
|
||||||
super.start(); // calls createAndAddWindows()
|
super.start(); // calls createAndAddWindows()
|
||||||
|
|
||||||
mMediaSessionManager
|
mMediaSessionManager
|
||||||
@@ -737,7 +740,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
|
|
||||||
ScrimView scrimBehind = (ScrimView) mStatusBarWindow.findViewById(R.id.scrim_behind);
|
ScrimView scrimBehind = (ScrimView) mStatusBarWindow.findViewById(R.id.scrim_behind);
|
||||||
ScrimView scrimInFront = (ScrimView) mStatusBarWindow.findViewById(R.id.scrim_in_front);
|
ScrimView scrimInFront = (ScrimView) mStatusBarWindow.findViewById(R.id.scrim_in_front);
|
||||||
mScrimController = new ScrimController(scrimBehind, scrimInFront);
|
mScrimController = new ScrimController(scrimBehind, scrimInFront, mScrimSrcModeEnabled);
|
||||||
mScrimController.setBackDropView(mBackdrop);
|
mScrimController.setBackDropView(mBackdrop);
|
||||||
mStatusBarView.setScrimController(mScrimController);
|
mStatusBarView.setScrimController(mScrimController);
|
||||||
|
|
||||||
@@ -1870,7 +1873,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
if (mBackdropBack.getDrawable() != null) {
|
if (mBackdropBack.getDrawable() != null) {
|
||||||
Drawable drawable = mBackdropBack.getDrawable();
|
Drawable drawable = mBackdropBack.getDrawable();
|
||||||
mBackdropFront.setImageDrawable(drawable);
|
mBackdropFront.setImageDrawable(drawable);
|
||||||
mBackdropFront.getDrawable().mutate().setXfermode(mSrcOverXferMode);
|
if (mScrimSrcModeEnabled) {
|
||||||
|
mBackdropFront.getDrawable().mutate().setXfermode(mSrcOverXferMode);
|
||||||
|
}
|
||||||
mBackdropFront.setAlpha(1f);
|
mBackdropFront.setAlpha(1f);
|
||||||
mBackdropFront.setVisibility(View.VISIBLE);
|
mBackdropFront.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
@@ -1885,7 +1890,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
} else {
|
} else {
|
||||||
mBackdropBack.setImageBitmap(artworkBitmap);
|
mBackdropBack.setImageBitmap(artworkBitmap);
|
||||||
}
|
}
|
||||||
mBackdropBack.getDrawable().mutate().setXfermode(mSrcXferMode);
|
if (mScrimSrcModeEnabled) {
|
||||||
|
mBackdropBack.getDrawable().mutate().setXfermode(mSrcXferMode);
|
||||||
|
}
|
||||||
|
|
||||||
if (mBackdropFront.getVisibility() == View.VISIBLE) {
|
if (mBackdropFront.getVisibility() == View.VISIBLE) {
|
||||||
if (DEBUG_MEDIA) {
|
if (DEBUG_MEDIA) {
|
||||||
@@ -2134,6 +2141,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
return mMediaNotificationKey;
|
return mMediaNotificationKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isScrimSrcModeEnabled() {
|
||||||
|
return mScrimSrcModeEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All changes to the status bar and notifications funnel through here and are batched.
|
* All changes to the status bar and notifications funnel through here and are batched.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -74,8 +74,9 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener {
|
|||||||
private final Interpolator mInterpolator = new DecelerateInterpolator();
|
private final Interpolator mInterpolator = new DecelerateInterpolator();
|
||||||
private final Interpolator mLinearOutSlowInInterpolator;
|
private final Interpolator mLinearOutSlowInInterpolator;
|
||||||
private BackDropView mBackDropView;
|
private BackDropView mBackDropView;
|
||||||
|
private boolean mScrimSrcEnabled;
|
||||||
|
|
||||||
public ScrimController(ScrimView scrimBehind, ScrimView scrimInFront) {
|
public ScrimController(ScrimView scrimBehind, ScrimView scrimInFront, boolean scrimSrcEnabled) {
|
||||||
mScrimBehind = scrimBehind;
|
mScrimBehind = scrimBehind;
|
||||||
mScrimInFront = scrimInFront;
|
mScrimInFront = scrimInFront;
|
||||||
final Context context = scrimBehind.getContext();
|
final Context context = scrimBehind.getContext();
|
||||||
@@ -83,6 +84,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener {
|
|||||||
mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
|
mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
|
||||||
android.R.interpolator.linear_out_slow_in);
|
android.R.interpolator.linear_out_slow_in);
|
||||||
mDozeParameters = new DozeParameters(context);
|
mDozeParameters = new DozeParameters(context);
|
||||||
|
mScrimSrcEnabled = scrimSrcEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeyguardShowing(boolean showing) {
|
public void setKeyguardShowing(boolean showing) {
|
||||||
@@ -384,7 +386,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateScrimBehindDrawingMode() {
|
private void updateScrimBehindDrawingMode() {
|
||||||
boolean asSrc = mBackDropView.getVisibility() != View.VISIBLE;
|
boolean asSrc = mBackDropView.getVisibility() != View.VISIBLE && mScrimSrcEnabled;
|
||||||
mScrimBehind.setDrawAsSrc(asSrc);
|
mScrimBehind.setDrawAsSrc(asSrc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ public class StatusBarWindowView extends FrameLayout {
|
|||||||
public StatusBarWindowView(Context context, AttributeSet attrs) {
|
public StatusBarWindowView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
setMotionEventSplittingEnabled(false);
|
setMotionEventSplittingEnabled(false);
|
||||||
setWillNotDraw(false);
|
|
||||||
mTransparentSrcPaint.setColor(0);
|
mTransparentSrcPaint.setColor(0);
|
||||||
mTransparentSrcPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
|
mTransparentSrcPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
|
||||||
}
|
}
|
||||||
@@ -105,11 +104,16 @@ public class StatusBarWindowView extends FrameLayout {
|
|||||||
// We need to ensure that our window doesn't suffer from overdraw which would normally
|
// 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
|
// 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.
|
// the scrim, we don't need the window to be cleared in the beginning.
|
||||||
IBinder windowToken = getWindowToken();
|
if (mService.isScrimSrcModeEnabled()) {
|
||||||
WindowManager.LayoutParams lp = (WindowManager.LayoutParams) getLayoutParams();
|
IBinder windowToken = getWindowToken();
|
||||||
lp.token = windowToken;
|
WindowManager.LayoutParams lp = (WindowManager.LayoutParams) getLayoutParams();
|
||||||
setLayoutParams(lp);
|
lp.token = windowToken;
|
||||||
WindowManagerGlobal.getInstance().changeCanvasOpacity(windowToken, true);
|
setLayoutParams(lp);
|
||||||
|
WindowManagerGlobal.getInstance().changeCanvasOpacity(windowToken, true);
|
||||||
|
setWillNotDraw(false);
|
||||||
|
} else {
|
||||||
|
setWillNotDraw(!DEBUG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -199,23 +203,25 @@ public class StatusBarWindowView extends FrameLayout {
|
|||||||
@Override
|
@Override
|
||||||
public void onDraw(Canvas canvas) {
|
public void onDraw(Canvas canvas) {
|
||||||
super.onDraw(canvas);
|
super.onDraw(canvas);
|
||||||
// We need to ensure that our window is always drawn fully even when we have paddings,
|
if (mService.isScrimSrcModeEnabled()) {
|
||||||
// since we simulate it to be opaque.
|
// We need to ensure that our window is always drawn fully even when we have paddings,
|
||||||
int paddedBottom = getHeight() - getPaddingBottom();
|
// since we simulate it to be opaque.
|
||||||
int paddedRight = getWidth() - getPaddingRight();
|
int paddedBottom = getHeight() - getPaddingBottom();
|
||||||
if (getPaddingTop() != 0) {
|
int paddedRight = getWidth() - getPaddingRight();
|
||||||
canvas.drawRect(0, 0, getWidth(), getPaddingTop(), mTransparentSrcPaint);
|
if (getPaddingTop() != 0) {
|
||||||
}
|
canvas.drawRect(0, 0, getWidth(), getPaddingTop(), mTransparentSrcPaint);
|
||||||
if (getPaddingBottom() != 0) {
|
}
|
||||||
canvas.drawRect(0, paddedBottom, getWidth(), getHeight(), mTransparentSrcPaint);
|
if (getPaddingBottom() != 0) {
|
||||||
}
|
canvas.drawRect(0, paddedBottom, getWidth(), getHeight(), mTransparentSrcPaint);
|
||||||
if (getPaddingLeft() != 0) {
|
}
|
||||||
canvas.drawRect(0, getPaddingTop(), getPaddingLeft(), paddedBottom,
|
if (getPaddingLeft() != 0) {
|
||||||
mTransparentSrcPaint);
|
canvas.drawRect(0, getPaddingTop(), getPaddingLeft(), paddedBottom,
|
||||||
}
|
mTransparentSrcPaint);
|
||||||
if (getPaddingRight() != 0) {
|
}
|
||||||
canvas.drawRect(paddedRight, getPaddingTop(), getWidth(), paddedBottom,
|
if (getPaddingRight() != 0) {
|
||||||
mTransparentSrcPaint);
|
canvas.drawRect(paddedRight, getPaddingTop(), getWidth(), paddedBottom,
|
||||||
|
mTransparentSrcPaint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Paint pt = new Paint();
|
Paint pt = new Paint();
|
||||||
|
|||||||
Reference in New Issue
Block a user