eglApi.cpp revision 7c0441ac271f4e00a2d63eb3048c037ebffa90b9
1518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian/* 2518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** Copyright 2007, The Android Open Source Project 3518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** 4518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** Licensed under the Apache License, Version 2.0 (the "License"); 5518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** you may not use this file except in compliance with the License. 6518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** You may obtain a copy of the License at 7518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** 8518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** http://www.apache.org/licenses/LICENSE-2.0 9518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** 10518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** Unless required by applicable law or agreed to in writing, software 11518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** distributed under the License is distributed on an "AS IS" BASIS, 12518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** See the License for the specific language governing permissions and 14518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian ** limitations under the License. 15518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian */ 16518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 17518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <ctype.h> 18518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <stdlib.h> 19518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <string.h> 20518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 21518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <hardware/gralloc.h> 22518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <system/window.h> 23518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 24518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <EGL/egl.h> 25518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <EGL/eglext.h> 26518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <GLES/gl.h> 27518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <GLES/glext.h> 28518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 29518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <cutils/log.h> 30518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <cutils/atomic.h> 31518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <cutils/properties.h> 32518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <cutils/memory.h> 33518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 34518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <utils/KeyedVector.h> 35518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <utils/SortedVector.h> 36518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include <utils/String8.h> 37518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 38518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include "egl_impl.h" 39518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include "egl_tls.h" 400469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#include "glestrace.h" 41518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include "hooks.h" 42518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 43518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include "egl_display.h" 44518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include "egl_impl.h" 45518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include "egl_object.h" 46518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#include "egl_tls.h" 47ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian#include "egldefs.h" 48518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 49518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianusing namespace android; 50518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 51518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 52518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 53bc2d79ed7ada6243f3690f94ab512c0ddcdbed12Mathias Agopian#define EGL_VERSION_HW_ANDROID 0x3143 54bc2d79ed7ada6243f3690f94ab512c0ddcdbed12Mathias Agopian 55518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianstruct extention_map_t { 56518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian const char* name; 57518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian __eglMustCastToProperFunctionPointerType address; 58518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian}; 59518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 60518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianstatic const extention_map_t sExtentionMap[] = { 61518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian { "eglLockSurfaceKHR", 62518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian (__eglMustCastToProperFunctionPointerType)&eglLockSurfaceKHR }, 63518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian { "eglUnlockSurfaceKHR", 64518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian (__eglMustCastToProperFunctionPointerType)&eglUnlockSurfaceKHR }, 65518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian { "eglCreateImageKHR", 66518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian (__eglMustCastToProperFunctionPointerType)&eglCreateImageKHR }, 67518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian { "eglDestroyImageKHR", 68518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian (__eglMustCastToProperFunctionPointerType)&eglDestroyImageKHR }, 691c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang { "eglGetSystemTimeFrequencyNV", 701c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang (__eglMustCastToProperFunctionPointerType)&eglGetSystemTimeFrequencyNV }, 711c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang { "eglGetSystemTimeNV", 721c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang (__eglMustCastToProperFunctionPointerType)&eglGetSystemTimeNV }, 73518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian}; 74518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 75518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// accesses protected by sExtensionMapMutex 76518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianstatic DefaultKeyedVector<String8, __eglMustCastToProperFunctionPointerType> sGLExtentionMap; 77518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianstatic int sGLExtentionSlot = 0; 78518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianstatic pthread_mutex_t sExtensionMapMutex = PTHREAD_MUTEX_INITIALIZER; 79518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 80518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianstatic void(*findProcAddress(const char* name, 81518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian const extention_map_t* map, size_t n))() { 82518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian for (uint32_t i=0 ; i<n ; i++) { 83518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!strcmp(name, map[i].name)) { 84518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return map[i].address; 85518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 86518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 87518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return NULL; 88518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 89518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 90518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 91518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 92518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopiannamespace android { 93518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianextern void setGLHooksThreadSpecific(gl_hooks_t const *value); 94518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianextern EGLBoolean egl_init_drivers(); 95518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianextern const __eglMustCastToProperFunctionPointerType gExtensionForwarders[MAX_NUMBER_OF_GL_EXTENSIONS]; 96518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianextern int gEGLDebugLevel; 97518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianextern gl_hooks_t gHooksTrace; 98518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} // namespace android; 99518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 100518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 101518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 102518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianstatic inline void clearError() { egl_tls_t::clearError(); } 103518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianstatic inline EGLContext getContext() { return egl_tls_t::getContext(); } 104518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 105518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 106518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 107518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLDisplay eglGetDisplay(EGLNativeDisplayType display) 108518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 109518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 110518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 111518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian uint32_t index = uint32_t(display); 112518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (index >= NUM_DISPLAYS) { 113518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_PARAMETER, EGL_NO_DISPLAY); 114518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 115518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 116518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (egl_init_drivers() == EGL_FALSE) { 117518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_PARAMETER, EGL_NO_DISPLAY); 118518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 119518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 120518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLDisplay dpy = egl_display_t::getFromNativeDisplay(display); 121518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return dpy; 122518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 123518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 124518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 125518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// Initialization 126518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 127518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 128518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) 129518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 130518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 131518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 132518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t * const dp = get_display(dpy); 133518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return setError(EGL_BAD_DISPLAY, EGL_FALSE); 134518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 135518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLBoolean res = dp->initialize(major, minor); 136518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 137518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return res; 138518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 139518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 140518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglTerminate(EGLDisplay dpy) 141518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 142518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // NOTE: don't unload the drivers b/c some APIs can be called 143518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // after eglTerminate() has been called. eglTerminate() only 144518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // terminates an EGLDisplay, not a EGL itself. 145518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 146518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 147518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 148518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t* const dp = get_display(dpy); 149518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return setError(EGL_BAD_DISPLAY, EGL_FALSE); 150518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 151518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLBoolean res = dp->terminate(); 152518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 153518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return res; 154518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 155518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 156518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 157518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// configuration 158518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 159518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 160518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglGetConfigs( EGLDisplay dpy, 161518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLConfig *configs, 162518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLint config_size, EGLint *num_config) 163518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 164518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 165518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 166518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 167518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 168518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1697773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian if (num_config==0) { 1707773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian return setError(EGL_BAD_PARAMETER, EGL_FALSE); 171518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 172518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1737773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian EGLBoolean res = EGL_FALSE; 1747773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian *num_config = 0; 1757773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian 1767773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian egl_connection_t* const cnx = &gEGLImpl; 1777773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian if (cnx->dso) { 1787773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian res = cnx->egl.eglGetConfigs( 1797773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, configs, config_size, num_config); 180518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1817773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian 1827773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian return res; 183518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 184518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 185518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglChooseConfig( EGLDisplay dpy, const EGLint *attrib_list, 186518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLConfig *configs, EGLint config_size, 187518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLint *num_config) 188518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 189518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 190518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 191518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 192518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 193518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 194518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (num_config==0) { 195518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_PARAMETER, EGL_FALSE); 196518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 197518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 198518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLBoolean res = EGL_FALSE; 199518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian *num_config = 0; 200518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 201ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 202ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso) { 2037773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian res = cnx->egl.eglChooseConfig( 2047773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, attrib_list, configs, config_size, num_config); 205518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 206518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return res; 207518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 208518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 209518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, 210518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLint attribute, EGLint *value) 211518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 212518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 213518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 214518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const* dp = 0; 215518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_connection_t* cnx = validate_display_config(dpy, config, dp); 216518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!cnx) return EGL_FALSE; 217518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 218518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return cnx->egl.eglGetConfigAttrib( 2197773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, config, attribute, value); 220518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 221518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 222518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 223518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// surfaces 224518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 225518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 226518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config, 227518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian NativeWindowType window, 228518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian const EGLint *attrib_list) 229518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 230518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 231518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 232518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const* dp = 0; 233518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_connection_t* cnx = validate_display_config(dpy, config, dp); 234518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (cnx) { 235ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian EGLDisplay iDpy = dp->disp.dpy; 236518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLint format; 237518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 23881a63350527cafce6929309533c58586878f10b5Mathias Agopian if (native_window_api_connect(window, NATIVE_WINDOW_API_EGL) != OK) { 239e6f43ddce78d6846af12550ff9193c5c6fe5844bSteve Block ALOGE("EGLNativeWindowType %p already connected to another API", 24081a63350527cafce6929309533c58586878f10b5Mathias Agopian window); 24181a63350527cafce6929309533c58586878f10b5Mathias Agopian return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); 24281a63350527cafce6929309533c58586878f10b5Mathias Agopian } 24381a63350527cafce6929309533c58586878f10b5Mathias Agopian 244518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // set the native window's buffers format to match this config 245518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (cnx->egl.eglGetConfigAttrib(iDpy, 2467773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian config, EGL_NATIVE_VISUAL_ID, &format)) { 247518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (format != 0) { 248bee205fd58a27c10a0895de5339e76025d429d2bJamie Gennis int err = native_window_set_buffers_format(window, format); 249bee205fd58a27c10a0895de5339e76025d429d2bJamie Gennis if (err != 0) { 250e6f43ddce78d6846af12550ff9193c5c6fe5844bSteve Block ALOGE("error setting native window pixel format: %s (%d)", 251bee205fd58a27c10a0895de5339e76025d429d2bJamie Gennis strerror(-err), err); 25281a63350527cafce6929309533c58586878f10b5Mathias Agopian native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL); 253bee205fd58a27c10a0895de5339e76025d429d2bJamie Gennis return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); 254bee205fd58a27c10a0895de5339e76025d429d2bJamie Gennis } 255518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 256518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 257518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 25859769469e4b9b2d8b12c020eb44b030b3927a50bJamie Gennis // the EGL spec requires that a new EGLSurface default to swap interval 25959769469e4b9b2d8b12c020eb44b030b3927a50bJamie Gennis // 1, so explicitly set that on the window here. 26059769469e4b9b2d8b12c020eb44b030b3927a50bJamie Gennis ANativeWindow* anw = reinterpret_cast<ANativeWindow*>(window); 26159769469e4b9b2d8b12c020eb44b030b3927a50bJamie Gennis anw->setSwapInterval(anw, 1); 26259769469e4b9b2d8b12c020eb44b030b3927a50bJamie Gennis 263518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLSurface surface = cnx->egl.eglCreateWindowSurface( 2647773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian iDpy, config, window, attrib_list); 265518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (surface != EGL_NO_SURFACE) { 266ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_surface_t* s = new egl_surface_t(dpy, config, window, surface, cnx); 267518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return s; 268518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 26981a63350527cafce6929309533c58586878f10b5Mathias Agopian 27081a63350527cafce6929309533c58586878f10b5Mathias Agopian // EGLSurface creation failed 27181a63350527cafce6929309533c58586878f10b5Mathias Agopian native_window_set_buffers_format(window, 0); 27281a63350527cafce6929309533c58586878f10b5Mathias Agopian native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL); 273518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 274518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_NO_SURFACE; 275518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 276518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 277518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLSurface eglCreatePixmapSurface( EGLDisplay dpy, EGLConfig config, 278518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian NativePixmapType pixmap, 279518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian const EGLint *attrib_list) 280518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 281518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 282518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 283518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const* dp = 0; 284518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_connection_t* cnx = validate_display_config(dpy, config, dp); 285518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (cnx) { 286518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLSurface surface = cnx->egl.eglCreatePixmapSurface( 2877773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, config, pixmap, attrib_list); 288518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (surface != EGL_NO_SURFACE) { 289ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_surface_t* s = new egl_surface_t(dpy, config, NULL, surface, cnx); 290518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return s; 291518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 292518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 293518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_NO_SURFACE; 294518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 295518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 296518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLSurface eglCreatePbufferSurface( EGLDisplay dpy, EGLConfig config, 297518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian const EGLint *attrib_list) 298518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 299518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 300518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 301518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const* dp = 0; 302518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_connection_t* cnx = validate_display_config(dpy, config, dp); 303518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (cnx) { 304518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLSurface surface = cnx->egl.eglCreatePbufferSurface( 3057773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, config, attrib_list); 306518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (surface != EGL_NO_SURFACE) { 307ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_surface_t* s = new egl_surface_t(dpy, config, NULL, surface, cnx); 308518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return s; 309518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 310518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 311518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_NO_SURFACE; 312518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 313518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 314518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface) 315518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 316518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 317518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 318518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 319518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 320518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 321f0480de37492597a5c5cf1e6f8346f1467e3a552Mathias Agopian SurfaceRef _s(dp, surface); 3225b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 3235b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 324518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 325518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t * const s = get_surface(surface); 326ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian EGLBoolean result = s->cnx->egl.eglDestroySurface(dp->disp.dpy, s->surface); 327518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (result == EGL_TRUE) { 328518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian _s.terminate(); 329518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 330518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return result; 331518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 332518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 333518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglQuerySurface( EGLDisplay dpy, EGLSurface surface, 334518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLint attribute, EGLint *value) 335518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 336518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 337518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 338518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 339518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 340518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 341f0480de37492597a5c5cf1e6f8346f1467e3a552Mathias Agopian SurfaceRef _s(dp, surface); 3425b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 3435b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 344518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 345518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * const s = get_surface(surface); 3467773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian return s->cnx->egl.eglQuerySurface( 3477773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, s->surface, attribute, value); 348518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 349518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 350e8696a40e09b24b634214684d18526187b316a2fJamie Gennisvoid EGLAPI eglBeginFrame(EGLDisplay dpy, EGLSurface surface) { 351e8696a40e09b24b634214684d18526187b316a2fJamie Gennis clearError(); 352e8696a40e09b24b634214684d18526187b316a2fJamie Gennis 353e8696a40e09b24b634214684d18526187b316a2fJamie Gennis egl_display_t const * const dp = validate_display(dpy); 354e8696a40e09b24b634214684d18526187b316a2fJamie Gennis if (!dp) { 355e8696a40e09b24b634214684d18526187b316a2fJamie Gennis return; 356e8696a40e09b24b634214684d18526187b316a2fJamie Gennis } 357e8696a40e09b24b634214684d18526187b316a2fJamie Gennis 358e8696a40e09b24b634214684d18526187b316a2fJamie Gennis SurfaceRef _s(dp, surface); 359e8696a40e09b24b634214684d18526187b316a2fJamie Gennis if (!_s.get()) { 360e8696a40e09b24b634214684d18526187b316a2fJamie Gennis setError(EGL_BAD_SURFACE, EGL_FALSE); 361e8696a40e09b24b634214684d18526187b316a2fJamie Gennis return; 362e8696a40e09b24b634214684d18526187b316a2fJamie Gennis } 363e8696a40e09b24b634214684d18526187b316a2fJamie Gennis 364e8696a40e09b24b634214684d18526187b316a2fJamie Gennis int64_t timestamp = systemTime(SYSTEM_TIME_MONOTONIC); 365e8696a40e09b24b634214684d18526187b316a2fJamie Gennis 366e8696a40e09b24b634214684d18526187b316a2fJamie Gennis egl_surface_t const * const s = get_surface(surface); 367e8696a40e09b24b634214684d18526187b316a2fJamie Gennis native_window_set_buffers_timestamp(s->win.get(), timestamp); 368e8696a40e09b24b634214684d18526187b316a2fJamie Gennis} 369e8696a40e09b24b634214684d18526187b316a2fJamie Gennis 370518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 371518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// Contexts 372518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 373518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 374518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, 375518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLContext share_list, const EGLint *attrib_list) 376518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 377518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 378518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 379518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const* dp = 0; 380518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_connection_t* cnx = validate_display_config(dpy, config, dp); 381518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (cnx) { 382518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (share_list != EGL_NO_CONTEXT) { 383518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_context_t* const c = get_context(share_list); 384518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian share_list = c->context; 385518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 386518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLContext context = cnx->egl.eglCreateContext( 3877773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, config, share_list, attrib_list); 388518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (context != EGL_NO_CONTEXT) { 389518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // figure out if it's a GLESv1 or GLESv2 390518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian int version = 0; 391518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (attrib_list) { 392518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian while (*attrib_list != EGL_NONE) { 393518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian GLint attr = *attrib_list++; 394518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian GLint value = *attrib_list++; 395518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (attr == EGL_CONTEXT_CLIENT_VERSION) { 396518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (value == 1) { 3977773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian version = egl_connection_t::GLESv1_INDEX; 398518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } else if (value == 2) { 3997773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian version = egl_connection_t::GLESv2_INDEX; 400518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 401518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 402518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian }; 403518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 404ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_context_t* c = new egl_context_t(dpy, context, config, cnx, version); 4050469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#if EGL_TRACE 4060469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy if (gEGLDebugLevel > 0) 4070469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy GLTrace_eglCreateContext(version, c); 4080469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#endif 409518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return c; 410518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 411518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 412518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_NO_CONTEXT; 413518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 414518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 415518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) 416518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 417518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 418518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 419518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 4205b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!dp) 4215b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return EGL_FALSE; 422518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 423f0480de37492597a5c5cf1e6f8346f1467e3a552Mathias Agopian ContextRef _c(dp, ctx); 4245b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_c.get()) 4255b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_CONTEXT, EGL_FALSE); 426518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 427518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_context_t * const c = get_context(ctx); 428ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian EGLBoolean result = c->cnx->egl.eglDestroyContext(dp->disp.dpy, c->context); 429518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (result == EGL_TRUE) { 430518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian _c.terminate(); 431518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 432518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return result; 433518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 434518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 435518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw, 436518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLSurface read, EGLContext ctx) 437518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 438518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 439518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 440518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = get_display(dpy); 441518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return setError(EGL_BAD_DISPLAY, EGL_FALSE); 442518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 4435b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian // If ctx is not EGL_NO_CONTEXT, read is not EGL_NO_SURFACE, or draw is not 4445b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian // EGL_NO_SURFACE, then an EGL_NOT_INITIALIZED error is generated if dpy is 4455b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian // a valid but uninitialized display. 446518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if ( (ctx != EGL_NO_CONTEXT) || (read != EGL_NO_SURFACE) || 447518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian (draw != EGL_NO_SURFACE) ) { 448518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp->isReady()) return setError(EGL_NOT_INITIALIZED, EGL_FALSE); 449518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 450518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 451518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // get a reference to the object passed in 452f0480de37492597a5c5cf1e6f8346f1467e3a552Mathias Agopian ContextRef _c(dp, ctx); 453f0480de37492597a5c5cf1e6f8346f1467e3a552Mathias Agopian SurfaceRef _d(dp, draw); 454f0480de37492597a5c5cf1e6f8346f1467e3a552Mathias Agopian SurfaceRef _r(dp, read); 455518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 456518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // validate the context (if not EGL_NO_CONTEXT) 4575b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if ((ctx != EGL_NO_CONTEXT) && !_c.get()) { 458518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // EGL_NO_CONTEXT is valid 459518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_FALSE; 460518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 461518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 462518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // these are the underlying implementation's object 463518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLContext impl_ctx = EGL_NO_CONTEXT; 464518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLSurface impl_draw = EGL_NO_SURFACE; 465518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLSurface impl_read = EGL_NO_SURFACE; 466518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 467518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // these are our objects structs passed in 468518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_context_t * c = NULL; 469518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * d = NULL; 470518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * r = NULL; 471518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 472518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // these are the current objects structs 473518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_context_t * cur_c = get_context(getContext()); 474518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 475518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (ctx != EGL_NO_CONTEXT) { 476518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian c = get_context(ctx); 477518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian impl_ctx = c->context; 478518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } else { 479518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // no context given, use the implementation of the current context 480518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (cur_c == NULL) { 481518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // no current context 482518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE) { 483518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // calling eglMakeCurrent( ..., !=0, !=0, EGL_NO_CONTEXT); 484518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_MATCH, EGL_FALSE); 485518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 486518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // not an error, there is just no current context. 487518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_TRUE; 488518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 489518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 490518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 491518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // retrieve the underlying implementation's draw EGLSurface 492518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (draw != EGL_NO_SURFACE) { 493518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian d = get_surface(draw); 494518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian impl_draw = d->surface; 495518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 496518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 497518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // retrieve the underlying implementation's read EGLSurface 498518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (read != EGL_NO_SURFACE) { 499518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian r = get_surface(read); 500518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian impl_read = r->surface; 501518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 502518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 503518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 504fb87e54a9af8bc5063ca4deebe81d90126992480Mathias Agopian EGLBoolean result = const_cast<egl_display_t*>(dp)->makeCurrent(c, cur_c, 505fb87e54a9af8bc5063ca4deebe81d90126992480Mathias Agopian draw, read, ctx, 506fb87e54a9af8bc5063ca4deebe81d90126992480Mathias Agopian impl_draw, impl_read, impl_ctx); 507518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 508518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (result == EGL_TRUE) { 509fb87e54a9af8bc5063ca4deebe81d90126992480Mathias Agopian if (c) { 510518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian setGLHooksThreadSpecific(c->cnx->hooks[c->version]); 511518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_tls_t::setContext(ctx); 5120469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#if EGL_TRACE 5130469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy if (gEGLDebugLevel > 0) 51493a826f78f6313db791e6fc880439189897651b3Siva Velusamy GLTrace_eglMakeCurrent(c->version, c->cnx->hooks[c->version], ctx); 5150469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#endif 516518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian _c.acquire(); 517518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian _r.acquire(); 518518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian _d.acquire(); 519518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } else { 520518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian setGLHooksThreadSpecific(&gHooksNoContext); 521518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_tls_t::setContext(EGL_NO_CONTEXT); 522518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 5235fecea776a5f093c21ac1a0ad3552b847d4be23eMathias Agopian } else { 524e6f43ddce78d6846af12550ff9193c5c6fe5844bSteve Block // this will ALOGE the error 5255fecea776a5f093c21ac1a0ad3552b847d4be23eMathias Agopian result = setError(c->cnx->egl.eglGetError(), EGL_FALSE); 526518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 527518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return result; 528518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 529518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 530518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 531518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglQueryContext( EGLDisplay dpy, EGLContext ctx, 532518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLint attribute, EGLint *value) 533518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 534518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 535518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 536518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 537518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 538518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 539f0480de37492597a5c5cf1e6f8346f1467e3a552Mathias Agopian ContextRef _c(dp, ctx); 540518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!_c.get()) return setError(EGL_BAD_CONTEXT, EGL_FALSE); 541518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 542518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_context_t * const c = get_context(ctx); 5437773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian return c->cnx->egl.eglQueryContext( 5447773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, c->context, attribute, value); 545518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 546518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 547518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 548518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLContext eglGetCurrentContext(void) 549518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 550518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // could be called before eglInitialize(), but we wouldn't have a context 551518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // then, and this function would correctly return EGL_NO_CONTEXT. 552518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 553518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 554518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 555518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLContext ctx = getContext(); 556518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return ctx; 557518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 558518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 559518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLSurface eglGetCurrentSurface(EGLint readdraw) 560518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 561518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // could be called before eglInitialize(), but we wouldn't have a context 562518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // then, and this function would correctly return EGL_NO_SURFACE. 563518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 564518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 565518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 566518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLContext ctx = getContext(); 567518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (ctx) { 568518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_context_t const * const c = get_context(ctx); 569518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!c) return setError(EGL_BAD_CONTEXT, EGL_NO_SURFACE); 570518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian switch (readdraw) { 571518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian case EGL_READ: return c->read; 572518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian case EGL_DRAW: return c->draw; 573518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian default: return setError(EGL_BAD_PARAMETER, EGL_NO_SURFACE); 574518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 575518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 576518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_NO_SURFACE; 577518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 578518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 579518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLDisplay eglGetCurrentDisplay(void) 580518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 581518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // could be called before eglInitialize(), but we wouldn't have a context 582518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // then, and this function would correctly return EGL_NO_DISPLAY. 583518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 584518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 585518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 586518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLContext ctx = getContext(); 587518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (ctx) { 588518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_context_t const * const c = get_context(ctx); 589518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!c) return setError(EGL_BAD_CONTEXT, EGL_NO_SURFACE); 590518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return c->dpy; 591518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 592518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_NO_DISPLAY; 593518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 594518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 595518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglWaitGL(void) 596518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 597518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 598518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 599ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 600ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (!cnx->dso) 601ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return setError(EGL_BAD_CONTEXT, EGL_FALSE); 602ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian 603ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return cnx->egl.eglWaitGL(); 604518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 605518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 606518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglWaitNative(EGLint engine) 607518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 608518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 609518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 610ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 611ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (!cnx->dso) 612ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return setError(EGL_BAD_CONTEXT, EGL_FALSE); 613ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian 614ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return cnx->egl.eglWaitNative(engine); 615518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 616518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 617518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLint eglGetError(void) 618518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 619ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian EGLint err = EGL_SUCCESS; 620ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 621ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso) { 622ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian err = cnx->egl.eglGetError(); 623518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 624ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (err == EGL_SUCCESS) { 625ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian err = egl_tls_t::getError(); 626ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian } 627ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return err; 628518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 629518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 630518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) 631518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 632518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // eglGetProcAddress() could be the very first function called 633518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // in which case we must make sure we've initialized ourselves, this 634518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // happens the first time egl_get_display() is called. 635518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 636518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 637518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 638518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (egl_init_drivers() == EGL_FALSE) { 639518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian setError(EGL_BAD_PARAMETER, NULL); 640518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return NULL; 641518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 642518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 643aca51c06f38155f1435fbc6944d7fc0a9bf1e4e9Jamie Gennis // The EGL_ANDROID_blob_cache extension should not be exposed to 644aca51c06f38155f1435fbc6944d7fc0a9bf1e4e9Jamie Gennis // applications. It is used internally by the Android EGL layer. 645c42fcf05ce253d5342993b28c412be16e61efffbJamie Gennis if (!strcmp(procname, "eglSetBlobCacheFuncsANDROID")) { 646aca51c06f38155f1435fbc6944d7fc0a9bf1e4e9Jamie Gennis return NULL; 647aca51c06f38155f1435fbc6944d7fc0a9bf1e4e9Jamie Gennis } 648aca51c06f38155f1435fbc6944d7fc0a9bf1e4e9Jamie Gennis 649518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian __eglMustCastToProperFunctionPointerType addr; 650518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian addr = findProcAddress(procname, sExtentionMap, NELEM(sExtentionMap)); 651518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (addr) return addr; 652518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 653aca51c06f38155f1435fbc6944d7fc0a9bf1e4e9Jamie Gennis 654518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // this protects accesses to sGLExtentionMap and sGLExtentionSlot 655518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian pthread_mutex_lock(&sExtensionMapMutex); 656518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 657518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian /* 658518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * Since eglGetProcAddress() is not associated to anything, it needs 659518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * to return a function pointer that "works" regardless of what 660518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * the current context is. 661518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * 662518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * For this reason, we return a "forwarder", a small stub that takes 663518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * care of calling the function associated with the context 664518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * currently bound. 665518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * 666518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * We first look for extensions we've already resolved, if we're seeing 667518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * this extension for the first time, we go through all our 668518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * implementations and call eglGetProcAddress() and record the 669518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * result in the appropriate implementation hooks and return the 670518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * address of the forwarder corresponding to that hook set. 671518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian * 672518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian */ 673518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 674518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian const String8 name(procname); 675518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian addr = sGLExtentionMap.valueFor(name); 676518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian const int slot = sGLExtentionSlot; 677518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 678e6f43ddce78d6846af12550ff9193c5c6fe5844bSteve Block ALOGE_IF(slot >= MAX_NUMBER_OF_GL_EXTENSIONS, 679518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian "no more slots for eglGetProcAddress(\"%s\")", 680518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian procname); 681518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 6820469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#if EGL_TRACE 6830469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy gl_hooks_t *debugHooks = GLTrace_getGLHooks(); 6840469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#endif 6850469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy 686518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!addr && (slot < MAX_NUMBER_OF_GL_EXTENSIONS)) { 687518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian bool found = false; 688ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian 689ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 690ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso && cnx->egl.eglGetProcAddress) { 691ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian found = true; 692ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian // Extensions are independent of the bound context 6937773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian cnx->hooks[egl_connection_t::GLESv1_INDEX]->ext.extensions[slot] = 6947773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian cnx->hooks[egl_connection_t::GLESv2_INDEX]->ext.extensions[slot] = 695518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#if EGL_TRACE 696ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian debugHooks->ext.extensions[slot] = 697ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian gHooksTrace.ext.extensions[slot] = 698518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian#endif 699ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian cnx->egl.eglGetProcAddress(procname); 700518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 701ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian 702518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (found) { 703518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian addr = gExtensionForwarders[slot]; 704518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian sGLExtentionMap.add(name, addr); 705518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian sGLExtentionSlot++; 706518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 707518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 708518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 709518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian pthread_mutex_unlock(&sExtensionMapMutex); 710518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return addr; 711518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 712518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 713518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) 714518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 715518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 716518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 717518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 718518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 719518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 720f0480de37492597a5c5cf1e6f8346f1467e3a552Mathias Agopian SurfaceRef _s(dp, draw); 7215b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 7225b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 723518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 7240469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#if EGL_TRACE 7250469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy if (gEGLDebugLevel > 0) 7260469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy GLTrace_eglSwapBuffers(dpy, draw); 7270469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#endif 7280469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy 729518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * const s = get_surface(draw); 730ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return s->cnx->egl.eglSwapBuffers(dp->disp.dpy, s->surface); 731518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 732518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 733518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglCopyBuffers( EGLDisplay dpy, EGLSurface surface, 734518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian NativePixmapType target) 735518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 736518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 737518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 738518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 739518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 740518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 741f0480de37492597a5c5cf1e6f8346f1467e3a552Mathias Agopian SurfaceRef _s(dp, surface); 7425b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 7435b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 744518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 745518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * const s = get_surface(surface); 746ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return s->cnx->egl.eglCopyBuffers(dp->disp.dpy, s->surface, target); 747518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 748518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 749518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopianconst char* eglQueryString(EGLDisplay dpy, EGLint name) 750518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 751518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 752518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 753518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 754518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return (const char *) NULL; 755518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 756518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian switch (name) { 757518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian case EGL_VENDOR: 7584b9511c16195a646242eff833b0af212933b6ecaMathias Agopian return dp->getVendorString(); 759518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian case EGL_VERSION: 7604b9511c16195a646242eff833b0af212933b6ecaMathias Agopian return dp->getVersionString(); 761518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian case EGL_EXTENSIONS: 7624b9511c16195a646242eff833b0af212933b6ecaMathias Agopian return dp->getExtensionString(); 763518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian case EGL_CLIENT_APIS: 7644b9511c16195a646242eff833b0af212933b6ecaMathias Agopian return dp->getClientApiString(); 765ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian case EGL_VERSION_HW_ANDROID: 766ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return dp->disp.queryString.version; 767518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 768518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_PARAMETER, (const char *)0); 769518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 770518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 771518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 772518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 773518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// EGL 1.1 774518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 775518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 776518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglSurfaceAttrib( 777518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) 778518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 779518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 780518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 781518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 782518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 783518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 784f0480de37492597a5c5cf1e6f8346f1467e3a552Mathias Agopian SurfaceRef _s(dp, surface); 7855b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 7865b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 787518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 788518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * const s = get_surface(surface); 789518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (s->cnx->egl.eglSurfaceAttrib) { 790518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return s->cnx->egl.eglSurfaceAttrib( 791ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian dp->disp.dpy, s->surface, attribute, value); 792518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 793518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 794518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 795518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 796518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglBindTexImage( 797518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLDisplay dpy, EGLSurface surface, EGLint buffer) 798518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 799518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 800518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 801518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 802518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 803518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 804f0480de37492597a5c5cf1e6f8346f1467e3a552Mathias Agopian SurfaceRef _s(dp, surface); 8055b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 8065b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 807518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 808518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * const s = get_surface(surface); 809518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (s->cnx->egl.eglBindTexImage) { 810518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return s->cnx->egl.eglBindTexImage( 811ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian dp->disp.dpy, s->surface, buffer); 812518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 813518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 814518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 815518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 816518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglReleaseTexImage( 817518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLDisplay dpy, EGLSurface surface, EGLint buffer) 818518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 819518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 820518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 821518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 822518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 823518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 824f0480de37492597a5c5cf1e6f8346f1467e3a552Mathias Agopian SurfaceRef _s(dp, surface); 8255b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 8265b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 827518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 828518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * const s = get_surface(surface); 829518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (s->cnx->egl.eglReleaseTexImage) { 830518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return s->cnx->egl.eglReleaseTexImage( 831ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian dp->disp.dpy, s->surface, buffer); 832518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 833518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 834518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 835518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 836518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval) 837518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 838518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 839518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 840518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 841518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 842518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 843518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLBoolean res = EGL_TRUE; 844ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 845ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso && cnx->egl.eglSwapInterval) { 846ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian res = cnx->egl.eglSwapInterval(dp->disp.dpy, interval); 847518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 848ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian 849518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return res; 850518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 851518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 852518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 853518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 854518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// EGL 1.2 855518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 856518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 857518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglWaitClient(void) 858518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 859518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 860518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 861ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 862ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (!cnx->dso) 863ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return setError(EGL_BAD_CONTEXT, EGL_FALSE); 864ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian 865ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian EGLBoolean res; 866ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->egl.eglWaitClient) { 867ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian res = cnx->egl.eglWaitClient(); 868ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian } else { 869ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian res = cnx->egl.eglWaitGL(); 870518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 871518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return res; 872518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 873518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 874518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglBindAPI(EGLenum api) 875518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 876518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 877518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 878518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (egl_init_drivers() == EGL_FALSE) { 879518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_PARAMETER, EGL_FALSE); 880518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 881518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 882518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // bind this API on all EGLs 883518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLBoolean res = EGL_TRUE; 884ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 885ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso && cnx->egl.eglBindAPI) { 886ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian res = cnx->egl.eglBindAPI(api); 887518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 888518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return res; 889518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 890518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 891518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLenum eglQueryAPI(void) 892518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 893518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 894518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 895518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (egl_init_drivers() == EGL_FALSE) { 896518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_PARAMETER, EGL_FALSE); 897518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 898518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 899ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 900ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso && cnx->egl.eglQueryAPI) { 901ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return cnx->egl.eglQueryAPI(); 902518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 903ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian 904518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // or, it can only be OpenGL ES 905518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_OPENGL_ES_API; 906518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 907518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 908518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglReleaseThread(void) 909518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 910518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 911518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 912518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian // If there is context bound to the thread, release it 913fb87e54a9af8bc5063ca4deebe81d90126992480Mathias Agopian egl_display_t::loseCurrent(get_context(getContext())); 914518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 915ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 916ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso && cnx->egl.eglReleaseThread) { 917ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian cnx->egl.eglReleaseThread(); 918518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 919ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian 920518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_tls_t::clearTLS(); 9210469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#if EGL_TRACE 9220469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy if (gEGLDebugLevel > 0) 9230469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy GLTrace_eglReleaseThread(); 9240469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#endif 925518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_TRUE; 926518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 927518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 928518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLSurface eglCreatePbufferFromClientBuffer( 929518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, 930518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLConfig config, const EGLint *attrib_list) 931518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 932518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 933518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 934518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const* dp = 0; 935518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_connection_t* cnx = validate_display_config(dpy, config, dp); 936518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!cnx) return EGL_FALSE; 937518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (cnx->egl.eglCreatePbufferFromClientBuffer) { 938518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return cnx->egl.eglCreatePbufferFromClientBuffer( 9397773c435bc5da8217433e1b242d3a6712a17b5f7Mathias Agopian dp->disp.dpy, buftype, buffer, config, attrib_list); 940518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 941518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_CONFIG, EGL_NO_SURFACE); 942518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 943518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 944518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 945518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// EGL_EGLEXT_VERSION 3 946518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 947518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 948518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglLockSurfaceKHR(EGLDisplay dpy, EGLSurface surface, 949518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian const EGLint *attrib_list) 950518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 951518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 952518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 953518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 954518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 955518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 956f0480de37492597a5c5cf1e6f8346f1467e3a552Mathias Agopian SurfaceRef _s(dp, surface); 9575b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 9585b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 959518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 960518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * const s = get_surface(surface); 961518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (s->cnx->egl.eglLockSurfaceKHR) { 962518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return s->cnx->egl.eglLockSurfaceKHR( 963ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian dp->disp.dpy, s->surface, attrib_list); 964518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 965518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_DISPLAY, EGL_FALSE); 966518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 967518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 968518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglUnlockSurfaceKHR(EGLDisplay dpy, EGLSurface surface) 969518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 970518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 971518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 972518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 973518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 974518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 975f0480de37492597a5c5cf1e6f8346f1467e3a552Mathias Agopian SurfaceRef _s(dp, surface); 9765b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian if (!_s.get()) 9775b287a6ea8dfac7ab3e03ae1e98f9e2214cbae09Mathias Agopian return setError(EGL_BAD_SURFACE, EGL_FALSE); 978518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 979518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_surface_t const * const s = get_surface(surface); 980518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (s->cnx->egl.eglUnlockSurfaceKHR) { 981ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return s->cnx->egl.eglUnlockSurfaceKHR(dp->disp.dpy, s->surface); 982518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 983518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return setError(EGL_BAD_DISPLAY, EGL_FALSE); 984518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 985518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 986518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, 987518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLClientBuffer buffer, const EGLint *attrib_list) 988518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 989518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 990518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 991518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 992518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_NO_IMAGE_KHR; 993518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 9947c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian ContextRef _c(dp, ctx); 9957c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian egl_context_t * const c = _c.get(); 996518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 9977c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian EGLImageKHR result = EGL_NO_IMAGE_KHR; 9987c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian egl_connection_t* const cnx = &gEGLImpl; 9997c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian if (cnx->dso && cnx->egl.eglCreateImageKHR) { 10007c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian result = cnx->egl.eglCreateImageKHR( 10017c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian dp->disp.dpy, 10027c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian c ? c->context : EGL_NO_CONTEXT, 10037c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian target, buffer, attrib_list); 1004518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 10057c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian return result; 1006518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1007518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1008518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img) 1009518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1010518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1011518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1012518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 1013518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 1014518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1015ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 10167c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian if (cnx->dso && cnx->egl.eglDestroyImageKHR) { 10177c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian cnx->egl.eglDestroyImageKHR(dp->disp.dpy, img); 1018518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1019518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return EGL_TRUE; 1020518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1021518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1022518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 1023518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// EGL_EGLEXT_VERSION 5 1024518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 1025518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1026518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1027518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list) 1028518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1029518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1030518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1031518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 1032518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_NO_SYNC_KHR; 1033518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1034518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLSyncKHR result = EGL_NO_SYNC_KHR; 10357c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian egl_connection_t* const cnx = &gEGLImpl; 10367c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian if (cnx->dso && cnx->egl.eglCreateSyncKHR) { 10377c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian result = cnx->egl.eglCreateSyncKHR(dp->disp.dpy, type, attrib_list); 1038518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 10397c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian return result; 1040518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1041518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1042518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias AgopianEGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync) 1043518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1044518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1045518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1046518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 1047518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 1048518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1049518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian EGLBoolean result = EGL_FALSE; 10507c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian egl_connection_t* const cnx = &gEGLImpl; 10517c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian if (cnx->dso && cnx->egl.eglDestroySyncKHR) { 10527c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian result = cnx->egl.eglDestroySyncKHR(dp->disp.dpy, sync); 1053518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 1054518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian return result; 1055518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1056518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 10577c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias AgopianEGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, 10587c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian EGLint flags, EGLTimeKHR timeout) 1059518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1060518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1061518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1062518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 1063518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 1064518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 10657c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian EGLBoolean result = EGL_FALSE; 10667c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian egl_connection_t* const cnx = &gEGLImpl; 10677c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian if (cnx->dso && cnx->egl.eglClientWaitSyncKHR) { 10687c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian result = cnx->egl.eglClientWaitSyncKHR( 10697c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian dp->disp.dpy, sync, flags, timeout); 1070518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 10717c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian return result; 1072518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1073518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 10747c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias AgopianEGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, 10757c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian EGLint attribute, EGLint *value) 1076518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian{ 1077518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian clearError(); 1078518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1079518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian egl_display_t const * const dp = validate_display(dpy); 1080518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian if (!dp) return EGL_FALSE; 1081518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 10827c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian EGLBoolean result = EGL_FALSE; 10837c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian egl_connection_t* const cnx = &gEGLImpl; 10847c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian if (cnx->dso && cnx->egl.eglGetSyncAttribKHR) { 10857c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian result = cnx->egl.eglGetSyncAttribKHR( 10867c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian dp->disp.dpy, sync, attribute, value); 1087518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian } 10887c0441ac271f4e00a2d63eb3048c037ebffa90b9Mathias Agopian return result; 1089518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian} 1090518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 1091518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 1092518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ANDROID extensions 1093518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian// ---------------------------------------------------------------------------- 1094518ec112f468eb67bf681b3eec896d7bfb4ff98dMathias Agopian 10954b9511c16195a646242eff833b0af212933b6ecaMathias Agopian/* ANDROID extensions entry-point go here */ 10961c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 10971c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang// ---------------------------------------------------------------------------- 10981c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang// NVIDIA extensions 10991c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang// ---------------------------------------------------------------------------- 11001c3d72a2291827fb15e2ef311a571c860e0dba41Jonas YangEGLuint64NV eglGetSystemTimeFrequencyNV() 11011c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang{ 11021c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang clearError(); 11031c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 11041c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang if (egl_init_drivers() == EGL_FALSE) { 11051c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang return setError(EGL_BAD_PARAMETER, EGL_FALSE); 11061c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang } 11071c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 11081c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang EGLuint64NV ret = 0; 1109ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 11101c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 1111ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso && cnx->egl.eglGetSystemTimeFrequencyNV) { 1112ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return cnx->egl.eglGetSystemTimeFrequencyNV(); 11131c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang } 11141c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 11150e8bbee5775d81c7bbc479b995496cac9238559fMathias Agopian return setErrorQuiet(EGL_BAD_DISPLAY, 0); 11161c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang} 11171c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 11181c3d72a2291827fb15e2ef311a571c860e0dba41Jonas YangEGLuint64NV eglGetSystemTimeNV() 11191c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang{ 11201c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang clearError(); 11211c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 11221c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang if (egl_init_drivers() == EGL_FALSE) { 11231c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang return setError(EGL_BAD_PARAMETER, EGL_FALSE); 11241c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang } 11251c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 11261c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang EGLuint64NV ret = 0; 1127ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian egl_connection_t* const cnx = &gEGLImpl; 11281c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 1129ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian if (cnx->dso && cnx->egl.eglGetSystemTimeNV) { 1130ada798b7ca7cabc255aa159964b64975e7fdb2dfMathias Agopian return cnx->egl.eglGetSystemTimeNV(); 11311c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang } 11321c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang 11330e8bbee5775d81c7bbc479b995496cac9238559fMathias Agopian return setErrorQuiet(EGL_BAD_DISPLAY, 0); 11341c3d72a2291827fb15e2ef311a571c860e0dba41Jonas Yang} 1135