Loading core/java/android/view/SurfaceControl.java +32 −126 Original line number Diff line number Diff line Loading @@ -181,7 +181,6 @@ public final class SurfaceControl implements Parcelable { private static native void nativeSeverChildren(long transactionObj, long nativeObject); private static native void nativeSetOverrideScalingMode(long transactionObj, long nativeObject, int scalingMode); private static native boolean nativeGetTransformToDisplayInverse(long nativeObject); private static native Display.HdrCapabilities nativeGetHdrCapabilities(IBinder displayToken); Loading Loading @@ -303,8 +302,8 @@ public final class SurfaceControl implements Parcelable { /** * Surface creation flag: Creates a Dim surface. * Everything behind this surface is dimmed by the amount specified * in {@link #setAlpha}. It is an error to lock a Dim surface, since it * doesn't have a backing store. * in {@link Transaction#setAlpha(SurfaceControl, float)}. It is an error to lock a Dim * surface, since it doesn't have a backing store. * * @hide */ Loading Loading @@ -740,7 +739,8 @@ public final class SurfaceControl implements Parcelable { * <p> * Good practice is to first create the surface with the {@link #HIDDEN} flag * specified, open a transaction, set the surface layer, layer stack, alpha, * and position, call {@link #show} if appropriate, and close the transaction. * and position, call {@link Transaction#show(SurfaceControl)} if appropriate, and close the * transaction. * <p> * Bounds of the surface is determined by its crop and its buffer size. If the * surface has no buffer or crop, the surface is boundless and only constrained Loading @@ -753,7 +753,6 @@ public final class SurfaceControl implements Parcelable { * @param flags The surface creation flags. Should always include {@link #HIDDEN} * in the creation flags. * @param metadata Initial metadata. * * @throws throws OutOfResourcesException If the SurfaceControl cannot be created. */ private SurfaceControl(SurfaceSession session, String name, int w, int h, int format, int flags, Loading Loading @@ -1011,15 +1010,6 @@ public final class SurfaceControl implements Parcelable { } } /** * @hide */ public void deferTransactionUntil(Surface barrier, long frame) { synchronized(SurfaceControl.class) { sGlobalTransaction.deferTransactionUntilSurface(this, barrier, frame); } } /** * @hide */ Loading @@ -1029,15 +1019,6 @@ public final class SurfaceControl implements Parcelable { } } /** * @hide */ public void reparent(SurfaceControl newParent) { synchronized(SurfaceControl.class) { sGlobalTransaction.reparent(this, newParent); } } /** * @hide */ Loading @@ -1057,15 +1038,6 @@ public final class SurfaceControl implements Parcelable { } } /** * @hide */ public static void setAnimationTransaction() { synchronized (SurfaceControl.class) { sGlobalTransaction.setAnimationTransaction(); } } /** * @hide */ Loading @@ -1077,16 +1049,6 @@ public final class SurfaceControl implements Parcelable { } } /** * @hide */ public void setRelativeLayer(SurfaceControl relativeTo, int zorder) { checkNotReleased(); synchronized(SurfaceControl.class) { sGlobalTransaction.setRelativeLayer(this, relativeTo, zorder); } } /** * @hide */ Loading Loading @@ -1180,16 +1142,6 @@ public final class SurfaceControl implements Parcelable { } } /** * @hide */ public void setColor(@Size(3) float[] color) { checkNotReleased(); synchronized (SurfaceControl.class) { sGlobalTransaction.setColor(this, color); } } /** * @hide */ Loading @@ -1200,36 +1152,6 @@ public final class SurfaceControl implements Parcelable { } } /** * Sets the transform and position of a {@link SurfaceControl} from a 3x3 transformation matrix. * * @param matrix The matrix to apply. * @param float9 An array of 9 floats to be used to extract the values from the matrix. * @hide */ public void setMatrix(Matrix matrix, float[] float9) { checkNotReleased(); matrix.getValues(float9); synchronized (SurfaceControl.class) { sGlobalTransaction.setMatrix(this, float9[MSCALE_X], float9[MSKEW_Y], float9[MSKEW_X], float9[MSCALE_Y]); sGlobalTransaction.setPosition(this, float9[MTRANS_X], float9[MTRANS_Y]); } } /** * Sets the color transform for the Surface. * @param matrix A float array with 9 values represents a 3x3 transform matrix * @param translation A float array with 3 values represents a translation vector * @hide */ public void setColorTransform(@Size(9) float[] matrix, @Size(3) float[] translation) { checkNotReleased(); synchronized (SurfaceControl.class) { sGlobalTransaction.setColorTransform(this, matrix, translation); } } /** * Sets the Surface to be color space agnostic. If a surface is color space agnostic, * the color can be interpreted in any color space. Loading Loading @@ -1259,43 +1181,6 @@ public final class SurfaceControl implements Parcelable { } } /** * Same as {@link SurfaceControl#setWindowCrop(Rect)} but sets the crop rect top left at 0, 0. * * @param width width of crop rect * @param height height of crop rect * @hide */ public void setWindowCrop(int width, int height) { checkNotReleased(); synchronized (SurfaceControl.class) { sGlobalTransaction.setWindowCrop(this, width, height); } } /** * Sets the corner radius of a {@link SurfaceControl}. * * @param cornerRadius Corner radius in pixels. * @hide */ public void setCornerRadius(float cornerRadius) { checkNotReleased(); synchronized (SurfaceControl.class) { sGlobalTransaction.setCornerRadius(this, cornerRadius); } } /** * @hide */ public void setLayerStack(int layerStack) { checkNotReleased(); synchronized(SurfaceControl.class) { sGlobalTransaction.setLayerStack(this, layerStack); } } /** * @hide */ Loading Loading @@ -2302,6 +2187,12 @@ public final class SurfaceControl implements Parcelable { } /** * Sets the transform and position of a {@link SurfaceControl} from a 3x3 transformation * matrix. * * @param sc SurfaceControl to set matrix of * @param matrix The matrix to apply. * @param float9 An array of 9 floats to be used to extract the values from the matrix. * @hide */ @UnsupportedAppUsage Loading @@ -2315,6 +2206,8 @@ public final class SurfaceControl implements Parcelable { /** * Sets the color transform for the Surface. * * @param sc SurfaceControl to set color transform of * @param matrix A float array with 9 values represents a 3x3 transform matrix * @param translation A float array with 3 values represents a translation vector * @hide Loading @@ -2339,6 +2232,13 @@ public final class SurfaceControl implements Parcelable { } /** * Bounds the surface and its children to the bounds specified. Size of the surface will be * ignored and only the crop and buffer size will be used to determine the bounds of the * surface. If no crop is specified and the surface has no buffer, the surface bounds is * only constrained by the size of its parent bounds. * * @param sc SurfaceControl to set crop of. * @param crop Bounds of the crop to apply. * @hide */ @UnsupportedAppUsage Loading @@ -2355,6 +2255,12 @@ public final class SurfaceControl implements Parcelable { } /** * Same as {@link Transaction#setWindowCrop(SurfaceControl, Rect)} but sets the crop rect * top left at 0, 0. * * @param sc SurfaceControl to set crop of. * @param width width of crop rect * @param height height of crop rect * @hide */ public Transaction setWindowCrop(SurfaceControl sc, int width, int height) { Loading core/java/android/view/SurfaceView.java +58 −69 Original line number Diff line number Diff line Loading @@ -418,12 +418,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall Log.d(TAG, System.identityHashCode(this) + " updateSurfaceAlpha: set alpha=" + alpha); } SurfaceControl.openTransaction(); try { mSurfaceControl.setAlpha(alpha); } finally { SurfaceControl.closeTransaction(); } mTmpTransaction.setAlpha(mSurfaceControl, alpha).apply(); } mSurfaceAlpha = alpha; } Loading Loading @@ -701,17 +696,18 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall } } private void updateBackgroundVisibilityInTransaction() { private void updateBackgroundVisibility(Transaction t) { if (mBackgroundControl == null) { return; } if ((mSubLayer < 0) && ((mSurfaceFlags & SurfaceControl.OPAQUE) != 0)) { mBackgroundControl.show(); t.show(mBackgroundControl); } else { mBackgroundControl.hide(); t.hide(mBackgroundControl); } } private void releaseSurfaces() { mSurfaceAlpha = 1f; Loading Loading @@ -853,8 +849,6 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall if (DEBUG) Log.i(TAG, System.identityHashCode(this) + " " + "Cur surface: " + mSurface); SurfaceControl.openTransaction(); try { // If we are creating the surface control or the parent surface has not // changed, then set relative z. Otherwise allow the parent // SurfaceChangedCallback to update the relative z. This is needed so that Loading @@ -862,18 +856,18 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall // parent surface. if (creating || (mParentSurfaceGenerationId == viewRoot.mSurface.getGenerationId())) { SurfaceControl.mergeToGlobalTransaction(updateRelativeZ()); updateRelativeZ(mTmpTransaction); } mParentSurfaceGenerationId = viewRoot.mSurface.getGenerationId(); if (mViewVisibility) { mSurfaceControl.show(); mTmpTransaction.show(mSurfaceControl); } else { mSurfaceControl.hide(); mTmpTransaction.hide(mSurfaceControl); } updateBackgroundVisibilityInTransaction(); updateBackgroundVisibility(mTmpTransaction); if (mUseAlpha) { mSurfaceControl.setAlpha(alpha); mTmpTransaction.setAlpha(mSurfaceControl, alpha); mSurfaceAlpha = alpha; } Loading @@ -886,28 +880,30 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall // we still need to latch a buffer). // b/28866173 if (sizeChanged || creating || !mRtHandlingPositionUpdates) { mSurfaceControl.setPosition(mScreenRect.left, mScreenRect.top); mSurfaceControl.setMatrix(mScreenRect.width() / (float) mSurfaceWidth, 0.0f, 0.0f, mTmpTransaction.setPosition(mSurfaceControl, mScreenRect.left, mScreenRect.top); mTmpTransaction.setMatrix(mSurfaceControl, mScreenRect.width() / (float) mSurfaceWidth, 0.0f, 0.0f, mScreenRect.height() / (float) mSurfaceHeight); // Set a window crop when creating the surface or changing its size to // crop the buffer to the surface size since the buffer producer may // use SCALING_MODE_SCALE and submit a larger size than the surface // size. if (mClipSurfaceToBounds && mClipBounds != null) { mSurfaceControl.setWindowCrop(mClipBounds); mTmpTransaction.setWindowCrop(mSurfaceControl, mClipBounds); } else { mSurfaceControl.setWindowCrop(mSurfaceWidth, mSurfaceHeight); mTmpTransaction.setWindowCrop(mSurfaceControl, mSurfaceWidth, mSurfaceHeight); } } mSurfaceControl.setCornerRadius(mCornerRadius); mTmpTransaction.setCornerRadius(mSurfaceControl, mCornerRadius); if (sizeChanged && !creating) { mSurfaceControl.setBufferSize(mSurfaceWidth, mSurfaceHeight); } } finally { SurfaceControl.closeTransaction(); mTmpTransaction.setBufferSize(mSurfaceControl, mSurfaceWidth, mSurfaceHeight); } mTmpTransaction.apply(); if (sizeChanged || creating) { redrawNeeded = true; } Loading Loading @@ -1260,12 +1256,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall final float[] colorComponents = new float[] { Color.red(bgColor) / 255.f, Color.green(bgColor) / 255.f, Color.blue(bgColor) / 255.f }; SurfaceControl.openTransaction(); try { mBackgroundControl.setColor(colorComponents); } finally { SurfaceControl.closeTransaction(); } mTmpTransaction.setColor(mBackgroundControl, colorComponents).apply(); } @UnsupportedAppUsage Loading Loading @@ -1480,15 +1471,13 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall @Override public void surfaceReplaced(Transaction t) { if (mSurfaceControl != null && mBackgroundControl != null) { t.merge(updateRelativeZ()); updateRelativeZ(t); } } private Transaction updateRelativeZ() { Transaction t = new Transaction(); private void updateRelativeZ(Transaction t) { SurfaceControl viewRoot = getViewRootImpl().getSurfaceControl(); t.setRelativeLayer(mBackgroundControl, viewRoot, Integer.MIN_VALUE); t.setRelativeLayer(mSurfaceControl, viewRoot, mSubLayer); return t; } } services/core/java/com/android/server/display/ColorFade.java +6 −8 Original line number Diff line number Diff line Loading @@ -114,6 +114,8 @@ final class ColorFade { private final FloatBuffer mVertexBuffer = createNativeFloatBuffer(8); private final FloatBuffer mTexCoordBuffer = createNativeFloatBuffer(8); private final Transaction mTransaction = new Transaction(); /** * Animates an color fade warming up. */ Loading Loading @@ -659,14 +661,10 @@ final class ColorFade { private boolean showSurface(float alpha) { if (!mSurfaceVisible || mSurfaceAlpha != alpha) { SurfaceControl.openTransaction(); try { mSurfaceControl.setLayer(COLOR_FADE_LAYER); mSurfaceControl.setAlpha(alpha); mSurfaceControl.show(); } finally { SurfaceControl.closeTransaction(); } mTransaction.setLayer(mSurfaceControl, COLOR_FADE_LAYER) .setAlpha(mSurfaceControl, alpha) .show(mSurfaceControl) .apply(); mSurfaceVisible = true; mSurfaceAlpha = alpha; } Loading services/core/java/com/android/server/wm/AccessibilityController.java +20 −22 Original line number Diff line number Diff line Loading @@ -271,11 +271,11 @@ final class AccessibilityController { } } /** NOTE: This has to be called within a surface transaction. */ public void drawMagnifiedRegionBorderIfNeededLocked(int displayId) { public void drawMagnifiedRegionBorderIfNeededLocked(int displayId, SurfaceControl.Transaction t) { final DisplayMagnifier displayMagnifier = mDisplayMagnifiers.get(displayId); if (displayMagnifier != null) { displayMagnifier.drawMagnifiedRegionBorderIfNeededLocked(); displayMagnifier.drawMagnifiedRegionBorderIfNeededLocked(t); } // Not relevant for the window observer. } Loading Loading @@ -431,7 +431,7 @@ final class AccessibilityController { Slog.i(LOG_TAG, "Rotation: " + Surface.rotationToString(rotation) + " displayId: " + displayContent.getDisplayId()); } mMagnifedViewport.onRotationChangedLocked(); mMagnifedViewport.onRotationChangedLocked(displayContent.getPendingTransaction()); mHandler.sendEmptyMessage(MyHandler.MESSAGE_NOTIFY_ROTATION_CHANGED); } Loading Loading @@ -536,9 +536,8 @@ final class AccessibilityController { .sendToTarget(); } /** NOTE: This has to be called within a surface transaction. */ public void drawMagnifiedRegionBorderIfNeededLocked() { mMagnifedViewport.drawWindowIfNeededLocked(); public void drawMagnifiedRegionBorderIfNeededLocked(SurfaceControl.Transaction t) { mMagnifedViewport.drawWindowIfNeededLocked(t); } private final class MagnifiedViewport { Loading Loading @@ -744,7 +743,7 @@ final class AccessibilityController { return letterboxBounds; } public void onRotationChangedLocked() { public void onRotationChangedLocked(SurfaceControl.Transaction t) { // If we are showing the magnification border, hide it immediately so // the user does not see strange artifacts during rotation. The screenshot // used for rotation already has the border. After the rotation is complete Loading @@ -758,7 +757,7 @@ final class AccessibilityController { mHandler.sendMessageDelayed(message, delay); } recomputeBoundsLocked(); mWindow.updateSize(); mWindow.updateSize(t); } public void setMagnifiedRegionBorderShownLocked(boolean shown, boolean animate) { Loading @@ -784,10 +783,9 @@ final class AccessibilityController { return mMagnificationSpec; } /** NOTE: This has to be called within a surface transaction. */ public void drawWindowIfNeededLocked() { public void drawWindowIfNeededLocked(SurfaceControl.Transaction t) { recomputeBoundsLocked(); mWindow.drawIfNeeded(); mWindow.drawIfNeeded(t); } public void destroyWindow() { Loading Loading @@ -837,10 +835,11 @@ final class AccessibilityController { /* ignore */ } mSurfaceControl = surfaceControl; mSurfaceControl.setLayer(mService.mPolicy.getWindowLayerFromTypeLw( TYPE_MAGNIFICATION_OVERLAY) * WindowManagerService.TYPE_LAYER_MULTIPLIER); mSurfaceControl.setPosition(0, 0); mService.mTransactionFactory.get().setLayer(mSurfaceControl, mService.mPolicy.getWindowLayerFromTypeLw(TYPE_MAGNIFICATION_OVERLAY) * WindowManagerService.TYPE_LAYER_MULTIPLIER) .setPosition(mSurfaceControl, 0, 0) .apply(); mSurface.copyFrom(mSurfaceControl); mAnimationController = new AnimationController(context, Loading Loading @@ -905,10 +904,10 @@ final class AccessibilityController { } } public void updateSize() { public void updateSize(SurfaceControl.Transaction t) { synchronized (mService.mGlobalLock) { mWindowManager.getDefaultDisplay().getRealSize(mTempPoint); mSurfaceControl.setBufferSize(mTempPoint.x, mTempPoint.y); t.setBufferSize(mSurfaceControl, mTempPoint.x, mTempPoint.y); invalidate(mDirtyRect); } } Loading @@ -923,8 +922,7 @@ final class AccessibilityController { mService.scheduleAnimationLocked(); } /** NOTE: This has to be called within a surface transaction. */ public void drawIfNeeded() { public void drawIfNeeded(SurfaceControl.Transaction t) { synchronized (mService.mGlobalLock) { if (!mInvalidated) { return; Loading Loading @@ -959,9 +957,9 @@ final class AccessibilityController { canvas.drawPath(path, mPaint); mSurface.unlockCanvasAndPost(canvas); mSurfaceControl.show(); t.show(mSurfaceControl); } else { mSurfaceControl.hide(); t.hide(mSurfaceControl); } } } Loading services/core/java/com/android/server/wm/AppWindowToken.java +1 −1 Original line number Diff line number Diff line Loading @@ -2930,7 +2930,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree layer += Z_BOOST_BASE; } if (!mNeedsAnimationBoundsLayer) { leash.setLayer(layer); t.setLayer(leash, layer); } final DisplayContent dc = getDisplayContent(); Loading Loading
core/java/android/view/SurfaceControl.java +32 −126 Original line number Diff line number Diff line Loading @@ -181,7 +181,6 @@ public final class SurfaceControl implements Parcelable { private static native void nativeSeverChildren(long transactionObj, long nativeObject); private static native void nativeSetOverrideScalingMode(long transactionObj, long nativeObject, int scalingMode); private static native boolean nativeGetTransformToDisplayInverse(long nativeObject); private static native Display.HdrCapabilities nativeGetHdrCapabilities(IBinder displayToken); Loading Loading @@ -303,8 +302,8 @@ public final class SurfaceControl implements Parcelable { /** * Surface creation flag: Creates a Dim surface. * Everything behind this surface is dimmed by the amount specified * in {@link #setAlpha}. It is an error to lock a Dim surface, since it * doesn't have a backing store. * in {@link Transaction#setAlpha(SurfaceControl, float)}. It is an error to lock a Dim * surface, since it doesn't have a backing store. * * @hide */ Loading Loading @@ -740,7 +739,8 @@ public final class SurfaceControl implements Parcelable { * <p> * Good practice is to first create the surface with the {@link #HIDDEN} flag * specified, open a transaction, set the surface layer, layer stack, alpha, * and position, call {@link #show} if appropriate, and close the transaction. * and position, call {@link Transaction#show(SurfaceControl)} if appropriate, and close the * transaction. * <p> * Bounds of the surface is determined by its crop and its buffer size. If the * surface has no buffer or crop, the surface is boundless and only constrained Loading @@ -753,7 +753,6 @@ public final class SurfaceControl implements Parcelable { * @param flags The surface creation flags. Should always include {@link #HIDDEN} * in the creation flags. * @param metadata Initial metadata. * * @throws throws OutOfResourcesException If the SurfaceControl cannot be created. */ private SurfaceControl(SurfaceSession session, String name, int w, int h, int format, int flags, Loading Loading @@ -1011,15 +1010,6 @@ public final class SurfaceControl implements Parcelable { } } /** * @hide */ public void deferTransactionUntil(Surface barrier, long frame) { synchronized(SurfaceControl.class) { sGlobalTransaction.deferTransactionUntilSurface(this, barrier, frame); } } /** * @hide */ Loading @@ -1029,15 +1019,6 @@ public final class SurfaceControl implements Parcelable { } } /** * @hide */ public void reparent(SurfaceControl newParent) { synchronized(SurfaceControl.class) { sGlobalTransaction.reparent(this, newParent); } } /** * @hide */ Loading @@ -1057,15 +1038,6 @@ public final class SurfaceControl implements Parcelable { } } /** * @hide */ public static void setAnimationTransaction() { synchronized (SurfaceControl.class) { sGlobalTransaction.setAnimationTransaction(); } } /** * @hide */ Loading @@ -1077,16 +1049,6 @@ public final class SurfaceControl implements Parcelable { } } /** * @hide */ public void setRelativeLayer(SurfaceControl relativeTo, int zorder) { checkNotReleased(); synchronized(SurfaceControl.class) { sGlobalTransaction.setRelativeLayer(this, relativeTo, zorder); } } /** * @hide */ Loading Loading @@ -1180,16 +1142,6 @@ public final class SurfaceControl implements Parcelable { } } /** * @hide */ public void setColor(@Size(3) float[] color) { checkNotReleased(); synchronized (SurfaceControl.class) { sGlobalTransaction.setColor(this, color); } } /** * @hide */ Loading @@ -1200,36 +1152,6 @@ public final class SurfaceControl implements Parcelable { } } /** * Sets the transform and position of a {@link SurfaceControl} from a 3x3 transformation matrix. * * @param matrix The matrix to apply. * @param float9 An array of 9 floats to be used to extract the values from the matrix. * @hide */ public void setMatrix(Matrix matrix, float[] float9) { checkNotReleased(); matrix.getValues(float9); synchronized (SurfaceControl.class) { sGlobalTransaction.setMatrix(this, float9[MSCALE_X], float9[MSKEW_Y], float9[MSKEW_X], float9[MSCALE_Y]); sGlobalTransaction.setPosition(this, float9[MTRANS_X], float9[MTRANS_Y]); } } /** * Sets the color transform for the Surface. * @param matrix A float array with 9 values represents a 3x3 transform matrix * @param translation A float array with 3 values represents a translation vector * @hide */ public void setColorTransform(@Size(9) float[] matrix, @Size(3) float[] translation) { checkNotReleased(); synchronized (SurfaceControl.class) { sGlobalTransaction.setColorTransform(this, matrix, translation); } } /** * Sets the Surface to be color space agnostic. If a surface is color space agnostic, * the color can be interpreted in any color space. Loading Loading @@ -1259,43 +1181,6 @@ public final class SurfaceControl implements Parcelable { } } /** * Same as {@link SurfaceControl#setWindowCrop(Rect)} but sets the crop rect top left at 0, 0. * * @param width width of crop rect * @param height height of crop rect * @hide */ public void setWindowCrop(int width, int height) { checkNotReleased(); synchronized (SurfaceControl.class) { sGlobalTransaction.setWindowCrop(this, width, height); } } /** * Sets the corner radius of a {@link SurfaceControl}. * * @param cornerRadius Corner radius in pixels. * @hide */ public void setCornerRadius(float cornerRadius) { checkNotReleased(); synchronized (SurfaceControl.class) { sGlobalTransaction.setCornerRadius(this, cornerRadius); } } /** * @hide */ public void setLayerStack(int layerStack) { checkNotReleased(); synchronized(SurfaceControl.class) { sGlobalTransaction.setLayerStack(this, layerStack); } } /** * @hide */ Loading Loading @@ -2302,6 +2187,12 @@ public final class SurfaceControl implements Parcelable { } /** * Sets the transform and position of a {@link SurfaceControl} from a 3x3 transformation * matrix. * * @param sc SurfaceControl to set matrix of * @param matrix The matrix to apply. * @param float9 An array of 9 floats to be used to extract the values from the matrix. * @hide */ @UnsupportedAppUsage Loading @@ -2315,6 +2206,8 @@ public final class SurfaceControl implements Parcelable { /** * Sets the color transform for the Surface. * * @param sc SurfaceControl to set color transform of * @param matrix A float array with 9 values represents a 3x3 transform matrix * @param translation A float array with 3 values represents a translation vector * @hide Loading @@ -2339,6 +2232,13 @@ public final class SurfaceControl implements Parcelable { } /** * Bounds the surface and its children to the bounds specified. Size of the surface will be * ignored and only the crop and buffer size will be used to determine the bounds of the * surface. If no crop is specified and the surface has no buffer, the surface bounds is * only constrained by the size of its parent bounds. * * @param sc SurfaceControl to set crop of. * @param crop Bounds of the crop to apply. * @hide */ @UnsupportedAppUsage Loading @@ -2355,6 +2255,12 @@ public final class SurfaceControl implements Parcelable { } /** * Same as {@link Transaction#setWindowCrop(SurfaceControl, Rect)} but sets the crop rect * top left at 0, 0. * * @param sc SurfaceControl to set crop of. * @param width width of crop rect * @param height height of crop rect * @hide */ public Transaction setWindowCrop(SurfaceControl sc, int width, int height) { Loading
core/java/android/view/SurfaceView.java +58 −69 Original line number Diff line number Diff line Loading @@ -418,12 +418,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall Log.d(TAG, System.identityHashCode(this) + " updateSurfaceAlpha: set alpha=" + alpha); } SurfaceControl.openTransaction(); try { mSurfaceControl.setAlpha(alpha); } finally { SurfaceControl.closeTransaction(); } mTmpTransaction.setAlpha(mSurfaceControl, alpha).apply(); } mSurfaceAlpha = alpha; } Loading Loading @@ -701,17 +696,18 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall } } private void updateBackgroundVisibilityInTransaction() { private void updateBackgroundVisibility(Transaction t) { if (mBackgroundControl == null) { return; } if ((mSubLayer < 0) && ((mSurfaceFlags & SurfaceControl.OPAQUE) != 0)) { mBackgroundControl.show(); t.show(mBackgroundControl); } else { mBackgroundControl.hide(); t.hide(mBackgroundControl); } } private void releaseSurfaces() { mSurfaceAlpha = 1f; Loading Loading @@ -853,8 +849,6 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall if (DEBUG) Log.i(TAG, System.identityHashCode(this) + " " + "Cur surface: " + mSurface); SurfaceControl.openTransaction(); try { // If we are creating the surface control or the parent surface has not // changed, then set relative z. Otherwise allow the parent // SurfaceChangedCallback to update the relative z. This is needed so that Loading @@ -862,18 +856,18 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall // parent surface. if (creating || (mParentSurfaceGenerationId == viewRoot.mSurface.getGenerationId())) { SurfaceControl.mergeToGlobalTransaction(updateRelativeZ()); updateRelativeZ(mTmpTransaction); } mParentSurfaceGenerationId = viewRoot.mSurface.getGenerationId(); if (mViewVisibility) { mSurfaceControl.show(); mTmpTransaction.show(mSurfaceControl); } else { mSurfaceControl.hide(); mTmpTransaction.hide(mSurfaceControl); } updateBackgroundVisibilityInTransaction(); updateBackgroundVisibility(mTmpTransaction); if (mUseAlpha) { mSurfaceControl.setAlpha(alpha); mTmpTransaction.setAlpha(mSurfaceControl, alpha); mSurfaceAlpha = alpha; } Loading @@ -886,28 +880,30 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall // we still need to latch a buffer). // b/28866173 if (sizeChanged || creating || !mRtHandlingPositionUpdates) { mSurfaceControl.setPosition(mScreenRect.left, mScreenRect.top); mSurfaceControl.setMatrix(mScreenRect.width() / (float) mSurfaceWidth, 0.0f, 0.0f, mTmpTransaction.setPosition(mSurfaceControl, mScreenRect.left, mScreenRect.top); mTmpTransaction.setMatrix(mSurfaceControl, mScreenRect.width() / (float) mSurfaceWidth, 0.0f, 0.0f, mScreenRect.height() / (float) mSurfaceHeight); // Set a window crop when creating the surface or changing its size to // crop the buffer to the surface size since the buffer producer may // use SCALING_MODE_SCALE and submit a larger size than the surface // size. if (mClipSurfaceToBounds && mClipBounds != null) { mSurfaceControl.setWindowCrop(mClipBounds); mTmpTransaction.setWindowCrop(mSurfaceControl, mClipBounds); } else { mSurfaceControl.setWindowCrop(mSurfaceWidth, mSurfaceHeight); mTmpTransaction.setWindowCrop(mSurfaceControl, mSurfaceWidth, mSurfaceHeight); } } mSurfaceControl.setCornerRadius(mCornerRadius); mTmpTransaction.setCornerRadius(mSurfaceControl, mCornerRadius); if (sizeChanged && !creating) { mSurfaceControl.setBufferSize(mSurfaceWidth, mSurfaceHeight); } } finally { SurfaceControl.closeTransaction(); mTmpTransaction.setBufferSize(mSurfaceControl, mSurfaceWidth, mSurfaceHeight); } mTmpTransaction.apply(); if (sizeChanged || creating) { redrawNeeded = true; } Loading Loading @@ -1260,12 +1256,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall final float[] colorComponents = new float[] { Color.red(bgColor) / 255.f, Color.green(bgColor) / 255.f, Color.blue(bgColor) / 255.f }; SurfaceControl.openTransaction(); try { mBackgroundControl.setColor(colorComponents); } finally { SurfaceControl.closeTransaction(); } mTmpTransaction.setColor(mBackgroundControl, colorComponents).apply(); } @UnsupportedAppUsage Loading Loading @@ -1480,15 +1471,13 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall @Override public void surfaceReplaced(Transaction t) { if (mSurfaceControl != null && mBackgroundControl != null) { t.merge(updateRelativeZ()); updateRelativeZ(t); } } private Transaction updateRelativeZ() { Transaction t = new Transaction(); private void updateRelativeZ(Transaction t) { SurfaceControl viewRoot = getViewRootImpl().getSurfaceControl(); t.setRelativeLayer(mBackgroundControl, viewRoot, Integer.MIN_VALUE); t.setRelativeLayer(mSurfaceControl, viewRoot, mSubLayer); return t; } }
services/core/java/com/android/server/display/ColorFade.java +6 −8 Original line number Diff line number Diff line Loading @@ -114,6 +114,8 @@ final class ColorFade { private final FloatBuffer mVertexBuffer = createNativeFloatBuffer(8); private final FloatBuffer mTexCoordBuffer = createNativeFloatBuffer(8); private final Transaction mTransaction = new Transaction(); /** * Animates an color fade warming up. */ Loading Loading @@ -659,14 +661,10 @@ final class ColorFade { private boolean showSurface(float alpha) { if (!mSurfaceVisible || mSurfaceAlpha != alpha) { SurfaceControl.openTransaction(); try { mSurfaceControl.setLayer(COLOR_FADE_LAYER); mSurfaceControl.setAlpha(alpha); mSurfaceControl.show(); } finally { SurfaceControl.closeTransaction(); } mTransaction.setLayer(mSurfaceControl, COLOR_FADE_LAYER) .setAlpha(mSurfaceControl, alpha) .show(mSurfaceControl) .apply(); mSurfaceVisible = true; mSurfaceAlpha = alpha; } Loading
services/core/java/com/android/server/wm/AccessibilityController.java +20 −22 Original line number Diff line number Diff line Loading @@ -271,11 +271,11 @@ final class AccessibilityController { } } /** NOTE: This has to be called within a surface transaction. */ public void drawMagnifiedRegionBorderIfNeededLocked(int displayId) { public void drawMagnifiedRegionBorderIfNeededLocked(int displayId, SurfaceControl.Transaction t) { final DisplayMagnifier displayMagnifier = mDisplayMagnifiers.get(displayId); if (displayMagnifier != null) { displayMagnifier.drawMagnifiedRegionBorderIfNeededLocked(); displayMagnifier.drawMagnifiedRegionBorderIfNeededLocked(t); } // Not relevant for the window observer. } Loading Loading @@ -431,7 +431,7 @@ final class AccessibilityController { Slog.i(LOG_TAG, "Rotation: " + Surface.rotationToString(rotation) + " displayId: " + displayContent.getDisplayId()); } mMagnifedViewport.onRotationChangedLocked(); mMagnifedViewport.onRotationChangedLocked(displayContent.getPendingTransaction()); mHandler.sendEmptyMessage(MyHandler.MESSAGE_NOTIFY_ROTATION_CHANGED); } Loading Loading @@ -536,9 +536,8 @@ final class AccessibilityController { .sendToTarget(); } /** NOTE: This has to be called within a surface transaction. */ public void drawMagnifiedRegionBorderIfNeededLocked() { mMagnifedViewport.drawWindowIfNeededLocked(); public void drawMagnifiedRegionBorderIfNeededLocked(SurfaceControl.Transaction t) { mMagnifedViewport.drawWindowIfNeededLocked(t); } private final class MagnifiedViewport { Loading Loading @@ -744,7 +743,7 @@ final class AccessibilityController { return letterboxBounds; } public void onRotationChangedLocked() { public void onRotationChangedLocked(SurfaceControl.Transaction t) { // If we are showing the magnification border, hide it immediately so // the user does not see strange artifacts during rotation. The screenshot // used for rotation already has the border. After the rotation is complete Loading @@ -758,7 +757,7 @@ final class AccessibilityController { mHandler.sendMessageDelayed(message, delay); } recomputeBoundsLocked(); mWindow.updateSize(); mWindow.updateSize(t); } public void setMagnifiedRegionBorderShownLocked(boolean shown, boolean animate) { Loading @@ -784,10 +783,9 @@ final class AccessibilityController { return mMagnificationSpec; } /** NOTE: This has to be called within a surface transaction. */ public void drawWindowIfNeededLocked() { public void drawWindowIfNeededLocked(SurfaceControl.Transaction t) { recomputeBoundsLocked(); mWindow.drawIfNeeded(); mWindow.drawIfNeeded(t); } public void destroyWindow() { Loading Loading @@ -837,10 +835,11 @@ final class AccessibilityController { /* ignore */ } mSurfaceControl = surfaceControl; mSurfaceControl.setLayer(mService.mPolicy.getWindowLayerFromTypeLw( TYPE_MAGNIFICATION_OVERLAY) * WindowManagerService.TYPE_LAYER_MULTIPLIER); mSurfaceControl.setPosition(0, 0); mService.mTransactionFactory.get().setLayer(mSurfaceControl, mService.mPolicy.getWindowLayerFromTypeLw(TYPE_MAGNIFICATION_OVERLAY) * WindowManagerService.TYPE_LAYER_MULTIPLIER) .setPosition(mSurfaceControl, 0, 0) .apply(); mSurface.copyFrom(mSurfaceControl); mAnimationController = new AnimationController(context, Loading Loading @@ -905,10 +904,10 @@ final class AccessibilityController { } } public void updateSize() { public void updateSize(SurfaceControl.Transaction t) { synchronized (mService.mGlobalLock) { mWindowManager.getDefaultDisplay().getRealSize(mTempPoint); mSurfaceControl.setBufferSize(mTempPoint.x, mTempPoint.y); t.setBufferSize(mSurfaceControl, mTempPoint.x, mTempPoint.y); invalidate(mDirtyRect); } } Loading @@ -923,8 +922,7 @@ final class AccessibilityController { mService.scheduleAnimationLocked(); } /** NOTE: This has to be called within a surface transaction. */ public void drawIfNeeded() { public void drawIfNeeded(SurfaceControl.Transaction t) { synchronized (mService.mGlobalLock) { if (!mInvalidated) { return; Loading Loading @@ -959,9 +957,9 @@ final class AccessibilityController { canvas.drawPath(path, mPaint); mSurface.unlockCanvasAndPost(canvas); mSurfaceControl.show(); t.show(mSurfaceControl); } else { mSurfaceControl.hide(); t.hide(mSurfaceControl); } } } Loading
services/core/java/com/android/server/wm/AppWindowToken.java +1 −1 Original line number Diff line number Diff line Loading @@ -2930,7 +2930,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree layer += Z_BOOST_BASE; } if (!mNeedsAnimationBoundsLayer) { leash.setLayer(layer); t.setLayer(leash, layer); } final DisplayContent dc = getDisplayContent(); Loading