Loading packages/SystemUI/animation/lib/src/com/android/systemui/animation/OriginRemoteTransition.java +2 −1 Original line number Diff line number Diff line Loading @@ -441,7 +441,8 @@ public class OriginRemoteTransition extends IRemoteTransition.Stub implements /* alpha= */ 1.0f, /* visible= */ true, /* bounds= */ maxBounds, /* baseBounds= */ maxBounds); /* baseBounds= */ maxBounds, /* enableBackgroundDimming= */ false); } private static void applyWindowAnimationStates( Loading packages/SystemUI/animation/lib/src/com/android/systemui/animation/SurfaceUIComponent.java +52 −10 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.animation; import android.annotation.Nullable; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.RectF; Loading @@ -31,17 +32,29 @@ import java.util.concurrent.Executor; * @hide */ public class SurfaceUIComponent implements UIComponent { private final Collection<SurfaceControl> mSurfaces; private final ArrayList<SurfaceControl> mSurfaces = new ArrayList<>(); private final Rect mBaseBounds; private final float[] mFloat9 = new float[9]; private float mAlpha; private boolean mVisible; private Rect mBounds; @Nullable private final SurfaceControl mBackgroundDimmingSurface; public SurfaceUIComponent( SurfaceControl sc, float alpha, boolean visible, Rect bounds, Rect baseBounds) { this(Arrays.asList(sc), alpha, visible, bounds, baseBounds); SurfaceControl sc, float alpha, boolean visible, Rect bounds, Rect baseBounds, boolean enableBackgroundDimming) { this(Arrays.asList(sc), alpha, visible, bounds, baseBounds, enableBackgroundDimming); } public SurfaceUIComponent( Loading @@ -49,12 +62,34 @@ public class SurfaceUIComponent implements UIComponent { float alpha, boolean visible, Rect bounds, Rect baseBounds) { mSurfaces = surfaces; Rect baseBounds, boolean enableBackgroundDimming) { mSurfaces.addAll(surfaces); mAlpha = alpha; mVisible = visible; mBounds = bounds; mBaseBounds = baseBounds; if (enableBackgroundDimming) { mBackgroundDimmingSurface = new SurfaceControl.Builder() .setName("SurfaceUIComponent-BackgroundDimming") .setColorLayer() .setBufferSize(baseBounds.width(), baseBounds.height()) .setHidden(!visible) .build(); if (!bounds.equals(baseBounds)) { Matrix matrix = new Matrix(); matrix.setRectToRect( new RectF(baseBounds), new RectF(bounds), Matrix.ScaleToFit.CENTER); new SurfaceControl.Transaction() .setMatrix(mBackgroundDimmingSurface, matrix, mFloat9).apply(); } mSurfaces.add(mBackgroundDimmingSurface); } else { mBackgroundDimmingSurface = null; } } @Override Loading Loading @@ -109,7 +144,9 @@ public class SurfaceUIComponent implements UIComponent { mChanges.add( () -> { ui.mAlpha = alpha; ui.mSurfaces.forEach(s -> mTransaction.setAlpha(s, alpha)); ui.mSurfaces.forEach( s -> mTransaction.setAlpha( s, s != ui.mBackgroundDimmingSurface ? alpha : 1)); }); return this; } Loading Loading @@ -140,8 +177,9 @@ public class SurfaceUIComponent implements UIComponent { matrix.setRectToRect( new RectF(ui.mBaseBounds), new RectF(ui.mBounds), Matrix.ScaleToFit.FILL); ui.mSurfaces.forEach(s -> mTransaction.setMatrix(s, matrix, ui.mFloat9)); Matrix.ScaleToFit.CENTER); ui.mSurfaces.forEach( s -> mTransaction.setMatrix(s, matrix, ui.mFloat9)); }); return this; } Loading @@ -150,7 +188,10 @@ public class SurfaceUIComponent implements UIComponent { public Transaction attachToTransitionLeash( SurfaceUIComponent ui, SurfaceControl transitionLeash, int w, int h) { mChanges.add( () -> ui.mSurfaces.forEach(s -> mTransaction.reparent(s, transitionLeash))); () -> { ui.mSurfaces.forEach( s -> mTransaction.reparent(s, transitionLeash)); }); return this; } Loading @@ -159,7 +200,8 @@ public class SurfaceUIComponent implements UIComponent { SurfaceUIComponent ui, Executor executor, Runnable onDone) { mChanges.add( () -> { ui.mSurfaces.forEach(s -> mTransaction.reparent(s, null)); ui.mSurfaces.forEach( s -> mTransaction.reparent(s, null)); mTransaction.addTransactionCommittedListener(executor, onDone::run); }); return this; Loading packages/SystemUI/animation/lib/src/com/android/systemui/animation/ViewUIComponent.java +21 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,9 @@ package com.android.systemui.animation; import android.annotation.Nullable; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Outline; import android.graphics.Paint; import android.graphics.Path; import android.graphics.PorterDuff; import android.graphics.Rect; Loading Loading @@ -56,16 +58,18 @@ public class ViewUIComponent implements UIComponent { private final LifecycleListener mLifecycleListener = new LifecycleListener(); private final View mView; private final Handler mMainHandler; @Nullable private SurfaceControl mSurfaceControl; @Nullable private Surface mSurface; @Nullable private Rect mViewBoundsOverride; private boolean mVisibleOverride; private final boolean mEnableBackgroundDimming; private final Paint mPaint = new Paint(); private boolean mDirty; public ViewUIComponent(View view) { public ViewUIComponent(View view, boolean enableBackgroundDimming) { mView = view; mMainHandler = new Handler(Looper.getMainLooper()); mEnableBackgroundDimming = enableBackgroundDimming; } /** Loading Loading @@ -209,6 +213,21 @@ public class ViewUIComponent implements UIComponent { (float) renderBounds.width() / realBounds.width(), (float) renderBounds.height() / realBounds.height()); if (mEnableBackgroundDimming) { // draw backing layer for background dimming using bounds/radius mPaint.setColor(Color.BLACK); mPaint.setStyle(Paint.Style.FILL); // TODO: use corner radius for drawing canvas.drawRoundRect( renderBounds.left, renderBounds.top, renderBounds.right, renderBounds.bottom, renderBounds.width() / 2, renderBounds.height() / 2, mPaint); } if (mView.getClipToOutline()) { mView.getOutlineProvider().getOutline(mView, mClippingOutline); mClippingPath.reset(); Loading Loading
packages/SystemUI/animation/lib/src/com/android/systemui/animation/OriginRemoteTransition.java +2 −1 Original line number Diff line number Diff line Loading @@ -441,7 +441,8 @@ public class OriginRemoteTransition extends IRemoteTransition.Stub implements /* alpha= */ 1.0f, /* visible= */ true, /* bounds= */ maxBounds, /* baseBounds= */ maxBounds); /* baseBounds= */ maxBounds, /* enableBackgroundDimming= */ false); } private static void applyWindowAnimationStates( Loading
packages/SystemUI/animation/lib/src/com/android/systemui/animation/SurfaceUIComponent.java +52 −10 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.animation; import android.annotation.Nullable; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.RectF; Loading @@ -31,17 +32,29 @@ import java.util.concurrent.Executor; * @hide */ public class SurfaceUIComponent implements UIComponent { private final Collection<SurfaceControl> mSurfaces; private final ArrayList<SurfaceControl> mSurfaces = new ArrayList<>(); private final Rect mBaseBounds; private final float[] mFloat9 = new float[9]; private float mAlpha; private boolean mVisible; private Rect mBounds; @Nullable private final SurfaceControl mBackgroundDimmingSurface; public SurfaceUIComponent( SurfaceControl sc, float alpha, boolean visible, Rect bounds, Rect baseBounds) { this(Arrays.asList(sc), alpha, visible, bounds, baseBounds); SurfaceControl sc, float alpha, boolean visible, Rect bounds, Rect baseBounds, boolean enableBackgroundDimming) { this(Arrays.asList(sc), alpha, visible, bounds, baseBounds, enableBackgroundDimming); } public SurfaceUIComponent( Loading @@ -49,12 +62,34 @@ public class SurfaceUIComponent implements UIComponent { float alpha, boolean visible, Rect bounds, Rect baseBounds) { mSurfaces = surfaces; Rect baseBounds, boolean enableBackgroundDimming) { mSurfaces.addAll(surfaces); mAlpha = alpha; mVisible = visible; mBounds = bounds; mBaseBounds = baseBounds; if (enableBackgroundDimming) { mBackgroundDimmingSurface = new SurfaceControl.Builder() .setName("SurfaceUIComponent-BackgroundDimming") .setColorLayer() .setBufferSize(baseBounds.width(), baseBounds.height()) .setHidden(!visible) .build(); if (!bounds.equals(baseBounds)) { Matrix matrix = new Matrix(); matrix.setRectToRect( new RectF(baseBounds), new RectF(bounds), Matrix.ScaleToFit.CENTER); new SurfaceControl.Transaction() .setMatrix(mBackgroundDimmingSurface, matrix, mFloat9).apply(); } mSurfaces.add(mBackgroundDimmingSurface); } else { mBackgroundDimmingSurface = null; } } @Override Loading Loading @@ -109,7 +144,9 @@ public class SurfaceUIComponent implements UIComponent { mChanges.add( () -> { ui.mAlpha = alpha; ui.mSurfaces.forEach(s -> mTransaction.setAlpha(s, alpha)); ui.mSurfaces.forEach( s -> mTransaction.setAlpha( s, s != ui.mBackgroundDimmingSurface ? alpha : 1)); }); return this; } Loading Loading @@ -140,8 +177,9 @@ public class SurfaceUIComponent implements UIComponent { matrix.setRectToRect( new RectF(ui.mBaseBounds), new RectF(ui.mBounds), Matrix.ScaleToFit.FILL); ui.mSurfaces.forEach(s -> mTransaction.setMatrix(s, matrix, ui.mFloat9)); Matrix.ScaleToFit.CENTER); ui.mSurfaces.forEach( s -> mTransaction.setMatrix(s, matrix, ui.mFloat9)); }); return this; } Loading @@ -150,7 +188,10 @@ public class SurfaceUIComponent implements UIComponent { public Transaction attachToTransitionLeash( SurfaceUIComponent ui, SurfaceControl transitionLeash, int w, int h) { mChanges.add( () -> ui.mSurfaces.forEach(s -> mTransaction.reparent(s, transitionLeash))); () -> { ui.mSurfaces.forEach( s -> mTransaction.reparent(s, transitionLeash)); }); return this; } Loading @@ -159,7 +200,8 @@ public class SurfaceUIComponent implements UIComponent { SurfaceUIComponent ui, Executor executor, Runnable onDone) { mChanges.add( () -> { ui.mSurfaces.forEach(s -> mTransaction.reparent(s, null)); ui.mSurfaces.forEach( s -> mTransaction.reparent(s, null)); mTransaction.addTransactionCommittedListener(executor, onDone::run); }); return this; Loading
packages/SystemUI/animation/lib/src/com/android/systemui/animation/ViewUIComponent.java +21 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,9 @@ package com.android.systemui.animation; import android.annotation.Nullable; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Outline; import android.graphics.Paint; import android.graphics.Path; import android.graphics.PorterDuff; import android.graphics.Rect; Loading Loading @@ -56,16 +58,18 @@ public class ViewUIComponent implements UIComponent { private final LifecycleListener mLifecycleListener = new LifecycleListener(); private final View mView; private final Handler mMainHandler; @Nullable private SurfaceControl mSurfaceControl; @Nullable private Surface mSurface; @Nullable private Rect mViewBoundsOverride; private boolean mVisibleOverride; private final boolean mEnableBackgroundDimming; private final Paint mPaint = new Paint(); private boolean mDirty; public ViewUIComponent(View view) { public ViewUIComponent(View view, boolean enableBackgroundDimming) { mView = view; mMainHandler = new Handler(Looper.getMainLooper()); mEnableBackgroundDimming = enableBackgroundDimming; } /** Loading Loading @@ -209,6 +213,21 @@ public class ViewUIComponent implements UIComponent { (float) renderBounds.width() / realBounds.width(), (float) renderBounds.height() / realBounds.height()); if (mEnableBackgroundDimming) { // draw backing layer for background dimming using bounds/radius mPaint.setColor(Color.BLACK); mPaint.setStyle(Paint.Style.FILL); // TODO: use corner radius for drawing canvas.drawRoundRect( renderBounds.left, renderBounds.top, renderBounds.right, renderBounds.bottom, renderBounds.width() / 2, renderBounds.height() / 2, mPaint); } if (mView.getClipToOutline()) { mView.getOutlineProvider().getOutline(mView, mClippingOutline); mClippingPath.reset(); Loading