summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2011-07-29 17:55:48 -0700
committerMathias Agopian <mathias@google.com>2011-08-01 14:06:20 -0700
commit982d2da4eef0a48d84d88e3e1d2d1dbdbb413a27 (patch)
tree2a5036e97e04b0467eab8f73a283f0a0730c0d61
parent03116780a17cb6db7c926d01630cb9f68a19539b (diff)
downloadframeworks_base-982d2da4eef0a48d84d88e3e1d2d1dbdbb413a27.zip
frameworks_base-982d2da4eef0a48d84d88e3e1d2d1dbdbb413a27.tar.gz
frameworks_base-982d2da4eef0a48d84d88e3e1d2d1dbdbb413a27.tar.bz2
connect/disconnect is now called from our EGL wrapper
the original connect/disconnect hooks are deprecated and replace by api_connect/api_disconnect. the original hooks are no no-ops. api_connect/api_disconnect is now only called from the android framework. Bug: 5057915 Change-Id: I8ca64cd1acd6cabf915bf54689ec2e5f6dfa495a
-rw-r--r--libs/gui/SurfaceTextureClient.cpp10
-rw-r--r--libs/ui/FramebufferNativeWindow.cpp2
-rw-r--r--media/libmedia/mediaplayer.cpp8
-rw-r--r--opengl/libs/EGL/eglApi.cpp19
-rw-r--r--services/camera/libcameraservice/CameraService.cpp8
5 files changed, 35 insertions, 12 deletions
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp
index e6837ea..d1037de 100644
--- a/libs/gui/SurfaceTextureClient.cpp
+++ b/libs/gui/SurfaceTextureClient.cpp
@@ -258,10 +258,10 @@ int SurfaceTextureClient::perform(int operation, va_list args)
int res = NO_ERROR;
switch (operation) {
case NATIVE_WINDOW_CONNECT:
- res = dispatchConnect(args);
+ // deprecated. must return NO_ERROR.
break;
case NATIVE_WINDOW_DISCONNECT:
- res = dispatchDisconnect(args);
+ // deprecated. must return NO_ERROR.
break;
case NATIVE_WINDOW_SET_USAGE:
res = dispatchSetUsage(args);
@@ -296,6 +296,12 @@ int SurfaceTextureClient::perform(int operation, va_list args)
case NATIVE_WINDOW_SET_SCALING_MODE:
res = dispatchSetScalingMode(args);
break;
+ case NATIVE_WINDOW_API_CONNECT:
+ res = dispatchConnect(args);
+ break;
+ case NATIVE_WINDOW_API_DISCONNECT:
+ res = dispatchDisconnect(args);
+ break;
default:
res = NAME_NOT_FOUND;
break;
diff --git a/libs/ui/FramebufferNativeWindow.cpp b/libs/ui/FramebufferNativeWindow.cpp
index 0e8ae61..8949730 100644
--- a/libs/ui/FramebufferNativeWindow.cpp
+++ b/libs/ui/FramebufferNativeWindow.cpp
@@ -317,6 +317,8 @@ int FramebufferNativeWindow::perform(ANativeWindow* window,
case NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS:
case NATIVE_WINDOW_SET_BUFFERS_FORMAT:
case NATIVE_WINDOW_SET_BUFFERS_TRANSFORM:
+ case NATIVE_WINDOW_API_CONNECT:
+ case NATIVE_WINDOW_API_DISCONNECT:
// TODO: we should implement these
return NO_ERROR;
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp
index a11fb80..3dd9249 100644
--- a/media/libmedia/mediaplayer.cpp
+++ b/media/libmedia/mediaplayer.cpp
@@ -201,11 +201,11 @@ status_t MediaPlayer::getMetadata(bool update_only, bool apply_filter, Parcel *m
void MediaPlayer::disconnectNativeWindow() {
if (mConnectedWindow != NULL) {
- status_t err = native_window_disconnect(mConnectedWindow.get(),
+ status_t err = native_window_api_disconnect(mConnectedWindow.get(),
NATIVE_WINDOW_API_MEDIA);
if (err != OK) {
- LOGW("native_window_disconnect returned an error: %s (%d)",
+ LOGW("native_window_api_disconnect returned an error: %s (%d)",
strerror(-err), err);
}
}
@@ -224,7 +224,7 @@ status_t MediaPlayer::setVideoSurface(const sp<Surface>& surface)
}
if (surface != NULL) {
- status_t err = native_window_connect(surface.get(),
+ status_t err = native_window_api_connect(surface.get(),
NATIVE_WINDOW_API_MEDIA);
if (err != OK) {
@@ -274,7 +274,7 @@ status_t MediaPlayer::setVideoSurfaceTexture(
sp<ANativeWindow> anw;
if (surfaceTexture != NULL) {
anw = new SurfaceTextureClient(surfaceTexture);
- status_t err = native_window_connect(anw.get(),
+ status_t err = native_window_api_connect(anw.get(),
NATIVE_WINDOW_API_MEDIA);
if (err != OK) {
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index ba5d29a..10cea22 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -363,6 +363,12 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
EGLConfig iConfig = dp->configs[intptr_t(config)].config;
EGLint format;
+ if (native_window_api_connect(window, NATIVE_WINDOW_API_EGL) != OK) {
+ LOGE("EGLNativeWindowType %p already connected to another API",
+ window);
+ return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
+ }
+
// set the native window's buffers format to match this config
if (cnx->egl.eglGetConfigAttrib(iDpy,
iConfig, EGL_NATIVE_VISUAL_ID, &format)) {
@@ -371,6 +377,7 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
if (err != 0) {
LOGE("error setting native window pixel format: %s (%d)",
strerror(-err), err);
+ native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL);
return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
}
}
@@ -383,6 +390,10 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
dp->configs[intptr_t(config)].impl, cnx);
return s;
}
+
+ // EGLSurface creation failed
+ native_window_set_buffers_format(window, 0);
+ native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL);
}
return EGL_NO_SURFACE;
}
@@ -443,8 +454,12 @@ EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
EGLBoolean result = s->cnx->egl.eglDestroySurface(
dp->disp[s->impl].dpy, s->surface);
if (result == EGL_TRUE) {
- if (s->win != NULL) {
- native_window_set_buffers_geometry(s->win.get(), 0, 0, 0);
+ ANativeWindow* const window = s->win.get();
+ if (window != NULL) {
+ native_window_set_buffers_format(window, 0);
+ if (native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL)) {
+ LOGE("EGLNativeWindowType %p disconnected failed", window);
+ }
}
_s.terminate();
}
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index b03649e..def25d1 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -460,10 +460,10 @@ status_t CameraService::Client::connect(const sp<ICameraClient>& client) {
static void disconnectWindow(const sp<ANativeWindow>& window) {
if (window != 0) {
- status_t result = native_window_disconnect(window.get(),
+ status_t result = native_window_api_disconnect(window.get(),
NATIVE_WINDOW_API_CAMERA);
if (result != NO_ERROR) {
- LOGW("native_window_disconnect failed: %s (%d)", strerror(-result),
+ LOGW("native_window_api_disconnect failed: %s (%d)", strerror(-result),
result);
}
}
@@ -526,9 +526,9 @@ status_t CameraService::Client::setPreviewWindow(const sp<IBinder>& binder,
}
if (window != 0) {
- result = native_window_connect(window.get(), NATIVE_WINDOW_API_CAMERA);
+ result = native_window_api_connect(window.get(), NATIVE_WINDOW_API_CAMERA);
if (result != NO_ERROR) {
- LOGE("native_window_connect failed: %s (%d)", strerror(-result),
+ LOGE("native_window_api_connect failed: %s (%d)", strerror(-result),
result);
return result;
}