| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 1 | /* | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 2 | ** Copyright 2007, The Android Open Source Project | 
|  | 3 | ** | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 4 | ** Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | ** you may not use this file except in compliance with the License. | 
|  | 6 | ** You may obtain a copy of the License at | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 7 | ** | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 8 | **     http://www.apache.org/licenses/LICENSE-2.0 | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 9 | ** | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 10 | ** Unless required by applicable law or agreed to in writing, software | 
|  | 11 | ** distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | ** See the License for the specific language governing permissions and | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 14 | ** limitations under the License. | 
|  | 15 | */ | 
|  | 16 |  | 
| Jamie Gennis | 1c8e95c | 2012-02-23 19:27:23 -0800 | [diff] [blame] | 17 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS | 
|  | 18 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 19 | #include <ctype.h> | 
| Mark Salyzyn | a5e161b | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 20 | #include <dlfcn.h> | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 21 | #include <stdlib.h> | 
|  | 22 | #include <string.h> | 
|  | 23 |  | 
| Craig Donner | e96a325 | 2017-02-02 12:13:34 -0800 | [diff] [blame] | 24 | #include <hardware/gralloc1.h> | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 25 |  | 
|  | 26 | #include <EGL/egl.h> | 
|  | 27 | #include <EGL/eglext.h> | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 28 |  | 
| Craig Donner | 6076107 | 2017-01-27 12:30:44 -0800 | [diff] [blame] | 29 | #include <android/hardware_buffer.h> | 
| Mathias Agopian | 89ed4c8 | 2017-02-09 18:48:34 -0800 | [diff] [blame] | 30 | #include <private/android/AHardwareBufferHelpers.h> | 
|  | 31 |  | 
| Mathias Agopian | 7db993a | 2012-03-25 00:49:46 -0700 | [diff] [blame] | 32 | #include <cutils/compiler.h> | 
| Mark Salyzyn | a5e161b | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 33 | #include <cutils/properties.h> | 
| Mark Salyzyn | 7823e12 | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 34 | #include <log/log.h> | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 35 |  | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 36 | #include <condition_variable> | 
|  | 37 | #include <deque> | 
|  | 38 | #include <mutex> | 
|  | 39 | #include <unordered_map> | 
|  | 40 | #include <string> | 
|  | 41 | #include <thread> | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 42 |  | 
| Mathias Agopian | 39c24a2 | 2013-04-04 23:17:56 -0700 | [diff] [blame] | 43 | #include "../egl_impl.h" | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 44 |  | 
|  | 45 | #include "egl_display.h" | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 46 | #include "egl_object.h" | 
|  | 47 | #include "egl_tls.h" | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 48 | #include "egl_trace.h" | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 49 |  | 
|  | 50 | using namespace android; | 
|  | 51 |  | 
|  | 52 | // ---------------------------------------------------------------------------- | 
|  | 53 |  | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 54 | namespace android { | 
|  | 55 |  | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 56 | using nsecs_t = int64_t; | 
|  | 57 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 58 | struct extention_map_t { | 
|  | 59 | const char* name; | 
|  | 60 | __eglMustCastToProperFunctionPointerType address; | 
|  | 61 | }; | 
|  | 62 |  | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 63 | /* | 
| Jesse Hall | 21558da | 2013-08-06 15:31:22 -0700 | [diff] [blame] | 64 | * This is the list of EGL extensions exposed to applications. | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 65 | * | 
| Jesse Hall | 21558da | 2013-08-06 15:31:22 -0700 | [diff] [blame] | 66 | * Some of them (gBuiltinExtensionString) are implemented entirely in this EGL | 
|  | 67 | * wrapper and are always available. | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 68 | * | 
| Jesse Hall | 21558da | 2013-08-06 15:31:22 -0700 | [diff] [blame] | 69 | * The rest (gExtensionString) depend on support in the EGL driver, and are | 
|  | 70 | * only available if the driver supports them. However, some of these must be | 
|  | 71 | * supported because they are used by the Android system itself; these are | 
| Pablo Ceballos | 02b05da | 2016-02-02 17:53:18 -0800 | [diff] [blame] | 72 | * listed as mandatory below and are required by the CDD. The system *assumes* | 
| Jesse Hall | 21558da | 2013-08-06 15:31:22 -0700 | [diff] [blame] | 73 | * the mandatory extensions are present and may not function properly if some | 
|  | 74 | * are missing. | 
|  | 75 | * | 
|  | 76 | * NOTE: Both strings MUST have a single space as the last character. | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 77 | */ | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 78 |  | 
| Mathias Agopian | 311b479 | 2017-02-28 15:00:49 -0800 | [diff] [blame] | 79 | extern char const * const gBuiltinExtensionString; | 
|  | 80 | extern char const * const gExtensionString; | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 81 |  | 
| Mathias Agopian | 311b479 | 2017-02-28 15:00:49 -0800 | [diff] [blame] | 82 | char const * const gBuiltinExtensionString = | 
| Jesse Hall | 21558da | 2013-08-06 15:31:22 -0700 | [diff] [blame] | 83 | "EGL_KHR_get_all_proc_addresses " | 
|  | 84 | "EGL_ANDROID_presentation_time " | 
| Dan Stoza | a894d08 | 2015-02-19 15:27:36 -0800 | [diff] [blame] | 85 | "EGL_KHR_swap_buffers_with_damage " | 
| Craig Donner | 6076107 | 2017-01-27 12:30:44 -0800 | [diff] [blame] | 86 | "EGL_ANDROID_get_native_client_buffer " | 
| Pablo Ceballos | 02b05da | 2016-02-02 17:53:18 -0800 | [diff] [blame] | 87 | "EGL_ANDROID_front_buffer_auto_refresh " | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 88 | "EGL_ANDROID_get_frame_timestamps " | 
| Jesse Hall | 21558da | 2013-08-06 15:31:22 -0700 | [diff] [blame] | 89 | ; | 
| Mathias Agopian | 311b479 | 2017-02-28 15:00:49 -0800 | [diff] [blame] | 90 |  | 
|  | 91 | char const * const gExtensionString  = | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 92 | "EGL_KHR_image "                        // mandatory | 
|  | 93 | "EGL_KHR_image_base "                   // mandatory | 
|  | 94 | "EGL_KHR_image_pixmap " | 
|  | 95 | "EGL_KHR_lock_surface " | 
| Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 96 | "EGL_KHR_gl_colorspace " | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 97 | "EGL_KHR_gl_texture_2D_image " | 
| Season Li | 000d88f | 2015-07-01 11:39:40 -0700 | [diff] [blame] | 98 | "EGL_KHR_gl_texture_3D_image " | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 99 | "EGL_KHR_gl_texture_cubemap_image " | 
|  | 100 | "EGL_KHR_gl_renderbuffer_image " | 
|  | 101 | "EGL_KHR_reusable_sync " | 
|  | 102 | "EGL_KHR_fence_sync " | 
| Jamie Gennis | f6d1c39 | 2013-04-25 18:48:41 -0700 | [diff] [blame] | 103 | "EGL_KHR_create_context " | 
| Season Li | 000d88f | 2015-07-01 11:39:40 -0700 | [diff] [blame] | 104 | "EGL_KHR_config_attribs " | 
|  | 105 | "EGL_KHR_surfaceless_context " | 
|  | 106 | "EGL_KHR_stream " | 
|  | 107 | "EGL_KHR_stream_fifo " | 
|  | 108 | "EGL_KHR_stream_producer_eglsurface " | 
|  | 109 | "EGL_KHR_stream_consumer_gltexture " | 
|  | 110 | "EGL_KHR_stream_cross_process_fd " | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 111 | "EGL_EXT_create_context_robustness " | 
|  | 112 | "EGL_NV_system_time " | 
|  | 113 | "EGL_ANDROID_image_native_buffer "      // mandatory | 
| Mathias Agopian | 2bb7168 | 2013-03-27 17:32:41 -0700 | [diff] [blame] | 114 | "EGL_KHR_wait_sync "                    // strongly recommended | 
| Jamie Gennis | dbe9245 | 2013-09-23 17:22:10 -0700 | [diff] [blame] | 115 | "EGL_ANDROID_recordable "               // mandatory | 
| Dan Stoza | a894d08 | 2015-02-19 15:27:36 -0800 | [diff] [blame] | 116 | "EGL_KHR_partial_update "               // strongly recommended | 
| Courtney Goeltzenleuchter | 0e4e395 | 2016-11-16 13:53:40 -0700 | [diff] [blame] | 117 | "EGL_EXT_pixel_format_float " | 
| Dan Stoza | a894d08 | 2015-02-19 15:27:36 -0800 | [diff] [blame] | 118 | "EGL_EXT_buffer_age "                   // strongly recommended with partial_update | 
| Jesse Hall | 408e59f | 2015-04-24 01:40:42 -0700 | [diff] [blame] | 119 | "EGL_KHR_create_context_no_error " | 
| Pablo Ceballos | ceb9ee7 | 2016-04-13 11:17:32 -0700 | [diff] [blame] | 120 | "EGL_KHR_mutable_render_buffer " | 
| Mika Isojärvi | f37864b | 2016-04-15 11:58:56 -0700 | [diff] [blame] | 121 | "EGL_EXT_yuv_surface " | 
| Craig Donner | aec8697 | 2016-04-28 18:09:40 -0700 | [diff] [blame] | 122 | "EGL_EXT_protected_content " | 
| Christian Poetzsch | a7805f6 | 2016-12-01 16:34:39 +0000 | [diff] [blame] | 123 | "EGL_IMG_context_priority " | 
| Pyry Haulos | 51d53c4 | 2017-03-06 09:39:09 -0800 | [diff] [blame] | 124 | "EGL_KHR_no_config_context " | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 125 | ; | 
|  | 126 |  | 
|  | 127 | // extensions not exposed to applications but used by the ANDROID system | 
|  | 128 | //      "EGL_ANDROID_blob_cache "               // strongly recommended | 
|  | 129 | //      "EGL_IMG_hibernate_process "            // optional | 
|  | 130 | //      "EGL_ANDROID_native_fence_sync "        // strongly recommended | 
|  | 131 | //      "EGL_ANDROID_framebuffer_target "       // mandatory for HWC 1.1 | 
| Jamie Gennis | dbe9245 | 2013-09-23 17:22:10 -0700 | [diff] [blame] | 132 | //      "EGL_ANDROID_image_crop "               // optional | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 133 |  | 
|  | 134 | /* | 
|  | 135 | * EGL Extensions entry-points exposed to 3rd party applications | 
|  | 136 | * (keep in sync with gExtensionString above) | 
|  | 137 | * | 
|  | 138 | */ | 
|  | 139 | static const extention_map_t sExtensionMap[] = { | 
|  | 140 | // EGL_KHR_lock_surface | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 141 | { "eglLockSurfaceKHR", | 
|  | 142 | (__eglMustCastToProperFunctionPointerType)&eglLockSurfaceKHR }, | 
|  | 143 | { "eglUnlockSurfaceKHR", | 
|  | 144 | (__eglMustCastToProperFunctionPointerType)&eglUnlockSurfaceKHR }, | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 145 |  | 
|  | 146 | // EGL_KHR_image, EGL_KHR_image_base | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 147 | { "eglCreateImageKHR", | 
|  | 148 | (__eglMustCastToProperFunctionPointerType)&eglCreateImageKHR }, | 
|  | 149 | { "eglDestroyImageKHR", | 
|  | 150 | (__eglMustCastToProperFunctionPointerType)&eglDestroyImageKHR }, | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 151 |  | 
|  | 152 | // EGL_KHR_reusable_sync, EGL_KHR_fence_sync | 
|  | 153 | { "eglCreateSyncKHR", | 
|  | 154 | (__eglMustCastToProperFunctionPointerType)&eglCreateSyncKHR }, | 
|  | 155 | { "eglDestroySyncKHR", | 
|  | 156 | (__eglMustCastToProperFunctionPointerType)&eglDestroySyncKHR }, | 
|  | 157 | { "eglClientWaitSyncKHR", | 
|  | 158 | (__eglMustCastToProperFunctionPointerType)&eglClientWaitSyncKHR }, | 
|  | 159 | { "eglSignalSyncKHR", | 
|  | 160 | (__eglMustCastToProperFunctionPointerType)&eglSignalSyncKHR }, | 
|  | 161 | { "eglGetSyncAttribKHR", | 
|  | 162 | (__eglMustCastToProperFunctionPointerType)&eglGetSyncAttribKHR }, | 
|  | 163 |  | 
|  | 164 | // EGL_NV_system_time | 
| Jonas Yang | 1c3d72a | 2011-08-26 20:04:39 +0800 | [diff] [blame] | 165 | { "eglGetSystemTimeFrequencyNV", | 
|  | 166 | (__eglMustCastToProperFunctionPointerType)&eglGetSystemTimeFrequencyNV }, | 
|  | 167 | { "eglGetSystemTimeNV", | 
|  | 168 | (__eglMustCastToProperFunctionPointerType)&eglGetSystemTimeNV }, | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 169 |  | 
| Mathias Agopian | 2bb7168 | 2013-03-27 17:32:41 -0700 | [diff] [blame] | 170 | // EGL_KHR_wait_sync | 
|  | 171 | { "eglWaitSyncKHR", | 
|  | 172 | (__eglMustCastToProperFunctionPointerType)&eglWaitSyncKHR }, | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 173 |  | 
|  | 174 | // EGL_ANDROID_presentation_time | 
|  | 175 | { "eglPresentationTimeANDROID", | 
|  | 176 | (__eglMustCastToProperFunctionPointerType)&eglPresentationTimeANDROID }, | 
| Dan Stoza | a894d08 | 2015-02-19 15:27:36 -0800 | [diff] [blame] | 177 |  | 
|  | 178 | // EGL_KHR_swap_buffers_with_damage | 
|  | 179 | { "eglSwapBuffersWithDamageKHR", | 
|  | 180 | (__eglMustCastToProperFunctionPointerType)&eglSwapBuffersWithDamageKHR }, | 
|  | 181 |  | 
| Craig Donner | 6076107 | 2017-01-27 12:30:44 -0800 | [diff] [blame] | 182 | // EGL_ANDROID_get_native_client_buffer | 
|  | 183 | { "eglGetNativeClientBufferANDROID", | 
|  | 184 | (__eglMustCastToProperFunctionPointerType)&eglGetNativeClientBufferANDROID }, | 
|  | 185 |  | 
| Dan Stoza | a894d08 | 2015-02-19 15:27:36 -0800 | [diff] [blame] | 186 | // EGL_KHR_partial_update | 
|  | 187 | { "eglSetDamageRegionKHR", | 
|  | 188 | (__eglMustCastToProperFunctionPointerType)&eglSetDamageRegionKHR }, | 
| Season Li | 000d88f | 2015-07-01 11:39:40 -0700 | [diff] [blame] | 189 |  | 
|  | 190 | { "eglCreateStreamKHR", | 
|  | 191 | (__eglMustCastToProperFunctionPointerType)&eglCreateStreamKHR }, | 
|  | 192 | { "eglDestroyStreamKHR", | 
|  | 193 | (__eglMustCastToProperFunctionPointerType)&eglDestroyStreamKHR }, | 
|  | 194 | { "eglStreamAttribKHR", | 
|  | 195 | (__eglMustCastToProperFunctionPointerType)&eglStreamAttribKHR }, | 
|  | 196 | { "eglQueryStreamKHR", | 
|  | 197 | (__eglMustCastToProperFunctionPointerType)&eglQueryStreamKHR }, | 
|  | 198 | { "eglQueryStreamu64KHR", | 
|  | 199 | (__eglMustCastToProperFunctionPointerType)&eglQueryStreamu64KHR }, | 
|  | 200 | { "eglQueryStreamTimeKHR", | 
|  | 201 | (__eglMustCastToProperFunctionPointerType)&eglQueryStreamTimeKHR }, | 
|  | 202 | { "eglCreateStreamProducerSurfaceKHR", | 
|  | 203 | (__eglMustCastToProperFunctionPointerType)&eglCreateStreamProducerSurfaceKHR }, | 
|  | 204 | { "eglStreamConsumerGLTextureExternalKHR", | 
|  | 205 | (__eglMustCastToProperFunctionPointerType)&eglStreamConsumerGLTextureExternalKHR }, | 
|  | 206 | { "eglStreamConsumerAcquireKHR", | 
|  | 207 | (__eglMustCastToProperFunctionPointerType)&eglStreamConsumerAcquireKHR }, | 
|  | 208 | { "eglStreamConsumerReleaseKHR", | 
|  | 209 | (__eglMustCastToProperFunctionPointerType)&eglStreamConsumerReleaseKHR }, | 
|  | 210 | { "eglGetStreamFileDescriptorKHR", | 
|  | 211 | (__eglMustCastToProperFunctionPointerType)&eglGetStreamFileDescriptorKHR }, | 
|  | 212 | { "eglCreateStreamFromFileDescriptorKHR", | 
|  | 213 | (__eglMustCastToProperFunctionPointerType)&eglCreateStreamFromFileDescriptorKHR }, | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 214 |  | 
|  | 215 | // EGL_ANDROID_get_frame_timestamps | 
| Brian Anderson | 1049d1d | 2016-12-16 17:25:57 -0800 | [diff] [blame] | 216 | { "eglGetNextFrameIdANDROID", | 
|  | 217 | (__eglMustCastToProperFunctionPointerType)&eglGetNextFrameIdANDROID }, | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 218 | { "eglGetCompositorTimingANDROID", | 
|  | 219 | (__eglMustCastToProperFunctionPointerType)&eglGetCompositorTimingANDROID }, | 
|  | 220 | { "eglGetCompositorTimingSupportedANDROID", | 
|  | 221 | (__eglMustCastToProperFunctionPointerType)&eglGetCompositorTimingSupportedANDROID }, | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 222 | { "eglGetFrameTimestampsANDROID", | 
|  | 223 | (__eglMustCastToProperFunctionPointerType)&eglGetFrameTimestampsANDROID }, | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 224 | { "eglGetFrameTimestampSupportedANDROID", | 
|  | 225 | (__eglMustCastToProperFunctionPointerType)&eglGetFrameTimestampSupportedANDROID }, | 
| Craig Donner | 55901a2 | 2017-04-17 15:31:06 -0700 | [diff] [blame] | 226 |  | 
|  | 227 | // EGL_ANDROID_native_fence_sync | 
|  | 228 | { "eglDupNativeFenceFDANDROID", | 
|  | 229 | (__eglMustCastToProperFunctionPointerType)&eglDupNativeFenceFDANDROID }, | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 230 | }; | 
|  | 231 |  | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 232 | /* | 
|  | 233 | * These extensions entry-points should not be exposed to applications. | 
|  | 234 | * They're used internally by the Android EGL layer. | 
|  | 235 | */ | 
|  | 236 | #define FILTER_EXTENSIONS(procname) \ | 
|  | 237 | (!strcmp((procname), "eglSetBlobCacheFuncsANDROID") ||    \ | 
|  | 238 | !strcmp((procname), "eglHibernateProcessIMG")      ||    \ | 
| Craig Donner | 55901a2 | 2017-04-17 15:31:06 -0700 | [diff] [blame] | 239 | !strcmp((procname), "eglAwakenProcessIMG")) | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 240 |  | 
|  | 241 |  | 
|  | 242 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 243 | // accesses protected by sExtensionMapMutex | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 244 | static std::unordered_map<std::string, __eglMustCastToProperFunctionPointerType> sGLExtentionMap; | 
|  | 245 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 246 | static int sGLExtentionSlot = 0; | 
|  | 247 | static pthread_mutex_t sExtensionMapMutex = PTHREAD_MUTEX_INITIALIZER; | 
|  | 248 |  | 
|  | 249 | static void(*findProcAddress(const char* name, | 
|  | 250 | const extention_map_t* map, size_t n))() { | 
|  | 251 | for (uint32_t i=0 ; i<n ; i++) { | 
|  | 252 | if (!strcmp(name, map[i].name)) { | 
|  | 253 | return map[i].address; | 
|  | 254 | } | 
|  | 255 | } | 
|  | 256 | return NULL; | 
|  | 257 | } | 
|  | 258 |  | 
|  | 259 | // ---------------------------------------------------------------------------- | 
|  | 260 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 261 | extern void setGLHooksThreadSpecific(gl_hooks_t const *value); | 
|  | 262 | extern EGLBoolean egl_init_drivers(); | 
|  | 263 | extern const __eglMustCastToProperFunctionPointerType gExtensionForwarders[MAX_NUMBER_OF_GL_EXTENSIONS]; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 264 | extern gl_hooks_t gHooksTrace; | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 265 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 266 | } // namespace android; | 
|  | 267 |  | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 268 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 269 | // ---------------------------------------------------------------------------- | 
|  | 270 |  | 
|  | 271 | static inline void clearError() { egl_tls_t::clearError(); } | 
|  | 272 | static inline EGLContext getContext() { return egl_tls_t::getContext(); } | 
|  | 273 |  | 
|  | 274 | // ---------------------------------------------------------------------------- | 
|  | 275 |  | 
|  | 276 | EGLDisplay eglGetDisplay(EGLNativeDisplayType display) | 
|  | 277 | { | 
| Jesse Hall | 1508ae6 | 2017-01-19 17:43:26 -0800 | [diff] [blame] | 278 | ATRACE_CALL(); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 279 | clearError(); | 
|  | 280 |  | 
| Dan Stoza | c3289c4 | 2014-01-17 11:38:34 -0800 | [diff] [blame] | 281 | uintptr_t index = reinterpret_cast<uintptr_t>(display); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 282 | if (index >= NUM_DISPLAYS) { | 
|  | 283 | return setError(EGL_BAD_PARAMETER, EGL_NO_DISPLAY); | 
|  | 284 | } | 
|  | 285 |  | 
|  | 286 | if (egl_init_drivers() == EGL_FALSE) { | 
|  | 287 | return setError(EGL_BAD_PARAMETER, EGL_NO_DISPLAY); | 
|  | 288 | } | 
|  | 289 |  | 
|  | 290 | EGLDisplay dpy = egl_display_t::getFromNativeDisplay(display); | 
|  | 291 | return dpy; | 
|  | 292 | } | 
|  | 293 |  | 
|  | 294 | // ---------------------------------------------------------------------------- | 
|  | 295 | // Initialization | 
|  | 296 | // ---------------------------------------------------------------------------- | 
|  | 297 |  | 
|  | 298 | EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) | 
|  | 299 | { | 
|  | 300 | clearError(); | 
|  | 301 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 302 | egl_display_ptr dp = get_display(dpy); | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 303 | if (!dp) return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 304 |  | 
|  | 305 | EGLBoolean res = dp->initialize(major, minor); | 
|  | 306 |  | 
|  | 307 | return res; | 
|  | 308 | } | 
|  | 309 |  | 
|  | 310 | EGLBoolean eglTerminate(EGLDisplay dpy) | 
|  | 311 | { | 
|  | 312 | // NOTE: don't unload the drivers b/c some APIs can be called | 
|  | 313 | // after eglTerminate() has been called. eglTerminate() only | 
|  | 314 | // terminates an EGLDisplay, not a EGL itself. | 
|  | 315 |  | 
|  | 316 | clearError(); | 
|  | 317 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 318 | egl_display_ptr dp = get_display(dpy); | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 319 | if (!dp) return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 320 |  | 
|  | 321 | EGLBoolean res = dp->terminate(); | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 322 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 323 | return res; | 
|  | 324 | } | 
|  | 325 |  | 
|  | 326 | // ---------------------------------------------------------------------------- | 
|  | 327 | // configuration | 
|  | 328 | // ---------------------------------------------------------------------------- | 
|  | 329 |  | 
|  | 330 | EGLBoolean eglGetConfigs(   EGLDisplay dpy, | 
|  | 331 | EGLConfig *configs, | 
|  | 332 | EGLint config_size, EGLint *num_config) | 
|  | 333 | { | 
|  | 334 | clearError(); | 
|  | 335 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 336 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 337 | if (!dp) return EGL_FALSE; | 
|  | 338 |  | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 339 | if (num_config==0) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 340 | return setError(EGL_BAD_PARAMETER, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 341 | } | 
|  | 342 |  | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 343 | EGLBoolean res = EGL_FALSE; | 
|  | 344 | *num_config = 0; | 
|  | 345 |  | 
|  | 346 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 347 | if (cnx->dso) { | 
|  | 348 | res = cnx->egl.eglGetConfigs( | 
|  | 349 | dp->disp.dpy, configs, config_size, num_config); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 350 | } | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 351 |  | 
|  | 352 | return res; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 353 | } | 
|  | 354 |  | 
|  | 355 | EGLBoolean eglChooseConfig( EGLDisplay dpy, const EGLint *attrib_list, | 
|  | 356 | EGLConfig *configs, EGLint config_size, | 
|  | 357 | EGLint *num_config) | 
|  | 358 | { | 
|  | 359 | clearError(); | 
|  | 360 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 361 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 362 | if (!dp) return EGL_FALSE; | 
|  | 363 |  | 
|  | 364 | if (num_config==0) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 365 | return setError(EGL_BAD_PARAMETER, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 366 | } | 
|  | 367 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 368 | EGLBoolean res = EGL_FALSE; | 
|  | 369 | *num_config = 0; | 
|  | 370 |  | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 371 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 372 | if (cnx->dso) { | 
| Romain Guy | 1cffc80 | 2012-10-15 18:13:05 -0700 | [diff] [blame] | 373 | if (attrib_list) { | 
|  | 374 | char value[PROPERTY_VALUE_MAX]; | 
|  | 375 | property_get("debug.egl.force_msaa", value, "false"); | 
|  | 376 |  | 
|  | 377 | if (!strcmp(value, "true")) { | 
|  | 378 | size_t attribCount = 0; | 
|  | 379 | EGLint attrib = attrib_list[0]; | 
|  | 380 |  | 
|  | 381 | // Only enable MSAA if the context is OpenGL ES 2.0 and | 
| Romain Guy | be3c3e4 | 2012-10-15 19:25:18 -0700 | [diff] [blame] | 382 | // if no caveat is requested | 
| Romain Guy | 1cffc80 | 2012-10-15 18:13:05 -0700 | [diff] [blame] | 383 | const EGLint *attribRendererable = NULL; | 
|  | 384 | const EGLint *attribCaveat = NULL; | 
|  | 385 |  | 
|  | 386 | // Count the number of attributes and look for | 
| Romain Guy | be3c3e4 | 2012-10-15 19:25:18 -0700 | [diff] [blame] | 387 | // EGL_RENDERABLE_TYPE and EGL_CONFIG_CAVEAT | 
| Romain Guy | 1cffc80 | 2012-10-15 18:13:05 -0700 | [diff] [blame] | 388 | while (attrib != EGL_NONE) { | 
|  | 389 | attrib = attrib_list[attribCount]; | 
|  | 390 | switch (attrib) { | 
|  | 391 | case EGL_RENDERABLE_TYPE: | 
|  | 392 | attribRendererable = &attrib_list[attribCount]; | 
|  | 393 | break; | 
|  | 394 | case EGL_CONFIG_CAVEAT: | 
|  | 395 | attribCaveat = &attrib_list[attribCount]; | 
|  | 396 | break; | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 397 | default: | 
|  | 398 | break; | 
| Romain Guy | 1cffc80 | 2012-10-15 18:13:05 -0700 | [diff] [blame] | 399 | } | 
|  | 400 | attribCount++; | 
|  | 401 | } | 
|  | 402 |  | 
|  | 403 | if (attribRendererable && attribRendererable[1] == EGL_OPENGL_ES2_BIT && | 
|  | 404 | (!attribCaveat || attribCaveat[1] != EGL_NONE)) { | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 405 |  | 
| Romain Guy | 1cffc80 | 2012-10-15 18:13:05 -0700 | [diff] [blame] | 406 | // Insert 2 extra attributes to force-enable MSAA 4x | 
|  | 407 | EGLint aaAttribs[attribCount + 4]; | 
|  | 408 | aaAttribs[0] = EGL_SAMPLE_BUFFERS; | 
|  | 409 | aaAttribs[1] = 1; | 
|  | 410 | aaAttribs[2] = EGL_SAMPLES; | 
|  | 411 | aaAttribs[3] = 4; | 
|  | 412 |  | 
|  | 413 | memcpy(&aaAttribs[4], attrib_list, attribCount * sizeof(EGLint)); | 
|  | 414 |  | 
|  | 415 | EGLint numConfigAA; | 
|  | 416 | EGLBoolean resAA = cnx->egl.eglChooseConfig( | 
|  | 417 | dp->disp.dpy, aaAttribs, configs, config_size, &numConfigAA); | 
|  | 418 |  | 
|  | 419 | if (resAA == EGL_TRUE && numConfigAA > 0) { | 
|  | 420 | ALOGD("Enabling MSAA 4x"); | 
|  | 421 | *num_config = numConfigAA; | 
|  | 422 | return resAA; | 
|  | 423 | } | 
|  | 424 | } | 
|  | 425 | } | 
|  | 426 | } | 
|  | 427 |  | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 428 | res = cnx->egl.eglChooseConfig( | 
|  | 429 | dp->disp.dpy, attrib_list, configs, config_size, num_config); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 430 | } | 
|  | 431 | return res; | 
|  | 432 | } | 
|  | 433 |  | 
|  | 434 | EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, | 
|  | 435 | EGLint attribute, EGLint *value) | 
|  | 436 | { | 
|  | 437 | clearError(); | 
|  | 438 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 439 | egl_connection_t* cnx = NULL; | 
|  | 440 | const egl_display_ptr dp = validate_display_connection(dpy, cnx); | 
|  | 441 | if (!dp) return EGL_FALSE; | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 442 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 443 | return cnx->egl.eglGetConfigAttrib( | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 444 | dp->disp.dpy, config, attribute, value); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 445 | } | 
|  | 446 |  | 
|  | 447 | // ---------------------------------------------------------------------------- | 
|  | 448 | // surfaces | 
|  | 449 | // ---------------------------------------------------------------------------- | 
|  | 450 |  | 
| Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 451 | // Turn linear formats into corresponding sRGB formats when colorspace is | 
|  | 452 | // EGL_GL_COLORSPACE_SRGB_KHR, or turn sRGB formats into corresponding linear | 
|  | 453 | // formats when colorspace is EGL_GL_COLORSPACE_LINEAR_KHR. In any cases where | 
| Eino-Ville Talvala | 82c6bcc | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 454 | // the modification isn't possible, the original dataSpace is returned. | 
|  | 455 | static android_dataspace modifyBufferDataspace( android_dataspace dataSpace, | 
|  | 456 | EGLint colorspace) { | 
| Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 457 | if (colorspace == EGL_GL_COLORSPACE_LINEAR_KHR) { | 
| Eino-Ville Talvala | 82c6bcc | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 458 | return HAL_DATASPACE_SRGB_LINEAR; | 
| Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 459 | } else if (colorspace == EGL_GL_COLORSPACE_SRGB_KHR) { | 
| Eino-Ville Talvala | 82c6bcc | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 460 | return HAL_DATASPACE_SRGB; | 
| Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 461 | } | 
| Eino-Ville Talvala | 82c6bcc | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 462 | return dataSpace; | 
| Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 463 | } | 
|  | 464 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 465 | EGLSurface eglCreateWindowSurface(  EGLDisplay dpy, EGLConfig config, | 
|  | 466 | NativeWindowType window, | 
|  | 467 | const EGLint *attrib_list) | 
|  | 468 | { | 
|  | 469 | clearError(); | 
|  | 470 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 471 | egl_connection_t* cnx = NULL; | 
|  | 472 | egl_display_ptr dp = validate_display_connection(dpy, cnx); | 
|  | 473 | if (dp) { | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 474 | EGLDisplay iDpy = dp->disp.dpy; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 475 |  | 
| Mathias Agopian | 10e9ab5 | 2017-03-08 15:02:55 -0800 | [diff] [blame] | 476 | if (!window) { | 
|  | 477 | return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); | 
|  | 478 | } | 
|  | 479 |  | 
|  | 480 | int value = 0; | 
|  | 481 | window->query(window, NATIVE_WINDOW_IS_VALID, &value); | 
|  | 482 | if (!value) { | 
|  | 483 | return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); | 
|  | 484 | } | 
|  | 485 |  | 
| Andy McFadden | d566ce3 | 2014-01-07 15:54:17 -0800 | [diff] [blame] | 486 | int result = native_window_api_connect(window, NATIVE_WINDOW_API_EGL); | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 487 | if (result < 0) { | 
| Andy McFadden | d566ce3 | 2014-01-07 15:54:17 -0800 | [diff] [blame] | 488 | ALOGE("eglCreateWindowSurface: native_window_api_connect (win=%p) " | 
|  | 489 | "failed (%#x) (already connected to another API?)", | 
|  | 490 | window, result); | 
| Jonathan Hamilton | 77a9b4a | 2013-07-17 09:41:42 -0700 | [diff] [blame] | 491 | return setError(EGL_BAD_ALLOC, EGL_NO_SURFACE); | 
| Mathias Agopian | 81a6335 | 2011-07-29 17:55:48 -0700 | [diff] [blame] | 492 | } | 
|  | 493 |  | 
| Mathias Agopian | 0f288fc | 2013-08-21 16:36:34 -0700 | [diff] [blame] | 494 | // Set the native window's buffers format to match what this config requests. | 
| Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 495 | // Whether to use sRGB gamma is not part of the EGLconfig, but is part | 
|  | 496 | // of our native format. So if sRGB gamma is requested, we have to | 
|  | 497 | // modify the EGLconfig's format before setting the native window's | 
|  | 498 | // format. | 
| Alistair Strachan | 733a807 | 2015-02-12 12:33:25 -0800 | [diff] [blame] | 499 |  | 
| Courtney Goeltzenleuchter | 0e4e395 | 2016-11-16 13:53:40 -0700 | [diff] [blame] | 500 | EGLint componentType = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT; | 
|  | 501 | cnx->egl.eglGetConfigAttrib(iDpy, config, EGL_COLOR_COMPONENT_TYPE_EXT, | 
|  | 502 | &componentType); | 
|  | 503 |  | 
| Mathias Agopian | 9592156 | 2017-02-24 14:31:31 -0800 | [diff] [blame] | 504 | EGLint format; | 
| Eino-Ville Talvala | 82c6bcc | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 505 | android_dataspace dataSpace = HAL_DATASPACE_UNKNOWN; | 
| Mathias Agopian | 0f288fc | 2013-08-21 16:36:34 -0700 | [diff] [blame] | 506 | EGLint a = 0; | 
| Courtney Goeltzenleuchter | 0e4e395 | 2016-11-16 13:53:40 -0700 | [diff] [blame] | 507 | EGLint r, g, b; | 
|  | 508 | r = g = b = 0; | 
|  | 509 | cnx->egl.eglGetConfigAttrib(iDpy, config, EGL_RED_SIZE,   &r); | 
|  | 510 | cnx->egl.eglGetConfigAttrib(iDpy, config, EGL_GREEN_SIZE, &g); | 
|  | 511 | cnx->egl.eglGetConfigAttrib(iDpy, config, EGL_BLUE_SIZE,  &b); | 
| Mathias Agopian | 0f288fc | 2013-08-21 16:36:34 -0700 | [diff] [blame] | 512 | cnx->egl.eglGetConfigAttrib(iDpy, config, EGL_ALPHA_SIZE, &a); | 
| Courtney Goeltzenleuchter | 0e4e395 | 2016-11-16 13:53:40 -0700 | [diff] [blame] | 513 | EGLint colorDepth = r + g + b; | 
|  | 514 |  | 
|  | 515 | if (a == 0) { | 
| Mathias Agopian | 0f288fc | 2013-08-21 16:36:34 -0700 | [diff] [blame] | 516 | if (colorDepth <= 16) { | 
|  | 517 | format = HAL_PIXEL_FORMAT_RGB_565; | 
|  | 518 | } else { | 
| Courtney Goeltzenleuchter | 0e4e395 | 2016-11-16 13:53:40 -0700 | [diff] [blame] | 519 | if (componentType == EGL_COLOR_COMPONENT_TYPE_FIXED_EXT) { | 
|  | 520 | if (colorDepth > 24) { | 
|  | 521 | format = HAL_PIXEL_FORMAT_RGBA_1010102; | 
|  | 522 | } else { | 
|  | 523 | format = HAL_PIXEL_FORMAT_RGBX_8888; | 
|  | 524 | } | 
|  | 525 | } else { | 
|  | 526 | format = HAL_PIXEL_FORMAT_RGBA_FP16; | 
|  | 527 | } | 
|  | 528 | } | 
|  | 529 | } else { | 
|  | 530 | if (componentType == EGL_COLOR_COMPONENT_TYPE_FIXED_EXT) { | 
|  | 531 | if (colorDepth > 24) { | 
|  | 532 | format = HAL_PIXEL_FORMAT_RGBA_1010102; | 
|  | 533 | } else { | 
|  | 534 | format = HAL_PIXEL_FORMAT_RGBA_8888; | 
|  | 535 | } | 
|  | 536 | } else { | 
|  | 537 | format = HAL_PIXEL_FORMAT_RGBA_FP16; | 
| Mathias Agopian | 0f288fc | 2013-08-21 16:36:34 -0700 | [diff] [blame] | 538 | } | 
| Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 539 | } | 
| Mathias Agopian | 0f288fc | 2013-08-21 16:36:34 -0700 | [diff] [blame] | 540 |  | 
|  | 541 | // now select a corresponding sRGB format if needed | 
|  | 542 | if (attrib_list && dp->haveExtension("EGL_KHR_gl_colorspace")) { | 
|  | 543 | for (const EGLint* attr = attrib_list; *attr != EGL_NONE; attr += 2) { | 
|  | 544 | if (*attr == EGL_GL_COLORSPACE_KHR) { | 
| Sandeep Shinde | 9c67bfd | 2015-02-10 16:04:15 +0530 | [diff] [blame] | 545 | dataSpace = modifyBufferDataspace(dataSpace, *(attr+1)); | 
| Jamie Gennis | bee205f | 2011-07-01 13:12:07 -0700 | [diff] [blame] | 546 | } | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 547 | } | 
|  | 548 | } | 
| Alistair Strachan | 733a807 | 2015-02-12 12:33:25 -0800 | [diff] [blame] | 549 |  | 
| Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 550 | if (format != 0) { | 
|  | 551 | int err = native_window_set_buffers_format(window, format); | 
|  | 552 | if (err != 0) { | 
|  | 553 | ALOGE("error setting native window pixel format: %s (%d)", | 
|  | 554 | strerror(-err), err); | 
|  | 555 | native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL); | 
|  | 556 | return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); | 
|  | 557 | } | 
|  | 558 | } | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 559 |  | 
| Eino-Ville Talvala | 82c6bcc | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 560 | if (dataSpace != 0) { | 
|  | 561 | int err = native_window_set_buffers_data_space(window, dataSpace); | 
|  | 562 | if (err != 0) { | 
|  | 563 | ALOGE("error setting native window pixel dataSpace: %s (%d)", | 
|  | 564 | strerror(-err), err); | 
|  | 565 | native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL); | 
|  | 566 | return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); | 
|  | 567 | } | 
|  | 568 | } | 
|  | 569 |  | 
| Jamie Gennis | 5976946 | 2011-11-19 18:04:43 -0800 | [diff] [blame] | 570 | // the EGL spec requires that a new EGLSurface default to swap interval | 
|  | 571 | // 1, so explicitly set that on the window here. | 
|  | 572 | ANativeWindow* anw = reinterpret_cast<ANativeWindow*>(window); | 
|  | 573 | anw->setSwapInterval(anw, 1); | 
|  | 574 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 575 | EGLSurface surface = cnx->egl.eglCreateWindowSurface( | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 576 | iDpy, config, window, attrib_list); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 577 | if (surface != EGL_NO_SURFACE) { | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 578 | egl_surface_t* s = new egl_surface_t(dp.get(), config, window, | 
|  | 579 | surface, cnx); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 580 | return s; | 
|  | 581 | } | 
| Mathias Agopian | 81a6335 | 2011-07-29 17:55:48 -0700 | [diff] [blame] | 582 |  | 
|  | 583 | // EGLSurface creation failed | 
|  | 584 | native_window_set_buffers_format(window, 0); | 
|  | 585 | native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 586 | } | 
|  | 587 | return EGL_NO_SURFACE; | 
|  | 588 | } | 
|  | 589 |  | 
|  | 590 | EGLSurface eglCreatePixmapSurface(  EGLDisplay dpy, EGLConfig config, | 
|  | 591 | NativePixmapType pixmap, | 
|  | 592 | const EGLint *attrib_list) | 
|  | 593 | { | 
|  | 594 | clearError(); | 
|  | 595 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 596 | egl_connection_t* cnx = NULL; | 
|  | 597 | egl_display_ptr dp = validate_display_connection(dpy, cnx); | 
|  | 598 | if (dp) { | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 599 | EGLSurface surface = cnx->egl.eglCreatePixmapSurface( | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 600 | dp->disp.dpy, config, pixmap, attrib_list); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 601 | if (surface != EGL_NO_SURFACE) { | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 602 | egl_surface_t* s = new egl_surface_t(dp.get(), config, NULL, | 
|  | 603 | surface, cnx); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 604 | return s; | 
|  | 605 | } | 
|  | 606 | } | 
|  | 607 | return EGL_NO_SURFACE; | 
|  | 608 | } | 
|  | 609 |  | 
|  | 610 | EGLSurface eglCreatePbufferSurface( EGLDisplay dpy, EGLConfig config, | 
|  | 611 | const EGLint *attrib_list) | 
|  | 612 | { | 
|  | 613 | clearError(); | 
|  | 614 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 615 | egl_connection_t* cnx = NULL; | 
|  | 616 | egl_display_ptr dp = validate_display_connection(dpy, cnx); | 
|  | 617 | if (dp) { | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 618 | EGLSurface surface = cnx->egl.eglCreatePbufferSurface( | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 619 | dp->disp.dpy, config, attrib_list); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 620 | if (surface != EGL_NO_SURFACE) { | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 621 | egl_surface_t* s = new egl_surface_t(dp.get(), config, NULL, | 
|  | 622 | surface, cnx); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 623 | return s; | 
|  | 624 | } | 
|  | 625 | } | 
|  | 626 | return EGL_NO_SURFACE; | 
|  | 627 | } | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 628 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 629 | EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface) | 
|  | 630 | { | 
|  | 631 | clearError(); | 
|  | 632 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 633 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 634 | if (!dp) return EGL_FALSE; | 
|  | 635 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 636 | SurfaceRef _s(dp.get(), surface); | 
| Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 637 | if (!_s.get()) | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 638 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 639 |  | 
|  | 640 | egl_surface_t * const s = get_surface(surface); | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 641 | EGLBoolean result = s->cnx->egl.eglDestroySurface(dp->disp.dpy, s->surface); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 642 | if (result == EGL_TRUE) { | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 643 | _s.terminate(); | 
|  | 644 | } | 
|  | 645 | return result; | 
|  | 646 | } | 
|  | 647 |  | 
|  | 648 | EGLBoolean eglQuerySurface( EGLDisplay dpy, EGLSurface surface, | 
|  | 649 | EGLint attribute, EGLint *value) | 
|  | 650 | { | 
|  | 651 | clearError(); | 
|  | 652 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 653 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 654 | if (!dp) return EGL_FALSE; | 
|  | 655 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 656 | SurfaceRef _s(dp.get(), surface); | 
| Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 657 | if (!_s.get()) | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 658 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 659 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 660 | egl_surface_t const * const s = get_surface(surface); | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 661 | return s->cnx->egl.eglQuerySurface( | 
|  | 662 | dp->disp.dpy, s->surface, attribute, value); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 663 | } | 
|  | 664 |  | 
| Jamie Gennis | e8696a4 | 2012-01-15 18:54:57 -0800 | [diff] [blame] | 665 | void EGLAPI eglBeginFrame(EGLDisplay dpy, EGLSurface surface) { | 
| Jamie Gennis | 1c8e95c | 2012-02-23 19:27:23 -0800 | [diff] [blame] | 666 | ATRACE_CALL(); | 
| Jamie Gennis | e8696a4 | 2012-01-15 18:54:57 -0800 | [diff] [blame] | 667 | clearError(); | 
|  | 668 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 669 | const egl_display_ptr dp = validate_display(dpy); | 
| Jamie Gennis | e8696a4 | 2012-01-15 18:54:57 -0800 | [diff] [blame] | 670 | if (!dp) { | 
|  | 671 | return; | 
|  | 672 | } | 
|  | 673 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 674 | SurfaceRef _s(dp.get(), surface); | 
| Jamie Gennis | e8696a4 | 2012-01-15 18:54:57 -0800 | [diff] [blame] | 675 | if (!_s.get()) { | 
|  | 676 | setError(EGL_BAD_SURFACE, EGL_FALSE); | 
| Jamie Gennis | e8696a4 | 2012-01-15 18:54:57 -0800 | [diff] [blame] | 677 | } | 
| Jamie Gennis | e8696a4 | 2012-01-15 18:54:57 -0800 | [diff] [blame] | 678 | } | 
|  | 679 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 680 | // ---------------------------------------------------------------------------- | 
|  | 681 | // Contexts | 
|  | 682 | // ---------------------------------------------------------------------------- | 
|  | 683 |  | 
|  | 684 | EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, | 
|  | 685 | EGLContext share_list, const EGLint *attrib_list) | 
|  | 686 | { | 
|  | 687 | clearError(); | 
|  | 688 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 689 | egl_connection_t* cnx = NULL; | 
|  | 690 | const egl_display_ptr dp = validate_display_connection(dpy, cnx); | 
| Michael Chock | 0673e1e | 2012-06-21 12:53:17 -0700 | [diff] [blame] | 691 | if (dp) { | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 692 | if (share_list != EGL_NO_CONTEXT) { | 
| Michael Chock | 0673e1e | 2012-06-21 12:53:17 -0700 | [diff] [blame] | 693 | if (!ContextRef(dp.get(), share_list).get()) { | 
|  | 694 | return setError(EGL_BAD_CONTEXT, EGL_NO_CONTEXT); | 
|  | 695 | } | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 696 | egl_context_t* const c = get_context(share_list); | 
|  | 697 | share_list = c->context; | 
|  | 698 | } | 
|  | 699 | EGLContext context = cnx->egl.eglCreateContext( | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 700 | dp->disp.dpy, config, share_list, attrib_list); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 701 | if (context != EGL_NO_CONTEXT) { | 
|  | 702 | // figure out if it's a GLESv1 or GLESv2 | 
|  | 703 | int version = 0; | 
|  | 704 | if (attrib_list) { | 
|  | 705 | while (*attrib_list != EGL_NONE) { | 
|  | 706 | GLint attr = *attrib_list++; | 
|  | 707 | GLint value = *attrib_list++; | 
|  | 708 | if (attr == EGL_CONTEXT_CLIENT_VERSION) { | 
|  | 709 | if (value == 1) { | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 710 | version = egl_connection_t::GLESv1_INDEX; | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 711 | } else if (value == 2 || value == 3) { | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 712 | version = egl_connection_t::GLESv2_INDEX; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 713 | } | 
|  | 714 | } | 
|  | 715 | }; | 
|  | 716 | } | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 717 | egl_context_t* c = new egl_context_t(dpy, context, config, cnx, | 
|  | 718 | version); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 719 | return c; | 
|  | 720 | } | 
|  | 721 | } | 
|  | 722 | return EGL_NO_CONTEXT; | 
|  | 723 | } | 
|  | 724 |  | 
|  | 725 | EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) | 
|  | 726 | { | 
|  | 727 | clearError(); | 
|  | 728 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 729 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 730 | if (!dp) | 
|  | 731 | return EGL_FALSE; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 732 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 733 | ContextRef _c(dp.get(), ctx); | 
| Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 734 | if (!_c.get()) | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 735 | return setError(EGL_BAD_CONTEXT, (EGLBoolean)EGL_FALSE); | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 736 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 737 | egl_context_t * const c = get_context(ctx); | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 738 | EGLBoolean result = c->cnx->egl.eglDestroyContext(dp->disp.dpy, c->context); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 739 | if (result == EGL_TRUE) { | 
|  | 740 | _c.terminate(); | 
|  | 741 | } | 
|  | 742 | return result; | 
|  | 743 | } | 
|  | 744 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 745 | EGLBoolean eglMakeCurrent(  EGLDisplay dpy, EGLSurface draw, | 
|  | 746 | EGLSurface read, EGLContext ctx) | 
|  | 747 | { | 
|  | 748 | clearError(); | 
|  | 749 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 750 | egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 751 | if (!dp) return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 752 |  | 
| Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 753 | // If ctx is not EGL_NO_CONTEXT, read is not EGL_NO_SURFACE, or draw is not | 
|  | 754 | // EGL_NO_SURFACE, then an EGL_NOT_INITIALIZED error is generated if dpy is | 
|  | 755 | // a valid but uninitialized display. | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 756 | if ( (ctx != EGL_NO_CONTEXT) || (read != EGL_NO_SURFACE) || | 
|  | 757 | (draw != EGL_NO_SURFACE) ) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 758 | if (!dp->isReady()) return setError(EGL_NOT_INITIALIZED, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 759 | } | 
|  | 760 |  | 
|  | 761 | // get a reference to the object passed in | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 762 | ContextRef _c(dp.get(), ctx); | 
|  | 763 | SurfaceRef _d(dp.get(), draw); | 
|  | 764 | SurfaceRef _r(dp.get(), read); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 765 |  | 
|  | 766 | // validate the context (if not EGL_NO_CONTEXT) | 
| Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 767 | if ((ctx != EGL_NO_CONTEXT) && !_c.get()) { | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 768 | // EGL_NO_CONTEXT is valid | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 769 | return setError(EGL_BAD_CONTEXT, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 770 | } | 
|  | 771 |  | 
|  | 772 | // these are the underlying implementation's object | 
|  | 773 | EGLContext impl_ctx  = EGL_NO_CONTEXT; | 
|  | 774 | EGLSurface impl_draw = EGL_NO_SURFACE; | 
|  | 775 | EGLSurface impl_read = EGL_NO_SURFACE; | 
|  | 776 |  | 
|  | 777 | // these are our objects structs passed in | 
|  | 778 | egl_context_t       * c = NULL; | 
|  | 779 | egl_surface_t const * d = NULL; | 
|  | 780 | egl_surface_t const * r = NULL; | 
|  | 781 |  | 
|  | 782 | // these are the current objects structs | 
|  | 783 | egl_context_t * cur_c = get_context(getContext()); | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 784 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 785 | if (ctx != EGL_NO_CONTEXT) { | 
|  | 786 | c = get_context(ctx); | 
|  | 787 | impl_ctx = c->context; | 
|  | 788 | } else { | 
|  | 789 | // no context given, use the implementation of the current context | 
| Michael Chock | 0673e1e | 2012-06-21 12:53:17 -0700 | [diff] [blame] | 790 | if (draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE) { | 
|  | 791 | // calling eglMakeCurrent( ..., !=0, !=0, EGL_NO_CONTEXT); | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 792 | return setError(EGL_BAD_MATCH, (EGLBoolean)EGL_FALSE); | 
| Michael Chock | 0673e1e | 2012-06-21 12:53:17 -0700 | [diff] [blame] | 793 | } | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 794 | if (cur_c == NULL) { | 
|  | 795 | // no current context | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 796 | // not an error, there is just no current context. | 
|  | 797 | return EGL_TRUE; | 
|  | 798 | } | 
|  | 799 | } | 
|  | 800 |  | 
|  | 801 | // retrieve the underlying implementation's draw EGLSurface | 
|  | 802 | if (draw != EGL_NO_SURFACE) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 803 | if (!_d.get()) return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 804 | d = get_surface(draw); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 805 | impl_draw = d->surface; | 
|  | 806 | } | 
|  | 807 |  | 
|  | 808 | // retrieve the underlying implementation's read EGLSurface | 
|  | 809 | if (read != EGL_NO_SURFACE) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 810 | if (!_r.get()) return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 811 | r = get_surface(read); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 812 | impl_read = r->surface; | 
|  | 813 | } | 
|  | 814 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 815 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 816 | EGLBoolean result = dp->makeCurrent(c, cur_c, | 
| Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 817 | draw, read, ctx, | 
|  | 818 | impl_draw, impl_read, impl_ctx); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 819 |  | 
|  | 820 | if (result == EGL_TRUE) { | 
| Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 821 | if (c) { | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 822 | setGLHooksThreadSpecific(c->cnx->hooks[c->version]); | 
|  | 823 | egl_tls_t::setContext(ctx); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 824 | _c.acquire(); | 
|  | 825 | _r.acquire(); | 
|  | 826 | _d.acquire(); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 827 | } else { | 
|  | 828 | setGLHooksThreadSpecific(&gHooksNoContext); | 
|  | 829 | egl_tls_t::setContext(EGL_NO_CONTEXT); | 
|  | 830 | } | 
| Mathias Agopian | 5fecea7 | 2011-08-25 18:38:24 -0700 | [diff] [blame] | 831 | } else { | 
| Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 832 | // this will ALOGE the error | 
| Mathias Agopian | 63108c3 | 2013-09-06 13:36:49 -0700 | [diff] [blame] | 833 | egl_connection_t* const cnx = &gEGLImpl; | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 834 | result = setError(cnx->egl.eglGetError(), (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 835 | } | 
|  | 836 | return result; | 
|  | 837 | } | 
|  | 838 |  | 
|  | 839 |  | 
|  | 840 | EGLBoolean eglQueryContext( EGLDisplay dpy, EGLContext ctx, | 
|  | 841 | EGLint attribute, EGLint *value) | 
|  | 842 | { | 
|  | 843 | clearError(); | 
|  | 844 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 845 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 846 | if (!dp) return EGL_FALSE; | 
|  | 847 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 848 | ContextRef _c(dp.get(), ctx); | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 849 | if (!_c.get()) return setError(EGL_BAD_CONTEXT, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 850 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 851 | egl_context_t * const c = get_context(ctx); | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 852 | return c->cnx->egl.eglQueryContext( | 
|  | 853 | dp->disp.dpy, c->context, attribute, value); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 854 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 855 | } | 
|  | 856 |  | 
|  | 857 | EGLContext eglGetCurrentContext(void) | 
|  | 858 | { | 
|  | 859 | // could be called before eglInitialize(), but we wouldn't have a context | 
|  | 860 | // then, and this function would correctly return EGL_NO_CONTEXT. | 
|  | 861 |  | 
|  | 862 | clearError(); | 
|  | 863 |  | 
|  | 864 | EGLContext ctx = getContext(); | 
|  | 865 | return ctx; | 
|  | 866 | } | 
|  | 867 |  | 
|  | 868 | EGLSurface eglGetCurrentSurface(EGLint readdraw) | 
|  | 869 | { | 
|  | 870 | // could be called before eglInitialize(), but we wouldn't have a context | 
|  | 871 | // then, and this function would correctly return EGL_NO_SURFACE. | 
|  | 872 |  | 
|  | 873 | clearError(); | 
|  | 874 |  | 
|  | 875 | EGLContext ctx = getContext(); | 
|  | 876 | if (ctx) { | 
|  | 877 | egl_context_t const * const c = get_context(ctx); | 
|  | 878 | if (!c) return setError(EGL_BAD_CONTEXT, EGL_NO_SURFACE); | 
|  | 879 | switch (readdraw) { | 
|  | 880 | case EGL_READ: return c->read; | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 881 | case EGL_DRAW: return c->draw; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 882 | default: return setError(EGL_BAD_PARAMETER, EGL_NO_SURFACE); | 
|  | 883 | } | 
|  | 884 | } | 
|  | 885 | return EGL_NO_SURFACE; | 
|  | 886 | } | 
|  | 887 |  | 
|  | 888 | EGLDisplay eglGetCurrentDisplay(void) | 
|  | 889 | { | 
|  | 890 | // could be called before eglInitialize(), but we wouldn't have a context | 
|  | 891 | // then, and this function would correctly return EGL_NO_DISPLAY. | 
|  | 892 |  | 
|  | 893 | clearError(); | 
|  | 894 |  | 
|  | 895 | EGLContext ctx = getContext(); | 
|  | 896 | if (ctx) { | 
|  | 897 | egl_context_t const * const c = get_context(ctx); | 
|  | 898 | if (!c) return setError(EGL_BAD_CONTEXT, EGL_NO_SURFACE); | 
|  | 899 | return c->dpy; | 
|  | 900 | } | 
|  | 901 | return EGL_NO_DISPLAY; | 
|  | 902 | } | 
|  | 903 |  | 
|  | 904 | EGLBoolean eglWaitGL(void) | 
|  | 905 | { | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 906 | clearError(); | 
|  | 907 |  | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 908 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 909 | if (!cnx->dso) | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 910 | return setError(EGL_BAD_CONTEXT, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 911 |  | 
|  | 912 | return cnx->egl.eglWaitGL(); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 913 | } | 
|  | 914 |  | 
|  | 915 | EGLBoolean eglWaitNative(EGLint engine) | 
|  | 916 | { | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 917 | clearError(); | 
|  | 918 |  | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 919 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 920 | if (!cnx->dso) | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 921 | return setError(EGL_BAD_CONTEXT, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 922 |  | 
|  | 923 | return cnx->egl.eglWaitNative(engine); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 924 | } | 
|  | 925 |  | 
|  | 926 | EGLint eglGetError(void) | 
|  | 927 | { | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 928 | EGLint err = EGL_SUCCESS; | 
|  | 929 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 930 | if (cnx->dso) { | 
|  | 931 | err = cnx->egl.eglGetError(); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 932 | } | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 933 | if (err == EGL_SUCCESS) { | 
|  | 934 | err = egl_tls_t::getError(); | 
|  | 935 | } | 
|  | 936 | return err; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 937 | } | 
|  | 938 |  | 
| Michael Chock | c0ec5e2 | 2014-01-27 08:14:33 -0800 | [diff] [blame] | 939 | static __eglMustCastToProperFunctionPointerType findBuiltinWrapper( | 
| Jesse Hall | c07b520 | 2013-07-04 12:08:16 -0700 | [diff] [blame] | 940 | const char* procname) { | 
|  | 941 | const egl_connection_t* cnx = &gEGLImpl; | 
|  | 942 | void* proc = NULL; | 
|  | 943 |  | 
| Michael Chock | c0ec5e2 | 2014-01-27 08:14:33 -0800 | [diff] [blame] | 944 | proc = dlsym(cnx->libEgl, procname); | 
|  | 945 | if (proc) return (__eglMustCastToProperFunctionPointerType)proc; | 
|  | 946 |  | 
| Jesse Hall | c07b520 | 2013-07-04 12:08:16 -0700 | [diff] [blame] | 947 | proc = dlsym(cnx->libGles2, procname); | 
|  | 948 | if (proc) return (__eglMustCastToProperFunctionPointerType)proc; | 
|  | 949 |  | 
|  | 950 | proc = dlsym(cnx->libGles1, procname); | 
|  | 951 | if (proc) return (__eglMustCastToProperFunctionPointerType)proc; | 
|  | 952 |  | 
|  | 953 | return NULL; | 
|  | 954 | } | 
|  | 955 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 956 | __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) | 
|  | 957 | { | 
|  | 958 | // eglGetProcAddress() could be the very first function called | 
|  | 959 | // in which case we must make sure we've initialized ourselves, this | 
|  | 960 | // happens the first time egl_get_display() is called. | 
|  | 961 |  | 
|  | 962 | clearError(); | 
|  | 963 |  | 
|  | 964 | if (egl_init_drivers() == EGL_FALSE) { | 
|  | 965 | setError(EGL_BAD_PARAMETER, NULL); | 
|  | 966 | return  NULL; | 
|  | 967 | } | 
|  | 968 |  | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 969 | if (FILTER_EXTENSIONS(procname)) { | 
| Jamie Gennis | aca51c0 | 2011-11-03 17:42:43 -0700 | [diff] [blame] | 970 | return NULL; | 
|  | 971 | } | 
|  | 972 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 973 | __eglMustCastToProperFunctionPointerType addr; | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 974 | addr = findProcAddress(procname, sExtensionMap, NELEM(sExtensionMap)); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 975 | if (addr) return addr; | 
|  | 976 |  | 
| Michael Chock | c0ec5e2 | 2014-01-27 08:14:33 -0800 | [diff] [blame] | 977 | addr = findBuiltinWrapper(procname); | 
| Jesse Hall | c07b520 | 2013-07-04 12:08:16 -0700 | [diff] [blame] | 978 | if (addr) return addr; | 
| Jamie Gennis | aca51c0 | 2011-11-03 17:42:43 -0700 | [diff] [blame] | 979 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 980 | // this protects accesses to sGLExtentionMap and sGLExtentionSlot | 
|  | 981 | pthread_mutex_lock(&sExtensionMapMutex); | 
|  | 982 |  | 
|  | 983 | /* | 
|  | 984 | * Since eglGetProcAddress() is not associated to anything, it needs | 
|  | 985 | * to return a function pointer that "works" regardless of what | 
|  | 986 | * the current context is. | 
|  | 987 | * | 
|  | 988 | * For this reason, we return a "forwarder", a small stub that takes | 
|  | 989 | * care of calling the function associated with the context | 
|  | 990 | * currently bound. | 
|  | 991 | * | 
|  | 992 | * We first look for extensions we've already resolved, if we're seeing | 
|  | 993 | * this extension for the first time, we go through all our | 
|  | 994 | * implementations and call eglGetProcAddress() and record the | 
|  | 995 | * result in the appropriate implementation hooks and return the | 
|  | 996 | * address of the forwarder corresponding to that hook set. | 
|  | 997 | * | 
|  | 998 | */ | 
|  | 999 |  | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1000 | const std::string name(procname); | 
|  | 1001 |  | 
|  | 1002 | auto& extentionMap = sGLExtentionMap; | 
|  | 1003 | auto pos = extentionMap.find(name); | 
|  | 1004 | addr = (pos != extentionMap.end()) ? pos->second : nullptr; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1005 | const int slot = sGLExtentionSlot; | 
|  | 1006 |  | 
| Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 1007 | ALOGE_IF(slot >= MAX_NUMBER_OF_GL_EXTENSIONS, | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1008 | "no more slots for eglGetProcAddress(\"%s\")", | 
|  | 1009 | procname); | 
|  | 1010 |  | 
|  | 1011 | if (!addr && (slot < MAX_NUMBER_OF_GL_EXTENSIONS)) { | 
|  | 1012 | bool found = false; | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1013 |  | 
|  | 1014 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1015 | if (cnx->dso && cnx->egl.eglGetProcAddress) { | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1016 | // Extensions are independent of the bound context | 
| luliuhui | 69d1007 | 2012-08-30 11:15:36 +0800 | [diff] [blame] | 1017 | addr = | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 1018 | cnx->hooks[egl_connection_t::GLESv1_INDEX]->ext.extensions[slot] = | 
|  | 1019 | cnx->hooks[egl_connection_t::GLESv2_INDEX]->ext.extensions[slot] = | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1020 | cnx->egl.eglGetProcAddress(procname); | 
| luliuhui | 69d1007 | 2012-08-30 11:15:36 +0800 | [diff] [blame] | 1021 | if (addr) found = true; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1022 | } | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1023 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1024 | if (found) { | 
|  | 1025 | addr = gExtensionForwarders[slot]; | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1026 | extentionMap[name] = addr; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1027 | sGLExtentionSlot++; | 
|  | 1028 | } | 
|  | 1029 | } | 
|  | 1030 |  | 
|  | 1031 | pthread_mutex_unlock(&sExtensionMapMutex); | 
|  | 1032 | return addr; | 
|  | 1033 | } | 
|  | 1034 |  | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1035 | class FrameCompletionThread { | 
| Jamie Gennis | 28ef8d7 | 2012-04-05 20:34:54 -0700 | [diff] [blame] | 1036 | public: | 
|  | 1037 |  | 
|  | 1038 | static void queueSync(EGLSyncKHR sync) { | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1039 | static FrameCompletionThread thread; | 
|  | 1040 |  | 
|  | 1041 | char name[64]; | 
|  | 1042 |  | 
|  | 1043 | std::lock_guard<std::mutex> lock(thread.mMutex); | 
|  | 1044 | snprintf(name, sizeof(name), "kicked off frame %u", (unsigned int)thread.mFramesQueued); | 
|  | 1045 | ATRACE_NAME(name); | 
|  | 1046 |  | 
|  | 1047 | thread.mQueue.push_back(sync); | 
|  | 1048 | thread.mCondition.notify_one(); | 
|  | 1049 | thread.mFramesQueued++; | 
|  | 1050 | ATRACE_INT("GPU Frames Outstanding", int32_t(thread.mQueue.size())); | 
| Jamie Gennis | 28ef8d7 | 2012-04-05 20:34:54 -0700 | [diff] [blame] | 1051 | } | 
|  | 1052 |  | 
|  | 1053 | private: | 
| Jamie Gennis | 28ef8d7 | 2012-04-05 20:34:54 -0700 | [diff] [blame] | 1054 |  | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1055 | FrameCompletionThread() : mFramesQueued(0), mFramesCompleted(0) { | 
|  | 1056 | std::thread thread(&FrameCompletionThread::loop, this); | 
|  | 1057 | thread.detach(); | 
|  | 1058 | } | 
|  | 1059 |  | 
|  | 1060 | #pragma clang diagnostic push | 
|  | 1061 | #pragma clang diagnostic ignored "-Wmissing-noreturn" | 
|  | 1062 | void loop() { | 
|  | 1063 | while (true) { | 
|  | 1064 | threadLoop(); | 
|  | 1065 | } | 
|  | 1066 | } | 
|  | 1067 | #pragma clang diagnostic pop | 
|  | 1068 |  | 
|  | 1069 | void threadLoop() { | 
| Jamie Gennis | 28ef8d7 | 2012-04-05 20:34:54 -0700 | [diff] [blame] | 1070 | EGLSyncKHR sync; | 
|  | 1071 | uint32_t frameNum; | 
|  | 1072 | { | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1073 | std::unique_lock<std::mutex> lock(mMutex); | 
|  | 1074 | while (mQueue.empty()) { | 
|  | 1075 | mCondition.wait(lock); | 
| Jamie Gennis | 28ef8d7 | 2012-04-05 20:34:54 -0700 | [diff] [blame] | 1076 | } | 
|  | 1077 | sync = mQueue[0]; | 
|  | 1078 | frameNum = mFramesCompleted; | 
|  | 1079 | } | 
|  | 1080 | EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); | 
|  | 1081 | { | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1082 | char name[64]; | 
|  | 1083 | snprintf(name, sizeof(name), "waiting for frame %u", (unsigned int)frameNum); | 
|  | 1084 | ATRACE_NAME(name); | 
|  | 1085 |  | 
| Jamie Gennis | 28ef8d7 | 2012-04-05 20:34:54 -0700 | [diff] [blame] | 1086 | EGLint result = eglClientWaitSyncKHR(dpy, sync, 0, EGL_FOREVER_KHR); | 
|  | 1087 | if (result == EGL_FALSE) { | 
|  | 1088 | ALOGE("FrameCompletion: error waiting for fence: %#x", eglGetError()); | 
|  | 1089 | } else if (result == EGL_TIMEOUT_EXPIRED_KHR) { | 
|  | 1090 | ALOGE("FrameCompletion: timeout waiting for fence"); | 
|  | 1091 | } | 
|  | 1092 | eglDestroySyncKHR(dpy, sync); | 
|  | 1093 | } | 
|  | 1094 | { | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1095 | std::lock_guard<std::mutex> lock(mMutex); | 
|  | 1096 | mQueue.pop_front(); | 
| Jamie Gennis | 28ef8d7 | 2012-04-05 20:34:54 -0700 | [diff] [blame] | 1097 | mFramesCompleted++; | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1098 | ATRACE_INT("GPU Frames Outstanding", int32_t(mQueue.size())); | 
| Jamie Gennis | 28ef8d7 | 2012-04-05 20:34:54 -0700 | [diff] [blame] | 1099 | } | 
| Jamie Gennis | 28ef8d7 | 2012-04-05 20:34:54 -0700 | [diff] [blame] | 1100 | } | 
|  | 1101 |  | 
|  | 1102 | uint32_t mFramesQueued; | 
|  | 1103 | uint32_t mFramesCompleted; | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1104 | std::deque<EGLSyncKHR> mQueue; | 
|  | 1105 | std::condition_variable mCondition; | 
|  | 1106 | std::mutex mMutex; | 
| Jamie Gennis | 28ef8d7 | 2012-04-05 20:34:54 -0700 | [diff] [blame] | 1107 | }; | 
|  | 1108 |  | 
| Dan Stoza | a894d08 | 2015-02-19 15:27:36 -0800 | [diff] [blame] | 1109 | EGLBoolean eglSwapBuffersWithDamageKHR(EGLDisplay dpy, EGLSurface draw, | 
|  | 1110 | EGLint *rects, EGLint n_rects) | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1111 | { | 
| Jamie Gennis | 1c8e95c | 2012-02-23 19:27:23 -0800 | [diff] [blame] | 1112 | ATRACE_CALL(); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1113 | clearError(); | 
|  | 1114 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1115 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1116 | if (!dp) return EGL_FALSE; | 
|  | 1117 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1118 | SurfaceRef _s(dp.get(), draw); | 
| Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 1119 | if (!_s.get()) | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1120 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1121 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1122 | egl_surface_t const * const s = get_surface(draw); | 
| Mathias Agopian | 7db993a | 2012-03-25 00:49:46 -0700 | [diff] [blame] | 1123 |  | 
| Mathias Agopian | ed6d08b | 2013-04-16 16:39:46 -0700 | [diff] [blame] | 1124 | if (CC_UNLIKELY(dp->traceGpuCompletion)) { | 
|  | 1125 | EGLSyncKHR sync = eglCreateSyncKHR(dpy, EGL_SYNC_FENCE_KHR, NULL); | 
|  | 1126 | if (sync != EGL_NO_SYNC_KHR) { | 
|  | 1127 | FrameCompletionThread::queueSync(sync); | 
|  | 1128 | } | 
|  | 1129 | } | 
|  | 1130 |  | 
| Mathias Agopian | 7db993a | 2012-03-25 00:49:46 -0700 | [diff] [blame] | 1131 | if (CC_UNLIKELY(dp->finishOnSwap)) { | 
|  | 1132 | uint32_t pixel; | 
|  | 1133 | egl_context_t * const c = get_context( egl_tls_t::getContext() ); | 
|  | 1134 | if (c) { | 
|  | 1135 | // glReadPixels() ensures that the frame is complete | 
|  | 1136 | s->cnx->hooks[c->version]->gl.glReadPixels(0,0,1,1, | 
|  | 1137 | GL_RGBA,GL_UNSIGNED_BYTE,&pixel); | 
|  | 1138 | } | 
|  | 1139 | } | 
|  | 1140 |  | 
| Dan Stoza | a894d08 | 2015-02-19 15:27:36 -0800 | [diff] [blame] | 1141 | if (n_rects == 0) { | 
|  | 1142 | return s->cnx->egl.eglSwapBuffers(dp->disp.dpy, s->surface); | 
|  | 1143 | } | 
|  | 1144 |  | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1145 | std::vector<android_native_rect_t> androidRects((size_t)n_rects); | 
| Dan Stoza | a894d08 | 2015-02-19 15:27:36 -0800 | [diff] [blame] | 1146 | for (int r = 0; r < n_rects; ++r) { | 
|  | 1147 | int offset = r * 4; | 
|  | 1148 | int x = rects[offset]; | 
|  | 1149 | int y = rects[offset + 1]; | 
|  | 1150 | int width = rects[offset + 2]; | 
|  | 1151 | int height = rects[offset + 3]; | 
|  | 1152 | android_native_rect_t androidRect; | 
|  | 1153 | androidRect.left = x; | 
|  | 1154 | androidRect.top = y + height; | 
|  | 1155 | androidRect.right = x + width; | 
|  | 1156 | androidRect.bottom = y; | 
|  | 1157 | androidRects.push_back(androidRect); | 
|  | 1158 | } | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1159 | native_window_set_surface_damage(s->getNativeWindow(), androidRects.data(), androidRects.size()); | 
| Dan Stoza | a894d08 | 2015-02-19 15:27:36 -0800 | [diff] [blame] | 1160 |  | 
|  | 1161 | if (s->cnx->egl.eglSwapBuffersWithDamageKHR) { | 
|  | 1162 | return s->cnx->egl.eglSwapBuffersWithDamageKHR(dp->disp.dpy, s->surface, | 
|  | 1163 | rects, n_rects); | 
|  | 1164 | } else { | 
|  | 1165 | return s->cnx->egl.eglSwapBuffers(dp->disp.dpy, s->surface); | 
|  | 1166 | } | 
|  | 1167 | } | 
|  | 1168 |  | 
|  | 1169 | EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) | 
|  | 1170 | { | 
|  | 1171 | return eglSwapBuffersWithDamageKHR(dpy, surface, NULL, 0); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1172 | } | 
|  | 1173 |  | 
|  | 1174 | EGLBoolean eglCopyBuffers(  EGLDisplay dpy, EGLSurface surface, | 
|  | 1175 | NativePixmapType target) | 
|  | 1176 | { | 
|  | 1177 | clearError(); | 
|  | 1178 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1179 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1180 | if (!dp) return EGL_FALSE; | 
|  | 1181 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1182 | SurfaceRef _s(dp.get(), surface); | 
| Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 1183 | if (!_s.get()) | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1184 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1185 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1186 | egl_surface_t const * const s = get_surface(surface); | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1187 | return s->cnx->egl.eglCopyBuffers(dp->disp.dpy, s->surface, target); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1188 | } | 
|  | 1189 |  | 
|  | 1190 | const char* eglQueryString(EGLDisplay dpy, EGLint name) | 
|  | 1191 | { | 
|  | 1192 | clearError(); | 
|  | 1193 |  | 
| Chia-I Wu | e57d135 | 2016-08-15 16:10:02 +0800 | [diff] [blame] | 1194 | // Generate an error quietly when client extensions (as defined by | 
|  | 1195 | // EGL_EXT_client_extensions) are queried.  We do not want to rely on | 
|  | 1196 | // validate_display to generate the error as validate_display would log | 
|  | 1197 | // the error, which can be misleading. | 
|  | 1198 | // | 
|  | 1199 | // If we want to support EGL_EXT_client_extensions later, we can return | 
|  | 1200 | // the client extension string here instead. | 
|  | 1201 | if (dpy == EGL_NO_DISPLAY && name == EGL_EXTENSIONS) | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1202 | return setErrorQuiet(EGL_BAD_DISPLAY, (const char*)0); | 
| Chia-I Wu | e57d135 | 2016-08-15 16:10:02 +0800 | [diff] [blame] | 1203 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1204 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1205 | if (!dp) return (const char *) NULL; | 
|  | 1206 |  | 
|  | 1207 | switch (name) { | 
|  | 1208 | case EGL_VENDOR: | 
| Mathias Agopian | 4b9511c | 2011-11-13 23:52:47 -0800 | [diff] [blame] | 1209 | return dp->getVendorString(); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1210 | case EGL_VERSION: | 
| Mathias Agopian | 4b9511c | 2011-11-13 23:52:47 -0800 | [diff] [blame] | 1211 | return dp->getVersionString(); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1212 | case EGL_EXTENSIONS: | 
| Mathias Agopian | 4b9511c | 2011-11-13 23:52:47 -0800 | [diff] [blame] | 1213 | return dp->getExtensionString(); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1214 | case EGL_CLIENT_APIS: | 
| Mathias Agopian | 4b9511c | 2011-11-13 23:52:47 -0800 | [diff] [blame] | 1215 | return dp->getClientApiString(); | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1216 | default: | 
|  | 1217 | break; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1218 | } | 
|  | 1219 | return setError(EGL_BAD_PARAMETER, (const char *)0); | 
|  | 1220 | } | 
|  | 1221 |  | 
| Mathias Agopian | ca08833 | 2013-03-28 17:44:13 -0700 | [diff] [blame] | 1222 | EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name) | 
|  | 1223 | { | 
|  | 1224 | clearError(); | 
|  | 1225 |  | 
|  | 1226 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1227 | if (!dp) return (const char *) NULL; | 
|  | 1228 |  | 
|  | 1229 | switch (name) { | 
|  | 1230 | case EGL_VENDOR: | 
|  | 1231 | return dp->disp.queryString.vendor; | 
|  | 1232 | case EGL_VERSION: | 
|  | 1233 | return dp->disp.queryString.version; | 
|  | 1234 | case EGL_EXTENSIONS: | 
|  | 1235 | return dp->disp.queryString.extensions; | 
|  | 1236 | case EGL_CLIENT_APIS: | 
|  | 1237 | return dp->disp.queryString.clientApi; | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1238 | default: | 
|  | 1239 | break; | 
| Mathias Agopian | ca08833 | 2013-03-28 17:44:13 -0700 | [diff] [blame] | 1240 | } | 
|  | 1241 | return setError(EGL_BAD_PARAMETER, (const char *)0); | 
|  | 1242 | } | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1243 |  | 
|  | 1244 | // ---------------------------------------------------------------------------- | 
|  | 1245 | // EGL 1.1 | 
|  | 1246 | // ---------------------------------------------------------------------------- | 
|  | 1247 |  | 
|  | 1248 | EGLBoolean eglSurfaceAttrib( | 
|  | 1249 | EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) | 
|  | 1250 | { | 
|  | 1251 | clearError(); | 
|  | 1252 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1253 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1254 | if (!dp) return EGL_FALSE; | 
|  | 1255 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1256 | SurfaceRef _s(dp.get(), surface); | 
| Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 1257 | if (!_s.get()) | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1258 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1259 |  | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 1260 | egl_surface_t * const s = get_surface(surface); | 
| Pablo Ceballos | ccdfd60 | 2015-10-07 15:05:45 -0700 | [diff] [blame] | 1261 |  | 
| Pablo Ceballos | 02b05da | 2016-02-02 17:53:18 -0800 | [diff] [blame] | 1262 | if (attribute == EGL_FRONT_BUFFER_AUTO_REFRESH_ANDROID) { | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1263 | if (!s->getNativeWindow()) { | 
| Brian Anderson | 069b365 | 2016-07-22 10:32:47 -0700 | [diff] [blame] | 1264 | setError(EGL_BAD_SURFACE, EGL_FALSE); | 
|  | 1265 | } | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1266 | int err = native_window_set_auto_refresh(s->getNativeWindow(), value != 0); | 
|  | 1267 | return (err == 0) ? EGL_TRUE : setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Pablo Ceballos | ccdfd60 | 2015-10-07 15:05:45 -0700 | [diff] [blame] | 1268 | } | 
|  | 1269 |  | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 1270 | if (attribute == EGL_TIMESTAMPS_ANDROID) { | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1271 | if (!s->getNativeWindow()) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1272 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Brian Anderson | 069b365 | 2016-07-22 10:32:47 -0700 | [diff] [blame] | 1273 | } | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1274 | int err = native_window_enable_frame_timestamps(s->getNativeWindow(), value != 0); | 
|  | 1275 | return (err == 0) ? EGL_TRUE : setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 1276 | } | 
|  | 1277 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1278 | if (s->cnx->egl.eglSurfaceAttrib) { | 
|  | 1279 | return s->cnx->egl.eglSurfaceAttrib( | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1280 | dp->disp.dpy, s->surface, attribute, value); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1281 | } | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1282 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1283 | } | 
|  | 1284 |  | 
|  | 1285 | EGLBoolean eglBindTexImage( | 
|  | 1286 | EGLDisplay dpy, EGLSurface surface, EGLint buffer) | 
|  | 1287 | { | 
|  | 1288 | clearError(); | 
|  | 1289 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1290 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1291 | if (!dp) return EGL_FALSE; | 
|  | 1292 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1293 | SurfaceRef _s(dp.get(), surface); | 
| Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 1294 | if (!_s.get()) | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1295 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1296 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1297 | egl_surface_t const * const s = get_surface(surface); | 
|  | 1298 | if (s->cnx->egl.eglBindTexImage) { | 
|  | 1299 | return s->cnx->egl.eglBindTexImage( | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1300 | dp->disp.dpy, s->surface, buffer); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1301 | } | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1302 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1303 | } | 
|  | 1304 |  | 
|  | 1305 | EGLBoolean eglReleaseTexImage( | 
|  | 1306 | EGLDisplay dpy, EGLSurface surface, EGLint buffer) | 
|  | 1307 | { | 
|  | 1308 | clearError(); | 
|  | 1309 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1310 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1311 | if (!dp) return EGL_FALSE; | 
|  | 1312 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1313 | SurfaceRef _s(dp.get(), surface); | 
| Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 1314 | if (!_s.get()) | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1315 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1316 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1317 | egl_surface_t const * const s = get_surface(surface); | 
|  | 1318 | if (s->cnx->egl.eglReleaseTexImage) { | 
|  | 1319 | return s->cnx->egl.eglReleaseTexImage( | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1320 | dp->disp.dpy, s->surface, buffer); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1321 | } | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1322 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1323 | } | 
|  | 1324 |  | 
|  | 1325 | EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval) | 
|  | 1326 | { | 
|  | 1327 | clearError(); | 
|  | 1328 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1329 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1330 | if (!dp) return EGL_FALSE; | 
|  | 1331 |  | 
|  | 1332 | EGLBoolean res = EGL_TRUE; | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1333 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1334 | if (cnx->dso && cnx->egl.eglSwapInterval) { | 
|  | 1335 | res = cnx->egl.eglSwapInterval(dp->disp.dpy, interval); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1336 | } | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1337 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1338 | return res; | 
|  | 1339 | } | 
|  | 1340 |  | 
|  | 1341 |  | 
|  | 1342 | // ---------------------------------------------------------------------------- | 
|  | 1343 | // EGL 1.2 | 
|  | 1344 | // ---------------------------------------------------------------------------- | 
|  | 1345 |  | 
|  | 1346 | EGLBoolean eglWaitClient(void) | 
|  | 1347 | { | 
|  | 1348 | clearError(); | 
|  | 1349 |  | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1350 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1351 | if (!cnx->dso) | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1352 | return setError(EGL_BAD_CONTEXT, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1353 |  | 
|  | 1354 | EGLBoolean res; | 
|  | 1355 | if (cnx->egl.eglWaitClient) { | 
|  | 1356 | res = cnx->egl.eglWaitClient(); | 
|  | 1357 | } else { | 
|  | 1358 | res = cnx->egl.eglWaitGL(); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1359 | } | 
|  | 1360 | return res; | 
|  | 1361 | } | 
|  | 1362 |  | 
|  | 1363 | EGLBoolean eglBindAPI(EGLenum api) | 
|  | 1364 | { | 
|  | 1365 | clearError(); | 
|  | 1366 |  | 
|  | 1367 | if (egl_init_drivers() == EGL_FALSE) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1368 | return setError(EGL_BAD_PARAMETER, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1369 | } | 
|  | 1370 |  | 
|  | 1371 | // bind this API on all EGLs | 
|  | 1372 | EGLBoolean res = EGL_TRUE; | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1373 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1374 | if (cnx->dso && cnx->egl.eglBindAPI) { | 
|  | 1375 | res = cnx->egl.eglBindAPI(api); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1376 | } | 
|  | 1377 | return res; | 
|  | 1378 | } | 
|  | 1379 |  | 
|  | 1380 | EGLenum eglQueryAPI(void) | 
|  | 1381 | { | 
|  | 1382 | clearError(); | 
|  | 1383 |  | 
|  | 1384 | if (egl_init_drivers() == EGL_FALSE) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1385 | return setError(EGL_BAD_PARAMETER, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1386 | } | 
|  | 1387 |  | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1388 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1389 | if (cnx->dso && cnx->egl.eglQueryAPI) { | 
|  | 1390 | return cnx->egl.eglQueryAPI(); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1391 | } | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1392 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1393 | // or, it can only be OpenGL ES | 
|  | 1394 | return EGL_OPENGL_ES_API; | 
|  | 1395 | } | 
|  | 1396 |  | 
|  | 1397 | EGLBoolean eglReleaseThread(void) | 
|  | 1398 | { | 
|  | 1399 | clearError(); | 
|  | 1400 |  | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1401 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1402 | if (cnx->dso && cnx->egl.eglReleaseThread) { | 
|  | 1403 | cnx->egl.eglReleaseThread(); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1404 | } | 
| Sai Kiran Korwar | 3ac517a | 2014-01-31 21:15:07 +0530 | [diff] [blame] | 1405 |  | 
|  | 1406 | // If there is context bound to the thread, release it | 
|  | 1407 | egl_display_t::loseCurrent(get_context(getContext())); | 
|  | 1408 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1409 | egl_tls_t::clearTLS(); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1410 | return EGL_TRUE; | 
|  | 1411 | } | 
|  | 1412 |  | 
|  | 1413 | EGLSurface eglCreatePbufferFromClientBuffer( | 
|  | 1414 | EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, | 
|  | 1415 | EGLConfig config, const EGLint *attrib_list) | 
|  | 1416 | { | 
|  | 1417 | clearError(); | 
|  | 1418 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1419 | egl_connection_t* cnx = NULL; | 
|  | 1420 | const egl_display_ptr dp = validate_display_connection(dpy, cnx); | 
|  | 1421 | if (!dp) return EGL_FALSE; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1422 | if (cnx->egl.eglCreatePbufferFromClientBuffer) { | 
|  | 1423 | return cnx->egl.eglCreatePbufferFromClientBuffer( | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 1424 | dp->disp.dpy, buftype, buffer, config, attrib_list); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1425 | } | 
|  | 1426 | return setError(EGL_BAD_CONFIG, EGL_NO_SURFACE); | 
|  | 1427 | } | 
|  | 1428 |  | 
|  | 1429 | // ---------------------------------------------------------------------------- | 
|  | 1430 | // EGL_EGLEXT_VERSION 3 | 
|  | 1431 | // ---------------------------------------------------------------------------- | 
|  | 1432 |  | 
|  | 1433 | EGLBoolean eglLockSurfaceKHR(EGLDisplay dpy, EGLSurface surface, | 
|  | 1434 | const EGLint *attrib_list) | 
|  | 1435 | { | 
|  | 1436 | clearError(); | 
|  | 1437 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1438 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1439 | if (!dp) return EGL_FALSE; | 
|  | 1440 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1441 | SurfaceRef _s(dp.get(), surface); | 
| Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 1442 | if (!_s.get()) | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1443 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1444 |  | 
|  | 1445 | egl_surface_t const * const s = get_surface(surface); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1446 | if (s->cnx->egl.eglLockSurfaceKHR) { | 
|  | 1447 | return s->cnx->egl.eglLockSurfaceKHR( | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1448 | dp->disp.dpy, s->surface, attrib_list); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1449 | } | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1450 | return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1451 | } | 
|  | 1452 |  | 
|  | 1453 | EGLBoolean eglUnlockSurfaceKHR(EGLDisplay dpy, EGLSurface surface) | 
|  | 1454 | { | 
|  | 1455 | clearError(); | 
|  | 1456 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1457 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1458 | if (!dp) return EGL_FALSE; | 
|  | 1459 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1460 | SurfaceRef _s(dp.get(), surface); | 
| Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 1461 | if (!_s.get()) | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1462 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1463 |  | 
|  | 1464 | egl_surface_t const * const s = get_surface(surface); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1465 | if (s->cnx->egl.eglUnlockSurfaceKHR) { | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1466 | return s->cnx->egl.eglUnlockSurfaceKHR(dp->disp.dpy, s->surface); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1467 | } | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1468 | return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1469 | } | 
|  | 1470 |  | 
|  | 1471 | EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, | 
|  | 1472 | EGLClientBuffer buffer, const EGLint *attrib_list) | 
|  | 1473 | { | 
|  | 1474 | clearError(); | 
|  | 1475 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1476 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1477 | if (!dp) return EGL_NO_IMAGE_KHR; | 
|  | 1478 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1479 | ContextRef _c(dp.get(), ctx); | 
| Mathias Agopian | 7c0441a | 2012-02-14 17:14:36 -0800 | [diff] [blame] | 1480 | egl_context_t * const c = _c.get(); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1481 |  | 
| Mathias Agopian | 7c0441a | 2012-02-14 17:14:36 -0800 | [diff] [blame] | 1482 | EGLImageKHR result = EGL_NO_IMAGE_KHR; | 
|  | 1483 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1484 | if (cnx->dso && cnx->egl.eglCreateImageKHR) { | 
|  | 1485 | result = cnx->egl.eglCreateImageKHR( | 
|  | 1486 | dp->disp.dpy, | 
|  | 1487 | c ? c->context : EGL_NO_CONTEXT, | 
|  | 1488 | target, buffer, attrib_list); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1489 | } | 
| Mathias Agopian | 7c0441a | 2012-02-14 17:14:36 -0800 | [diff] [blame] | 1490 | return result; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1491 | } | 
|  | 1492 |  | 
|  | 1493 | EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img) | 
|  | 1494 | { | 
|  | 1495 | clearError(); | 
|  | 1496 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1497 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1498 | if (!dp) return EGL_FALSE; | 
|  | 1499 |  | 
| Steven Holte | 646a5c5 | 2012-06-04 20:02:11 -0700 | [diff] [blame] | 1500 | EGLBoolean result = EGL_FALSE; | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1501 | egl_connection_t* const cnx = &gEGLImpl; | 
| Mathias Agopian | 7c0441a | 2012-02-14 17:14:36 -0800 | [diff] [blame] | 1502 | if (cnx->dso && cnx->egl.eglDestroyImageKHR) { | 
| Steven Holte | 646a5c5 | 2012-06-04 20:02:11 -0700 | [diff] [blame] | 1503 | result = cnx->egl.eglDestroyImageKHR(dp->disp.dpy, img); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1504 | } | 
| Steven Holte | 646a5c5 | 2012-06-04 20:02:11 -0700 | [diff] [blame] | 1505 | return result; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1506 | } | 
|  | 1507 |  | 
|  | 1508 | // ---------------------------------------------------------------------------- | 
|  | 1509 | // EGL_EGLEXT_VERSION 5 | 
|  | 1510 | // ---------------------------------------------------------------------------- | 
|  | 1511 |  | 
|  | 1512 |  | 
|  | 1513 | EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list) | 
|  | 1514 | { | 
|  | 1515 | clearError(); | 
|  | 1516 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1517 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1518 | if (!dp) return EGL_NO_SYNC_KHR; | 
|  | 1519 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1520 | EGLSyncKHR result = EGL_NO_SYNC_KHR; | 
| Mathias Agopian | 7c0441a | 2012-02-14 17:14:36 -0800 | [diff] [blame] | 1521 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1522 | if (cnx->dso && cnx->egl.eglCreateSyncKHR) { | 
|  | 1523 | result = cnx->egl.eglCreateSyncKHR(dp->disp.dpy, type, attrib_list); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1524 | } | 
| Mathias Agopian | 7c0441a | 2012-02-14 17:14:36 -0800 | [diff] [blame] | 1525 | return result; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1526 | } | 
|  | 1527 |  | 
|  | 1528 | EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync) | 
|  | 1529 | { | 
|  | 1530 | clearError(); | 
|  | 1531 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1532 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1533 | if (!dp) return EGL_FALSE; | 
|  | 1534 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1535 | EGLBoolean result = EGL_FALSE; | 
| Mathias Agopian | 7c0441a | 2012-02-14 17:14:36 -0800 | [diff] [blame] | 1536 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1537 | if (cnx->dso && cnx->egl.eglDestroySyncKHR) { | 
|  | 1538 | result = cnx->egl.eglDestroySyncKHR(dp->disp.dpy, sync); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1539 | } | 
|  | 1540 | return result; | 
|  | 1541 | } | 
|  | 1542 |  | 
| Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 1543 | EGLBoolean eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode) { | 
|  | 1544 | clearError(); | 
|  | 1545 |  | 
|  | 1546 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1547 | if (!dp) return EGL_FALSE; | 
|  | 1548 |  | 
|  | 1549 | EGLBoolean result = EGL_FALSE; | 
|  | 1550 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1551 | if (cnx->dso && cnx->egl.eglSignalSyncKHR) { | 
|  | 1552 | result = cnx->egl.eglSignalSyncKHR( | 
|  | 1553 | dp->disp.dpy, sync, mode); | 
|  | 1554 | } | 
|  | 1555 | return result; | 
|  | 1556 | } | 
|  | 1557 |  | 
| Mathias Agopian | 7c0441a | 2012-02-14 17:14:36 -0800 | [diff] [blame] | 1558 | EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, | 
|  | 1559 | EGLint flags, EGLTimeKHR timeout) | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1560 | { | 
|  | 1561 | clearError(); | 
|  | 1562 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1563 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1564 | if (!dp) return EGL_FALSE; | 
|  | 1565 |  | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1566 | EGLint result = EGL_FALSE; | 
| Mathias Agopian | 7c0441a | 2012-02-14 17:14:36 -0800 | [diff] [blame] | 1567 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1568 | if (cnx->dso && cnx->egl.eglClientWaitSyncKHR) { | 
|  | 1569 | result = cnx->egl.eglClientWaitSyncKHR( | 
|  | 1570 | dp->disp.dpy, sync, flags, timeout); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1571 | } | 
| Mathias Agopian | 7c0441a | 2012-02-14 17:14:36 -0800 | [diff] [blame] | 1572 | return result; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1573 | } | 
|  | 1574 |  | 
| Mathias Agopian | 7c0441a | 2012-02-14 17:14:36 -0800 | [diff] [blame] | 1575 | EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, | 
|  | 1576 | EGLint attribute, EGLint *value) | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1577 | { | 
|  | 1578 | clearError(); | 
|  | 1579 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 1580 | const egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1581 | if (!dp) return EGL_FALSE; | 
|  | 1582 |  | 
| Mathias Agopian | 7c0441a | 2012-02-14 17:14:36 -0800 | [diff] [blame] | 1583 | EGLBoolean result = EGL_FALSE; | 
|  | 1584 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1585 | if (cnx->dso && cnx->egl.eglGetSyncAttribKHR) { | 
|  | 1586 | result = cnx->egl.eglGetSyncAttribKHR( | 
|  | 1587 | dp->disp.dpy, sync, attribute, value); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1588 | } | 
| Mathias Agopian | 7c0441a | 2012-02-14 17:14:36 -0800 | [diff] [blame] | 1589 | return result; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1590 | } | 
|  | 1591 |  | 
| Season Li | 000d88f | 2015-07-01 11:39:40 -0700 | [diff] [blame] | 1592 | EGLStreamKHR eglCreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list) | 
|  | 1593 | { | 
|  | 1594 | clearError(); | 
|  | 1595 |  | 
|  | 1596 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1597 | if (!dp) return EGL_NO_STREAM_KHR; | 
|  | 1598 |  | 
|  | 1599 | EGLStreamKHR result = EGL_NO_STREAM_KHR; | 
|  | 1600 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1601 | if (cnx->dso && cnx->egl.eglCreateStreamKHR) { | 
|  | 1602 | result = cnx->egl.eglCreateStreamKHR( | 
|  | 1603 | dp->disp.dpy, attrib_list); | 
|  | 1604 | } | 
|  | 1605 | return result; | 
|  | 1606 | } | 
|  | 1607 |  | 
|  | 1608 | EGLBoolean eglDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream) | 
|  | 1609 | { | 
|  | 1610 | clearError(); | 
|  | 1611 |  | 
|  | 1612 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1613 | if (!dp) return EGL_FALSE; | 
|  | 1614 |  | 
|  | 1615 | EGLBoolean result = EGL_FALSE; | 
|  | 1616 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1617 | if (cnx->dso && cnx->egl.eglDestroyStreamKHR) { | 
|  | 1618 | result = cnx->egl.eglDestroyStreamKHR( | 
|  | 1619 | dp->disp.dpy, stream); | 
|  | 1620 | } | 
|  | 1621 | return result; | 
|  | 1622 | } | 
|  | 1623 |  | 
|  | 1624 | EGLBoolean eglStreamAttribKHR(EGLDisplay dpy, EGLStreamKHR stream, | 
|  | 1625 | EGLenum attribute, EGLint value) | 
|  | 1626 | { | 
|  | 1627 | clearError(); | 
|  | 1628 |  | 
|  | 1629 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1630 | if (!dp) return EGL_FALSE; | 
|  | 1631 |  | 
|  | 1632 | EGLBoolean result = EGL_FALSE; | 
|  | 1633 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1634 | if (cnx->dso && cnx->egl.eglStreamAttribKHR) { | 
|  | 1635 | result = cnx->egl.eglStreamAttribKHR( | 
|  | 1636 | dp->disp.dpy, stream, attribute, value); | 
|  | 1637 | } | 
|  | 1638 | return result; | 
|  | 1639 | } | 
|  | 1640 |  | 
|  | 1641 | EGLBoolean eglQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, | 
|  | 1642 | EGLenum attribute, EGLint *value) | 
|  | 1643 | { | 
|  | 1644 | clearError(); | 
|  | 1645 |  | 
|  | 1646 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1647 | if (!dp) return EGL_FALSE; | 
|  | 1648 |  | 
|  | 1649 | EGLBoolean result = EGL_FALSE; | 
|  | 1650 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1651 | if (cnx->dso && cnx->egl.eglQueryStreamKHR) { | 
|  | 1652 | result = cnx->egl.eglQueryStreamKHR( | 
|  | 1653 | dp->disp.dpy, stream, attribute, value); | 
|  | 1654 | } | 
|  | 1655 | return result; | 
|  | 1656 | } | 
|  | 1657 |  | 
|  | 1658 | EGLBoolean eglQueryStreamu64KHR(EGLDisplay dpy, EGLStreamKHR stream, | 
|  | 1659 | EGLenum attribute, EGLuint64KHR *value) | 
|  | 1660 | { | 
|  | 1661 | clearError(); | 
|  | 1662 |  | 
|  | 1663 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1664 | if (!dp) return EGL_FALSE; | 
|  | 1665 |  | 
|  | 1666 | EGLBoolean result = EGL_FALSE; | 
|  | 1667 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1668 | if (cnx->dso && cnx->egl.eglQueryStreamu64KHR) { | 
|  | 1669 | result = cnx->egl.eglQueryStreamu64KHR( | 
|  | 1670 | dp->disp.dpy, stream, attribute, value); | 
|  | 1671 | } | 
|  | 1672 | return result; | 
|  | 1673 | } | 
|  | 1674 |  | 
|  | 1675 | EGLBoolean eglQueryStreamTimeKHR(EGLDisplay dpy, EGLStreamKHR stream, | 
|  | 1676 | EGLenum attribute, EGLTimeKHR *value) | 
|  | 1677 | { | 
|  | 1678 | clearError(); | 
|  | 1679 |  | 
|  | 1680 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1681 | if (!dp) return EGL_FALSE; | 
|  | 1682 |  | 
|  | 1683 | EGLBoolean result = EGL_FALSE; | 
|  | 1684 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1685 | if (cnx->dso && cnx->egl.eglQueryStreamTimeKHR) { | 
|  | 1686 | result = cnx->egl.eglQueryStreamTimeKHR( | 
|  | 1687 | dp->disp.dpy, stream, attribute, value); | 
|  | 1688 | } | 
|  | 1689 | return result; | 
|  | 1690 | } | 
|  | 1691 |  | 
|  | 1692 | EGLSurface eglCreateStreamProducerSurfaceKHR(EGLDisplay dpy, EGLConfig config, | 
|  | 1693 | EGLStreamKHR stream, const EGLint *attrib_list) | 
|  | 1694 | { | 
|  | 1695 | clearError(); | 
|  | 1696 |  | 
|  | 1697 | egl_display_ptr dp = validate_display(dpy); | 
|  | 1698 | if (!dp) return EGL_NO_SURFACE; | 
|  | 1699 |  | 
|  | 1700 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1701 | if (cnx->dso && cnx->egl.eglCreateStreamProducerSurfaceKHR) { | 
|  | 1702 | EGLSurface surface = cnx->egl.eglCreateStreamProducerSurfaceKHR( | 
|  | 1703 | dp->disp.dpy, config, stream, attrib_list); | 
|  | 1704 | if (surface != EGL_NO_SURFACE) { | 
|  | 1705 | egl_surface_t* s = new egl_surface_t(dp.get(), config, NULL, | 
|  | 1706 | surface, cnx); | 
|  | 1707 | return s; | 
|  | 1708 | } | 
|  | 1709 | } | 
|  | 1710 | return EGL_NO_SURFACE; | 
|  | 1711 | } | 
|  | 1712 |  | 
|  | 1713 | EGLBoolean eglStreamConsumerGLTextureExternalKHR(EGLDisplay dpy, | 
|  | 1714 | EGLStreamKHR stream) | 
|  | 1715 | { | 
|  | 1716 | clearError(); | 
|  | 1717 |  | 
|  | 1718 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1719 | if (!dp) return EGL_FALSE; | 
|  | 1720 |  | 
|  | 1721 | EGLBoolean result = EGL_FALSE; | 
|  | 1722 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1723 | if (cnx->dso && cnx->egl.eglStreamConsumerGLTextureExternalKHR) { | 
|  | 1724 | result = cnx->egl.eglStreamConsumerGLTextureExternalKHR( | 
|  | 1725 | dp->disp.dpy, stream); | 
|  | 1726 | } | 
|  | 1727 | return result; | 
|  | 1728 | } | 
|  | 1729 |  | 
|  | 1730 | EGLBoolean eglStreamConsumerAcquireKHR(EGLDisplay dpy, | 
|  | 1731 | EGLStreamKHR stream) | 
|  | 1732 | { | 
|  | 1733 | clearError(); | 
|  | 1734 |  | 
|  | 1735 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1736 | if (!dp) return EGL_FALSE; | 
|  | 1737 |  | 
|  | 1738 | EGLBoolean result = EGL_FALSE; | 
|  | 1739 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1740 | if (cnx->dso && cnx->egl.eglStreamConsumerAcquireKHR) { | 
|  | 1741 | result = cnx->egl.eglStreamConsumerAcquireKHR( | 
|  | 1742 | dp->disp.dpy, stream); | 
|  | 1743 | } | 
|  | 1744 | return result; | 
|  | 1745 | } | 
|  | 1746 |  | 
|  | 1747 | EGLBoolean eglStreamConsumerReleaseKHR(EGLDisplay dpy, | 
|  | 1748 | EGLStreamKHR stream) | 
|  | 1749 | { | 
|  | 1750 | clearError(); | 
|  | 1751 |  | 
|  | 1752 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1753 | if (!dp) return EGL_FALSE; | 
|  | 1754 |  | 
|  | 1755 | EGLBoolean result = EGL_FALSE; | 
|  | 1756 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1757 | if (cnx->dso && cnx->egl.eglStreamConsumerReleaseKHR) { | 
|  | 1758 | result = cnx->egl.eglStreamConsumerReleaseKHR( | 
|  | 1759 | dp->disp.dpy, stream); | 
|  | 1760 | } | 
|  | 1761 | return result; | 
|  | 1762 | } | 
|  | 1763 |  | 
|  | 1764 | EGLNativeFileDescriptorKHR eglGetStreamFileDescriptorKHR( | 
|  | 1765 | EGLDisplay dpy, EGLStreamKHR stream) | 
|  | 1766 | { | 
|  | 1767 | clearError(); | 
|  | 1768 |  | 
|  | 1769 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1770 | if (!dp) return EGL_NO_FILE_DESCRIPTOR_KHR; | 
|  | 1771 |  | 
|  | 1772 | EGLNativeFileDescriptorKHR result = EGL_NO_FILE_DESCRIPTOR_KHR; | 
|  | 1773 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1774 | if (cnx->dso && cnx->egl.eglGetStreamFileDescriptorKHR) { | 
|  | 1775 | result = cnx->egl.eglGetStreamFileDescriptorKHR( | 
|  | 1776 | dp->disp.dpy, stream); | 
|  | 1777 | } | 
|  | 1778 | return result; | 
|  | 1779 | } | 
|  | 1780 |  | 
|  | 1781 | EGLStreamKHR eglCreateStreamFromFileDescriptorKHR( | 
|  | 1782 | EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor) | 
|  | 1783 | { | 
|  | 1784 | clearError(); | 
|  | 1785 |  | 
|  | 1786 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1787 | if (!dp) return EGL_NO_STREAM_KHR; | 
|  | 1788 |  | 
|  | 1789 | EGLStreamKHR result = EGL_NO_STREAM_KHR; | 
|  | 1790 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1791 | if (cnx->dso && cnx->egl.eglCreateStreamFromFileDescriptorKHR) { | 
|  | 1792 | result = cnx->egl.eglCreateStreamFromFileDescriptorKHR( | 
|  | 1793 | dp->disp.dpy, file_descriptor); | 
|  | 1794 | } | 
|  | 1795 | return result; | 
|  | 1796 | } | 
|  | 1797 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1798 | // ---------------------------------------------------------------------------- | 
| Mathias Agopian | 2bb7168 | 2013-03-27 17:32:41 -0700 | [diff] [blame] | 1799 | // EGL_EGLEXT_VERSION 15 | 
|  | 1800 | // ---------------------------------------------------------------------------- | 
|  | 1801 |  | 
|  | 1802 | EGLint eglWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags) { | 
|  | 1803 | clearError(); | 
|  | 1804 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1805 | if (!dp) return EGL_FALSE; | 
|  | 1806 | EGLint result = EGL_FALSE; | 
|  | 1807 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1808 | if (cnx->dso && cnx->egl.eglWaitSyncKHR) { | 
|  | 1809 | result = cnx->egl.eglWaitSyncKHR(dp->disp.dpy, sync, flags); | 
|  | 1810 | } | 
|  | 1811 | return result; | 
|  | 1812 | } | 
|  | 1813 |  | 
|  | 1814 | // ---------------------------------------------------------------------------- | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 1815 | // ANDROID extensions | 
|  | 1816 | // ---------------------------------------------------------------------------- | 
|  | 1817 |  | 
| Jamie Gennis | 331841b | 2012-09-06 14:52:00 -0700 | [diff] [blame] | 1818 | EGLint eglDupNativeFenceFDANDROID(EGLDisplay dpy, EGLSyncKHR sync) | 
|  | 1819 | { | 
|  | 1820 | clearError(); | 
|  | 1821 |  | 
|  | 1822 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1823 | if (!dp) return EGL_NO_NATIVE_FENCE_FD_ANDROID; | 
|  | 1824 |  | 
|  | 1825 | EGLint result = EGL_NO_NATIVE_FENCE_FD_ANDROID; | 
|  | 1826 | egl_connection_t* const cnx = &gEGLImpl; | 
|  | 1827 | if (cnx->dso && cnx->egl.eglDupNativeFenceFDANDROID) { | 
|  | 1828 | result = cnx->egl.eglDupNativeFenceFDANDROID(dp->disp.dpy, sync); | 
|  | 1829 | } | 
|  | 1830 | return result; | 
|  | 1831 | } | 
| Jonas Yang | 1c3d72a | 2011-08-26 20:04:39 +0800 | [diff] [blame] | 1832 |  | 
| Andy McFadden | 7284145 | 2013-03-01 16:25:32 -0800 | [diff] [blame] | 1833 | EGLBoolean eglPresentationTimeANDROID(EGLDisplay dpy, EGLSurface surface, | 
|  | 1834 | EGLnsecsANDROID time) | 
|  | 1835 | { | 
|  | 1836 | clearError(); | 
|  | 1837 |  | 
|  | 1838 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1839 | if (!dp) { | 
|  | 1840 | return EGL_FALSE; | 
|  | 1841 | } | 
|  | 1842 |  | 
|  | 1843 | SurfaceRef _s(dp.get(), surface); | 
|  | 1844 | if (!_s.get()) { | 
|  | 1845 | setError(EGL_BAD_SURFACE, EGL_FALSE); | 
|  | 1846 | return EGL_FALSE; | 
|  | 1847 | } | 
|  | 1848 |  | 
|  | 1849 | egl_surface_t const * const s = get_surface(surface); | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1850 | native_window_set_buffers_timestamp(s->getNativeWindow(), time); | 
| Andy McFadden | 7284145 | 2013-03-01 16:25:32 -0800 | [diff] [blame] | 1851 |  | 
|  | 1852 | return EGL_TRUE; | 
|  | 1853 | } | 
|  | 1854 |  | 
| Craig Donner | 6076107 | 2017-01-27 12:30:44 -0800 | [diff] [blame] | 1855 | EGLClientBuffer eglGetNativeClientBufferANDROID(const AHardwareBuffer *buffer) { | 
|  | 1856 | clearError(); | 
| Craig Donner | 6076107 | 2017-01-27 12:30:44 -0800 | [diff] [blame] | 1857 | if (!buffer) return setError(EGL_BAD_PARAMETER, (EGLClientBuffer)0); | 
| Mathias Agopian | 6196340 | 2017-02-24 16:38:15 -0800 | [diff] [blame] | 1858 | return const_cast<ANativeWindowBuffer *>(AHardwareBuffer_to_ANativeWindowBuffer(buffer)); | 
| Craig Donner | 6076107 | 2017-01-27 12:30:44 -0800 | [diff] [blame] | 1859 | } | 
|  | 1860 |  | 
| Jonas Yang | 1c3d72a | 2011-08-26 20:04:39 +0800 | [diff] [blame] | 1861 | // ---------------------------------------------------------------------------- | 
|  | 1862 | // NVIDIA extensions | 
|  | 1863 | // ---------------------------------------------------------------------------- | 
|  | 1864 | EGLuint64NV eglGetSystemTimeFrequencyNV() | 
|  | 1865 | { | 
|  | 1866 | clearError(); | 
|  | 1867 |  | 
|  | 1868 | if (egl_init_drivers() == EGL_FALSE) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1869 | return setError(EGL_BAD_PARAMETER, (EGLuint64NV)EGL_FALSE); | 
| Jonas Yang | 1c3d72a | 2011-08-26 20:04:39 +0800 | [diff] [blame] | 1870 | } | 
|  | 1871 |  | 
|  | 1872 | EGLuint64NV ret = 0; | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1873 | egl_connection_t* const cnx = &gEGLImpl; | 
| Jonas Yang | 1c3d72a | 2011-08-26 20:04:39 +0800 | [diff] [blame] | 1874 |  | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1875 | if (cnx->dso && cnx->egl.eglGetSystemTimeFrequencyNV) { | 
|  | 1876 | return cnx->egl.eglGetSystemTimeFrequencyNV(); | 
| Jonas Yang | 1c3d72a | 2011-08-26 20:04:39 +0800 | [diff] [blame] | 1877 | } | 
|  | 1878 |  | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1879 | return setErrorQuiet(EGL_BAD_DISPLAY, (EGLuint64NV)0); | 
| Jonas Yang | 1c3d72a | 2011-08-26 20:04:39 +0800 | [diff] [blame] | 1880 | } | 
|  | 1881 |  | 
|  | 1882 | EGLuint64NV eglGetSystemTimeNV() | 
|  | 1883 | { | 
|  | 1884 | clearError(); | 
|  | 1885 |  | 
|  | 1886 | if (egl_init_drivers() == EGL_FALSE) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1887 | return setError(EGL_BAD_PARAMETER, (EGLuint64NV)EGL_FALSE); | 
| Jonas Yang | 1c3d72a | 2011-08-26 20:04:39 +0800 | [diff] [blame] | 1888 | } | 
|  | 1889 |  | 
|  | 1890 | EGLuint64NV ret = 0; | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1891 | egl_connection_t* const cnx = &gEGLImpl; | 
| Jonas Yang | 1c3d72a | 2011-08-26 20:04:39 +0800 | [diff] [blame] | 1892 |  | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 1893 | if (cnx->dso && cnx->egl.eglGetSystemTimeNV) { | 
|  | 1894 | return cnx->egl.eglGetSystemTimeNV(); | 
| Jonas Yang | 1c3d72a | 2011-08-26 20:04:39 +0800 | [diff] [blame] | 1895 | } | 
|  | 1896 |  | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1897 | return setErrorQuiet(EGL_BAD_DISPLAY, (EGLuint64NV)0); | 
| Jonas Yang | 1c3d72a | 2011-08-26 20:04:39 +0800 | [diff] [blame] | 1898 | } | 
| Dan Stoza | a894d08 | 2015-02-19 15:27:36 -0800 | [diff] [blame] | 1899 |  | 
|  | 1900 | // ---------------------------------------------------------------------------- | 
|  | 1901 | // Partial update extension | 
|  | 1902 | // ---------------------------------------------------------------------------- | 
|  | 1903 | EGLBoolean eglSetDamageRegionKHR(EGLDisplay dpy, EGLSurface surface, | 
|  | 1904 | EGLint *rects, EGLint n_rects) | 
|  | 1905 | { | 
|  | 1906 | clearError(); | 
|  | 1907 |  | 
|  | 1908 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1909 | if (!dp) { | 
|  | 1910 | setError(EGL_BAD_DISPLAY, EGL_FALSE); | 
|  | 1911 | return EGL_FALSE; | 
|  | 1912 | } | 
|  | 1913 |  | 
|  | 1914 | SurfaceRef _s(dp.get(), surface); | 
|  | 1915 | if (!_s.get()) { | 
|  | 1916 | setError(EGL_BAD_SURFACE, EGL_FALSE); | 
|  | 1917 | return EGL_FALSE; | 
|  | 1918 | } | 
|  | 1919 |  | 
|  | 1920 | egl_surface_t const * const s = get_surface(surface); | 
|  | 1921 | if (s->cnx->egl.eglSetDamageRegionKHR) { | 
|  | 1922 | return s->cnx->egl.eglSetDamageRegionKHR(dp->disp.dpy, s->surface, | 
|  | 1923 | rects, n_rects); | 
|  | 1924 | } | 
|  | 1925 |  | 
|  | 1926 | return EGL_FALSE; | 
|  | 1927 | } | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 1928 |  | 
| Brian Anderson | 1049d1d | 2016-12-16 17:25:57 -0800 | [diff] [blame] | 1929 | EGLBoolean eglGetNextFrameIdANDROID(EGLDisplay dpy, EGLSurface surface, | 
|  | 1930 | EGLuint64KHR *frameId) { | 
|  | 1931 | clearError(); | 
|  | 1932 |  | 
|  | 1933 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1934 | if (!dp) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1935 | return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE); | 
| Brian Anderson | 1049d1d | 2016-12-16 17:25:57 -0800 | [diff] [blame] | 1936 | } | 
|  | 1937 |  | 
|  | 1938 | SurfaceRef _s(dp.get(), surface); | 
|  | 1939 | if (!_s.get()) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1940 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Brian Anderson | 1049d1d | 2016-12-16 17:25:57 -0800 | [diff] [blame] | 1941 | } | 
|  | 1942 |  | 
|  | 1943 | egl_surface_t const * const s = get_surface(surface); | 
|  | 1944 |  | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1945 | if (!s->getNativeWindow()) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1946 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Brian Anderson | 1049d1d | 2016-12-16 17:25:57 -0800 | [diff] [blame] | 1947 | } | 
|  | 1948 |  | 
|  | 1949 | uint64_t nextFrameId = 0; | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1950 | int ret = native_window_get_next_frame_id(s->getNativeWindow(), &nextFrameId); | 
| Brian Anderson | 1049d1d | 2016-12-16 17:25:57 -0800 | [diff] [blame] | 1951 |  | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1952 | if (ret != 0) { | 
| Brian Anderson | 1049d1d | 2016-12-16 17:25:57 -0800 | [diff] [blame] | 1953 | // This should not happen. Return an error that is not in the spec | 
|  | 1954 | // so it's obvious something is very wrong. | 
|  | 1955 | ALOGE("eglGetNextFrameId: Unexpected error."); | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1956 | return setError(EGL_NOT_INITIALIZED, (EGLBoolean)EGL_FALSE); | 
| Brian Anderson | 1049d1d | 2016-12-16 17:25:57 -0800 | [diff] [blame] | 1957 | } | 
|  | 1958 |  | 
|  | 1959 | *frameId = nextFrameId; | 
|  | 1960 | return EGL_TRUE; | 
|  | 1961 | } | 
|  | 1962 |  | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 1963 | EGLBoolean eglGetCompositorTimingANDROID(EGLDisplay dpy, EGLSurface surface, | 
|  | 1964 | EGLint numTimestamps, const EGLint *names, EGLnsecsANDROID *values) | 
|  | 1965 | { | 
|  | 1966 | clearError(); | 
|  | 1967 |  | 
|  | 1968 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 1969 | if (!dp) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1970 | return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE); | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 1971 | } | 
|  | 1972 |  | 
|  | 1973 | SurfaceRef _s(dp.get(), surface); | 
|  | 1974 | if (!_s.get()) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1975 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 1976 | } | 
|  | 1977 |  | 
|  | 1978 | egl_surface_t const * const s = get_surface(surface); | 
|  | 1979 |  | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 1980 | if (!s->getNativeWindow()) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 1981 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 1982 | } | 
|  | 1983 |  | 
|  | 1984 | nsecs_t* compositeDeadline = nullptr; | 
|  | 1985 | nsecs_t* compositeInterval = nullptr; | 
|  | 1986 | nsecs_t* compositeToPresentLatency = nullptr; | 
|  | 1987 |  | 
|  | 1988 | for (int i = 0; i < numTimestamps; i++) { | 
|  | 1989 | switch (names[i]) { | 
|  | 1990 | case EGL_COMPOSITE_DEADLINE_ANDROID: | 
|  | 1991 | compositeDeadline = &values[i]; | 
|  | 1992 | break; | 
|  | 1993 | case EGL_COMPOSITE_INTERVAL_ANDROID: | 
|  | 1994 | compositeInterval = &values[i]; | 
|  | 1995 | break; | 
|  | 1996 | case EGL_COMPOSITE_TO_PRESENT_LATENCY_ANDROID: | 
|  | 1997 | compositeToPresentLatency = &values[i]; | 
|  | 1998 | break; | 
|  | 1999 | default: | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2000 | return setError(EGL_BAD_PARAMETER, (EGLBoolean)EGL_FALSE); | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 2001 | } | 
|  | 2002 | } | 
|  | 2003 |  | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 2004 | int ret = native_window_get_compositor_timing(s->getNativeWindow(), | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 2005 | compositeDeadline, compositeInterval, compositeToPresentLatency); | 
|  | 2006 |  | 
|  | 2007 | switch (ret) { | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 2008 | case 0: | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 2009 | return EGL_TRUE; | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 2010 | case -ENOSYS: | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2011 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 2012 | default: | 
|  | 2013 | // This should not happen. Return an error that is not in the spec | 
|  | 2014 | // so it's obvious something is very wrong. | 
|  | 2015 | ALOGE("eglGetCompositorTiming: Unexpected error."); | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2016 | return setError(EGL_NOT_INITIALIZED, (EGLBoolean)EGL_FALSE); | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 2017 | } | 
|  | 2018 | } | 
|  | 2019 |  | 
|  | 2020 | EGLBoolean eglGetCompositorTimingSupportedANDROID( | 
|  | 2021 | EGLDisplay dpy, EGLSurface surface, EGLint name) | 
|  | 2022 | { | 
|  | 2023 | clearError(); | 
|  | 2024 |  | 
|  | 2025 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 2026 | if (!dp) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2027 | return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE); | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 2028 | } | 
|  | 2029 |  | 
|  | 2030 | SurfaceRef _s(dp.get(), surface); | 
|  | 2031 | if (!_s.get()) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2032 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 2033 | } | 
|  | 2034 |  | 
|  | 2035 | egl_surface_t const * const s = get_surface(surface); | 
|  | 2036 |  | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 2037 | ANativeWindow* window = s->getNativeWindow(); | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 2038 | if (!window) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2039 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 2040 | } | 
|  | 2041 |  | 
|  | 2042 | switch (name) { | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 2043 | case EGL_COMPOSITE_DEADLINE_ANDROID: | 
|  | 2044 | case EGL_COMPOSITE_INTERVAL_ANDROID: | 
|  | 2045 | case EGL_COMPOSITE_TO_PRESENT_LATENCY_ANDROID: | 
|  | 2046 | return EGL_TRUE; | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 2047 | default: | 
|  | 2048 | return EGL_FALSE; | 
|  | 2049 | } | 
|  | 2050 | } | 
|  | 2051 |  | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2052 | EGLBoolean eglGetFrameTimestampsANDROID(EGLDisplay dpy, EGLSurface surface, | 
| Brian Anderson | 1049d1d | 2016-12-16 17:25:57 -0800 | [diff] [blame] | 2053 | EGLuint64KHR frameId, EGLint numTimestamps, const EGLint *timestamps, | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2054 | EGLnsecsANDROID *values) | 
|  | 2055 | { | 
|  | 2056 | clearError(); | 
|  | 2057 |  | 
|  | 2058 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 2059 | if (!dp) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2060 | return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE); | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2061 | } | 
|  | 2062 |  | 
|  | 2063 | SurfaceRef _s(dp.get(), surface); | 
|  | 2064 | if (!_s.get()) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2065 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2066 | } | 
|  | 2067 |  | 
|  | 2068 | egl_surface_t const * const s = get_surface(surface); | 
|  | 2069 |  | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 2070 | if (!s->getNativeWindow()) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2071 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2072 | } | 
|  | 2073 |  | 
| Brian Anderson | dbd0ea8 | 2016-07-22 09:38:59 -0700 | [diff] [blame] | 2074 | nsecs_t* requestedPresentTime = nullptr; | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2075 | nsecs_t* acquireTime = nullptr; | 
| Brian Anderson | f7fd56a | 2016-09-02 10:10:04 -0700 | [diff] [blame] | 2076 | nsecs_t* latchTime = nullptr; | 
|  | 2077 | nsecs_t* firstRefreshStartTime = nullptr; | 
| Brian Anderson | b04c6f0 | 2016-10-21 12:57:46 -0700 | [diff] [blame] | 2078 | nsecs_t* gpuCompositionDoneTime = nullptr; | 
| Brian Anderson | f7fd56a | 2016-09-02 10:10:04 -0700 | [diff] [blame] | 2079 | nsecs_t* lastRefreshStartTime = nullptr; | 
| Brian Anderson | 069b365 | 2016-07-22 10:32:47 -0700 | [diff] [blame] | 2080 | nsecs_t* displayPresentTime = nullptr; | 
| Brian Anderson | f7fd56a | 2016-09-02 10:10:04 -0700 | [diff] [blame] | 2081 | nsecs_t* dequeueReadyTime = nullptr; | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2082 | nsecs_t* releaseTime = nullptr; | 
|  | 2083 |  | 
|  | 2084 | for (int i = 0; i < numTimestamps; i++) { | 
|  | 2085 | switch (timestamps[i]) { | 
| Brian Anderson | dbd0ea8 | 2016-07-22 09:38:59 -0700 | [diff] [blame] | 2086 | case EGL_REQUESTED_PRESENT_TIME_ANDROID: | 
|  | 2087 | requestedPresentTime = &values[i]; | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2088 | break; | 
|  | 2089 | case EGL_RENDERING_COMPLETE_TIME_ANDROID: | 
|  | 2090 | acquireTime = &values[i]; | 
|  | 2091 | break; | 
| Brian Anderson | f7fd56a | 2016-09-02 10:10:04 -0700 | [diff] [blame] | 2092 | case EGL_COMPOSITION_LATCH_TIME_ANDROID: | 
|  | 2093 | latchTime = &values[i]; | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2094 | break; | 
| Brian Anderson | f7fd56a | 2016-09-02 10:10:04 -0700 | [diff] [blame] | 2095 | case EGL_FIRST_COMPOSITION_START_TIME_ANDROID: | 
|  | 2096 | firstRefreshStartTime = &values[i]; | 
|  | 2097 | break; | 
|  | 2098 | case EGL_LAST_COMPOSITION_START_TIME_ANDROID: | 
|  | 2099 | lastRefreshStartTime = &values[i]; | 
|  | 2100 | break; | 
| Brian Anderson | b04c6f0 | 2016-10-21 12:57:46 -0700 | [diff] [blame] | 2101 | case EGL_FIRST_COMPOSITION_GPU_FINISHED_TIME_ANDROID: | 
|  | 2102 | gpuCompositionDoneTime = &values[i]; | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2103 | break; | 
| Brian Anderson | 069b365 | 2016-07-22 10:32:47 -0700 | [diff] [blame] | 2104 | case EGL_DISPLAY_PRESENT_TIME_ANDROID: | 
|  | 2105 | displayPresentTime = &values[i]; | 
|  | 2106 | break; | 
| Brian Anderson | f7fd56a | 2016-09-02 10:10:04 -0700 | [diff] [blame] | 2107 | case EGL_DEQUEUE_READY_TIME_ANDROID: | 
|  | 2108 | dequeueReadyTime = &values[i]; | 
|  | 2109 | break; | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2110 | case EGL_READS_DONE_TIME_ANDROID: | 
|  | 2111 | releaseTime = &values[i]; | 
|  | 2112 | break; | 
|  | 2113 | default: | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2114 | return setError(EGL_BAD_PARAMETER, (EGLBoolean)EGL_FALSE); | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2115 | } | 
|  | 2116 | } | 
|  | 2117 |  | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 2118 | int ret = native_window_get_frame_timestamps(s->getNativeWindow(), frameId, | 
| Brian Anderson | f7fd56a | 2016-09-02 10:10:04 -0700 | [diff] [blame] | 2119 | requestedPresentTime, acquireTime, latchTime, firstRefreshStartTime, | 
| Brian Anderson | b04c6f0 | 2016-10-21 12:57:46 -0700 | [diff] [blame] | 2120 | lastRefreshStartTime, gpuCompositionDoneTime, displayPresentTime, | 
| Brian Anderson | 4e606e3 | 2017-03-16 15:34:57 -0700 | [diff] [blame] | 2121 | dequeueReadyTime, releaseTime); | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2122 |  | 
| Brian Anderson | 069b365 | 2016-07-22 10:32:47 -0700 | [diff] [blame] | 2123 | switch (ret) { | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 2124 | case 0: | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2125 | return EGL_TRUE; | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 2126 | case -ENOENT: | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2127 | return setError(EGL_BAD_ACCESS, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 2128 | case -ENOSYS: | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2129 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 2130 | case -EINVAL: | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2131 | return setError(EGL_BAD_PARAMETER, (EGLBoolean)EGL_FALSE); | 
|  | 2132 | default: | 
|  | 2133 | // This should not happen. Return an error that is not in the spec | 
|  | 2134 | // so it's obvious something is very wrong. | 
|  | 2135 | ALOGE("eglGetFrameTimestamps: Unexpected error."); | 
|  | 2136 | return setError(EGL_NOT_INITIALIZED, (EGLBoolean)EGL_FALSE); | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2137 | } | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2138 | } | 
|  | 2139 |  | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 2140 | EGLBoolean eglGetFrameTimestampSupportedANDROID( | 
|  | 2141 | EGLDisplay dpy, EGLSurface surface, EGLint timestamp) | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2142 | { | 
|  | 2143 | clearError(); | 
|  | 2144 |  | 
|  | 2145 | const egl_display_ptr dp = validate_display(dpy); | 
|  | 2146 | if (!dp) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2147 | return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE); | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2148 | } | 
|  | 2149 |  | 
|  | 2150 | SurfaceRef _s(dp.get(), surface); | 
|  | 2151 | if (!_s.get()) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2152 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Brian Anderson | 069b365 | 2016-07-22 10:32:47 -0700 | [diff] [blame] | 2153 | } | 
|  | 2154 |  | 
|  | 2155 | egl_surface_t const * const s = get_surface(surface); | 
|  | 2156 |  | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 2157 | ANativeWindow* window = s->getNativeWindow(); | 
| Brian Anderson | 069b365 | 2016-07-22 10:32:47 -0700 | [diff] [blame] | 2158 | if (!window) { | 
| Mathias Agopian | 737b896 | 2017-02-24 14:32:05 -0800 | [diff] [blame] | 2159 | return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE); | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2160 | } | 
|  | 2161 |  | 
|  | 2162 | switch (timestamp) { | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 2163 | case EGL_COMPOSITE_DEADLINE_ANDROID: | 
|  | 2164 | case EGL_COMPOSITE_INTERVAL_ANDROID: | 
|  | 2165 | case EGL_COMPOSITE_TO_PRESENT_LATENCY_ANDROID: | 
| Brian Anderson | dbd0ea8 | 2016-07-22 09:38:59 -0700 | [diff] [blame] | 2166 | case EGL_REQUESTED_PRESENT_TIME_ANDROID: | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2167 | case EGL_RENDERING_COMPLETE_TIME_ANDROID: | 
| Brian Anderson | f7fd56a | 2016-09-02 10:10:04 -0700 | [diff] [blame] | 2168 | case EGL_COMPOSITION_LATCH_TIME_ANDROID: | 
|  | 2169 | case EGL_FIRST_COMPOSITION_START_TIME_ANDROID: | 
|  | 2170 | case EGL_LAST_COMPOSITION_START_TIME_ANDROID: | 
| Brian Anderson | b04c6f0 | 2016-10-21 12:57:46 -0700 | [diff] [blame] | 2171 | case EGL_FIRST_COMPOSITION_GPU_FINISHED_TIME_ANDROID: | 
| Brian Anderson | f7fd56a | 2016-09-02 10:10:04 -0700 | [diff] [blame] | 2172 | case EGL_DEQUEUE_READY_TIME_ANDROID: | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2173 | case EGL_READS_DONE_TIME_ANDROID: | 
|  | 2174 | return EGL_TRUE; | 
| Brian Anderson | 6b37671 | 2017-04-04 10:51:39 -0700 | [diff] [blame] | 2175 | case EGL_DISPLAY_PRESENT_TIME_ANDROID: { | 
|  | 2176 | int value = 0; | 
|  | 2177 | window->query(window, | 
|  | 2178 | NATIVE_WINDOW_FRAME_TIMESTAMPS_SUPPORTS_PRESENT, &value); | 
|  | 2179 | return value == 0 ? EGL_FALSE : EGL_TRUE; | 
|  | 2180 | } | 
| Pablo Ceballos | c18be29 | 2016-05-31 14:55:42 -0700 | [diff] [blame] | 2181 | default: | 
|  | 2182 | return EGL_FALSE; | 
|  | 2183 | } | 
|  | 2184 | } |