Expose Java side for parenting SurfaceControl
Proposed by itself so others can experiment. Test: Native side covered by SF Transaction test. Java side tested manually for now. Change-Id: I44cf3acd65480bfe14e26db83e905f3ade73f7e0
This commit is contained in:
@@ -34,7 +34,7 @@ public class SurfaceControl {
|
||||
private static final String TAG = "SurfaceControl";
|
||||
|
||||
private static native long nativeCreate(SurfaceSession session, String name,
|
||||
int w, int h, int format, int flags)
|
||||
int w, int h, int format, int flags, long parentObject)
|
||||
throws OutOfResourcesException;
|
||||
private static native void nativeRelease(long nativeObject);
|
||||
private static native void nativeDestroy(long nativeObject);
|
||||
@@ -287,6 +287,12 @@ public class SurfaceControl {
|
||||
public SurfaceControl(SurfaceSession session,
|
||||
String name, int w, int h, int format, int flags)
|
||||
throws OutOfResourcesException {
|
||||
this(session, name, w, h, format, flags, null);
|
||||
}
|
||||
|
||||
public SurfaceControl(SurfaceSession session,
|
||||
String name, int w, int h, int format, int flags, SurfaceControl parent)
|
||||
throws OutOfResourcesException {
|
||||
if (session == null) {
|
||||
throw new IllegalArgumentException("session must not be null");
|
||||
}
|
||||
@@ -304,7 +310,7 @@ public class SurfaceControl {
|
||||
}
|
||||
|
||||
mName = name;
|
||||
mNativeObject = nativeCreate(session, name, w, h, format, flags);
|
||||
mNativeObject = nativeCreate(session, name, w, h, format, flags, parent != null ? parent.mNativeObject : 0);
|
||||
if (mNativeObject == 0) {
|
||||
throw new OutOfResourcesException(
|
||||
"Couldn't allocate SurfaceControl native object");
|
||||
|
||||
@@ -98,11 +98,12 @@ static struct {
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static jlong nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj,
|
||||
jstring nameStr, jint w, jint h, jint format, jint flags) {
|
||||
jstring nameStr, jint w, jint h, jint format, jint flags, jlong parentObject) {
|
||||
ScopedUtfChars name(env, nameStr);
|
||||
sp<SurfaceComposerClient> client(android_view_SurfaceSession_getClient(env, sessionObj));
|
||||
SurfaceControl *parent = reinterpret_cast<SurfaceControl*>(parentObject);
|
||||
sp<SurfaceControl> surface = client->createSurface(
|
||||
String8(name.c_str()), w, h, format, flags);
|
||||
String8(name.c_str()), w, h, format, flags, parent);
|
||||
if (surface == NULL) {
|
||||
jniThrowException(env, OutOfResourcesException, NULL);
|
||||
return 0;
|
||||
@@ -741,7 +742,7 @@ static jobject nativeGetHdrCapabilities(JNIEnv* env, jclass clazz, jobject token
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static const JNINativeMethod sSurfaceControlMethods[] = {
|
||||
{"nativeCreate", "(Landroid/view/SurfaceSession;Ljava/lang/String;IIII)J",
|
||||
{"nativeCreate", "(Landroid/view/SurfaceSession;Ljava/lang/String;IIIIJ)J",
|
||||
(void*)nativeCreate },
|
||||
{"nativeRelease", "(J)V",
|
||||
(void*)nativeRelease },
|
||||
|
||||
Reference in New Issue
Block a user