diff options
Diffstat (limited to 'opengl/libs/EGL/eglApi.cpp')
-rw-r--r-- | opengl/libs/EGL/eglApi.cpp | 96 |
1 files changed, 49 insertions, 47 deletions
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp index d5e9cb8..73aab26 100644 --- a/opengl/libs/EGL/eglApi.cpp +++ b/opengl/libs/EGL/eglApi.cpp @@ -37,7 +37,7 @@ #include "egl_impl.h" #include "egl_tls.h" -#include "glesv2dbg.h" +#include "glestrace.h" #include "hooks.h" #include "egl_display.h" @@ -112,7 +112,6 @@ extern EGLBoolean egl_init_drivers(); extern const __eglMustCastToProperFunctionPointerType gExtensionForwarders[MAX_NUMBER_OF_GL_EXTENSIONS]; extern int gEGLDebugLevel; extern gl_hooks_t gHooksTrace; -extern gl_hooks_t gHooksDebug; } // namespace android; // ---------------------------------------------------------------------------- @@ -478,6 +477,26 @@ EGLBoolean eglQuerySurface( EGLDisplay dpy, EGLSurface surface, return result; } +void EGLAPI eglBeginFrame(EGLDisplay dpy, EGLSurface surface) { + clearError(); + + egl_display_t const * const dp = validate_display(dpy); + if (!dp) { + return; + } + + SurfaceRef _s(dp, surface); + if (!_s.get()) { + setError(EGL_BAD_SURFACE, EGL_FALSE); + return; + } + + int64_t timestamp = systemTime(SYSTEM_TIME_MONOTONIC); + + egl_surface_t const * const s = get_surface(surface); + native_window_set_buffers_timestamp(s->win.get(), timestamp); +} + // ---------------------------------------------------------------------------- // Contexts // ---------------------------------------------------------------------------- @@ -516,6 +535,10 @@ EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, } egl_context_t* c = new egl_context_t(dpy, context, config, dp->configs[intptr_t(config)].impl, cnx, version); +#if EGL_TRACE + if (gEGLDebugLevel > 0) + GLTrace_eglCreateContext(version, c); +#endif return c; } } @@ -543,27 +566,6 @@ EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) return result; } -static void loseCurrent(egl_context_t * cur_c) -{ - if (cur_c) { - egl_surface_t * cur_r = get_surface(cur_c->read); - egl_surface_t * cur_d = get_surface(cur_c->draw); - - // by construction, these are either 0 or valid (possibly terminated) - // it should be impossible for these to be invalid - ContextRef _cur_c(cur_c); - SurfaceRef _cur_r(cur_r); - SurfaceRef _cur_d(cur_d); - - cur_c->read = NULL; - cur_c->draw = NULL; - - _cur_c.release(); - _cur_r.release(); - _cur_d.release(); - } -} - EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { @@ -640,31 +642,22 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw, impl_read = r->surface; } - EGLBoolean result; - if (c) { - result = c->cnx->egl.eglMakeCurrent( - dp->disp[c->impl].dpy, impl_draw, impl_read, impl_ctx); - } else { - result = cur_c->cnx->egl.eglMakeCurrent( - dp->disp[cur_c->impl].dpy, impl_draw, impl_read, impl_ctx); - } + EGLBoolean result = const_cast<egl_display_t*>(dp)->makeCurrent(c, cur_c, + draw, read, ctx, + impl_draw, impl_read, impl_ctx); if (result == EGL_TRUE) { - - loseCurrent(cur_c); - - if (ctx != EGL_NO_CONTEXT) { + if (c) { setGLHooksThreadSpecific(c->cnx->hooks[c->version]); egl_tls_t::setContext(ctx); - if (gEGLDebugLevel > 0) { - CreateDbgContext(c->version, c->cnx->hooks[c->version]); - } +#if EGL_TRACE + if (gEGLDebugLevel > 0) + GLTrace_eglMakeCurrent(c->version, c->cnx->hooks[c->version], ctx); +#endif _c.acquire(); _r.acquire(); _d.acquire(); - c->read = read; - c->draw = draw; } else { setGLHooksThreadSpecific(&gHooksNoContext); egl_tls_t::setContext(EGL_NO_CONTEXT); @@ -886,6 +879,10 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) "no more slots for eglGetProcAddress(\"%s\")", procname); +#if EGL_TRACE + gl_hooks_t *debugHooks = GLTrace_getGLHooks(); +#endif + if (!addr && (slot < MAX_NUMBER_OF_GL_EXTENSIONS)) { bool found = false; for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) { @@ -896,7 +893,8 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) cnx->hooks[GLESv1_INDEX]->ext.extensions[slot] = cnx->hooks[GLESv2_INDEX]->ext.extensions[slot] = #if EGL_TRACE - gHooksDebug.ext.extensions[slot] = gHooksTrace.ext.extensions[slot] = + debugHooks->ext.extensions[slot] = + gHooksTrace.ext.extensions[slot] = #endif cnx->egl.eglGetProcAddress(procname); } @@ -924,10 +922,6 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) { - EGLBoolean Debug_eglSwapBuffers(EGLDisplay dpy, EGLSurface draw); - if (gEGLDebugLevel > 0) - Debug_eglSwapBuffers(dpy, draw); - clearError(); egl_display_t const * const dp = validate_display(dpy); @@ -937,6 +931,11 @@ EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) if (!_s.get()) return setError(EGL_BAD_SURFACE, EGL_FALSE); +#if EGL_TRACE + if (gEGLDebugLevel > 0) + GLTrace_eglSwapBuffers(dpy, draw); +#endif + egl_surface_t const * const s = get_surface(draw); return s->cnx->egl.eglSwapBuffers(dp->disp[s->impl].dpy, s->surface); } @@ -1151,7 +1150,7 @@ EGLBoolean eglReleaseThread(void) clearError(); // If there is context bound to the thread, release it - loseCurrent(get_context(getContext())); + egl_display_t::loseCurrent(get_context(getContext())); for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) { egl_connection_t* const cnx = &gEGLImpl[i]; @@ -1162,7 +1161,10 @@ EGLBoolean eglReleaseThread(void) } } egl_tls_t::clearTLS(); - dbgReleaseThread(); +#if EGL_TRACE + if (gEGLDebugLevel > 0) + GLTrace_eglReleaseThread(); +#endif return EGL_TRUE; } |