eglApi.cpp revision c07b52060acd627c8510c1a9151e0753fce76330
14774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall/* 2518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** Copyright 2007, The Android Open Source Project 3518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** 44774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall ** Licensed under the Apache License, Version 2.0 (the "License"); 54774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall ** you may not use this file except in compliance with the License. 64774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall ** You may obtain a copy of the License at 7518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** 84774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall ** http://www.apache.org/licenses/LICENSE-2.0 9518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** 104774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall ** Unless required by applicable law or agreed to in writing, software 114774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall ** distributed under the License is distributed on an "AS IS" BASIS, 124774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 134774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall ** See the License for the specific language governing permissions and 14518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** limitations under the License. 15518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian */ 16518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 171c8e95cf86f2182986385bc1ee85f13f425f3a3aJamie Gennis#define ATRACE_TAG ATRACE_TAG_GRAPHICS 181c8e95cf86f2182986385bc1ee85f13f425f3a3aJamie Gennis 19c07b52060acd627c8510c1a9151e0753fce76330Jesse Hall#include <dlfcn.h> 20518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <ctype.h> 21518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <stdlib.h> 22518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <string.h> 23518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 24518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <hardware/gralloc.h> 25518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <system/window.h> 26518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 27518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <EGL/egl.h> 28518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <EGL/eglext.h> 29518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 30518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <cutils/log.h> 31518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <cutils/atomic.h> 327db993a98b9239bd4e384cc4aa128262fe3cf52cMathias Agopian#include <cutils/compiler.h> 33518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <cutils/properties.h> 34518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <cutils/memory.h> 35518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 36518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <utils/KeyedVector.h> 37518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <utils/SortedVector.h> 38518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <utils/String8.h> 391c8e95cf86f2182986385bc1ee85f13f425f3a3aJamie Gennis#include <utils/Trace.h> 40518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 4139c24a20bbc697630d2b92c251b70c04d6f9d00cMathias Agopian#include "../egl_impl.h" 4239c24a20bbc697630d2b92c251b70c04d6f9d00cMathias Agopian#include "../glestrace.h" 4339c24a20bbc697630d2b92c251b70c04d6f9d00cMathias Agopian#include "../hooks.h" 44518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 45518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include "egl_display.h" 46518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include "egl_object.h" 47518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include "egl_tls.h" 48ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian#include "egldefs.h" 49518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 50518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianusing namespace android; 51518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 52518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 53518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 54e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopiannamespace android { 55e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 56518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianstruct extention_map_t { 57518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian const char* name; 58518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian __eglMustCastToProperFunctionPointerType address; 59518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian}; 60518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 61e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian/* 62e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian * This is the list of EGL extensions exposed to applications, 63e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian * some of them are mandatory because used by the ANDROID system. 64e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian * 65e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian * Mandatory extensions are required per the CDD and not explicitly 66e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian * checked during EGL initialization. the system *assumes* these extensions 67e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian * are present. the system may not function properly if some mandatory 68e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian * extensions are missing. 69e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian * 70e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian * NOTE: gExtensionString MUST have a single space as the last character. 71e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian */ 72e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopianextern char const * const gExtensionString = 73e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian "EGL_KHR_image " // mandatory 74e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian "EGL_KHR_image_base " // mandatory 75e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian "EGL_KHR_image_pixmap " 76e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian "EGL_KHR_lock_surface " 77e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian "EGL_KHR_gl_texture_2D_image " 78e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian "EGL_KHR_gl_texture_cubemap_image " 79e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian "EGL_KHR_gl_renderbuffer_image " 80e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian "EGL_KHR_reusable_sync " 81e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian "EGL_KHR_fence_sync " 82f6d1c3930eeba6b089ba12fb82ecad1c6622e550Jamie Gennis "EGL_KHR_create_context " 83e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian "EGL_EXT_create_context_robustness " 84e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian "EGL_NV_system_time " 85e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian "EGL_ANDROID_image_native_buffer " // mandatory 862bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias Agopian "EGL_KHR_wait_sync " // strongly recommended 87e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian "EGL_ANDROID_presentation_time " 88e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian ; 89e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 90e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian// extensions not exposed to applications but used by the ANDROID system 91e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian// "EGL_ANDROID_blob_cache " // strongly recommended 92e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian// "EGL_IMG_hibernate_process " // optional 93e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian// "EGL_ANDROID_native_fence_sync " // strongly recommended 94e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian// "EGL_ANDROID_framebuffer_target " // mandatory for HWC 1.1 95e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian// "EGL_ANDROID_recordable " // mandatory 96e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 97e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 98e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian/* 99e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian * EGL Extensions entry-points exposed to 3rd party applications 100e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian * (keep in sync with gExtensionString above) 101e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian * 102e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian */ 103e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopianstatic const extention_map_t sExtensionMap[] = { 104e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian // EGL_KHR_lock_surface 105518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian { "eglLockSurfaceKHR", 106518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian (__eglMustCastToProperFunctionPointerType)&eglLockSurfaceKHR }, 107518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian { "eglUnlockSurfaceKHR", 108518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian (__eglMustCastToProperFunctionPointerType)&eglUnlockSurfaceKHR }, 109e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 110e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian // EGL_KHR_image, EGL_KHR_image_base 111518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian { "eglCreateImageKHR", 112518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian (__eglMustCastToProperFunctionPointerType)&eglCreateImageKHR }, 113518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian { "eglDestroyImageKHR", 114518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian (__eglMustCastToProperFunctionPointerType)&eglDestroyImageKHR }, 115e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 116e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian // EGL_KHR_reusable_sync, EGL_KHR_fence_sync 117e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian { "eglCreateSyncKHR", 118e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian (__eglMustCastToProperFunctionPointerType)&eglCreateSyncKHR }, 119e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian { "eglDestroySyncKHR", 120e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian (__eglMustCastToProperFunctionPointerType)&eglDestroySyncKHR }, 121e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian { "eglClientWaitSyncKHR", 122e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian (__eglMustCastToProperFunctionPointerType)&eglClientWaitSyncKHR }, 123e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian { "eglSignalSyncKHR", 124e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian (__eglMustCastToProperFunctionPointerType)&eglSignalSyncKHR }, 125e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian { "eglGetSyncAttribKHR", 126e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian (__eglMustCastToProperFunctionPointerType)&eglGetSyncAttribKHR }, 127e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 128e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian // EGL_NV_system_time 1291c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang { "eglGetSystemTimeFrequencyNV", 1301c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang (__eglMustCastToProperFunctionPointerType)&eglGetSystemTimeFrequencyNV }, 1311c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang { "eglGetSystemTimeNV", 1321c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang (__eglMustCastToProperFunctionPointerType)&eglGetSystemTimeNV }, 133e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 1342bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias Agopian // EGL_KHR_wait_sync 1352bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias Agopian { "eglWaitSyncKHR", 1362bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias Agopian (__eglMustCastToProperFunctionPointerType)&eglWaitSyncKHR }, 137e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 138e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian // EGL_ANDROID_presentation_time 139e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian { "eglPresentationTimeANDROID", 140e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian (__eglMustCastToProperFunctionPointerType)&eglPresentationTimeANDROID }, 141518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian}; 142518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 143e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian/* 144e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian * These extensions entry-points should not be exposed to applications. 145e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian * They're used internally by the Android EGL layer. 146e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian */ 147e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian#define FILTER_EXTENSIONS(procname) \ 148e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian (!strcmp((procname), "eglSetBlobCacheFuncsANDROID") || \ 149e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian !strcmp((procname), "eglHibernateProcessIMG") || \ 150e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian !strcmp((procname), "eglAwakenProcessIMG") || \ 151e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian !strcmp((procname), "eglDupNativeFenceFDANDROID")) 152e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 153e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 154e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 155518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// accesses protected by sExtensionMapMutex 156518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianstatic DefaultKeyedVector<String8, __eglMustCastToProperFunctionPointerType> sGLExtentionMap; 157518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianstatic int sGLExtentionSlot = 0; 158518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianstatic pthread_mutex_t sExtensionMapMutex = PTHREAD_MUTEX_INITIALIZER; 159518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 160518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianstatic void(*findProcAddress(const char* name, 161518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian const extention_map_t* map, size_t n))() { 162518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian for (uint32_t i=0 ; i<n ; i++) { 163518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!strcmp(name, map[i].name)) { 164518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return map[i].address; 165518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 166518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 167518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return NULL; 168518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 169518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 170518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 171518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 172518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianextern void setGLHooksThreadSpecific(gl_hooks_t const *value); 173518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianextern EGLBoolean egl_init_drivers(); 174518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianextern const __eglMustCastToProperFunctionPointerType gExtensionForwarders[MAX_NUMBER_OF_GL_EXTENSIONS]; 175a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamyextern int getEGLDebugLevel(); 176a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamyextern void setEGLDebugLevel(int level); 177518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianextern gl_hooks_t gHooksTrace; 178e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 179518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} // namespace android; 180518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 181e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 182518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 183518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 184518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianstatic inline void clearError() { egl_tls_t::clearError(); } 185518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianstatic inline EGLContext getContext() { return egl_tls_t::getContext(); } 186518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 187518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 188518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 189518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLDisplay eglGetDisplay(EGLNativeDisplayType display) 190518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 191518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 192518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 193518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian uint32_t index = uint32_t(display); 194518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (index >= NUM_DISPLAYS) { 195518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_PARAMETER, EGL_NO_DISPLAY); 196518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 197518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 198518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (egl_init_drivers() == EGL_FALSE) { 199518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_PARAMETER, EGL_NO_DISPLAY); 200518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 201518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 202518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLDisplay dpy = egl_display_t::getFromNativeDisplay(display); 203518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return dpy; 204518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 205518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 206518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 207518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// Initialization 208518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 209518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 210518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) 211518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 212518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 213518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 214b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall egl_display_ptr dp = get_display(dpy); 215518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return setError(EGL_BAD_DISPLAY, EGL_FALSE); 216518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 217518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLBoolean res = dp->initialize(major, minor); 218518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 219518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return res; 220518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 221518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 222518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglTerminate(EGLDisplay dpy) 223518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 224518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // NOTE: don't unload the drivers b/c some APIs can be called 225518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // after eglTerminate() has been called. eglTerminate() only 226518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // terminates an EGLDisplay, not a EGL itself. 227518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 228518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 229518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 230b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall egl_display_ptr dp = get_display(dpy); 231518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return setError(EGL_BAD_DISPLAY, EGL_FALSE); 232518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 233518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLBoolean res = dp->terminate(); 2344774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall 235518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return res; 236518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 237518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 238518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 239518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// configuration 240518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 241518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 242518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglGetConfigs( EGLDisplay dpy, 243518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLConfig *configs, 244518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLint config_size, EGLint *num_config) 245518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 246518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 247518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 248b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 249518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 250518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 2517773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian if (num_config==0) { 2527773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian return setError(EGL_BAD_PARAMETER, EGL_FALSE); 253518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 254518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 2557773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian EGLBoolean res = EGL_FALSE; 2567773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian *num_config = 0; 2577773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian 2587773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian egl_connection_t* const cnx = &gEGLImpl; 2597773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian if (cnx->dso) { 2607773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian res = cnx->egl.eglGetConfigs( 2617773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, configs, config_size, num_config); 262518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 2637773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian 2647773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian return res; 265518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 266518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 267518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglChooseConfig( EGLDisplay dpy, const EGLint *attrib_list, 268518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLConfig *configs, EGLint config_size, 269518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLint *num_config) 270518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 271518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 272518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 273b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 274518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 275518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 276518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (num_config==0) { 277518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_PARAMETER, EGL_FALSE); 278518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 279518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 280518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLBoolean res = EGL_FALSE; 281518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian *num_config = 0; 282518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 283ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 284ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso) { 2851cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy if (attrib_list) { 2861cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy char value[PROPERTY_VALUE_MAX]; 2871cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy property_get("debug.egl.force_msaa", value, "false"); 2881cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy 2891cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy if (!strcmp(value, "true")) { 2901cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy size_t attribCount = 0; 2911cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy EGLint attrib = attrib_list[0]; 2921cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy 2931cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy // Only enable MSAA if the context is OpenGL ES 2.0 and 294be3c3e4ecad501eecfe1f7a424a792f0f7f3f307Romain Guy // if no caveat is requested 2951cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy const EGLint *attribRendererable = NULL; 2961cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy const EGLint *attribCaveat = NULL; 2971cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy 2981cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy // Count the number of attributes and look for 299be3c3e4ecad501eecfe1f7a424a792f0f7f3f307Romain Guy // EGL_RENDERABLE_TYPE and EGL_CONFIG_CAVEAT 3001cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy while (attrib != EGL_NONE) { 3011cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy attrib = attrib_list[attribCount]; 3021cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy switch (attrib) { 3031cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy case EGL_RENDERABLE_TYPE: 3041cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy attribRendererable = &attrib_list[attribCount]; 3051cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy break; 3061cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy case EGL_CONFIG_CAVEAT: 3071cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy attribCaveat = &attrib_list[attribCount]; 3081cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy break; 3091cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy } 3101cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy attribCount++; 3111cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy } 3121cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy 3131cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy if (attribRendererable && attribRendererable[1] == EGL_OPENGL_ES2_BIT && 3141cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy (!attribCaveat || attribCaveat[1] != EGL_NONE)) { 3154774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall 3161cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy // Insert 2 extra attributes to force-enable MSAA 4x 3171cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy EGLint aaAttribs[attribCount + 4]; 3181cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy aaAttribs[0] = EGL_SAMPLE_BUFFERS; 3191cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy aaAttribs[1] = 1; 3201cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy aaAttribs[2] = EGL_SAMPLES; 3211cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy aaAttribs[3] = 4; 3221cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy 3231cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy memcpy(&aaAttribs[4], attrib_list, attribCount * sizeof(EGLint)); 3241cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy 3251cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy EGLint numConfigAA; 3261cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy EGLBoolean resAA = cnx->egl.eglChooseConfig( 3271cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy dp->disp.dpy, aaAttribs, configs, config_size, &numConfigAA); 3281cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy 3291cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy if (resAA == EGL_TRUE && numConfigAA > 0) { 3301cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy ALOGD("Enabling MSAA 4x"); 3311cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy *num_config = numConfigAA; 3321cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy return resAA; 3331cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy } 3341cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy } 3351cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy } 3361cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy } 3371cffc80f978c55f09203d9d9a905775b951ba59aRomain Guy 3387773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian res = cnx->egl.eglChooseConfig( 3397773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, attrib_list, configs, config_size, num_config); 340518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 341518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return res; 342518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 343518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 344518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, 345518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLint attribute, EGLint *value) 346518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 347518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 348518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 349b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall egl_connection_t* cnx = NULL; 350b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display_connection(dpy, cnx); 351b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall if (!dp) return EGL_FALSE; 3524774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall 353518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return cnx->egl.eglGetConfigAttrib( 3547773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, config, attribute, value); 355518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 356518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 357518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 358518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// surfaces 359518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 360518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 361518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config, 362518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian NativeWindowType window, 363518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian const EGLint *attrib_list) 364518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 365518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 366518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 367b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall egl_connection_t* cnx = NULL; 368b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall egl_display_ptr dp = validate_display_connection(dpy, cnx); 369b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall if (dp) { 370ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian EGLDisplay iDpy = dp->disp.dpy; 371518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLint format; 372518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 37381a63350527cafce6929309533c58586878f10b5Mathias Agopian if (native_window_api_connect(window, NATIVE_WINDOW_API_EGL) != OK) { 374e6f43ddce78d6846af12550ff9193c5c6fe5844bSteve Block ALOGE("EGLNativeWindowType %p already connected to another API", 37581a63350527cafce6929309533c58586878f10b5Mathias Agopian window); 37681a63350527cafce6929309533c58586878f10b5Mathias Agopian return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); 37781a63350527cafce6929309533c58586878f10b5Mathias Agopian } 37881a63350527cafce6929309533c58586878f10b5Mathias Agopian 379518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // set the native window's buffers format to match this config 380518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (cnx->egl.eglGetConfigAttrib(iDpy, 3817773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian config, EGL_NATIVE_VISUAL_ID, &format)) { 382518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (format != 0) { 383bee205fd58a27c10a0895de5339e76025d429d2bJamie Gennis int err = native_window_set_buffers_format(window, format); 384bee205fd58a27c10a0895de5339e76025d429d2bJamie Gennis if (err != 0) { 385e6f43ddce78d6846af12550ff9193c5c6fe5844bSteve Block ALOGE("error setting native window pixel format: %s (%d)", 386bee205fd58a27c10a0895de5339e76025d429d2bJamie Gennis strerror(-err), err); 38781a63350527cafce6929309533c58586878f10b5Mathias Agopian native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL); 388bee205fd58a27c10a0895de5339e76025d429d2bJamie Gennis return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); 389bee205fd58a27c10a0895de5339e76025d429d2bJamie Gennis } 390518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 391518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 392518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 39359769469e4b9b2d8b12c020eb44b030b3927a50bJamie Gennis // the EGL spec requires that a new EGLSurface default to swap interval 39459769469e4b9b2d8b12c020eb44b030b3927a50bJamie Gennis // 1, so explicitly set that on the window here. 39559769469e4b9b2d8b12c020eb44b030b3927a50bJamie Gennis ANativeWindow* anw = reinterpret_cast<ANativeWindow*>(window); 39659769469e4b9b2d8b12c020eb44b030b3927a50bJamie Gennis anw->setSwapInterval(anw, 1); 39759769469e4b9b2d8b12c020eb44b030b3927a50bJamie Gennis 398518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLSurface surface = cnx->egl.eglCreateWindowSurface( 3997773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian iDpy, config, window, attrib_list); 400518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (surface != EGL_NO_SURFACE) { 401b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall egl_surface_t* s = new egl_surface_t(dp.get(), config, window, 402b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall surface, cnx); 403518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return s; 404518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 40581a63350527cafce6929309533c58586878f10b5Mathias Agopian 40681a63350527cafce6929309533c58586878f10b5Mathias Agopian // EGLSurface creation failed 40781a63350527cafce6929309533c58586878f10b5Mathias Agopian native_window_set_buffers_format(window, 0); 40881a63350527cafce6929309533c58586878f10b5Mathias Agopian native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL); 409518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 410518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_NO_SURFACE; 411518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 412518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 413518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLSurface eglCreatePixmapSurface( EGLDisplay dpy, EGLConfig config, 414518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian NativePixmapType pixmap, 415518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian const EGLint *attrib_list) 416518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 417518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 418518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 419b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall egl_connection_t* cnx = NULL; 420b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall egl_display_ptr dp = validate_display_connection(dpy, cnx); 421b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall if (dp) { 422518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLSurface surface = cnx->egl.eglCreatePixmapSurface( 4237773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, config, pixmap, attrib_list); 424518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (surface != EGL_NO_SURFACE) { 425b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall egl_surface_t* s = new egl_surface_t(dp.get(), config, NULL, 426b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall surface, cnx); 427518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return s; 428518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 429518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 430518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_NO_SURFACE; 431518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 432518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 433518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLSurface eglCreatePbufferSurface( EGLDisplay dpy, EGLConfig config, 434518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian const EGLint *attrib_list) 435518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 436518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 437518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 438b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall egl_connection_t* cnx = NULL; 439b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall egl_display_ptr dp = validate_display_connection(dpy, cnx); 440b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall if (dp) { 441518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLSurface surface = cnx->egl.eglCreatePbufferSurface( 4427773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, config, attrib_list); 443518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (surface != EGL_NO_SURFACE) { 444b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall egl_surface_t* s = new egl_surface_t(dp.get(), config, NULL, 445b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall surface, cnx); 446518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return s; 447518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 448518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 449518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_NO_SURFACE; 450518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 4514774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall 452518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface) 453518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 454518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 455518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 456b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 457518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 458518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 459b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall SurfaceRef _s(dp.get(), surface); 4605b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 4615b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 462518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 463518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t * const s = get_surface(surface); 464ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian EGLBoolean result = s->cnx->egl.eglDestroySurface(dp->disp.dpy, s->surface); 465518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (result == EGL_TRUE) { 466518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian _s.terminate(); 467518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 468518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return result; 469518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 470518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 471518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglQuerySurface( EGLDisplay dpy, EGLSurface surface, 472518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLint attribute, EGLint *value) 473518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 474518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 475518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 476b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 477518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 478518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 479b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall SurfaceRef _s(dp.get(), surface); 4805b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 4815b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 482518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 483518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * const s = get_surface(surface); 4847773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian return s->cnx->egl.eglQuerySurface( 4857773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, s->surface, attribute, value); 486518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 487518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 488e8696a40e09b24b634214684d18526187b316a2fJamie Gennisvoid EGLAPI eglBeginFrame(EGLDisplay dpy, EGLSurface surface) { 4891c8e95cf86f2182986385bc1ee85f13f425f3a3aJamie Gennis ATRACE_CALL(); 490e8696a40e09b24b634214684d18526187b316a2fJamie Gennis clearError(); 491e8696a40e09b24b634214684d18526187b316a2fJamie Gennis 492b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 493e8696a40e09b24b634214684d18526187b316a2fJamie Gennis if (!dp) { 494e8696a40e09b24b634214684d18526187b316a2fJamie Gennis return; 495e8696a40e09b24b634214684d18526187b316a2fJamie Gennis } 496e8696a40e09b24b634214684d18526187b316a2fJamie Gennis 497b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall SurfaceRef _s(dp.get(), surface); 498e8696a40e09b24b634214684d18526187b316a2fJamie Gennis if (!_s.get()) { 499e8696a40e09b24b634214684d18526187b316a2fJamie Gennis setError(EGL_BAD_SURFACE, EGL_FALSE); 500e8696a40e09b24b634214684d18526187b316a2fJamie Gennis return; 501e8696a40e09b24b634214684d18526187b316a2fJamie Gennis } 502e8696a40e09b24b634214684d18526187b316a2fJamie Gennis 503e8696a40e09b24b634214684d18526187b316a2fJamie Gennis int64_t timestamp = systemTime(SYSTEM_TIME_MONOTONIC); 504e8696a40e09b24b634214684d18526187b316a2fJamie Gennis 505e8696a40e09b24b634214684d18526187b316a2fJamie Gennis egl_surface_t const * const s = get_surface(surface); 506e8696a40e09b24b634214684d18526187b316a2fJamie Gennis native_window_set_buffers_timestamp(s->win.get(), timestamp); 507e8696a40e09b24b634214684d18526187b316a2fJamie Gennis} 508e8696a40e09b24b634214684d18526187b316a2fJamie Gennis 509518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 510518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// Contexts 511518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 512518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 513518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, 514518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLContext share_list, const EGLint *attrib_list) 515518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 516518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 517518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 518b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall egl_connection_t* cnx = NULL; 519b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display_connection(dpy, cnx); 520b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall if (dpy) { 521518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (share_list != EGL_NO_CONTEXT) { 522518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_context_t* const c = get_context(share_list); 523518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian share_list = c->context; 524518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 525518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLContext context = cnx->egl.eglCreateContext( 5267773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, config, share_list, attrib_list); 527518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (context != EGL_NO_CONTEXT) { 528518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // figure out if it's a GLESv1 or GLESv2 529518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian int version = 0; 530518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (attrib_list) { 531518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian while (*attrib_list != EGL_NONE) { 532518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian GLint attr = *attrib_list++; 533518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian GLint value = *attrib_list++; 534518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (attr == EGL_CONTEXT_CLIENT_VERSION) { 535518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (value == 1) { 5367773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian version = egl_connection_t::GLESv1_INDEX; 5374774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall } else if (value == 2 || value == 3) { 5387773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian version = egl_connection_t::GLESv2_INDEX; 539518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 540518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 541518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian }; 542518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 543b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall egl_context_t* c = new egl_context_t(dpy, context, config, cnx, 544b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall version); 5450469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#if EGL_TRACE 546a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy if (getEGLDebugLevel() > 0) 5470469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy GLTrace_eglCreateContext(version, c); 5480469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#endif 549518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return c; 550500407a2c07ced40c36e7356574a47bcec9c2fd9Mathias Agopian } else { 551500407a2c07ced40c36e7356574a47bcec9c2fd9Mathias Agopian EGLint error = eglGetError(); 552500407a2c07ced40c36e7356574a47bcec9c2fd9Mathias Agopian ALOGE_IF(error == EGL_SUCCESS, 553500407a2c07ced40c36e7356574a47bcec9c2fd9Mathias Agopian "eglCreateContext(%p, %p, %p, %p) returned EGL_NO_CONTEXT " 554500407a2c07ced40c36e7356574a47bcec9c2fd9Mathias Agopian "but no EGL error!", 555500407a2c07ced40c36e7356574a47bcec9c2fd9Mathias Agopian dpy, config, share_list, attrib_list); 556518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 557518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 558518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_NO_CONTEXT; 559518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 560518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 561518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) 562518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 563518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 564518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 565b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 5665b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!dp) 5675b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return EGL_FALSE; 568518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 569b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall ContextRef _c(dp.get(), ctx); 5705b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_c.get()) 5715b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_CONTEXT, EGL_FALSE); 5724774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall 573518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_context_t * const c = get_context(ctx); 574ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian EGLBoolean result = c->cnx->egl.eglDestroyContext(dp->disp.dpy, c->context); 575518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (result == EGL_TRUE) { 576518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian _c.terminate(); 577518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 578518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return result; 579518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 580518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 581518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw, 582518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLSurface read, EGLContext ctx) 583518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 584518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 585518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 586b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall egl_display_ptr dp = validate_display(dpy); 587518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return setError(EGL_BAD_DISPLAY, EGL_FALSE); 588518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 5895b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian // If ctx is not EGL_NO_CONTEXT, read is not EGL_NO_SURFACE, or draw is not 5905b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian // EGL_NO_SURFACE, then an EGL_NOT_INITIALIZED error is generated if dpy is 5915b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian // a valid but uninitialized display. 592518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if ( (ctx != EGL_NO_CONTEXT) || (read != EGL_NO_SURFACE) || 593518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian (draw != EGL_NO_SURFACE) ) { 594518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp->isReady()) return setError(EGL_NOT_INITIALIZED, EGL_FALSE); 595518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 596518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 597518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // get a reference to the object passed in 598b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall ContextRef _c(dp.get(), ctx); 599b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall SurfaceRef _d(dp.get(), draw); 600b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall SurfaceRef _r(dp.get(), read); 601518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 602518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // validate the context (if not EGL_NO_CONTEXT) 6035b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if ((ctx != EGL_NO_CONTEXT) && !_c.get()) { 604518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // EGL_NO_CONTEXT is valid 605518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_FALSE; 606518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 607518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 608518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // these are the underlying implementation's object 609518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLContext impl_ctx = EGL_NO_CONTEXT; 610518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLSurface impl_draw = EGL_NO_SURFACE; 611518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLSurface impl_read = EGL_NO_SURFACE; 612518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 613518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // these are our objects structs passed in 614518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_context_t * c = NULL; 615518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * d = NULL; 616518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * r = NULL; 617518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 618518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // these are the current objects structs 619518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_context_t * cur_c = get_context(getContext()); 6204774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall 621518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (ctx != EGL_NO_CONTEXT) { 622518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian c = get_context(ctx); 623518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian impl_ctx = c->context; 624518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } else { 625518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // no context given, use the implementation of the current context 626518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (cur_c == NULL) { 627518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // no current context 628518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE) { 629518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // calling eglMakeCurrent( ..., !=0, !=0, EGL_NO_CONTEXT); 630518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_MATCH, EGL_FALSE); 631518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 632518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // not an error, there is just no current context. 633518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_TRUE; 634518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 635518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 636518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 637518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // retrieve the underlying implementation's draw EGLSurface 638518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (draw != EGL_NO_SURFACE) { 639518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian d = get_surface(draw); 640518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian impl_draw = d->surface; 641518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 642518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 643518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // retrieve the underlying implementation's read EGLSurface 644518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (read != EGL_NO_SURFACE) { 645518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian r = get_surface(read); 646518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian impl_read = r->surface; 647518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 648518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 649518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 650b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall EGLBoolean result = dp->makeCurrent(c, cur_c, 651fb87e54a9af8bc5063ca4deebe81d90126992480Mathias Agopian draw, read, ctx, 652fb87e54a9af8bc5063ca4deebe81d90126992480Mathias Agopian impl_draw, impl_read, impl_ctx); 653518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 654518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (result == EGL_TRUE) { 655fb87e54a9af8bc5063ca4deebe81d90126992480Mathias Agopian if (c) { 656518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian setGLHooksThreadSpecific(c->cnx->hooks[c->version]); 657518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_tls_t::setContext(ctx); 6580469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#if EGL_TRACE 659a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy if (getEGLDebugLevel() > 0) 66093a826f78f6313db791e6fc880439189897651b3Siva Velusamy GLTrace_eglMakeCurrent(c->version, c->cnx->hooks[c->version], ctx); 6610469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#endif 662518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian _c.acquire(); 663518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian _r.acquire(); 664518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian _d.acquire(); 665518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } else { 666518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian setGLHooksThreadSpecific(&gHooksNoContext); 667518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_tls_t::setContext(EGL_NO_CONTEXT); 668518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 6695fecea776a5f093c21ac1a0ad3552b847d4be23eMathias Agopian } else { 670e6f43ddce78d6846af12550ff9193c5c6fe5844bSteve Block // this will ALOGE the error 6715fecea776a5f093c21ac1a0ad3552b847d4be23eMathias Agopian result = setError(c->cnx->egl.eglGetError(), EGL_FALSE); 672518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 673518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return result; 674518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 675518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 676518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 677518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglQueryContext( EGLDisplay dpy, EGLContext ctx, 678518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLint attribute, EGLint *value) 679518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 680518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 681518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 682b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 683518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 684518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 685b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall ContextRef _c(dp.get(), ctx); 686518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!_c.get()) return setError(EGL_BAD_CONTEXT, EGL_FALSE); 687518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 688518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_context_t * const c = get_context(ctx); 6897773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian return c->cnx->egl.eglQueryContext( 6907773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, c->context, attribute, value); 691518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 692518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 693518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 694518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLContext eglGetCurrentContext(void) 695518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 696518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // could be called before eglInitialize(), but we wouldn't have a context 697518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // then, and this function would correctly return EGL_NO_CONTEXT. 698518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 699518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 700518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 701518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLContext ctx = getContext(); 702518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return ctx; 703518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 704518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 705518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLSurface eglGetCurrentSurface(EGLint readdraw) 706518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 707518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // could be called before eglInitialize(), but we wouldn't have a context 708518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // then, and this function would correctly return EGL_NO_SURFACE. 709518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 710518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 711518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 712518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLContext ctx = getContext(); 713518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (ctx) { 714518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_context_t const * const c = get_context(ctx); 715518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!c) return setError(EGL_BAD_CONTEXT, EGL_NO_SURFACE); 716518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian switch (readdraw) { 717518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian case EGL_READ: return c->read; 7184774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall case EGL_DRAW: return c->draw; 719518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian default: return setError(EGL_BAD_PARAMETER, EGL_NO_SURFACE); 720518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 721518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 722518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_NO_SURFACE; 723518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 724518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 725518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLDisplay eglGetCurrentDisplay(void) 726518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 727518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // could be called before eglInitialize(), but we wouldn't have a context 728518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // then, and this function would correctly return EGL_NO_DISPLAY. 729518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 730518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 731518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 732518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLContext ctx = getContext(); 733518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (ctx) { 734518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_context_t const * const c = get_context(ctx); 735518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!c) return setError(EGL_BAD_CONTEXT, EGL_NO_SURFACE); 736518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return c->dpy; 737518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 738518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_NO_DISPLAY; 739518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 740518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 741518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglWaitGL(void) 742518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 743518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 744518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 745ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 746ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (!cnx->dso) 747ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return setError(EGL_BAD_CONTEXT, EGL_FALSE); 748ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian 749ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return cnx->egl.eglWaitGL(); 750518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 751518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 752518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglWaitNative(EGLint engine) 753518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 754518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 755518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 756ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 757ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (!cnx->dso) 758ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return setError(EGL_BAD_CONTEXT, EGL_FALSE); 759ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian 760ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return cnx->egl.eglWaitNative(engine); 761518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 762518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 763518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLint eglGetError(void) 764518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 765ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian EGLint err = EGL_SUCCESS; 766ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 767ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso) { 768ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian err = cnx->egl.eglGetError(); 769518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 770ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (err == EGL_SUCCESS) { 771ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian err = egl_tls_t::getError(); 772ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian } 773ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return err; 774518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 775518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 776c07b52060acd627c8510c1a9151e0753fce76330Jesse Hallstatic __eglMustCastToProperFunctionPointerType findBuiltinGLWrapper( 777c07b52060acd627c8510c1a9151e0753fce76330Jesse Hall const char* procname) { 778c07b52060acd627c8510c1a9151e0753fce76330Jesse Hall const egl_connection_t* cnx = &gEGLImpl; 779c07b52060acd627c8510c1a9151e0753fce76330Jesse Hall void* proc = NULL; 780c07b52060acd627c8510c1a9151e0753fce76330Jesse Hall 781c07b52060acd627c8510c1a9151e0753fce76330Jesse Hall proc = dlsym(cnx->libGles2, procname); 782c07b52060acd627c8510c1a9151e0753fce76330Jesse Hall if (proc) return (__eglMustCastToProperFunctionPointerType)proc; 783c07b52060acd627c8510c1a9151e0753fce76330Jesse Hall 784c07b52060acd627c8510c1a9151e0753fce76330Jesse Hall proc = dlsym(cnx->libGles1, procname); 785c07b52060acd627c8510c1a9151e0753fce76330Jesse Hall if (proc) return (__eglMustCastToProperFunctionPointerType)proc; 786c07b52060acd627c8510c1a9151e0753fce76330Jesse Hall 787c07b52060acd627c8510c1a9151e0753fce76330Jesse Hall return NULL; 788c07b52060acd627c8510c1a9151e0753fce76330Jesse Hall} 789c07b52060acd627c8510c1a9151e0753fce76330Jesse Hall 790518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) 791518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 792518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // eglGetProcAddress() could be the very first function called 793518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // in which case we must make sure we've initialized ourselves, this 794518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // happens the first time egl_get_display() is called. 795518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 796518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 797518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 798518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (egl_init_drivers() == EGL_FALSE) { 799518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian setError(EGL_BAD_PARAMETER, NULL); 800518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return NULL; 801518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 802518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 803e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian if (FILTER_EXTENSIONS(procname)) { 804aca51c06f38155f1435fbc6944d7fc0a9bf1e4e9Jamie Gennis return NULL; 805aca51c06f38155f1435fbc6944d7fc0a9bf1e4e9Jamie Gennis } 806aca51c06f38155f1435fbc6944d7fc0a9bf1e4e9Jamie Gennis 807518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian __eglMustCastToProperFunctionPointerType addr; 808e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian addr = findProcAddress(procname, sExtensionMap, NELEM(sExtensionMap)); 809518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (addr) return addr; 810518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 811c07b52060acd627c8510c1a9151e0753fce76330Jesse Hall addr = findBuiltinGLWrapper(procname); 812c07b52060acd627c8510c1a9151e0753fce76330Jesse Hall if (addr) return addr; 813aca51c06f38155f1435fbc6944d7fc0a9bf1e4e9Jamie Gennis 814518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // this protects accesses to sGLExtentionMap and sGLExtentionSlot 815518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian pthread_mutex_lock(&sExtensionMapMutex); 816518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 817518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian /* 818518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * Since eglGetProcAddress() is not associated to anything, it needs 819518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * to return a function pointer that "works" regardless of what 820518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * the current context is. 821518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * 822518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * For this reason, we return a "forwarder", a small stub that takes 823518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * care of calling the function associated with the context 824518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * currently bound. 825518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * 826518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * We first look for extensions we've already resolved, if we're seeing 827518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * this extension for the first time, we go through all our 828518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * implementations and call eglGetProcAddress() and record the 829518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * result in the appropriate implementation hooks and return the 830518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * address of the forwarder corresponding to that hook set. 831518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * 832518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian */ 833518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 834518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian const String8 name(procname); 835518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian addr = sGLExtentionMap.valueFor(name); 836518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian const int slot = sGLExtentionSlot; 837518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 838e6f43ddce78d6846af12550ff9193c5c6fe5844bSteve Block ALOGE_IF(slot >= MAX_NUMBER_OF_GL_EXTENSIONS, 839518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian "no more slots for eglGetProcAddress(\"%s\")", 840518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian procname); 841518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 8420469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#if EGL_TRACE 8430469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy gl_hooks_t *debugHooks = GLTrace_getGLHooks(); 8440469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#endif 8450469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy 846518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!addr && (slot < MAX_NUMBER_OF_GL_EXTENSIONS)) { 847518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian bool found = false; 848ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian 849ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 850ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso && cnx->egl.eglGetProcAddress) { 851ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian // Extensions are independent of the bound context 85269d100762c7c26d8328f4bb61cfef026d3a69bbfluliuhui addr = 8537773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian cnx->hooks[egl_connection_t::GLESv1_INDEX]->ext.extensions[slot] = 8547773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian cnx->hooks[egl_connection_t::GLESv2_INDEX]->ext.extensions[slot] = 855518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#if EGL_TRACE 856ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian debugHooks->ext.extensions[slot] = 857ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian gHooksTrace.ext.extensions[slot] = 858518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#endif 859ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian cnx->egl.eglGetProcAddress(procname); 86069d100762c7c26d8328f4bb61cfef026d3a69bbfluliuhui if (addr) found = true; 861518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 862ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian 863518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (found) { 86469d100762c7c26d8328f4bb61cfef026d3a69bbfluliuhui#if USE_FAST_TLS_KEY 865518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian addr = gExtensionForwarders[slot]; 86669d100762c7c26d8328f4bb61cfef026d3a69bbfluliuhui#endif 867518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian sGLExtentionMap.add(name, addr); 868518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian sGLExtentionSlot++; 869518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 870518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 871518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 872518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian pthread_mutex_unlock(&sExtensionMapMutex); 873518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return addr; 874518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 875518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 87628ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennisclass FrameCompletionThread : public Thread { 87728ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennispublic: 87828ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis 87928ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis static void queueSync(EGLSyncKHR sync) { 88028ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis static sp<FrameCompletionThread> thread(new FrameCompletionThread); 88128ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis static bool running = false; 88228ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis if (!running) { 88328ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis thread->run("GPUFrameCompletion"); 88428ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis running = true; 88528ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis } 88628ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis { 88728ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis Mutex::Autolock lock(thread->mMutex); 88828ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis ScopedTrace st(ATRACE_TAG, String8::format("kicked off frame %d", 88928ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis thread->mFramesQueued).string()); 89028ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis thread->mQueue.push_back(sync); 89128ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis thread->mCondition.signal(); 89228ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis thread->mFramesQueued++; 89328ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis ATRACE_INT("GPU Frames Outstanding", thread->mQueue.size()); 89428ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis } 89528ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis } 89628ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis 89728ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennisprivate: 89828ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis FrameCompletionThread() : mFramesQueued(0), mFramesCompleted(0) {} 89928ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis 90028ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis virtual bool threadLoop() { 90128ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis EGLSyncKHR sync; 90228ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis uint32_t frameNum; 90328ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis { 90428ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis Mutex::Autolock lock(mMutex); 90528ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis while (mQueue.isEmpty()) { 90628ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis mCondition.wait(mMutex); 90728ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis } 90828ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis sync = mQueue[0]; 90928ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis frameNum = mFramesCompleted; 91028ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis } 91128ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); 91228ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis { 91328ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis ScopedTrace st(ATRACE_TAG, String8::format("waiting for frame %d", 91428ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis frameNum).string()); 91528ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis EGLint result = eglClientWaitSyncKHR(dpy, sync, 0, EGL_FOREVER_KHR); 91628ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis if (result == EGL_FALSE) { 91728ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis ALOGE("FrameCompletion: error waiting for fence: %#x", eglGetError()); 91828ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis } else if (result == EGL_TIMEOUT_EXPIRED_KHR) { 91928ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis ALOGE("FrameCompletion: timeout waiting for fence"); 92028ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis } 92128ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis eglDestroySyncKHR(dpy, sync); 92228ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis } 92328ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis { 92428ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis Mutex::Autolock lock(mMutex); 92528ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis mQueue.removeAt(0); 92628ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis mFramesCompleted++; 92728ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis ATRACE_INT("GPU Frames Outstanding", mQueue.size()); 92828ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis } 92928ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis return true; 93028ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis } 93128ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis 93228ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis uint32_t mFramesQueued; 93328ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis uint32_t mFramesCompleted; 93428ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis Vector<EGLSyncKHR> mQueue; 93528ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis Condition mCondition; 93628ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis Mutex mMutex; 93728ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis}; 93828ef8d7911dbfd1bf8256fb43acba894d87fc07aJamie Gennis 939518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) 940518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 9411c8e95cf86f2182986385bc1ee85f13f425f3a3aJamie Gennis ATRACE_CALL(); 942518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 943518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 944b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 945518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 946518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 947b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall SurfaceRef _s(dp.get(), draw); 9485b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 9495b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 950518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 9510469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#if EGL_TRACE 952a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy gl_hooks_t const *trace_hooks = getGLTraceThreadSpecific(); 953a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy if (getEGLDebugLevel() > 0) { 954a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy if (trace_hooks == NULL) { 955a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy if (GLTrace_start() < 0) { 956a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy ALOGE("Disabling Tracer for OpenGL ES"); 957a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy setEGLDebugLevel(0); 958a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy } else { 959a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy // switch over to the trace version of hooks 960a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy EGLContext ctx = egl_tls_t::getContext(); 961a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy egl_context_t * const c = get_context(ctx); 962a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy if (c) { 963a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy setGLHooksThreadSpecific(c->cnx->hooks[c->version]); 964a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy GLTrace_eglMakeCurrent(c->version, c->cnx->hooks[c->version], ctx); 965a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy } 966a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy } 967a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy } 968a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy 9690469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy GLTrace_eglSwapBuffers(dpy, draw); 970a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy } else if (trace_hooks != NULL) { 971a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy // tracing is now disabled, so switch back to the non trace version 972a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy EGLContext ctx = egl_tls_t::getContext(); 973a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy egl_context_t * const c = get_context(ctx); 974a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy if (c) setGLHooksThreadSpecific(c->cnx->hooks[c->version]); 975a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy GLTrace_stop(); 976a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy } 9770469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#endif 9780469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy 979518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * const s = get_surface(draw); 9807db993a98b9239bd4e384cc4aa128262fe3cf52cMathias Agopian 981ed6d08b70d775852f4827471814c83eba3606aaaMathias Agopian if (CC_UNLIKELY(dp->traceGpuCompletion)) { 982ed6d08b70d775852f4827471814c83eba3606aaaMathias Agopian EGLSyncKHR sync = eglCreateSyncKHR(dpy, EGL_SYNC_FENCE_KHR, NULL); 983ed6d08b70d775852f4827471814c83eba3606aaaMathias Agopian if (sync != EGL_NO_SYNC_KHR) { 984ed6d08b70d775852f4827471814c83eba3606aaaMathias Agopian FrameCompletionThread::queueSync(sync); 985ed6d08b70d775852f4827471814c83eba3606aaaMathias Agopian } 986ed6d08b70d775852f4827471814c83eba3606aaaMathias Agopian } 987ed6d08b70d775852f4827471814c83eba3606aaaMathias Agopian 9887db993a98b9239bd4e384cc4aa128262fe3cf52cMathias Agopian if (CC_UNLIKELY(dp->finishOnSwap)) { 9897db993a98b9239bd4e384cc4aa128262fe3cf52cMathias Agopian uint32_t pixel; 9907db993a98b9239bd4e384cc4aa128262fe3cf52cMathias Agopian egl_context_t * const c = get_context( egl_tls_t::getContext() ); 9917db993a98b9239bd4e384cc4aa128262fe3cf52cMathias Agopian if (c) { 9927db993a98b9239bd4e384cc4aa128262fe3cf52cMathias Agopian // glReadPixels() ensures that the frame is complete 9937db993a98b9239bd4e384cc4aa128262fe3cf52cMathias Agopian s->cnx->hooks[c->version]->gl.glReadPixels(0,0,1,1, 9947db993a98b9239bd4e384cc4aa128262fe3cf52cMathias Agopian GL_RGBA,GL_UNSIGNED_BYTE,&pixel); 9957db993a98b9239bd4e384cc4aa128262fe3cf52cMathias Agopian } 9967db993a98b9239bd4e384cc4aa128262fe3cf52cMathias Agopian } 9977db993a98b9239bd4e384cc4aa128262fe3cf52cMathias Agopian 998ed6d08b70d775852f4827471814c83eba3606aaaMathias Agopian return s->cnx->egl.eglSwapBuffers(dp->disp.dpy, s->surface); 999518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1000518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1001518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglCopyBuffers( EGLDisplay dpy, EGLSurface surface, 1002518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian NativePixmapType target) 1003518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1004518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1005518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1006b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 1007518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 1008518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1009b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall SurfaceRef _s(dp.get(), surface); 10105b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 10115b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 1012518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1013518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * const s = get_surface(surface); 1014ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return s->cnx->egl.eglCopyBuffers(dp->disp.dpy, s->surface, target); 1015518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1016518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1017518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianconst char* eglQueryString(EGLDisplay dpy, EGLint name) 1018518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1019518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1020518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1021b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 1022518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return (const char *) NULL; 1023518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1024518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian switch (name) { 1025518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian case EGL_VENDOR: 10264b9511c16195a646242eff833b0af212933b6ecaMathias Agopian return dp->getVendorString(); 1027518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian case EGL_VERSION: 10284b9511c16195a646242eff833b0af212933b6ecaMathias Agopian return dp->getVersionString(); 1029518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian case EGL_EXTENSIONS: 10304b9511c16195a646242eff833b0af212933b6ecaMathias Agopian return dp->getExtensionString(); 1031518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian case EGL_CLIENT_APIS: 10324b9511c16195a646242eff833b0af212933b6ecaMathias Agopian return dp->getClientApiString(); 1033518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1034518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_PARAMETER, (const char *)0); 1035518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1036518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1037ca08833d5ea99130797e10ad68a651b50e99da74Mathias AgopianEGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name) 1038ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian{ 1039ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian clearError(); 1040ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian 1041ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian const egl_display_ptr dp = validate_display(dpy); 1042ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian if (!dp) return (const char *) NULL; 1043ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian 1044ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian switch (name) { 1045ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian case EGL_VENDOR: 1046ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian return dp->disp.queryString.vendor; 1047ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian case EGL_VERSION: 1048ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian return dp->disp.queryString.version; 1049ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian case EGL_EXTENSIONS: 1050ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian return dp->disp.queryString.extensions; 1051ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian case EGL_CLIENT_APIS: 1052ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian return dp->disp.queryString.clientApi; 1053ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian } 1054ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian return setError(EGL_BAD_PARAMETER, (const char *)0); 1055ca08833d5ea99130797e10ad68a651b50e99da74Mathias Agopian} 1056518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1057518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 1058518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// EGL 1.1 1059518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 1060518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1061518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglSurfaceAttrib( 1062518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) 1063518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1064518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1065518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1066b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 1067518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 1068518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1069b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall SurfaceRef _s(dp.get(), surface); 10705b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 10715b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 1072518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1073518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * const s = get_surface(surface); 1074518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (s->cnx->egl.eglSurfaceAttrib) { 1075518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return s->cnx->egl.eglSurfaceAttrib( 1076ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian dp->disp.dpy, s->surface, attribute, value); 1077518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1078518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 1079518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1080518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1081518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglBindTexImage( 1082518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLDisplay dpy, EGLSurface surface, EGLint buffer) 1083518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1084518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1085518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1086b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 1087518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 1088518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1089b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall SurfaceRef _s(dp.get(), surface); 10905b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 10915b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 1092518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1093518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * const s = get_surface(surface); 1094518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (s->cnx->egl.eglBindTexImage) { 1095518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return s->cnx->egl.eglBindTexImage( 1096ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian dp->disp.dpy, s->surface, buffer); 1097518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1098518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 1099518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1100518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1101518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglReleaseTexImage( 1102518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLDisplay dpy, EGLSurface surface, EGLint buffer) 1103518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1104518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1105518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1106b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 1107518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 1108518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1109b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall SurfaceRef _s(dp.get(), surface); 11105b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 11115b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 1112518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1113518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * const s = get_surface(surface); 1114518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (s->cnx->egl.eglReleaseTexImage) { 1115518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return s->cnx->egl.eglReleaseTexImage( 1116ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian dp->disp.dpy, s->surface, buffer); 1117518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1118518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 1119518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1120518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1121518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval) 1122518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1123518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1124518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1125b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 1126518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 1127518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1128518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLBoolean res = EGL_TRUE; 1129ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 1130ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso && cnx->egl.eglSwapInterval) { 1131ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian res = cnx->egl.eglSwapInterval(dp->disp.dpy, interval); 1132518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1133ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian 1134518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return res; 1135518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1136518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1137518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1138518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 1139518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// EGL 1.2 1140518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 1141518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1142518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglWaitClient(void) 1143518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1144518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1145518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1146ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 1147ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (!cnx->dso) 1148ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return setError(EGL_BAD_CONTEXT, EGL_FALSE); 1149ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian 1150ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian EGLBoolean res; 1151ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->egl.eglWaitClient) { 1152ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian res = cnx->egl.eglWaitClient(); 1153ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian } else { 1154ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian res = cnx->egl.eglWaitGL(); 1155518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1156518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return res; 1157518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1158518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1159518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglBindAPI(EGLenum api) 1160518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1161518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1162518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1163518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (egl_init_drivers() == EGL_FALSE) { 1164518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_PARAMETER, EGL_FALSE); 1165518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1166518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1167518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // bind this API on all EGLs 1168518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLBoolean res = EGL_TRUE; 1169ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 1170ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso && cnx->egl.eglBindAPI) { 1171ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian res = cnx->egl.eglBindAPI(api); 1172518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1173518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return res; 1174518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1175518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1176518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLenum eglQueryAPI(void) 1177518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1178518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1179518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1180518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (egl_init_drivers() == EGL_FALSE) { 1181518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_PARAMETER, EGL_FALSE); 1182518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1183518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1184ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 1185ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso && cnx->egl.eglQueryAPI) { 1186ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return cnx->egl.eglQueryAPI(); 1187518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1188ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian 1189518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // or, it can only be OpenGL ES 1190518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_OPENGL_ES_API; 1191518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1192518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1193518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglReleaseThread(void) 1194518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1195518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1196518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1197518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // If there is context bound to the thread, release it 1198fb87e54a9af8bc5063ca4deebe81d90126992480Mathias Agopian egl_display_t::loseCurrent(get_context(getContext())); 1199518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1200ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 1201ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso && cnx->egl.eglReleaseThread) { 1202ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian cnx->egl.eglReleaseThread(); 1203518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1204ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian 1205518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_tls_t::clearTLS(); 12060469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#if EGL_TRACE 1207a73a97728befb5ba5ad647ab3b60058c4d536ba4Siva Velusamy if (getEGLDebugLevel() > 0) 12080469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy GLTrace_eglReleaseThread(); 12090469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#endif 1210518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_TRUE; 1211518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1212518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1213518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLSurface eglCreatePbufferFromClientBuffer( 1214518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, 1215518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLConfig config, const EGLint *attrib_list) 1216518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1217518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1218518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1219b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall egl_connection_t* cnx = NULL; 1220b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display_connection(dpy, cnx); 1221b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall if (!dp) return EGL_FALSE; 1222518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (cnx->egl.eglCreatePbufferFromClientBuffer) { 1223518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return cnx->egl.eglCreatePbufferFromClientBuffer( 12247773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, buftype, buffer, config, attrib_list); 1225518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1226518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_CONFIG, EGL_NO_SURFACE); 1227518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1228518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1229518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 1230518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// EGL_EGLEXT_VERSION 3 1231518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 1232518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1233518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglLockSurfaceKHR(EGLDisplay dpy, EGLSurface surface, 1234518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian const EGLint *attrib_list) 1235518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1236518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1237518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1238b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 1239518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 1240518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1241b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall SurfaceRef _s(dp.get(), surface); 12425b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 12435b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 1244518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1245518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * const s = get_surface(surface); 1246518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (s->cnx->egl.eglLockSurfaceKHR) { 1247518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return s->cnx->egl.eglLockSurfaceKHR( 1248ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian dp->disp.dpy, s->surface, attrib_list); 1249518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1250518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_DISPLAY, EGL_FALSE); 1251518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1252518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1253518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglUnlockSurfaceKHR(EGLDisplay dpy, EGLSurface surface) 1254518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1255518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1256518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1257b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 1258518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 1259518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1260b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall SurfaceRef _s(dp.get(), surface); 12615b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 12625b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 1263518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1264518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * const s = get_surface(surface); 1265518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (s->cnx->egl.eglUnlockSurfaceKHR) { 1266ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return s->cnx->egl.eglUnlockSurfaceKHR(dp->disp.dpy, s->surface); 1267518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1268518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_DISPLAY, EGL_FALSE); 1269518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1270518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1271518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, 1272518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLClientBuffer buffer, const EGLint *attrib_list) 1273518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1274518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1275518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1276b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 1277518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_NO_IMAGE_KHR; 1278518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1279b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall ContextRef _c(dp.get(), ctx); 12807c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian egl_context_t * const c = _c.get(); 1281518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 12827c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian EGLImageKHR result = EGL_NO_IMAGE_KHR; 12837c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian egl_connection_t* const cnx = &gEGLImpl; 12847c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian if (cnx->dso && cnx->egl.eglCreateImageKHR) { 12857c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian result = cnx->egl.eglCreateImageKHR( 12867c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian dp->disp.dpy, 12877c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian c ? c->context : EGL_NO_CONTEXT, 12887c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian target, buffer, attrib_list); 1289518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 12907c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian return result; 1291518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1292518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1293518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img) 1294518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1295518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1296518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1297b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 1298518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 1299518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1300646a5c593f9819dc5da6a1ec859bc70cb7ba096fSteven Holte EGLBoolean result = EGL_FALSE; 1301ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 13027c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian if (cnx->dso && cnx->egl.eglDestroyImageKHR) { 1303646a5c593f9819dc5da6a1ec859bc70cb7ba096fSteven Holte result = cnx->egl.eglDestroyImageKHR(dp->disp.dpy, img); 1304518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1305646a5c593f9819dc5da6a1ec859bc70cb7ba096fSteven Holte return result; 1306518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1307518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1308518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 1309518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// EGL_EGLEXT_VERSION 5 1310518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 1311518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1312518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1313518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list) 1314518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1315518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1316518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1317b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 1318518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_NO_SYNC_KHR; 1319518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1320518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLSyncKHR result = EGL_NO_SYNC_KHR; 13217c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian egl_connection_t* const cnx = &gEGLImpl; 13227c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian if (cnx->dso && cnx->egl.eglCreateSyncKHR) { 13237c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian result = cnx->egl.eglCreateSyncKHR(dp->disp.dpy, type, attrib_list); 1324518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 13257c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian return result; 1326518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1327518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1328518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync) 1329518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1330518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1331518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1332b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 1333518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 1334518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1335518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLBoolean result = EGL_FALSE; 13367c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian egl_connection_t* const cnx = &gEGLImpl; 13377c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian if (cnx->dso && cnx->egl.eglDestroySyncKHR) { 13387c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian result = cnx->egl.eglDestroySyncKHR(dp->disp.dpy, sync); 1339518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1340518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return result; 1341518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1342518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1343e9b3dfb7d5cc233747407381a51a081c335dc076Mathias AgopianEGLBoolean eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode) { 1344e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian clearError(); 1345e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 1346e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian const egl_display_ptr dp = validate_display(dpy); 1347e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian if (!dp) return EGL_FALSE; 1348e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 1349e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian EGLBoolean result = EGL_FALSE; 1350e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian egl_connection_t* const cnx = &gEGLImpl; 1351e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian if (cnx->dso && cnx->egl.eglSignalSyncKHR) { 1352e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian result = cnx->egl.eglSignalSyncKHR( 1353e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian dp->disp.dpy, sync, mode); 1354e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian } 1355e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian return result; 1356e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian} 1357e9b3dfb7d5cc233747407381a51a081c335dc076Mathias Agopian 13587c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias AgopianEGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, 13597c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian EGLint flags, EGLTimeKHR timeout) 1360518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1361518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1362518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1363b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 1364518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 1365518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 13667c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian EGLBoolean result = EGL_FALSE; 13677c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian egl_connection_t* const cnx = &gEGLImpl; 13687c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian if (cnx->dso && cnx->egl.eglClientWaitSyncKHR) { 13697c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian result = cnx->egl.eglClientWaitSyncKHR( 13707c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian dp->disp.dpy, sync, flags, timeout); 1371518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 13727c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian return result; 1373518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1374518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 13757c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias AgopianEGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, 13767c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian EGLint attribute, EGLint *value) 1377518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1378518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1379518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1380b29e5e8c2682ae145e8c56d9afb061f8da7f854cJesse Hall const egl_display_ptr dp = validate_display(dpy); 1381518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 1382518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 13837c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian EGLBoolean result = EGL_FALSE; 13847c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian egl_connection_t* const cnx = &gEGLImpl; 13857c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian if (cnx->dso && cnx->egl.eglGetSyncAttribKHR) { 13867c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian result = cnx->egl.eglGetSyncAttribKHR( 13877c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian dp->disp.dpy, sync, attribute, value); 1388518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 13897c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian return result; 1390518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1391518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1392518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 13932bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias Agopian// EGL_EGLEXT_VERSION 15 1394518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 1395518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 13962bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias AgopianEGLint eglWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags) { 1397331841b96b92646c93c87627c03f77b892f711cdJamie Gennis clearError(); 1398331841b96b92646c93c87627c03f77b892f711cdJamie Gennis const egl_display_ptr dp = validate_display(dpy); 13992bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias Agopian if (!dp) return EGL_FALSE; 14002bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias Agopian EGLint result = EGL_FALSE; 1401331841b96b92646c93c87627c03f77b892f711cdJamie Gennis egl_connection_t* const cnx = &gEGLImpl; 14022bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias Agopian if (cnx->dso && cnx->egl.eglWaitSyncKHR) { 14032bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias Agopian result = cnx->egl.eglWaitSyncKHR(dp->disp.dpy, sync, flags); 1404331841b96b92646c93c87627c03f77b892f711cdJamie Gennis } 1405331841b96b92646c93c87627c03f77b892f711cdJamie Gennis return result; 1406331841b96b92646c93c87627c03f77b892f711cdJamie Gennis} 14071c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 14082bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias Agopian// ---------------------------------------------------------------------------- 14092bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias Agopian// ANDROID extensions 14102bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias Agopian// ---------------------------------------------------------------------------- 14112bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias Agopian 14122bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias AgopianEGLint eglDupNativeFenceFDANDROID(EGLDisplay dpy, EGLSyncKHR sync) 1413010dd4fb892aecf71e4631c22148fe57ef5b3958Jamie Gennis{ 1414010dd4fb892aecf71e4631c22148fe57ef5b3958Jamie Gennis clearError(); 1415010dd4fb892aecf71e4631c22148fe57ef5b3958Jamie Gennis 1416010dd4fb892aecf71e4631c22148fe57ef5b3958Jamie Gennis const egl_display_ptr dp = validate_display(dpy); 1417010dd4fb892aecf71e4631c22148fe57ef5b3958Jamie Gennis if (!dp) return EGL_NO_NATIVE_FENCE_FD_ANDROID; 1418010dd4fb892aecf71e4631c22148fe57ef5b3958Jamie Gennis 14192bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias Agopian EGLint result = EGL_NO_NATIVE_FENCE_FD_ANDROID; 1420010dd4fb892aecf71e4631c22148fe57ef5b3958Jamie Gennis egl_connection_t* const cnx = &gEGLImpl; 14212bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias Agopian if (cnx->dso && cnx->egl.eglDupNativeFenceFDANDROID) { 14222bb716871cf8bfadfff1193ed798da3bffc1f8ecMathias Agopian result = cnx->egl.eglDupNativeFenceFDANDROID(dp->disp.dpy, sync); 1423010dd4fb892aecf71e4631c22148fe57ef5b3958Jamie Gennis } 1424010dd4fb892aecf71e4631c22148fe57ef5b3958Jamie Gennis return result; 1425010dd4fb892aecf71e4631c22148fe57ef5b3958Jamie Gennis} 1426010dd4fb892aecf71e4631c22148fe57ef5b3958Jamie Gennis 14277284145d564fa8a422a8e564a38c730fb4a2962bAndy McFaddenEGLBoolean eglPresentationTimeANDROID(EGLDisplay dpy, EGLSurface surface, 14287284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden EGLnsecsANDROID time) 14297284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden{ 14307284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden clearError(); 14317284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden 14327284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden const egl_display_ptr dp = validate_display(dpy); 14337284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden if (!dp) { 14347284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden return EGL_FALSE; 14357284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden } 14367284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden 14377284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden SurfaceRef _s(dp.get(), surface); 14387284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden if (!_s.get()) { 14397284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden setError(EGL_BAD_SURFACE, EGL_FALSE); 14407284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden return EGL_FALSE; 14417284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden } 14427284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden 14437284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden egl_surface_t const * const s = get_surface(surface); 14447284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden native_window_set_buffers_timestamp(s->win.get(), time); 14457284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden 14467284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden return EGL_TRUE; 14477284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden} 14487284145d564fa8a422a8e564a38c730fb4a2962bAndy McFadden 14491c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang// ---------------------------------------------------------------------------- 14501c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang// NVIDIA extensions 14511c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang// ---------------------------------------------------------------------------- 14521c3d72a2291827fb15e2ef311a571c860e0dba41Jonas YangEGLuint64NV eglGetSystemTimeFrequencyNV() 14531c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang{ 14541c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang clearError(); 14551c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 14561c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang if (egl_init_drivers() == EGL_FALSE) { 14571c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang return setError(EGL_BAD_PARAMETER, EGL_FALSE); 14581c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang } 14591c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 14601c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang EGLuint64NV ret = 0; 1461ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 14621c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 1463ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso && cnx->egl.eglGetSystemTimeFrequencyNV) { 1464ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return cnx->egl.eglGetSystemTimeFrequencyNV(); 14651c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang } 14661c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 14670e8bbee5775d81c7bbc479b995496cac9238559fMathias Agopian return setErrorQuiet(EGL_BAD_DISPLAY, 0); 14681c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang} 14691c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 14701c3d72a2291827fb15e2ef311a571c860e0dba41Jonas YangEGLuint64NV eglGetSystemTimeNV() 14711c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang{ 14721c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang clearError(); 14731c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 14741c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang if (egl_init_drivers() == EGL_FALSE) { 14751c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang return setError(EGL_BAD_PARAMETER, EGL_FALSE); 14761c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang } 14771c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 14781c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang EGLuint64NV ret = 0; 1479ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 14801c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 1481ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso && cnx->egl.eglGetSystemTimeNV) { 1482ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return cnx->egl.eglGetSystemTimeNV(); 14831c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang } 14841c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 14850e8bbee5775d81c7bbc479b995496cac9238559fMathias Agopian return setErrorQuiet(EGL_BAD_DISPLAY, 0); 14861c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang} 1487