Loading core/java/android/view/SurfaceControl.java +1 −33 Original line number Diff line number Diff line Loading @@ -1968,37 +1968,6 @@ public final class SurfaceControl implements Parcelable { return getPhysicalDisplayToken(physicalDisplayIds[0]); } /** * @see SurfaceControl#screenshot(IBinder, Surface, Rect, int, int, boolean, int) * @hide */ public static void screenshot(IBinder display, Surface consumer) { screenshot(display, consumer, new Rect(), 0, 0, false, 0); } /** * Copy the current screen contents into the provided {@link Surface} * * @param consumer The {@link Surface} to take the screenshot into. * @see SurfaceControl#screenshotToBuffer(IBinder, Rect, int, int, boolean, int) * @hide */ public static void screenshot(IBinder display, Surface consumer, Rect sourceCrop, int width, int height, boolean useIdentityTransform, int rotation) { if (consumer == null) { throw new IllegalArgumentException("consumer must not be null"); } final ScreenshotHardwareBuffer buffer = screenshotToBuffer(display, sourceCrop, width, height, useIdentityTransform, rotation); try { consumer.attachAndQueueBufferWithColorSpace(buffer.getHardwareBuffer(), buffer.getColorSpace()); } catch (RuntimeException e) { Log.w(TAG, "Failed to take screenshot - " + e.getMessage()); } } /** * @see SurfaceControl#screenshot(Rect, int, int, boolean, int)} * @hide Loading @@ -2014,8 +1983,7 @@ public final class SurfaceControl implements Parcelable { * a software Bitmap using {@link Bitmap#copy(Bitmap.Config, boolean)} * * CAVEAT: Versions of screenshot that return a {@link Bitmap} can be extremely slow; avoid use * unless absolutely necessary; prefer the versions that use a {@link Surface} such as * {@link SurfaceControl#screenshot(IBinder, Surface)} or {@link HardwareBuffer} such as * unless absolutely necessary; prefer the versions that use a {@link HardwareBuffer} such as * {@link SurfaceControl#screenshotToBuffer(IBinder, Rect, int, int, boolean, int)}. * * @see SurfaceControl#screenshotToBuffer(IBinder, Rect, int, int, boolean, int)} Loading services/core/java/com/android/server/display/ColorFade.java +16 −9 Original line number Diff line number Diff line Loading @@ -491,7 +491,14 @@ final class ColorFade { mIsWideColor = SurfaceControl.getActiveColorMode(token) == Display.COLOR_MODE_DISPLAY_P3; SurfaceControl.screenshot(token, s); SurfaceControl.ScreenshotHardwareBuffer screenshotBuffer = mDisplayManagerInternal.systemScreenshot(mDisplayId); s.attachAndQueueBufferWithColorSpace(screenshotBuffer.getHardwareBuffer(), screenshotBuffer.getColorSpace()); if (screenshotBuffer.containsSecureLayers()) { mTransaction.setSecure(mSurfaceControl, true).apply(); } st.updateTexImage(); st.getTransformMatrix(mTexMatrix); } finally { Loading Loading @@ -586,7 +593,6 @@ final class ColorFade { } if (mSurfaceControl == null) { Transaction t = new Transaction(); try { final SurfaceControl.Builder builder = new SurfaceControl.Builder(mSurfaceSession) .setName("ColorFade") Loading @@ -602,15 +608,16 @@ final class ColorFade { return false; } t.setLayerStack(mSurfaceControl, mDisplayLayerStack); t.setWindowCrop(mSurfaceControl, mDisplayWidth, mDisplayHeight); mTransaction.setLayerStack(mSurfaceControl, mDisplayLayerStack); mTransaction.setWindowCrop(mSurfaceControl, mDisplayWidth, mDisplayHeight); mSurfaceLayout = new NaturalSurfaceLayout(mDisplayManagerInternal, mDisplayId, mSurfaceControl); mSurfaceLayout.onDisplayTransaction(mTransaction); mTransaction.apply(); mSurface = new Surface(); mSurface.copyFrom(mSurfaceControl); mSurfaceLayout = new NaturalSurfaceLayout(mDisplayManagerInternal, mDisplayId, mSurfaceControl); mSurfaceLayout.onDisplayTransaction(t); t.apply(); } return true; } Loading Loading @@ -652,7 +659,7 @@ final class ColorFade { if (mSurfaceControl != null) { mSurfaceLayout.dispose(); mSurfaceLayout = null; new Transaction().remove(mSurfaceControl).apply(); mTransaction.remove(mSurfaceControl).apply(); mSurface.release(); mSurfaceControl = null; mSurfaceVisible = false; Loading Loading
core/java/android/view/SurfaceControl.java +1 −33 Original line number Diff line number Diff line Loading @@ -1968,37 +1968,6 @@ public final class SurfaceControl implements Parcelable { return getPhysicalDisplayToken(physicalDisplayIds[0]); } /** * @see SurfaceControl#screenshot(IBinder, Surface, Rect, int, int, boolean, int) * @hide */ public static void screenshot(IBinder display, Surface consumer) { screenshot(display, consumer, new Rect(), 0, 0, false, 0); } /** * Copy the current screen contents into the provided {@link Surface} * * @param consumer The {@link Surface} to take the screenshot into. * @see SurfaceControl#screenshotToBuffer(IBinder, Rect, int, int, boolean, int) * @hide */ public static void screenshot(IBinder display, Surface consumer, Rect sourceCrop, int width, int height, boolean useIdentityTransform, int rotation) { if (consumer == null) { throw new IllegalArgumentException("consumer must not be null"); } final ScreenshotHardwareBuffer buffer = screenshotToBuffer(display, sourceCrop, width, height, useIdentityTransform, rotation); try { consumer.attachAndQueueBufferWithColorSpace(buffer.getHardwareBuffer(), buffer.getColorSpace()); } catch (RuntimeException e) { Log.w(TAG, "Failed to take screenshot - " + e.getMessage()); } } /** * @see SurfaceControl#screenshot(Rect, int, int, boolean, int)} * @hide Loading @@ -2014,8 +1983,7 @@ public final class SurfaceControl implements Parcelable { * a software Bitmap using {@link Bitmap#copy(Bitmap.Config, boolean)} * * CAVEAT: Versions of screenshot that return a {@link Bitmap} can be extremely slow; avoid use * unless absolutely necessary; prefer the versions that use a {@link Surface} such as * {@link SurfaceControl#screenshot(IBinder, Surface)} or {@link HardwareBuffer} such as * unless absolutely necessary; prefer the versions that use a {@link HardwareBuffer} such as * {@link SurfaceControl#screenshotToBuffer(IBinder, Rect, int, int, boolean, int)}. * * @see SurfaceControl#screenshotToBuffer(IBinder, Rect, int, int, boolean, int)} Loading
services/core/java/com/android/server/display/ColorFade.java +16 −9 Original line number Diff line number Diff line Loading @@ -491,7 +491,14 @@ final class ColorFade { mIsWideColor = SurfaceControl.getActiveColorMode(token) == Display.COLOR_MODE_DISPLAY_P3; SurfaceControl.screenshot(token, s); SurfaceControl.ScreenshotHardwareBuffer screenshotBuffer = mDisplayManagerInternal.systemScreenshot(mDisplayId); s.attachAndQueueBufferWithColorSpace(screenshotBuffer.getHardwareBuffer(), screenshotBuffer.getColorSpace()); if (screenshotBuffer.containsSecureLayers()) { mTransaction.setSecure(mSurfaceControl, true).apply(); } st.updateTexImage(); st.getTransformMatrix(mTexMatrix); } finally { Loading Loading @@ -586,7 +593,6 @@ final class ColorFade { } if (mSurfaceControl == null) { Transaction t = new Transaction(); try { final SurfaceControl.Builder builder = new SurfaceControl.Builder(mSurfaceSession) .setName("ColorFade") Loading @@ -602,15 +608,16 @@ final class ColorFade { return false; } t.setLayerStack(mSurfaceControl, mDisplayLayerStack); t.setWindowCrop(mSurfaceControl, mDisplayWidth, mDisplayHeight); mTransaction.setLayerStack(mSurfaceControl, mDisplayLayerStack); mTransaction.setWindowCrop(mSurfaceControl, mDisplayWidth, mDisplayHeight); mSurfaceLayout = new NaturalSurfaceLayout(mDisplayManagerInternal, mDisplayId, mSurfaceControl); mSurfaceLayout.onDisplayTransaction(mTransaction); mTransaction.apply(); mSurface = new Surface(); mSurface.copyFrom(mSurfaceControl); mSurfaceLayout = new NaturalSurfaceLayout(mDisplayManagerInternal, mDisplayId, mSurfaceControl); mSurfaceLayout.onDisplayTransaction(t); t.apply(); } return true; } Loading Loading @@ -652,7 +659,7 @@ final class ColorFade { if (mSurfaceControl != null) { mSurfaceLayout.dispose(); mSurfaceLayout = null; new Transaction().remove(mSurfaceControl).apply(); mTransaction.remove(mSurfaceControl).apply(); mSurface.release(); mSurfaceControl = null; mSurfaceVisible = false; Loading