Loading core/java/android/view/SurfaceControl.java +11 −2 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ public final class SurfaceControl implements Parcelable { Rect sourceCrop, int width, int height, boolean useIdentityTransform, int rotation, boolean captureSecureLayers); private static native ScreenshotGraphicBuffer nativeCaptureLayers(IBinder layerHandleToken, Rect sourceCrop, float frameScale); Rect sourceCrop, float frameScale, IBinder[] excludeLayers); private static native long nativeCreateTransaction(); private static native long nativeGetNativeTransactionFinalizer(); Loading Loading @@ -1991,7 +1991,16 @@ public final class SurfaceControl implements Parcelable { */ public static ScreenshotGraphicBuffer captureLayers(IBinder layerHandleToken, Rect sourceCrop, float frameScale) { return nativeCaptureLayers(layerHandleToken, sourceCrop, frameScale); return nativeCaptureLayers(layerHandleToken, sourceCrop, frameScale, null); } /** * Like {@link captureLayers} but with an array of layer handles to exclude. * @hide */ public static ScreenshotGraphicBuffer captureLayersExcluding(IBinder layerHandleToken, Rect sourceCrop, float frameScale, IBinder[] exclude) { return nativeCaptureLayers(layerHandleToken, sourceCrop, frameScale, exclude); } /** Loading core/jni/android_view_SurfaceControl.cpp +19 −3 Original line number Diff line number Diff line Loading @@ -270,7 +270,7 @@ static jobject nativeScreenshot(JNIEnv* env, jclass clazz, } static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerHandleToken, jobject sourceCropObj, jfloat frameScale) { jobject sourceCropObj, jfloat frameScale, jobjectArray excludeArray) { sp<IBinder> layerHandle = ibinderForJavaObject(env, layerHandleToken); if (layerHandle == NULL) { Loading @@ -282,11 +282,27 @@ static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerHandl sourceCrop = rectFromObj(env, sourceCropObj); } std::unordered_set<sp<IBinder>,ISurfaceComposer::SpHash<IBinder>> excludeHandles; if (excludeArray != NULL) { const jsize len = env->GetArrayLength(excludeArray); excludeHandles.reserve(len); for (jsize i = 0; i < len; i++) { jobject obj = env->GetObjectArrayElement(excludeArray, i); if (obj == nullptr) { jniThrowNullPointerException(env, "Exclude layer is null"); return NULL; } sp<IBinder> excludeHandle = ibinderForJavaObject(env, obj); excludeHandles.emplace(excludeHandle); } } sp<GraphicBuffer> buffer; const ui::Dataspace dataspace = ui::Dataspace::V0_SRGB; status_t res = ScreenshotClient::captureChildLayers(layerHandle, dataspace, ui::PixelFormat::RGBA_8888, sourceCrop, frameScale, &buffer); excludeHandles, frameScale, &buffer); if (res != NO_ERROR) { return NULL; } Loading Loading @@ -1354,7 +1370,7 @@ static const JNINativeMethod sSurfaceControlMethods[] = { "Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;", (void*)nativeScreenshot }, {"nativeCaptureLayers", "(Landroid/os/IBinder;Landroid/graphics/Rect;F)" "(Landroid/os/IBinder;Landroid/graphics/Rect;F[Landroid/os/IBinder;)" "Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;", (void*)nativeCaptureLayers }, {"nativeSetInputWindowInfo", "(JJLandroid/view/InputWindowHandle;)V", Loading Loading
core/java/android/view/SurfaceControl.java +11 −2 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ public final class SurfaceControl implements Parcelable { Rect sourceCrop, int width, int height, boolean useIdentityTransform, int rotation, boolean captureSecureLayers); private static native ScreenshotGraphicBuffer nativeCaptureLayers(IBinder layerHandleToken, Rect sourceCrop, float frameScale); Rect sourceCrop, float frameScale, IBinder[] excludeLayers); private static native long nativeCreateTransaction(); private static native long nativeGetNativeTransactionFinalizer(); Loading Loading @@ -1991,7 +1991,16 @@ public final class SurfaceControl implements Parcelable { */ public static ScreenshotGraphicBuffer captureLayers(IBinder layerHandleToken, Rect sourceCrop, float frameScale) { return nativeCaptureLayers(layerHandleToken, sourceCrop, frameScale); return nativeCaptureLayers(layerHandleToken, sourceCrop, frameScale, null); } /** * Like {@link captureLayers} but with an array of layer handles to exclude. * @hide */ public static ScreenshotGraphicBuffer captureLayersExcluding(IBinder layerHandleToken, Rect sourceCrop, float frameScale, IBinder[] exclude) { return nativeCaptureLayers(layerHandleToken, sourceCrop, frameScale, exclude); } /** Loading
core/jni/android_view_SurfaceControl.cpp +19 −3 Original line number Diff line number Diff line Loading @@ -270,7 +270,7 @@ static jobject nativeScreenshot(JNIEnv* env, jclass clazz, } static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerHandleToken, jobject sourceCropObj, jfloat frameScale) { jobject sourceCropObj, jfloat frameScale, jobjectArray excludeArray) { sp<IBinder> layerHandle = ibinderForJavaObject(env, layerHandleToken); if (layerHandle == NULL) { Loading @@ -282,11 +282,27 @@ static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerHandl sourceCrop = rectFromObj(env, sourceCropObj); } std::unordered_set<sp<IBinder>,ISurfaceComposer::SpHash<IBinder>> excludeHandles; if (excludeArray != NULL) { const jsize len = env->GetArrayLength(excludeArray); excludeHandles.reserve(len); for (jsize i = 0; i < len; i++) { jobject obj = env->GetObjectArrayElement(excludeArray, i); if (obj == nullptr) { jniThrowNullPointerException(env, "Exclude layer is null"); return NULL; } sp<IBinder> excludeHandle = ibinderForJavaObject(env, obj); excludeHandles.emplace(excludeHandle); } } sp<GraphicBuffer> buffer; const ui::Dataspace dataspace = ui::Dataspace::V0_SRGB; status_t res = ScreenshotClient::captureChildLayers(layerHandle, dataspace, ui::PixelFormat::RGBA_8888, sourceCrop, frameScale, &buffer); excludeHandles, frameScale, &buffer); if (res != NO_ERROR) { return NULL; } Loading Loading @@ -1354,7 +1370,7 @@ static const JNINativeMethod sSurfaceControlMethods[] = { "Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;", (void*)nativeScreenshot }, {"nativeCaptureLayers", "(Landroid/os/IBinder;Landroid/graphics/Rect;F)" "(Landroid/os/IBinder;Landroid/graphics/Rect;F[Landroid/os/IBinder;)" "Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;", (void*)nativeCaptureLayers }, {"nativeSetInputWindowInfo", "(JJLandroid/view/InputWindowHandle;)V", Loading