Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipAppIconOverlay.java +9 −16 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.hardware.HardwareBuffer; import android.util.TypedValue; import android.view.SurfaceControl; Loading @@ -39,7 +40,6 @@ public final class PipAppIconOverlay extends PipContentOverlay { private final Context mContext; private final int mAppIconSizePx; private final Rect mAppBounds; private final int mOverlayHalfSize; private final Matrix mTmpTransform = new Matrix(); private final float[] mTmpFloat9 = new float[9]; Loading @@ -56,10 +56,6 @@ public final class PipAppIconOverlay extends PipContentOverlay { final int overlaySize = getOverlaySize(appBounds, destinationBounds); mOverlayHalfSize = overlaySize >> 1; // When the activity is in the secondary split, make sure the scaling center is not // offset. mAppBounds = new Rect(0, 0, appBounds.width(), appBounds.height()); mBitmap = Bitmap.createBitmap(overlaySize, overlaySize, Bitmap.Config.ARGB_8888); prepareAppIconOverlay(appIcon); mLeash = new SurfaceControl.Builder() Loading @@ -85,12 +81,17 @@ public final class PipAppIconOverlay extends PipContentOverlay { @Override public void attach(SurfaceControl.Transaction tx, SurfaceControl parentLeash) { final HardwareBuffer buffer = mBitmap.getHardwareBuffer(); tx.show(mLeash); tx.setLayer(mLeash, Integer.MAX_VALUE); tx.setBuffer(mLeash, mBitmap.getHardwareBuffer()); tx.setBuffer(mLeash, buffer); tx.setAlpha(mLeash, 0f); tx.reparent(mLeash, parentLeash); tx.apply(); // Cleanup the bitmap and buffer after setting up the leash mBitmap.recycle(); mBitmap = null; buffer.close(); } @Override Loading @@ -108,16 +109,6 @@ public final class PipAppIconOverlay extends PipContentOverlay { .setAlpha(mLeash, fraction < 0.5f ? 0 : (fraction - 0.5f) * 2); } @Override public void detach(SurfaceControl.Transaction tx) { super.detach(tx); if (mBitmap != null && !mBitmap.isRecycled()) { mBitmap.recycle(); } } private void prepareAppIconOverlay(Drawable appIcon) { final Canvas canvas = new Canvas(); canvas.setBitmap(mBitmap); Loading @@ -139,6 +130,8 @@ public final class PipAppIconOverlay extends PipContentOverlay { mOverlayHalfSize + mAppIconSizePx / 2); appIcon.setBounds(appIconBounds); appIcon.draw(canvas); Bitmap oldBitmap = mBitmap; mBitmap = mBitmap.copy(Bitmap.Config.HARDWARE, false /* mutable */); oldBitmap.recycle(); } } libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java +1 −2 Original line number Diff line number Diff line Loading @@ -72,7 +72,6 @@ import com.android.wm.shell.pip2.animation.PipAlphaAnimator; import com.android.wm.shell.pip2.animation.PipEnterAnimator; import com.android.wm.shell.pip2.animation.PipExpandAnimator; import com.android.wm.shell.shared.TransitionUtil; import com.android.wm.shell.shared.pip.PipContentOverlay; import com.android.wm.shell.sysui.ShellInit; import com.android.wm.shell.transition.Transitions; Loading Loading @@ -422,7 +421,7 @@ public class PipTransition extends PipTransitionController implements final Rect destinationBounds = pipChange.getEndAbsBounds(); final SurfaceControl swipePipToHomeOverlay = mPipTransitionState.getSwipePipToHomeOverlay(); if (swipePipToHomeOverlay != null) { final int overlaySize = PipContentOverlay.PipAppIconOverlay.getOverlaySize( final int overlaySize = PipAppIconOverlay.getOverlaySize( mPipTransitionState.getSwipePipToHomeAppBounds(), destinationBounds); // It is possible we reparent the PIP activity to a new PIP task (in multi-activity // apps), so we should also reparent the overlay to the final PIP task. Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipAppIconOverlay.java +9 −16 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.hardware.HardwareBuffer; import android.util.TypedValue; import android.view.SurfaceControl; Loading @@ -39,7 +40,6 @@ public final class PipAppIconOverlay extends PipContentOverlay { private final Context mContext; private final int mAppIconSizePx; private final Rect mAppBounds; private final int mOverlayHalfSize; private final Matrix mTmpTransform = new Matrix(); private final float[] mTmpFloat9 = new float[9]; Loading @@ -56,10 +56,6 @@ public final class PipAppIconOverlay extends PipContentOverlay { final int overlaySize = getOverlaySize(appBounds, destinationBounds); mOverlayHalfSize = overlaySize >> 1; // When the activity is in the secondary split, make sure the scaling center is not // offset. mAppBounds = new Rect(0, 0, appBounds.width(), appBounds.height()); mBitmap = Bitmap.createBitmap(overlaySize, overlaySize, Bitmap.Config.ARGB_8888); prepareAppIconOverlay(appIcon); mLeash = new SurfaceControl.Builder() Loading @@ -85,12 +81,17 @@ public final class PipAppIconOverlay extends PipContentOverlay { @Override public void attach(SurfaceControl.Transaction tx, SurfaceControl parentLeash) { final HardwareBuffer buffer = mBitmap.getHardwareBuffer(); tx.show(mLeash); tx.setLayer(mLeash, Integer.MAX_VALUE); tx.setBuffer(mLeash, mBitmap.getHardwareBuffer()); tx.setBuffer(mLeash, buffer); tx.setAlpha(mLeash, 0f); tx.reparent(mLeash, parentLeash); tx.apply(); // Cleanup the bitmap and buffer after setting up the leash mBitmap.recycle(); mBitmap = null; buffer.close(); } @Override Loading @@ -108,16 +109,6 @@ public final class PipAppIconOverlay extends PipContentOverlay { .setAlpha(mLeash, fraction < 0.5f ? 0 : (fraction - 0.5f) * 2); } @Override public void detach(SurfaceControl.Transaction tx) { super.detach(tx); if (mBitmap != null && !mBitmap.isRecycled()) { mBitmap.recycle(); } } private void prepareAppIconOverlay(Drawable appIcon) { final Canvas canvas = new Canvas(); canvas.setBitmap(mBitmap); Loading @@ -139,6 +130,8 @@ public final class PipAppIconOverlay extends PipContentOverlay { mOverlayHalfSize + mAppIconSizePx / 2); appIcon.setBounds(appIconBounds); appIcon.draw(canvas); Bitmap oldBitmap = mBitmap; mBitmap = mBitmap.copy(Bitmap.Config.HARDWARE, false /* mutable */); oldBitmap.recycle(); } }
libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java +1 −2 Original line number Diff line number Diff line Loading @@ -72,7 +72,6 @@ import com.android.wm.shell.pip2.animation.PipAlphaAnimator; import com.android.wm.shell.pip2.animation.PipEnterAnimator; import com.android.wm.shell.pip2.animation.PipExpandAnimator; import com.android.wm.shell.shared.TransitionUtil; import com.android.wm.shell.shared.pip.PipContentOverlay; import com.android.wm.shell.sysui.ShellInit; import com.android.wm.shell.transition.Transitions; Loading Loading @@ -422,7 +421,7 @@ public class PipTransition extends PipTransitionController implements final Rect destinationBounds = pipChange.getEndAbsBounds(); final SurfaceControl swipePipToHomeOverlay = mPipTransitionState.getSwipePipToHomeOverlay(); if (swipePipToHomeOverlay != null) { final int overlaySize = PipContentOverlay.PipAppIconOverlay.getOverlaySize( final int overlaySize = PipAppIconOverlay.getOverlaySize( mPipTransitionState.getSwipePipToHomeAppBounds(), destinationBounds); // It is possible we reparent the PIP activity to a new PIP task (in multi-activity // apps), so we should also reparent the overlay to the final PIP task. Loading