Loading core/java/android/hardware/display/DisplayManagerInternal.java +3 −3 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ import android.util.SparseArray; import android.view.Display; import android.view.DisplayInfo; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceControl.Transaction; /** * Display manager local system service interface. Loading Loading @@ -126,7 +126,7 @@ public abstract class DisplayManagerInternal { * Called by the window manager to perform traversals while holding a * surface flinger transaction. */ public abstract void performTraversal(SurfaceControl.Transaction t); public abstract void performTraversal(Transaction t); /** * Tells the display manager about properties of the display that depend on the windows on it. Loading Loading @@ -383,6 +383,6 @@ public abstract class DisplayManagerInternal { * update the position of its surfaces as part of the same transaction. */ public interface DisplayTransactionListener { void onDisplayTransaction(); void onDisplayTransaction(Transaction t); } } core/java/android/view/SurfaceControl.java +19 −7 Original line number Diff line number Diff line Loading @@ -375,9 +375,13 @@ public class SurfaceControl implements Parcelable { * Construct a new {@link SurfaceControl} with the set parameters. */ public SurfaceControl build() { if (mWidth <= 0 || mHeight <= 0) { if (mWidth < 0 || mHeight < 0) { throw new IllegalArgumentException( "width and height must be set"); "width and height must be positive or unset"); } if ((mWidth > 0 || mHeight > 0) && (isColorLayerSet() || isContainerLayerSet())) { throw new IllegalArgumentException( "Only buffer layers can set a valid buffer size."); } return new SurfaceControl(mSession, mName, mWidth, mHeight, mFormat, mFlags, mParent, mWindowType, mOwnerUid); Loading @@ -399,8 +403,8 @@ public class SurfaceControl implements Parcelable { * @param width The buffer width in pixels. * @param height The buffer height in pixels. */ public Builder setSize(int width, int height) { if (width <= 0 || height <= 0) { public Builder setBufferSize(int width, int height) { if (width < 0 || height < 0) { throw new IllegalArgumentException( "width and height must be positive"); } Loading Loading @@ -533,6 +537,10 @@ public class SurfaceControl implements Parcelable { return this; } private boolean isColorLayerSet() { return (mFlags & FX_SURFACE_DIM) == FX_SURFACE_DIM; } /** * Indicates whether a 'ContainerLayer' is to be constructed. * Loading @@ -550,6 +558,10 @@ public class SurfaceControl implements Parcelable { return this; } private boolean isContainerLayerSet() { return (mFlags & FX_SURFACE_CONTAINER) == FX_SURFACE_CONTAINER; } /** * Set 'Surface creation flags' such as {@link HIDDEN}, {@link SECURE}. * Loading Loading @@ -869,10 +881,10 @@ public class SurfaceControl implements Parcelable { } } public void setSize(int w, int h) { public void setBufferSize(int w, int h) { checkNotReleased(); synchronized(SurfaceControl.class) { sGlobalTransaction.setSize(this, w, h); sGlobalTransaction.setBufferSize(this, w, h); } } Loading Loading @@ -1427,7 +1439,7 @@ public class SurfaceControl implements Parcelable { } @UnsupportedAppUsage public Transaction setSize(SurfaceControl sc, int w, int h) { public Transaction setBufferSize(SurfaceControl sc, int w, int h) { sc.checkNotReleased(); mResizedSurfaces.put(sc, new Point(w, h)); nativeSetSize(mNativeObject, sc.mNativeObject, w, h); Loading core/java/android/view/SurfaceView.java +12 −6 Original line number Diff line number Diff line Loading @@ -557,7 +557,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb name, (mSurfaceFlags & SurfaceControl.OPAQUE) != 0, new SurfaceControl.Builder(mSurfaceSession) .setSize(mSurfaceWidth, mSurfaceHeight) .setBufferSize(mSurfaceWidth, mSurfaceHeight) .setFormat(mFormat) .setFlags(mSurfaceFlags)); } else if (mSurfaceControl == null) { Loading Loading @@ -595,10 +595,14 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb mSurfaceControl.setMatrix(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. mSurfaceControl.setWindowCrop(mSurfaceWidth, mSurfaceHeight); } if (sizeChanged && !creating) { mSurfaceControl.setSize(mSurfaceWidth, mSurfaceHeight); mSurfaceControl.setWindowCrop(mSurfaceWidth, mSurfaceHeight); mSurfaceControl.setBufferSize(mSurfaceWidth, mSurfaceHeight); } } finally { SurfaceControl.closeTransaction(); Loading Loading @@ -1133,6 +1137,8 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb mBackgroundControl = b.setName("Background for -" + name) .setFormat(OPAQUE) // Unset the buffer size of the background color layer. .setBufferSize(0, 0) .setColorLayer(true) .build(); mOpaque = opaque; Loading @@ -1158,9 +1164,9 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb } @Override public void setSize(int w, int h) { super.setSize(w, h); mBackgroundControl.setSize(w, h); public void setBufferSize(int w, int h) { super.setBufferSize(w, h); // The background surface is a color layer so we do not set a size. } @Override Loading core/java/android/view/View.java +1 −1 Original line number Diff line number Diff line Loading @@ -24741,7 +24741,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final SurfaceSession session = new SurfaceSession(root.mSurface); final SurfaceControl surfaceControl = new SurfaceControl.Builder(session) .setName("drag surface") .setSize(shadowSize.x, shadowSize.y) .setBufferSize(shadowSize.x, shadowSize.y) .setFormat(PixelFormat.TRANSLUCENT) .build(); final Surface surface = new Surface(); core/java/android/view/ViewRootImpl.java +3 −12 Original line number Diff line number Diff line Loading @@ -1473,31 +1473,22 @@ public final class ViewRootImpl implements ViewParent, mBoundsSurfaceControl = new SurfaceControl.Builder(mSurfaceSession) .setName("Bounds for - " + getTitle().toString()) .setSize(mWidth, mHeight) .build(); setBoundsSurfaceSizeAndCrop(); setBoundsSurfaceCrop(); mTransaction.setLayer(mBoundsSurfaceControl, zOrderLayer) .show(mBoundsSurfaceControl) .apply(); mBoundsSurface.copyFrom(mBoundsSurfaceControl); } private void setBoundsSurfaceSizeAndCrop() { private void setBoundsSurfaceCrop() { // mWinFrame is already adjusted for surface insets. So offset it and use it as // the cropping bounds. mTempBoundsRect.set(mWinFrame); mTempBoundsRect.offsetTo(mWindowAttributes.surfaceInsets.left, mWindowAttributes.surfaceInsets.top); mTransaction.setWindowCrop(mBoundsSurfaceControl, mTempBoundsRect); // Expand the bounds by the surface insets to get the size of surface. mTempBoundsRect.inset(-mWindowAttributes.surfaceInsets.left, -mWindowAttributes.surfaceInsets.top, -mWindowAttributes.surfaceInsets.right, -mWindowAttributes.surfaceInsets.bottom); mTransaction.setSize(mBoundsSurfaceControl, mTempBoundsRect.width(), mTempBoundsRect.height()); } /** Loading @@ -1506,7 +1497,7 @@ public final class ViewRootImpl implements ViewParent, */ private void updateBoundsSurface() { if (mBoundsSurfaceControl != null && mSurface.isValid()) { setBoundsSurfaceSizeAndCrop(); setBoundsSurfaceCrop(); mTransaction.deferTransactionUntilSurface(mBoundsSurfaceControl, mSurface, mSurface.getNextFrameNumber()) .apply(); Loading Loading
core/java/android/hardware/display/DisplayManagerInternal.java +3 −3 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ import android.util.SparseArray; import android.view.Display; import android.view.DisplayInfo; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceControl.Transaction; /** * Display manager local system service interface. Loading Loading @@ -126,7 +126,7 @@ public abstract class DisplayManagerInternal { * Called by the window manager to perform traversals while holding a * surface flinger transaction. */ public abstract void performTraversal(SurfaceControl.Transaction t); public abstract void performTraversal(Transaction t); /** * Tells the display manager about properties of the display that depend on the windows on it. Loading Loading @@ -383,6 +383,6 @@ public abstract class DisplayManagerInternal { * update the position of its surfaces as part of the same transaction. */ public interface DisplayTransactionListener { void onDisplayTransaction(); void onDisplayTransaction(Transaction t); } }
core/java/android/view/SurfaceControl.java +19 −7 Original line number Diff line number Diff line Loading @@ -375,9 +375,13 @@ public class SurfaceControl implements Parcelable { * Construct a new {@link SurfaceControl} with the set parameters. */ public SurfaceControl build() { if (mWidth <= 0 || mHeight <= 0) { if (mWidth < 0 || mHeight < 0) { throw new IllegalArgumentException( "width and height must be set"); "width and height must be positive or unset"); } if ((mWidth > 0 || mHeight > 0) && (isColorLayerSet() || isContainerLayerSet())) { throw new IllegalArgumentException( "Only buffer layers can set a valid buffer size."); } return new SurfaceControl(mSession, mName, mWidth, mHeight, mFormat, mFlags, mParent, mWindowType, mOwnerUid); Loading @@ -399,8 +403,8 @@ public class SurfaceControl implements Parcelable { * @param width The buffer width in pixels. * @param height The buffer height in pixels. */ public Builder setSize(int width, int height) { if (width <= 0 || height <= 0) { public Builder setBufferSize(int width, int height) { if (width < 0 || height < 0) { throw new IllegalArgumentException( "width and height must be positive"); } Loading Loading @@ -533,6 +537,10 @@ public class SurfaceControl implements Parcelable { return this; } private boolean isColorLayerSet() { return (mFlags & FX_SURFACE_DIM) == FX_SURFACE_DIM; } /** * Indicates whether a 'ContainerLayer' is to be constructed. * Loading @@ -550,6 +558,10 @@ public class SurfaceControl implements Parcelable { return this; } private boolean isContainerLayerSet() { return (mFlags & FX_SURFACE_CONTAINER) == FX_SURFACE_CONTAINER; } /** * Set 'Surface creation flags' such as {@link HIDDEN}, {@link SECURE}. * Loading Loading @@ -869,10 +881,10 @@ public class SurfaceControl implements Parcelable { } } public void setSize(int w, int h) { public void setBufferSize(int w, int h) { checkNotReleased(); synchronized(SurfaceControl.class) { sGlobalTransaction.setSize(this, w, h); sGlobalTransaction.setBufferSize(this, w, h); } } Loading Loading @@ -1427,7 +1439,7 @@ public class SurfaceControl implements Parcelable { } @UnsupportedAppUsage public Transaction setSize(SurfaceControl sc, int w, int h) { public Transaction setBufferSize(SurfaceControl sc, int w, int h) { sc.checkNotReleased(); mResizedSurfaces.put(sc, new Point(w, h)); nativeSetSize(mNativeObject, sc.mNativeObject, w, h); Loading
core/java/android/view/SurfaceView.java +12 −6 Original line number Diff line number Diff line Loading @@ -557,7 +557,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb name, (mSurfaceFlags & SurfaceControl.OPAQUE) != 0, new SurfaceControl.Builder(mSurfaceSession) .setSize(mSurfaceWidth, mSurfaceHeight) .setBufferSize(mSurfaceWidth, mSurfaceHeight) .setFormat(mFormat) .setFlags(mSurfaceFlags)); } else if (mSurfaceControl == null) { Loading Loading @@ -595,10 +595,14 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb mSurfaceControl.setMatrix(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. mSurfaceControl.setWindowCrop(mSurfaceWidth, mSurfaceHeight); } if (sizeChanged && !creating) { mSurfaceControl.setSize(mSurfaceWidth, mSurfaceHeight); mSurfaceControl.setWindowCrop(mSurfaceWidth, mSurfaceHeight); mSurfaceControl.setBufferSize(mSurfaceWidth, mSurfaceHeight); } } finally { SurfaceControl.closeTransaction(); Loading Loading @@ -1133,6 +1137,8 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb mBackgroundControl = b.setName("Background for -" + name) .setFormat(OPAQUE) // Unset the buffer size of the background color layer. .setBufferSize(0, 0) .setColorLayer(true) .build(); mOpaque = opaque; Loading @@ -1158,9 +1164,9 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb } @Override public void setSize(int w, int h) { super.setSize(w, h); mBackgroundControl.setSize(w, h); public void setBufferSize(int w, int h) { super.setBufferSize(w, h); // The background surface is a color layer so we do not set a size. } @Override Loading
core/java/android/view/View.java +1 −1 Original line number Diff line number Diff line Loading @@ -24741,7 +24741,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final SurfaceSession session = new SurfaceSession(root.mSurface); final SurfaceControl surfaceControl = new SurfaceControl.Builder(session) .setName("drag surface") .setSize(shadowSize.x, shadowSize.y) .setBufferSize(shadowSize.x, shadowSize.y) .setFormat(PixelFormat.TRANSLUCENT) .build(); final Surface surface = new Surface();
core/java/android/view/ViewRootImpl.java +3 −12 Original line number Diff line number Diff line Loading @@ -1473,31 +1473,22 @@ public final class ViewRootImpl implements ViewParent, mBoundsSurfaceControl = new SurfaceControl.Builder(mSurfaceSession) .setName("Bounds for - " + getTitle().toString()) .setSize(mWidth, mHeight) .build(); setBoundsSurfaceSizeAndCrop(); setBoundsSurfaceCrop(); mTransaction.setLayer(mBoundsSurfaceControl, zOrderLayer) .show(mBoundsSurfaceControl) .apply(); mBoundsSurface.copyFrom(mBoundsSurfaceControl); } private void setBoundsSurfaceSizeAndCrop() { private void setBoundsSurfaceCrop() { // mWinFrame is already adjusted for surface insets. So offset it and use it as // the cropping bounds. mTempBoundsRect.set(mWinFrame); mTempBoundsRect.offsetTo(mWindowAttributes.surfaceInsets.left, mWindowAttributes.surfaceInsets.top); mTransaction.setWindowCrop(mBoundsSurfaceControl, mTempBoundsRect); // Expand the bounds by the surface insets to get the size of surface. mTempBoundsRect.inset(-mWindowAttributes.surfaceInsets.left, -mWindowAttributes.surfaceInsets.top, -mWindowAttributes.surfaceInsets.right, -mWindowAttributes.surfaceInsets.bottom); mTransaction.setSize(mBoundsSurfaceControl, mTempBoundsRect.width(), mTempBoundsRect.height()); } /** Loading @@ -1506,7 +1497,7 @@ public final class ViewRootImpl implements ViewParent, */ private void updateBoundsSurface() { if (mBoundsSurfaceControl != null && mSurface.isValid()) { setBoundsSurfaceSizeAndCrop(); setBoundsSurfaceCrop(); mTransaction.deferTransactionUntilSurface(mBoundsSurfaceControl, mSurface, mSurface.getNextFrameNumber()) .apply(); Loading