egl: Add EGL extension for front buffer auto-refresh mode
- Add an EGL extension for enabling/disabling auto-refresh mode on
a surface that's being used for front-buffer rendering.
- Remove the temporary hack that was directly enabling/disabling
front-buffer rendering from the EGL wrapper. From now on the driver
will have to implement it.
Bug 24949410
Change-Id: I722577521a37f9892dbadaf504b4551fe37182ed
diff --git a/opengl/include/EGL/eglext.h b/opengl/include/EGL/eglext.h
index 267f8af..5d838e6 100644
--- a/opengl/include/EGL/eglext.h
+++ b/opengl/include/EGL/eglext.h
@@ -611,6 +611,12 @@
#endif
#endif
+#ifndef EGL_ANDROID_front_buffer_auto_refresh
+#define EGL_ANDROID_front_buffer_auto_refresh 1
+#define EGL_FRONT_BUFFER_AUTO_REFRESH_ANDROID 0x314C
+#endif
+
+
#ifdef __cplusplus
}
#endif
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index 05700f8..794a7e5 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -72,7 +72,7 @@
* The rest (gExtensionString) depend on support in the EGL driver, and are
* only available if the driver supports them. However, some of these must be
* supported because they are used by the Android system itself; these are
- * listd as mandatory below and are required by the CDD. The system *assumes*
+ * listed as mandatory below and are required by the CDD. The system *assumes*
* the mandatory extensions are present and may not function properly if some
* are missing.
*
@@ -83,6 +83,7 @@
"EGL_ANDROID_presentation_time "
"EGL_KHR_swap_buffers_with_damage "
"EGL_ANDROID_create_native_client_buffer "
+ "EGL_ANDROID_front_buffer_auto_refresh "
;
extern char const * const gExtensionString =
"EGL_KHR_image " // mandatory
@@ -1194,12 +1195,9 @@
egl_surface_t const * const s = get_surface(surface);
- //XXX: temporary hack for the EGL hook-up for single buffer mode
- if (attribute == EGL_RENDER_BUFFER && (value == EGL_BACK_BUFFER ||
- value == EGL_SINGLE_BUFFER)) {
- native_window_set_auto_refresh(s->win.get(), true);
- return (native_window_set_single_buffer_mode(s->win.get(),
- value == EGL_SINGLE_BUFFER)) ? EGL_TRUE : EGL_FALSE;
+ if (attribute == EGL_FRONT_BUFFER_AUTO_REFRESH_ANDROID) {
+ return (native_window_set_auto_refresh(s->win.get(),
+ value ? true : false)) ? EGL_TRUE : EGL_FALSE;
}
if (s->cnx->egl.eglSurfaceAttrib) {
diff --git a/opengl/specs/EGL_ANDROID_front_buffer_auto_refresh.txt b/opengl/specs/EGL_ANDROID_front_buffer_auto_refresh.txt
new file mode 100644
index 0000000..4c0e64c
--- /dev/null
+++ b/opengl/specs/EGL_ANDROID_front_buffer_auto_refresh.txt
@@ -0,0 +1,70 @@
+Name
+
+ ANDROID_front_buffer_auto_refresh
+
+Name Strings
+
+ EGL_ANDROID_front_buffer_auto_refresh
+
+Contributors
+
+ Pablo Ceballos
+
+Contact
+
+ Pablo Ceballos, Google Inc. (pceballos 'at' google.com)
+
+Status
+
+ Draft
+
+Version
+
+ Version 1, February 3, 2016
+
+Number
+
+ EGL Extension #XXX
+
+Dependencies
+
+ Requires EGL 1.2
+
+ This extension is written against the wording of the EGL 1.5 Specification
+
+Overview
+
+ This extension is intended for latency-sensitive applications that are doing
+ front-buffer rendering. It allows them to indicate to the Android compositor
+ that it should perform composition every time the display refreshes. This
+ removes the overhead of having to notify the compositor that the window
+ surface has been updated, but it comes at the cost of doing potentially
+ unneeded composition work if the window surface has not been updated.
+
+New Types
+
+ None
+
+New Procedures and Functions
+
+ None
+
+New Tokens
+
+ EGL_FRONT_BUFFER_AUTO_REFRESH_ANDROID 0x314C
+
+Add to the list of supported tokens for eglSurfaceAttrib in section 3.5.6
+"Surface Attributes", page 43:
+
+ If attribute is EGL_ANDROID_front_buffer_auto_refresh, then value specifies
+ whether to enable or disable auto-refresh in the Android compositor when
+ doing front-buffer rendering.
+
+Issues
+
+ None
+
+Revision History
+
+#1 (Pablo Ceballos, February 3, 2016)
+ - Initial draft.
diff --git a/opengl/specs/README b/opengl/specs/README
index f4de1b3..8f1eaf3 100644
--- a/opengl/specs/README
+++ b/opengl/specs/README
@@ -6,10 +6,10 @@
Value Extension
---------------- ----------------------------------
-0x3140 EGL_ANDROID_image_native_buffer
-0x3141 (unused)
+0x3140 EGL_NATIVE_BUFFER_ANDROID (EGL_ANDROID_image_native_buffer)
+0x3141 EGL_PLATFORM_ANDROID_KHR (KHR_platform_android)
0x3142 EGL_RECORDABLE_ANDROID (EGL_ANDROID_recordable)
-0x3143 EGL_VERSION_HW_ANDROID (internal use)
+0x3143 EGL_NATIVE_BUFFER_USAGE_ANDROID (EGL_ANDROID_create_native_client_buffer)
0x3144 EGL_SYNC_NATIVE_FENCE_ANDROID (EGL_ANDROID_native_fence_sync)
0x3145 EGL_SYNC_NATIVE_FENCE_FD_ANDROID (EGL_ANDROID_native_fence_sync)
0x3146 EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID (EGL_ANDROID_native_fence_sync)
@@ -18,4 +18,5 @@
0x3149 EGL_IMAGE_CROP_TOP_ANDROID (EGL_ANDROID_image_crop)
0x314A EGL_IMAGE_CROP_RIGHT_ANDROID (EGL_ANDROID_image_crop)
0x314B EGL_IMAGE_CROP_BOTTOM_ANDROID (EGL_ANDROID_image_crop)
-0x314C - 0x314F (unused)
+0x314C EGL_FRONT_BUFFER_AUTO_REFRESH_ANDROID (EGL_ANDROID_front_buffer_auto_refresh)
+0x314D - 0x314F (unused)