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

Commit 2530b32d authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge "remove uses of Surface in favor of IGraphicBufferProducer" into jb-mr2-dev

parents 8be3bc4a 4a05f436
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -544,13 +544,17 @@ static void android_hardware_Camera_setPreviewDisplay(JNIEnv *env, jobject thiz,
    sp<Camera> camera = get_native_camera(env, thiz, NULL);
    if (camera == 0) return;

    sp<IGraphicBufferProducer> gbp;
    sp<Surface> surface;
    if (jSurface) {
        surface = android_view_Surface_getSurface(env, jSurface);
        if (surface != NULL) {
            gbp = surface->getIGraphicBufferProducer();
        }
    }

    if (camera->setPreviewDisplay(surface) != NO_ERROR) {
        jniThrowException(env, "java/io/IOException", "setPreviewDisplay failed");
    if (camera->setPreviewTexture(gbp) != NO_ERROR) {
        jniThrowException(env, "java/io/IOException", "setPreviewTexture failed");
    }
}

+10 −3
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@
#include <android_runtime/android_view_Surface.h>
#include <android_runtime/android_graphics_SurfaceTexture.h>

#include <binder/Parcel.h>

#include <gui/Surface.h>
#include <gui/SurfaceControl.h>
#include <gui/GLConsumer.h>
@@ -334,10 +336,15 @@ static jint nativeReadFromParcel(JNIEnv* env, jclass clazz,
    if (self != NULL) {
        self->decStrong(&sRefBaseOwner);
    }
    sp<Surface> sur(Surface::readFromParcel(*parcel));
    if (sur != NULL) {

    sp<Surface> sur;
    sp<IGraphicBufferProducer> gbp(
            interface_cast<IGraphicBufferProducer>(parcel->readStrongBinder()));
    if (gbp != NULL) {
        sur = new Surface(gbp);
        sur->incStrong(&sRefBaseOwner);
    }

    return int(sur.get());
}

@@ -349,7 +356,7 @@ static void nativeWriteToParcel(JNIEnv* env, jclass clazz,
        return;
    }
    sp<Surface> self(reinterpret_cast<Surface *>(nativeObject));
    Surface::writeToParcel(self, parcel);
    parcel->writeStrongBinder( self != 0 ? self->getIGraphicBufferProducer()->asBinder() : NULL);
}

// ----------------------------------------------------------------------------
+1 −1
Original line number Diff line number Diff line
@@ -327,7 +327,7 @@ android_media_MediaRecorder_prepare(JNIEnv *env, jobject thiz)
        }

        ALOGI("prepare: surface=%p", native_surface.get());
        if (process_media_recorder_call(env, mr->setPreviewSurface(native_surface), "java/lang/RuntimeException", "setPreviewSurface failed.")) {
        if (process_media_recorder_call(env, mr->setPreviewSurface(native_surface->getIGraphicBufferProducer()), "java/lang/RuntimeException", "setPreviewSurface failed.")) {
            return;
        }
    }