diff options
author | Dan Stoza <stoza@google.com> | 2015-02-19 15:27:36 -0800 |
---|---|---|
committer | Dan Stoza <stoza@google.com> | 2015-04-15 13:02:27 -0700 |
commit | a894d082cfee8d12ee5913163a34ec5dc521d005 (patch) | |
tree | e0dad36f86a1d2ad9d293a2bf2a174781c446b6b /opengl/libs/EGL | |
parent | f9ab2ad2d5786b2dd04f08f5d5a67102bd3d796a (diff) | |
download | frameworks_native-a894d082cfee8d12ee5913163a34ec5dc521d005.tar.gz frameworks_native-a894d082cfee8d12ee5913163a34ec5dc521d005.tar.bz2 frameworks_native-a894d082cfee8d12ee5913163a34ec5dc521d005.zip |
libEGL: Add wrappers for partial update functions
This adds EGL wrapper functions for the following EGL extensions:
EGL_EXT_buffer_age
EGL_KHR_partial_update
EGL_KHR_swap_buffers_with_damage
Change-Id: I407acda1e0310f7f01a5efe9c915721a941138a4
Diffstat (limited to 'opengl/libs/EGL')
-rw-r--r-- | opengl/libs/EGL/eglApi.cpp | 76 | ||||
-rw-r--r-- | opengl/libs/EGL/egl_entries.in | 7 |
2 files changed, 80 insertions, 3 deletions
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp index 11a13c311..f5b90dd84 100644 --- a/opengl/libs/EGL/eglApi.cpp +++ b/opengl/libs/EGL/eglApi.cpp @@ -80,6 +80,7 @@ struct extention_map_t { extern char const * const gBuiltinExtensionString = "EGL_KHR_get_all_proc_addresses " "EGL_ANDROID_presentation_time " + "EGL_KHR_swap_buffers_with_damage " ; extern char const * const gExtensionString = "EGL_KHR_image " // mandatory @@ -100,6 +101,8 @@ extern char const * const gExtensionString = "EGL_ANDROID_image_native_buffer " // mandatory "EGL_KHR_wait_sync " // strongly recommended "EGL_ANDROID_recordable " // mandatory + "EGL_KHR_partial_update " // strongly recommended + "EGL_EXT_buffer_age " // strongly recommended with partial_update ; // extensions not exposed to applications but used by the ANDROID system @@ -152,6 +155,14 @@ static const extention_map_t sExtensionMap[] = { // EGL_ANDROID_presentation_time { "eglPresentationTimeANDROID", (__eglMustCastToProperFunctionPointerType)&eglPresentationTimeANDROID }, + + // EGL_KHR_swap_buffers_with_damage + { "eglSwapBuffersWithDamageKHR", + (__eglMustCastToProperFunctionPointerType)&eglSwapBuffersWithDamageKHR }, + + // EGL_KHR_partial_update + { "eglSetDamageRegionKHR", + (__eglMustCastToProperFunctionPointerType)&eglSetDamageRegionKHR }, }; /* @@ -1021,7 +1032,8 @@ private: Mutex mMutex; }; -EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) +EGLBoolean eglSwapBuffersWithDamageKHR(EGLDisplay dpy, EGLSurface draw, + EGLint *rects, EGLint n_rects) { ATRACE_CALL(); clearError(); @@ -1080,7 +1092,38 @@ EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) } } - return s->cnx->egl.eglSwapBuffers(dp->disp.dpy, s->surface); + if (n_rects == 0) { + return s->cnx->egl.eglSwapBuffers(dp->disp.dpy, s->surface); + } + + Vector<android_native_rect_t> androidRects; + for (int r = 0; r < n_rects; ++r) { + int offset = r * 4; + int x = rects[offset]; + int y = rects[offset + 1]; + int width = rects[offset + 2]; + int height = rects[offset + 3]; + android_native_rect_t androidRect; + androidRect.left = x; + androidRect.top = y + height; + androidRect.right = x + width; + androidRect.bottom = y; + androidRects.push_back(androidRect); + } + native_window_set_surface_damage(s->win.get(), androidRects.array(), + androidRects.size()); + + if (s->cnx->egl.eglSwapBuffersWithDamageKHR) { + return s->cnx->egl.eglSwapBuffersWithDamageKHR(dp->disp.dpy, s->surface, + rects, n_rects); + } else { + return s->cnx->egl.eglSwapBuffers(dp->disp.dpy, s->surface); + } +} + +EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) +{ + return eglSwapBuffersWithDamageKHR(dpy, surface, NULL, 0); } EGLBoolean eglCopyBuffers( EGLDisplay dpy, EGLSurface surface, @@ -1569,3 +1612,32 @@ EGLuint64NV eglGetSystemTimeNV() return setErrorQuiet(EGL_BAD_DISPLAY, 0); } + +// ---------------------------------------------------------------------------- +// Partial update extension +// ---------------------------------------------------------------------------- +EGLBoolean eglSetDamageRegionKHR(EGLDisplay dpy, EGLSurface surface, + EGLint *rects, EGLint n_rects) +{ + clearError(); + + const egl_display_ptr dp = validate_display(dpy); + if (!dp) { + setError(EGL_BAD_DISPLAY, EGL_FALSE); + return EGL_FALSE; + } + + SurfaceRef _s(dp.get(), surface); + if (!_s.get()) { + setError(EGL_BAD_SURFACE, EGL_FALSE); + return EGL_FALSE; + } + + egl_surface_t const * const s = get_surface(surface); + if (s->cnx->egl.eglSetDamageRegionKHR) { + return s->cnx->egl.eglSetDamageRegionKHR(dp->disp.dpy, s->surface, + rects, n_rects); + } + + return EGL_FALSE; +} diff --git a/opengl/libs/EGL/egl_entries.in b/opengl/libs/EGL/egl_entries.in index 70d0e52fd..1e27cb64f 100644 --- a/opengl/libs/EGL/egl_entries.in +++ b/opengl/libs/EGL/egl_entries.in @@ -89,4 +89,9 @@ EGL_ENTRY(EGLuint64NV, eglGetSystemTimeNV, void) /* IMG extensions */ EGL_ENTRY(EGLBoolean, eglHibernateProcessIMG, void) -EGL_ENTRY(EGLBoolean, eglAwakenProcessIMG, void)
\ No newline at end of file +EGL_ENTRY(EGLBoolean, eglAwakenProcessIMG, void) + +/* Partial update extensions */ + +EGL_ENTRY(EGLBoolean, eglSwapBuffersWithDamageKHR, EGLDisplay, EGLSurface, EGLint *, EGLint) +EGL_ENTRY(EGLBoolean, eglSetDamageRegionKHR, EGLDisplay, EGLSurface, EGLint *, EGLint) |