Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1677c879 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow creating child surfaces from BlastBufferQueue"

parents 3971f269 ce1a6484
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp
               cmds/uinput/
               core/jni/
               libs/input/
               native/
               services/core/jni/
               services/incremental/
               tests/
+1 −1
Original line number Diff line number Diff line
@@ -1207,7 +1207,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
            // Therefore, we must explicitly recreate the {@link Surface} in these
            // cases.
            if (mUseBlastAdapter) {
                mSurface.transferFrom(mBlastBufferQueue.createSurface());
                mSurface.transferFrom(mBlastBufferQueue.createSurfaceWithHandle());
            } else {
                mSurface.createFrom(mSurfaceControl);
            }
+5 −3
Original line number Diff line number Diff line
@@ -53,9 +53,11 @@ static void nativeDestroy(JNIEnv* env, jclass clazz, jlong ptr) {
    queue->decStrong((void*)nativeCreate);
}

static jobject nativeGetSurface(JNIEnv* env, jclass clazz, jlong ptr) {
static jobject nativeGetSurface(JNIEnv* env, jclass clazz, jlong ptr,
                                jboolean includeSurfaceControlHandle) {
    sp<BLASTBufferQueue> queue = reinterpret_cast<BLASTBufferQueue*>(ptr);
    return android_view_Surface_createFromSurface(env, queue->getSurface());
    return android_view_Surface_createFromSurface(env,
                                                  queue->getSurface(includeSurfaceControlHandle));
}

static void nativeSetNextTransaction(JNIEnv* env, jclass clazz, jlong ptr, jlong transactionPtr) {
@@ -77,7 +79,7 @@ static void nativeFlushShadowQueue(JNIEnv* env, jclass clazz, jlong ptr) {
static const JNINativeMethod gMethods[] = {
        /* name, signature, funcPtr */
        {"nativeCreate", "(Ljava/lang/String;JJJZ)J", (void*)nativeCreate},
        {"nativeGetSurface", "(J)Landroid/view/Surface;", (void*)nativeGetSurface},
        {"nativeGetSurface", "(JZ)Landroid/view/Surface;", (void*)nativeGetSurface},
        {"nativeDestroy", "(J)V", (void*)nativeDestroy},
        {"nativeSetNextTransaction", "(JJ)V", (void*)nativeSetNextTransaction},
        {"nativeUpdate", "(JJJJ)V", (void*)nativeUpdate},
+4 −2
Original line number Diff line number Diff line
@@ -313,7 +313,7 @@ static jlong nativeGetFromBlastBufferQueue(JNIEnv* env, jclass clazz, jlong nati
        return nativeObject;
    }

    sp<Surface> surface = queue->getSurface();
    sp<Surface> surface = queue->getSurface(true /* includeSurfaceControlHandle */);
    if (surface != NULL) {
        surface->incStrong(&sRefBaseOwner);
    }
@@ -349,7 +349,8 @@ static jlong nativeReadFromParcel(JNIEnv* env, jclass clazz,
    sp<Surface> sur;
    if (surfaceShim.graphicBufferProducer != nullptr) {
        // we have a new IGraphicBufferProducer, create a new Surface for it
        sur = new Surface(surfaceShim.graphicBufferProducer, true);
        sur = new Surface(surfaceShim.graphicBufferProducer, true,
                          surfaceShim.surfaceControlHandle);
        // and keep a reference before passing to java
        sur->incStrong(&sRefBaseOwner);
    }
@@ -373,6 +374,7 @@ static void nativeWriteToParcel(JNIEnv* env, jclass clazz,
    android::view::Surface surfaceShim;
    if (self != nullptr) {
        surfaceShim.graphicBufferProducer = self->getIGraphicBufferProducer();
        surfaceShim.surfaceControlHandle = self->getSurfaceControlHandle();
    }
    // Calling code in Surface.java has already written the name of the Surface
    // to the Parcel
+7 −2
Original line number Diff line number Diff line
@@ -318,8 +318,13 @@ static jlong nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj,
        }
    }

    status_t err = client->createSurfaceChecked(
            String8(name.c_str()), w, h, format, &surface, flags, parent, std::move(metadata));
    sp<IBinder> parentHandle;
    if (parent != nullptr) {
        parentHandle = parent->getHandle();
    }

    status_t err = client->createSurfaceChecked(String8(name.c_str()), w, h, format, &surface,
                                                flags, parentHandle, std::move(metadata));
    if (err == NAME_NOT_FOUND) {
        jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
        return 0;
Loading