Merge "connect/disconnect is now called from our EGL wrapper"
This commit is contained in:
committed by
Android (Google) Code Review
commit
34e1fb1ee2
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user