remove uses of Surface in favor of IGraphicBufferProducer
Change-Id: I2ec590eed03c76a084ee6b0af362a3ca6476bf9f
diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp
index 6fbaaf2..686e4e3 100644
--- a/core/jni/android_hardware_Camera.cpp
+++ b/core/jni/android_hardware_Camera.cpp
@@ -544,13 +544,17 @@
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");
}
}
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index 0104f4b..9c78abe 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -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 @@
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 @@
return;
}
sp<Surface> self(reinterpret_cast<Surface *>(nativeObject));
- Surface::writeToParcel(self, parcel);
+ parcel->writeStrongBinder( self != 0 ? self->getIGraphicBufferProducer()->asBinder() : NULL);
}
// ----------------------------------------------------------------------------
diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp
index 4ebbbde..9888591 100644
--- a/media/jni/android_media_MediaRecorder.cpp
+++ b/media/jni/android_media_MediaRecorder.cpp
@@ -327,7 +327,7 @@
}
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;
}
}