diff options
| author | Robert Carr <racarr@google.com> | 2017-01-09 19:48:29 -0800 |
|---|---|---|
| committer | Robert Carr <racarr@google.com> | 2017-01-12 11:16:34 -0800 |
| commit | 6486d31dcbffb7179127a72ceefa11a1e726271f (patch) | |
| tree | fa94b997afd1c23b2809d63a6931e95cfc4872b2 /core/java | |
| parent | d26d2af79e5bb52f4392bdbfd1858f905f80480d (diff) | |
Expose SurfaceControl method to screenshot to GraphicBuffer.
A graphic buffer is most useful, as we can both attach it
to starting windows, and directly use it in Sys-UI. The old
codepath for starting windows/saved surfaces, is co-existing
at the moment, so I don't make large attempts to clean up
the existing screenshot code.
Bug: 31339431
Test: Manual test in combination with other branches
Change-Id: I562fdd5460dbce3201ba090272e8731850780f20
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/view/SurfaceControl.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index b87250e5f131..a12600a0d4e2 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -17,6 +17,7 @@ package android.view; import android.graphics.Bitmap; +import android.graphics.GraphicBuffer; import android.graphics.Rect; import android.graphics.Region; import android.os.IBinder; @@ -42,6 +43,9 @@ public class SurfaceControl { private static native Bitmap nativeScreenshot(IBinder displayToken, Rect sourceCrop, int width, int height, int minLayer, int maxLayer, boolean allLayers, boolean useIdentityTransform, int rotation); + private static native GraphicBuffer nativeScreenshotToBuffer(IBinder displayToken, + Rect sourceCrop, int width, int height, int minLayer, int maxLayer, + boolean allLayers, boolean useIdentityTransform, int rotation); private static native void nativeScreenshot(IBinder displayToken, Surface consumer, Rect sourceCrop, int width, int height, int minLayer, int maxLayer, boolean allLayers, boolean useIdentityTransform); @@ -828,6 +832,19 @@ public class SurfaceControl { } /** + * Like {@link SurfaceControl#screenshot(Rect, int, int, int, int, boolean, int)} + * but returns a GraphicBuffer. + */ + public static GraphicBuffer screenshotToBuffer(Rect sourceCrop, int width, int height, + int minLayer, int maxLayer, boolean useIdentityTransform, + int rotation) { + IBinder displayToken = SurfaceControl.getBuiltInDisplay( + SurfaceControl.BUILT_IN_DISPLAY_ID_MAIN); + return nativeScreenshotToBuffer(displayToken, sourceCrop, width, height, + minLayer, maxLayer, false, useIdentityTransform, rotation); + } + + /** * Like {@link SurfaceControl#screenshot(int, int, int, int, boolean)} but * includes all Surfaces in the screenshot. * |
