Merge "SurfaceFlinger: Add exclusion list for captureLayers." into qt-dev
am: f6bd0bc297
Change-Id: I42eda2074fa5e2ad9b3071d2e6e17b19e3fac934
This commit is contained in:
@@ -92,7 +92,7 @@ public final class SurfaceControl implements Parcelable {
|
|||||||
Rect sourceCrop, int width, int height, boolean useIdentityTransform, int rotation,
|
Rect sourceCrop, int width, int height, boolean useIdentityTransform, int rotation,
|
||||||
boolean captureSecureLayers);
|
boolean captureSecureLayers);
|
||||||
private static native ScreenshotGraphicBuffer nativeCaptureLayers(IBinder layerHandleToken,
|
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 nativeCreateTransaction();
|
||||||
private static native long nativeGetNativeTransactionFinalizer();
|
private static native long nativeGetNativeTransactionFinalizer();
|
||||||
@@ -1991,7 +1991,16 @@ public final class SurfaceControl implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public static ScreenshotGraphicBuffer captureLayers(IBinder layerHandleToken, Rect sourceCrop,
|
public static ScreenshotGraphicBuffer captureLayers(IBinder layerHandleToken, Rect sourceCrop,
|
||||||
float frameScale) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ static jobject nativeScreenshot(JNIEnv* env, jclass clazz,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerHandleToken,
|
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);
|
sp<IBinder> layerHandle = ibinderForJavaObject(env, layerHandleToken);
|
||||||
if (layerHandle == NULL) {
|
if (layerHandle == NULL) {
|
||||||
@@ -282,11 +282,27 @@ static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerHandl
|
|||||||
sourceCrop = rectFromObj(env, sourceCropObj);
|
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;
|
sp<GraphicBuffer> buffer;
|
||||||
const ui::Dataspace dataspace = ui::Dataspace::V0_SRGB;
|
const ui::Dataspace dataspace = ui::Dataspace::V0_SRGB;
|
||||||
status_t res = ScreenshotClient::captureChildLayers(layerHandle, dataspace,
|
status_t res = ScreenshotClient::captureChildLayers(layerHandle, dataspace,
|
||||||
ui::PixelFormat::RGBA_8888, sourceCrop,
|
ui::PixelFormat::RGBA_8888, sourceCrop,
|
||||||
frameScale, &buffer);
|
excludeHandles, frameScale, &buffer);
|
||||||
if (res != NO_ERROR) {
|
if (res != NO_ERROR) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1354,7 +1370,7 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
|
|||||||
"Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;",
|
"Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;",
|
||||||
(void*)nativeScreenshot },
|
(void*)nativeScreenshot },
|
||||||
{"nativeCaptureLayers",
|
{"nativeCaptureLayers",
|
||||||
"(Landroid/os/IBinder;Landroid/graphics/Rect;F)"
|
"(Landroid/os/IBinder;Landroid/graphics/Rect;F[Landroid/os/IBinder;)"
|
||||||
"Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;",
|
"Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;",
|
||||||
(void*)nativeCaptureLayers },
|
(void*)nativeCaptureLayers },
|
||||||
{"nativeSetInputWindowInfo", "(JJLandroid/view/InputWindowHandle;)V",
|
{"nativeSetInputWindowInfo", "(JJLandroid/view/InputWindowHandle;)V",
|
||||||
|
|||||||
Reference in New Issue
Block a user