xref: /aosp_15_r20/external/angle/src/libGLESv2/egl_ext_stubs.cpp (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker //
2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2020 The ANGLE Project Authors. All rights reserved.
3*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
4*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file.
5*8975f5c5SAndroid Build Coastguard Worker //
6*8975f5c5SAndroid Build Coastguard Worker // egl_ext_stubs.cpp: Stubs for EXT extension entry points.
7*8975f5c5SAndroid Build Coastguard Worker //
8*8975f5c5SAndroid Build Coastguard Worker 
9*8975f5c5SAndroid Build Coastguard Worker #include "libGLESv2/egl_ext_stubs_autogen.h"
10*8975f5c5SAndroid Build Coastguard Worker 
11*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Device.h"
12*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Display.h"
13*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/EGLSync.h"
14*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Surface.h"
15*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Thread.h"
16*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/entry_points_utils.h"
17*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/queryutils.h"
18*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/DisplayImpl.h"
19*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/validationEGL.h"
20*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/validationEGL_autogen.h"
21*8975f5c5SAndroid Build Coastguard Worker #include "libGLESv2/global_state.h"
22*8975f5c5SAndroid Build Coastguard Worker 
23*8975f5c5SAndroid Build Coastguard Worker namespace egl
24*8975f5c5SAndroid Build Coastguard Worker {
ClientWaitSyncKHR(Thread * thread,Display * display,SyncID syncID,EGLint flags,EGLTimeKHR timeout)25*8975f5c5SAndroid Build Coastguard Worker EGLint ClientWaitSyncKHR(Thread *thread,
26*8975f5c5SAndroid Build Coastguard Worker                          Display *display,
27*8975f5c5SAndroid Build Coastguard Worker                          SyncID syncID,
28*8975f5c5SAndroid Build Coastguard Worker                          EGLint flags,
29*8975f5c5SAndroid Build Coastguard Worker                          EGLTimeKHR timeout)
30*8975f5c5SAndroid Build Coastguard Worker {
31*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglClientWaitSyncKHR",
32*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
33*8975f5c5SAndroid Build Coastguard Worker     gl::Context *currentContext = thread->getContext();
34*8975f5c5SAndroid Build Coastguard Worker     EGLint syncStatus           = EGL_FALSE;
35*8975f5c5SAndroid Build Coastguard Worker     Sync *sync                  = display->getSync(syncID);
36*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread,
37*8975f5c5SAndroid Build Coastguard Worker                          sync->clientWait(display, currentContext, flags, timeout, &syncStatus),
38*8975f5c5SAndroid Build Coastguard Worker                          "eglClientWaitSyncKHR", GetSyncIfValid(display, syncID), EGL_FALSE);
39*8975f5c5SAndroid Build Coastguard Worker 
40*8975f5c5SAndroid Build Coastguard Worker     // When performing CPU wait through UnlockedTailCall we need to handle any error conditions
41*8975f5c5SAndroid Build Coastguard Worker     if (egl::Display::GetCurrentThreadUnlockedTailCall()->any())
42*8975f5c5SAndroid Build Coastguard Worker     {
43*8975f5c5SAndroid Build Coastguard Worker         auto handleErrorStatus = [thread, display, syncID](void *result) {
44*8975f5c5SAndroid Build Coastguard Worker             EGLint *eglResult = static_cast<EGLint *>(result);
45*8975f5c5SAndroid Build Coastguard Worker             ASSERT(eglResult);
46*8975f5c5SAndroid Build Coastguard Worker             if (*eglResult == EGL_FALSE)
47*8975f5c5SAndroid Build Coastguard Worker             {
48*8975f5c5SAndroid Build Coastguard Worker                 thread->setError(egl::Error(EGL_BAD_ALLOC), "eglClientWaitSyncKHR",
49*8975f5c5SAndroid Build Coastguard Worker                                  GetSyncIfValid(display, syncID));
50*8975f5c5SAndroid Build Coastguard Worker             }
51*8975f5c5SAndroid Build Coastguard Worker             else
52*8975f5c5SAndroid Build Coastguard Worker             {
53*8975f5c5SAndroid Build Coastguard Worker                 thread->setSuccess();
54*8975f5c5SAndroid Build Coastguard Worker             }
55*8975f5c5SAndroid Build Coastguard Worker         };
56*8975f5c5SAndroid Build Coastguard Worker         egl::Display::GetCurrentThreadUnlockedTailCall()->add(handleErrorStatus);
57*8975f5c5SAndroid Build Coastguard Worker     }
58*8975f5c5SAndroid Build Coastguard Worker     else
59*8975f5c5SAndroid Build Coastguard Worker     {
60*8975f5c5SAndroid Build Coastguard Worker         thread->setSuccess();
61*8975f5c5SAndroid Build Coastguard Worker     }
62*8975f5c5SAndroid Build Coastguard Worker     return syncStatus;
63*8975f5c5SAndroid Build Coastguard Worker }
64*8975f5c5SAndroid Build Coastguard Worker 
CreateImageKHR(Thread * thread,Display * display,gl::ContextID contextID,EGLenum target,EGLClientBuffer buffer,const AttributeMap & attributes)65*8975f5c5SAndroid Build Coastguard Worker EGLImageKHR CreateImageKHR(Thread *thread,
66*8975f5c5SAndroid Build Coastguard Worker                            Display *display,
67*8975f5c5SAndroid Build Coastguard Worker                            gl::ContextID contextID,
68*8975f5c5SAndroid Build Coastguard Worker                            EGLenum target,
69*8975f5c5SAndroid Build Coastguard Worker                            EGLClientBuffer buffer,
70*8975f5c5SAndroid Build Coastguard Worker                            const AttributeMap &attributes)
71*8975f5c5SAndroid Build Coastguard Worker {
72*8975f5c5SAndroid Build Coastguard Worker     gl::Context *context = display->getContext(contextID);
73*8975f5c5SAndroid Build Coastguard Worker 
74*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglCreateImageKHR",
75*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_NO_IMAGE);
76*8975f5c5SAndroid Build Coastguard Worker 
77*8975f5c5SAndroid Build Coastguard Worker     Image *image = nullptr;
78*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, display->createImage(context, target, buffer, attributes, &image),
79*8975f5c5SAndroid Build Coastguard Worker                          "", GetDisplayIfValid(display), EGL_NO_IMAGE);
80*8975f5c5SAndroid Build Coastguard Worker 
81*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
82*8975f5c5SAndroid Build Coastguard Worker     return reinterpret_cast<EGLImage>(static_cast<uintptr_t>(image->id().value));
83*8975f5c5SAndroid Build Coastguard Worker }
84*8975f5c5SAndroid Build Coastguard Worker 
CreateNativeClientBufferANDROID(Thread * thread,const AttributeMap & attribMap)85*8975f5c5SAndroid Build Coastguard Worker EGLClientBuffer CreateNativeClientBufferANDROID(Thread *thread, const AttributeMap &attribMap)
86*8975f5c5SAndroid Build Coastguard Worker {
87*8975f5c5SAndroid Build Coastguard Worker     EGLClientBuffer eglClientBuffer = nullptr;
88*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread,
89*8975f5c5SAndroid Build Coastguard Worker                          egl::Display::CreateNativeClientBuffer(attribMap, &eglClientBuffer),
90*8975f5c5SAndroid Build Coastguard Worker                          "eglCreateNativeClientBufferANDROID", nullptr, nullptr);
91*8975f5c5SAndroid Build Coastguard Worker 
92*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
93*8975f5c5SAndroid Build Coastguard Worker     return eglClientBuffer;
94*8975f5c5SAndroid Build Coastguard Worker }
95*8975f5c5SAndroid Build Coastguard Worker 
CreatePlatformPixmapSurfaceEXT(Thread * thread,Display * display,Config * configPacked,void * native_pixmap,const AttributeMap & attributes)96*8975f5c5SAndroid Build Coastguard Worker EGLSurface CreatePlatformPixmapSurfaceEXT(Thread *thread,
97*8975f5c5SAndroid Build Coastguard Worker                                           Display *display,
98*8975f5c5SAndroid Build Coastguard Worker                                           Config *configPacked,
99*8975f5c5SAndroid Build Coastguard Worker                                           void *native_pixmap,
100*8975f5c5SAndroid Build Coastguard Worker                                           const AttributeMap &attributes)
101*8975f5c5SAndroid Build Coastguard Worker {
102*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
103*8975f5c5SAndroid Build Coastguard Worker                                           "eglCreatePlatformPixmapSurfaceEXT",
104*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_NO_SURFACE);
105*8975f5c5SAndroid Build Coastguard Worker     thread->setError(EGL_BAD_DISPLAY, "eglCreatePlatformPixmapSurfaceEXT",
106*8975f5c5SAndroid Build Coastguard Worker                      GetDisplayIfValid(display), "CreatePlatformPixmapSurfaceEXT unimplemented.");
107*8975f5c5SAndroid Build Coastguard Worker     return EGL_NO_SURFACE;
108*8975f5c5SAndroid Build Coastguard Worker }
109*8975f5c5SAndroid Build Coastguard Worker 
CreatePlatformWindowSurfaceEXT(Thread * thread,Display * display,Config * configPacked,void * native_window,const AttributeMap & attributes)110*8975f5c5SAndroid Build Coastguard Worker EGLSurface CreatePlatformWindowSurfaceEXT(Thread *thread,
111*8975f5c5SAndroid Build Coastguard Worker                                           Display *display,
112*8975f5c5SAndroid Build Coastguard Worker                                           Config *configPacked,
113*8975f5c5SAndroid Build Coastguard Worker                                           void *native_window,
114*8975f5c5SAndroid Build Coastguard Worker                                           const AttributeMap &attributes)
115*8975f5c5SAndroid Build Coastguard Worker {
116*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
117*8975f5c5SAndroid Build Coastguard Worker                                           "eglCreatePlatformWindowSurfaceEXT",
118*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_NO_SURFACE);
119*8975f5c5SAndroid Build Coastguard Worker     Surface *surface = nullptr;
120*8975f5c5SAndroid Build Coastguard Worker 
121*8975f5c5SAndroid Build Coastguard Worker     // In X11, eglCreatePlatformWindowSurfaceEXT expects the native_window argument to be a pointer
122*8975f5c5SAndroid Build Coastguard Worker     // to a Window while the EGLNativeWindowType for X11 is its actual value.
123*8975f5c5SAndroid Build Coastguard Worker     // https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_platform_x11.txt
124*8975f5c5SAndroid Build Coastguard Worker     void *actualNativeWindow =
125*8975f5c5SAndroid Build Coastguard Worker         display->getImplementation()->getWindowSystem() == angle::NativeWindowSystem::X11
126*8975f5c5SAndroid Build Coastguard Worker             ? *reinterpret_cast<void **>(native_window)
127*8975f5c5SAndroid Build Coastguard Worker             : native_window;
128*8975f5c5SAndroid Build Coastguard Worker     EGLNativeWindowType nativeWindow = reinterpret_cast<EGLNativeWindowType>(actualNativeWindow);
129*8975f5c5SAndroid Build Coastguard Worker 
130*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(
131*8975f5c5SAndroid Build Coastguard Worker         thread, display->createWindowSurface(configPacked, nativeWindow, attributes, &surface),
132*8975f5c5SAndroid Build Coastguard Worker         "eglCreatePlatformWindowSurfaceEXT", GetDisplayIfValid(display), EGL_NO_SURFACE);
133*8975f5c5SAndroid Build Coastguard Worker 
134*8975f5c5SAndroid Build Coastguard Worker     return reinterpret_cast<EGLSurface>(static_cast<uintptr_t>(surface->id().value));
135*8975f5c5SAndroid Build Coastguard Worker }
136*8975f5c5SAndroid Build Coastguard Worker 
CreateStreamKHR(Thread * thread,Display * display,const AttributeMap & attributes)137*8975f5c5SAndroid Build Coastguard Worker EGLStreamKHR CreateStreamKHR(Thread *thread, Display *display, const AttributeMap &attributes)
138*8975f5c5SAndroid Build Coastguard Worker {
139*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglCreateStreamKHR",
140*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_NO_STREAM_KHR);
141*8975f5c5SAndroid Build Coastguard Worker     Stream *stream;
142*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, display->createStream(attributes, &stream), "eglCreateStreamKHR",
143*8975f5c5SAndroid Build Coastguard Worker                          GetDisplayIfValid(display), EGL_NO_STREAM_KHR);
144*8975f5c5SAndroid Build Coastguard Worker 
145*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
146*8975f5c5SAndroid Build Coastguard Worker     return static_cast<EGLStreamKHR>(stream);
147*8975f5c5SAndroid Build Coastguard Worker }
148*8975f5c5SAndroid Build Coastguard Worker 
CreateSyncKHR(Thread * thread,Display * display,EGLenum type,const AttributeMap & attributes)149*8975f5c5SAndroid Build Coastguard Worker EGLSyncKHR CreateSyncKHR(Thread *thread,
150*8975f5c5SAndroid Build Coastguard Worker                          Display *display,
151*8975f5c5SAndroid Build Coastguard Worker                          EGLenum type,
152*8975f5c5SAndroid Build Coastguard Worker                          const AttributeMap &attributes)
153*8975f5c5SAndroid Build Coastguard Worker {
154*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglCreateSyncKHR",
155*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_NO_SYNC);
156*8975f5c5SAndroid Build Coastguard Worker     egl::Sync *syncObject = nullptr;
157*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread,
158*8975f5c5SAndroid Build Coastguard Worker                          display->createSync(thread->getContext(), type, attributes, &syncObject),
159*8975f5c5SAndroid Build Coastguard Worker                          "eglCreateSyncKHR", GetDisplayIfValid(display), EGL_NO_SYNC);
160*8975f5c5SAndroid Build Coastguard Worker 
161*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
162*8975f5c5SAndroid Build Coastguard Worker     return reinterpret_cast<EGLSync>(static_cast<uintptr_t>(syncObject->id().value));
163*8975f5c5SAndroid Build Coastguard Worker }
164*8975f5c5SAndroid Build Coastguard Worker 
DebugMessageControlKHR(Thread * thread,EGLDEBUGPROCKHR callback,const AttributeMap & attributes)165*8975f5c5SAndroid Build Coastguard Worker EGLint DebugMessageControlKHR(Thread *thread,
166*8975f5c5SAndroid Build Coastguard Worker                               EGLDEBUGPROCKHR callback,
167*8975f5c5SAndroid Build Coastguard Worker                               const AttributeMap &attributes)
168*8975f5c5SAndroid Build Coastguard Worker {
169*8975f5c5SAndroid Build Coastguard Worker     Debug *debug = GetDebug();
170*8975f5c5SAndroid Build Coastguard Worker     debug->setCallback(callback, attributes);
171*8975f5c5SAndroid Build Coastguard Worker 
172*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
173*8975f5c5SAndroid Build Coastguard Worker     return EGL_SUCCESS;
174*8975f5c5SAndroid Build Coastguard Worker }
175*8975f5c5SAndroid Build Coastguard Worker 
DestroyImageKHR(Thread * thread,Display * display,egl::ImageID imageID)176*8975f5c5SAndroid Build Coastguard Worker EGLBoolean DestroyImageKHR(Thread *thread, Display *display, egl::ImageID imageID)
177*8975f5c5SAndroid Build Coastguard Worker {
178*8975f5c5SAndroid Build Coastguard Worker     Image *img = display->getImage(imageID);
179*8975f5c5SAndroid Build Coastguard Worker 
180*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglDestroyImageKHR",
181*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
182*8975f5c5SAndroid Build Coastguard Worker     display->destroyImage(img);
183*8975f5c5SAndroid Build Coastguard Worker 
184*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
185*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
186*8975f5c5SAndroid Build Coastguard Worker }
187*8975f5c5SAndroid Build Coastguard Worker 
DestroyStreamKHR(Thread * thread,Display * display,Stream * streamObject)188*8975f5c5SAndroid Build Coastguard Worker EGLBoolean DestroyStreamKHR(Thread *thread, Display *display, Stream *streamObject)
189*8975f5c5SAndroid Build Coastguard Worker {
190*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglDestroyStreamKHR",
191*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
192*8975f5c5SAndroid Build Coastguard Worker     display->destroyStream(streamObject);
193*8975f5c5SAndroid Build Coastguard Worker 
194*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
195*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
196*8975f5c5SAndroid Build Coastguard Worker }
197*8975f5c5SAndroid Build Coastguard Worker 
DestroySyncKHR(Thread * thread,Display * display,SyncID syncID)198*8975f5c5SAndroid Build Coastguard Worker EGLBoolean DestroySyncKHR(Thread *thread, Display *display, SyncID syncID)
199*8975f5c5SAndroid Build Coastguard Worker {
200*8975f5c5SAndroid Build Coastguard Worker     Sync *sync = display->getSync(syncID);
201*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglDestroySync",
202*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
203*8975f5c5SAndroid Build Coastguard Worker     display->destroySync(sync);
204*8975f5c5SAndroid Build Coastguard Worker 
205*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
206*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
207*8975f5c5SAndroid Build Coastguard Worker }
208*8975f5c5SAndroid Build Coastguard Worker 
DupNativeFenceFDANDROID(Thread * thread,Display * display,SyncID syncID)209*8975f5c5SAndroid Build Coastguard Worker EGLint DupNativeFenceFDANDROID(Thread *thread, Display *display, SyncID syncID)
210*8975f5c5SAndroid Build Coastguard Worker {
211*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
212*8975f5c5SAndroid Build Coastguard Worker                                           "eglDupNativeFenceFDANDROID", GetDisplayIfValid(display),
213*8975f5c5SAndroid Build Coastguard Worker                                           EGL_NO_NATIVE_FENCE_FD_ANDROID);
214*8975f5c5SAndroid Build Coastguard Worker     EGLint result    = EGL_NO_NATIVE_FENCE_FD_ANDROID;
215*8975f5c5SAndroid Build Coastguard Worker     Sync *syncObject = display->getSync(syncID);
216*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, syncObject->dupNativeFenceFD(display, &result),
217*8975f5c5SAndroid Build Coastguard Worker                          "eglDupNativeFenceFDANDROID", GetSyncIfValid(display, syncID),
218*8975f5c5SAndroid Build Coastguard Worker                          EGL_NO_NATIVE_FENCE_FD_ANDROID);
219*8975f5c5SAndroid Build Coastguard Worker 
220*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
221*8975f5c5SAndroid Build Coastguard Worker     return result;
222*8975f5c5SAndroid Build Coastguard Worker }
223*8975f5c5SAndroid Build Coastguard Worker 
GetNativeClientBufferANDROID(Thread * thread,const struct AHardwareBuffer * buffer)224*8975f5c5SAndroid Build Coastguard Worker EGLClientBuffer GetNativeClientBufferANDROID(Thread *thread, const struct AHardwareBuffer *buffer)
225*8975f5c5SAndroid Build Coastguard Worker {
226*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
227*8975f5c5SAndroid Build Coastguard Worker     return egl::Display::GetNativeClientBuffer(buffer);
228*8975f5c5SAndroid Build Coastguard Worker }
229*8975f5c5SAndroid Build Coastguard Worker 
GetPlatformDisplayEXT(Thread * thread,EGLenum platform,void * native_display,const AttributeMap & attribMap)230*8975f5c5SAndroid Build Coastguard Worker EGLDisplay GetPlatformDisplayEXT(Thread *thread,
231*8975f5c5SAndroid Build Coastguard Worker                                  EGLenum platform,
232*8975f5c5SAndroid Build Coastguard Worker                                  void *native_display,
233*8975f5c5SAndroid Build Coastguard Worker                                  const AttributeMap &attribMap)
234*8975f5c5SAndroid Build Coastguard Worker {
235*8975f5c5SAndroid Build Coastguard Worker     switch (platform)
236*8975f5c5SAndroid Build Coastguard Worker     {
237*8975f5c5SAndroid Build Coastguard Worker         case EGL_PLATFORM_ANGLE_ANGLE:
238*8975f5c5SAndroid Build Coastguard Worker         case EGL_PLATFORM_GBM_KHR:
239*8975f5c5SAndroid Build Coastguard Worker         case EGL_PLATFORM_WAYLAND_EXT:
240*8975f5c5SAndroid Build Coastguard Worker         case EGL_PLATFORM_SURFACELESS_MESA:
241*8975f5c5SAndroid Build Coastguard Worker         {
242*8975f5c5SAndroid Build Coastguard Worker             return egl::Display::GetDisplayFromNativeDisplay(
243*8975f5c5SAndroid Build Coastguard Worker                 platform, gl::bitCast<EGLNativeDisplayType>(native_display), attribMap);
244*8975f5c5SAndroid Build Coastguard Worker         }
245*8975f5c5SAndroid Build Coastguard Worker         case EGL_PLATFORM_DEVICE_EXT:
246*8975f5c5SAndroid Build Coastguard Worker         {
247*8975f5c5SAndroid Build Coastguard Worker             Device *eglDevice = static_cast<Device *>(native_display);
248*8975f5c5SAndroid Build Coastguard Worker             return egl::Display::GetDisplayFromDevice(eglDevice, attribMap);
249*8975f5c5SAndroid Build Coastguard Worker         }
250*8975f5c5SAndroid Build Coastguard Worker         default:
251*8975f5c5SAndroid Build Coastguard Worker         {
252*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
253*8975f5c5SAndroid Build Coastguard Worker             return EGL_NO_DISPLAY;
254*8975f5c5SAndroid Build Coastguard Worker         }
255*8975f5c5SAndroid Build Coastguard Worker     }
256*8975f5c5SAndroid Build Coastguard Worker }
257*8975f5c5SAndroid Build Coastguard Worker 
GetSyncAttribKHR(Thread * thread,Display * display,SyncID syncObject,EGLint attribute,EGLint * value)258*8975f5c5SAndroid Build Coastguard Worker EGLBoolean GetSyncAttribKHR(Thread *thread,
259*8975f5c5SAndroid Build Coastguard Worker                             Display *display,
260*8975f5c5SAndroid Build Coastguard Worker                             SyncID syncObject,
261*8975f5c5SAndroid Build Coastguard Worker                             EGLint attribute,
262*8975f5c5SAndroid Build Coastguard Worker                             EGLint *value)
263*8975f5c5SAndroid Build Coastguard Worker {
264*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglGetSyncAttrib",
265*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
266*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, GetSyncAttrib(display, syncObject, attribute, value),
267*8975f5c5SAndroid Build Coastguard Worker                          "eglGetSyncAttrib", GetSyncIfValid(display, syncObject), EGL_FALSE);
268*8975f5c5SAndroid Build Coastguard Worker 
269*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
270*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
271*8975f5c5SAndroid Build Coastguard Worker }
272*8975f5c5SAndroid Build Coastguard Worker 
LabelObjectKHR(Thread * thread,Display * display,ObjectType objectTypePacked,EGLObjectKHR object,EGLLabelKHR label)273*8975f5c5SAndroid Build Coastguard Worker EGLint LabelObjectKHR(Thread *thread,
274*8975f5c5SAndroid Build Coastguard Worker                       Display *display,
275*8975f5c5SAndroid Build Coastguard Worker                       ObjectType objectTypePacked,
276*8975f5c5SAndroid Build Coastguard Worker                       EGLObjectKHR object,
277*8975f5c5SAndroid Build Coastguard Worker                       EGLLabelKHR label)
278*8975f5c5SAndroid Build Coastguard Worker {
279*8975f5c5SAndroid Build Coastguard Worker     LabeledObject *labeledObject =
280*8975f5c5SAndroid Build Coastguard Worker         GetLabeledObjectIfValid(thread, display, objectTypePacked, object);
281*8975f5c5SAndroid Build Coastguard Worker     ASSERT(labeledObject != nullptr);
282*8975f5c5SAndroid Build Coastguard Worker     labeledObject->setLabel(label);
283*8975f5c5SAndroid Build Coastguard Worker 
284*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
285*8975f5c5SAndroid Build Coastguard Worker     return EGL_SUCCESS;
286*8975f5c5SAndroid Build Coastguard Worker }
287*8975f5c5SAndroid Build Coastguard Worker 
PostSubBufferNV(Thread * thread,Display * display,SurfaceID surfaceID,EGLint x,EGLint y,EGLint width,EGLint height)288*8975f5c5SAndroid Build Coastguard Worker EGLBoolean PostSubBufferNV(Thread *thread,
289*8975f5c5SAndroid Build Coastguard Worker                            Display *display,
290*8975f5c5SAndroid Build Coastguard Worker                            SurfaceID surfaceID,
291*8975f5c5SAndroid Build Coastguard Worker                            EGLint x,
292*8975f5c5SAndroid Build Coastguard Worker                            EGLint y,
293*8975f5c5SAndroid Build Coastguard Worker                            EGLint width,
294*8975f5c5SAndroid Build Coastguard Worker                            EGLint height)
295*8975f5c5SAndroid Build Coastguard Worker {
296*8975f5c5SAndroid Build Coastguard Worker     Surface *eglSurface = display->getSurface(surfaceID);
297*8975f5c5SAndroid Build Coastguard Worker 
298*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglPostSubBufferNV",
299*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
300*8975f5c5SAndroid Build Coastguard Worker     Error error = eglSurface->postSubBuffer(thread->getContext(), x, y, width, height);
301*8975f5c5SAndroid Build Coastguard Worker     if (error.isError())
302*8975f5c5SAndroid Build Coastguard Worker     {
303*8975f5c5SAndroid Build Coastguard Worker         thread->setError(error, "eglPostSubBufferNV", GetSurfaceIfValid(display, surfaceID));
304*8975f5c5SAndroid Build Coastguard Worker         return EGL_FALSE;
305*8975f5c5SAndroid Build Coastguard Worker     }
306*8975f5c5SAndroid Build Coastguard Worker 
307*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
308*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
309*8975f5c5SAndroid Build Coastguard Worker }
310*8975f5c5SAndroid Build Coastguard Worker 
PresentationTimeANDROID(Thread * thread,Display * display,SurfaceID surfaceID,EGLnsecsANDROID time)311*8975f5c5SAndroid Build Coastguard Worker EGLBoolean PresentationTimeANDROID(Thread *thread,
312*8975f5c5SAndroid Build Coastguard Worker                                    Display *display,
313*8975f5c5SAndroid Build Coastguard Worker                                    SurfaceID surfaceID,
314*8975f5c5SAndroid Build Coastguard Worker                                    EGLnsecsANDROID time)
315*8975f5c5SAndroid Build Coastguard Worker {
316*8975f5c5SAndroid Build Coastguard Worker     Surface *eglSurface = display->getSurface(surfaceID);
317*8975f5c5SAndroid Build Coastguard Worker 
318*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
319*8975f5c5SAndroid Build Coastguard Worker                                           "eglPresentationTimeANDROID", GetDisplayIfValid(display),
320*8975f5c5SAndroid Build Coastguard Worker                                           EGL_FALSE);
321*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, eglSurface->setPresentationTime(time),
322*8975f5c5SAndroid Build Coastguard Worker                          "eglPresentationTimeANDROID", GetSurfaceIfValid(display, surfaceID),
323*8975f5c5SAndroid Build Coastguard Worker                          EGL_FALSE);
324*8975f5c5SAndroid Build Coastguard Worker 
325*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
326*8975f5c5SAndroid Build Coastguard Worker }
327*8975f5c5SAndroid Build Coastguard Worker 
GetCompositorTimingSupportedANDROID(Thread * thread,Display * display,SurfaceID surfaceID,CompositorTiming nameInternal)328*8975f5c5SAndroid Build Coastguard Worker EGLBoolean GetCompositorTimingSupportedANDROID(Thread *thread,
329*8975f5c5SAndroid Build Coastguard Worker                                                Display *display,
330*8975f5c5SAndroid Build Coastguard Worker                                                SurfaceID surfaceID,
331*8975f5c5SAndroid Build Coastguard Worker                                                CompositorTiming nameInternal)
332*8975f5c5SAndroid Build Coastguard Worker {
333*8975f5c5SAndroid Build Coastguard Worker     Surface *eglSurface = display->getSurface(surfaceID);
334*8975f5c5SAndroid Build Coastguard Worker 
335*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
336*8975f5c5SAndroid Build Coastguard Worker     return eglSurface->getSupportedCompositorTimings().test(nameInternal);
337*8975f5c5SAndroid Build Coastguard Worker }
338*8975f5c5SAndroid Build Coastguard Worker 
GetCompositorTimingANDROID(Thread * thread,Display * display,SurfaceID surfaceID,EGLint numTimestamps,const EGLint * names,EGLnsecsANDROID * values)339*8975f5c5SAndroid Build Coastguard Worker EGLBoolean GetCompositorTimingANDROID(Thread *thread,
340*8975f5c5SAndroid Build Coastguard Worker                                       Display *display,
341*8975f5c5SAndroid Build Coastguard Worker                                       SurfaceID surfaceID,
342*8975f5c5SAndroid Build Coastguard Worker                                       EGLint numTimestamps,
343*8975f5c5SAndroid Build Coastguard Worker                                       const EGLint *names,
344*8975f5c5SAndroid Build Coastguard Worker                                       EGLnsecsANDROID *values)
345*8975f5c5SAndroid Build Coastguard Worker {
346*8975f5c5SAndroid Build Coastguard Worker     Surface *eglSurface = display->getSurface(surfaceID);
347*8975f5c5SAndroid Build Coastguard Worker 
348*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
349*8975f5c5SAndroid Build Coastguard Worker                                           "eglGetCompositorTimingANDROIDD",
350*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
351*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, eglSurface->getCompositorTiming(numTimestamps, names, values),
352*8975f5c5SAndroid Build Coastguard Worker                          "eglGetCompositorTimingANDROIDD", GetSurfaceIfValid(display, surfaceID),
353*8975f5c5SAndroid Build Coastguard Worker                          EGL_FALSE);
354*8975f5c5SAndroid Build Coastguard Worker 
355*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
356*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
357*8975f5c5SAndroid Build Coastguard Worker }
358*8975f5c5SAndroid Build Coastguard Worker 
GetNextFrameIdANDROID(Thread * thread,Display * display,SurfaceID surfaceID,EGLuint64KHR * frameId)359*8975f5c5SAndroid Build Coastguard Worker EGLBoolean GetNextFrameIdANDROID(Thread *thread,
360*8975f5c5SAndroid Build Coastguard Worker                                  Display *display,
361*8975f5c5SAndroid Build Coastguard Worker                                  SurfaceID surfaceID,
362*8975f5c5SAndroid Build Coastguard Worker                                  EGLuint64KHR *frameId)
363*8975f5c5SAndroid Build Coastguard Worker {
364*8975f5c5SAndroid Build Coastguard Worker     Surface *eglSurface = display->getSurface(surfaceID);
365*8975f5c5SAndroid Build Coastguard Worker 
366*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
367*8975f5c5SAndroid Build Coastguard Worker                                           "eglGetNextFrameIdANDROID", GetDisplayIfValid(display),
368*8975f5c5SAndroid Build Coastguard Worker                                           EGL_FALSE);
369*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, eglSurface->getNextFrameId(frameId), "eglGetNextFrameIdANDROID",
370*8975f5c5SAndroid Build Coastguard Worker                          GetSurfaceIfValid(display, surfaceID), EGL_FALSE);
371*8975f5c5SAndroid Build Coastguard Worker 
372*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
373*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
374*8975f5c5SAndroid Build Coastguard Worker }
375*8975f5c5SAndroid Build Coastguard Worker 
GetFrameTimestampSupportedANDROID(Thread * thread,Display * display,SurfaceID surfaceID,Timestamp timestampInternal)376*8975f5c5SAndroid Build Coastguard Worker EGLBoolean GetFrameTimestampSupportedANDROID(Thread *thread,
377*8975f5c5SAndroid Build Coastguard Worker                                              Display *display,
378*8975f5c5SAndroid Build Coastguard Worker                                              SurfaceID surfaceID,
379*8975f5c5SAndroid Build Coastguard Worker                                              Timestamp timestampInternal)
380*8975f5c5SAndroid Build Coastguard Worker {
381*8975f5c5SAndroid Build Coastguard Worker     Surface *eglSurface = display->getSurface(surfaceID);
382*8975f5c5SAndroid Build Coastguard Worker 
383*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
384*8975f5c5SAndroid Build Coastguard Worker                                           "eglQueryTimestampSupportedANDROID",
385*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
386*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
387*8975f5c5SAndroid Build Coastguard Worker     return eglSurface->getSupportedTimestamps().test(timestampInternal);
388*8975f5c5SAndroid Build Coastguard Worker }
389*8975f5c5SAndroid Build Coastguard Worker 
GetFrameTimestampsANDROID(Thread * thread,Display * display,SurfaceID surfaceID,EGLuint64KHR frameId,EGLint numTimestamps,const EGLint * timestamps,EGLnsecsANDROID * values)390*8975f5c5SAndroid Build Coastguard Worker EGLBoolean GetFrameTimestampsANDROID(Thread *thread,
391*8975f5c5SAndroid Build Coastguard Worker                                      Display *display,
392*8975f5c5SAndroid Build Coastguard Worker                                      SurfaceID surfaceID,
393*8975f5c5SAndroid Build Coastguard Worker                                      EGLuint64KHR frameId,
394*8975f5c5SAndroid Build Coastguard Worker                                      EGLint numTimestamps,
395*8975f5c5SAndroid Build Coastguard Worker                                      const EGLint *timestamps,
396*8975f5c5SAndroid Build Coastguard Worker                                      EGLnsecsANDROID *values)
397*8975f5c5SAndroid Build Coastguard Worker {
398*8975f5c5SAndroid Build Coastguard Worker     Surface *eglSurface = display->getSurface(surfaceID);
399*8975f5c5SAndroid Build Coastguard Worker 
400*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
401*8975f5c5SAndroid Build Coastguard Worker                                           "eglGetFrameTimestampsANDROID",
402*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
403*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(
404*8975f5c5SAndroid Build Coastguard Worker         thread, eglSurface->getFrameTimestamps(frameId, numTimestamps, timestamps, values),
405*8975f5c5SAndroid Build Coastguard Worker         "eglGetFrameTimestampsANDROID", GetSurfaceIfValid(display, surfaceID), EGL_FALSE);
406*8975f5c5SAndroid Build Coastguard Worker 
407*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
408*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
409*8975f5c5SAndroid Build Coastguard Worker }
410*8975f5c5SAndroid Build Coastguard Worker 
QueryDebugKHR(Thread * thread,EGLint attribute,EGLAttrib * value)411*8975f5c5SAndroid Build Coastguard Worker EGLBoolean QueryDebugKHR(Thread *thread, EGLint attribute, EGLAttrib *value)
412*8975f5c5SAndroid Build Coastguard Worker {
413*8975f5c5SAndroid Build Coastguard Worker     Debug *debug = GetDebug();
414*8975f5c5SAndroid Build Coastguard Worker     switch (attribute)
415*8975f5c5SAndroid Build Coastguard Worker     {
416*8975f5c5SAndroid Build Coastguard Worker         case EGL_DEBUG_MSG_CRITICAL_KHR:
417*8975f5c5SAndroid Build Coastguard Worker         case EGL_DEBUG_MSG_ERROR_KHR:
418*8975f5c5SAndroid Build Coastguard Worker         case EGL_DEBUG_MSG_WARN_KHR:
419*8975f5c5SAndroid Build Coastguard Worker         case EGL_DEBUG_MSG_INFO_KHR:
420*8975f5c5SAndroid Build Coastguard Worker             *value = debug->isMessageTypeEnabled(FromEGLenum<MessageType>(attribute)) ? EGL_TRUE
421*8975f5c5SAndroid Build Coastguard Worker                                                                                       : EGL_FALSE;
422*8975f5c5SAndroid Build Coastguard Worker             break;
423*8975f5c5SAndroid Build Coastguard Worker         case EGL_DEBUG_CALLBACK_KHR:
424*8975f5c5SAndroid Build Coastguard Worker             *value = reinterpret_cast<EGLAttrib>(debug->getCallback());
425*8975f5c5SAndroid Build Coastguard Worker             break;
426*8975f5c5SAndroid Build Coastguard Worker 
427*8975f5c5SAndroid Build Coastguard Worker         default:
428*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
429*8975f5c5SAndroid Build Coastguard Worker     }
430*8975f5c5SAndroid Build Coastguard Worker 
431*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
432*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
433*8975f5c5SAndroid Build Coastguard Worker }
434*8975f5c5SAndroid Build Coastguard Worker 
QueryDeviceAttribEXT(Thread * thread,Device * dev,EGLint attribute,EGLAttrib * value)435*8975f5c5SAndroid Build Coastguard Worker EGLBoolean QueryDeviceAttribEXT(Thread *thread, Device *dev, EGLint attribute, EGLAttrib *value)
436*8975f5c5SAndroid Build Coastguard Worker {
437*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, dev->getAttribute(attribute, value), "eglQueryDeviceAttribEXT",
438*8975f5c5SAndroid Build Coastguard Worker                          GetDeviceIfValid(dev), EGL_FALSE);
439*8975f5c5SAndroid Build Coastguard Worker 
440*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
441*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
442*8975f5c5SAndroid Build Coastguard Worker }
443*8975f5c5SAndroid Build Coastguard Worker 
QueryDeviceStringEXT(Thread * thread,Device * dev,EGLint name)444*8975f5c5SAndroid Build Coastguard Worker const char *QueryDeviceStringEXT(Thread *thread, Device *dev, EGLint name)
445*8975f5c5SAndroid Build Coastguard Worker {
446*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, dev->getOwningDisplay()->prepareForCall(),
447*8975f5c5SAndroid Build Coastguard Worker                                           "eglQueryDeviceStringEXT",
448*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(dev->getOwningDisplay()), EGL_FALSE);
449*8975f5c5SAndroid Build Coastguard Worker     const char *result;
450*8975f5c5SAndroid Build Coastguard Worker     switch (name)
451*8975f5c5SAndroid Build Coastguard Worker     {
452*8975f5c5SAndroid Build Coastguard Worker         case EGL_EXTENSIONS:
453*8975f5c5SAndroid Build Coastguard Worker             result = dev->getExtensionString().c_str();
454*8975f5c5SAndroid Build Coastguard Worker             break;
455*8975f5c5SAndroid Build Coastguard Worker         case EGL_DRM_DEVICE_FILE_EXT:
456*8975f5c5SAndroid Build Coastguard Worker         case EGL_DRM_RENDER_NODE_FILE_EXT:
457*8975f5c5SAndroid Build Coastguard Worker             result = dev->getDeviceString(name).c_str();
458*8975f5c5SAndroid Build Coastguard Worker             break;
459*8975f5c5SAndroid Build Coastguard Worker         default:
460*8975f5c5SAndroid Build Coastguard Worker             thread->setError(EglBadDevice(), "eglQueryDeviceStringEXT", GetDeviceIfValid(dev));
461*8975f5c5SAndroid Build Coastguard Worker             return nullptr;
462*8975f5c5SAndroid Build Coastguard Worker     }
463*8975f5c5SAndroid Build Coastguard Worker 
464*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
465*8975f5c5SAndroid Build Coastguard Worker     return result;
466*8975f5c5SAndroid Build Coastguard Worker }
467*8975f5c5SAndroid Build Coastguard Worker 
QueryDisplayAttribEXT(Thread * thread,Display * display,EGLint attribute,EGLAttrib * value)468*8975f5c5SAndroid Build Coastguard Worker EGLBoolean QueryDisplayAttribEXT(Thread *thread,
469*8975f5c5SAndroid Build Coastguard Worker                                  Display *display,
470*8975f5c5SAndroid Build Coastguard Worker                                  EGLint attribute,
471*8975f5c5SAndroid Build Coastguard Worker                                  EGLAttrib *value)
472*8975f5c5SAndroid Build Coastguard Worker {
473*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
474*8975f5c5SAndroid Build Coastguard Worker                                           "eglQueryDisplayAttribEXT", GetDisplayIfValid(display),
475*8975f5c5SAndroid Build Coastguard Worker                                           EGL_FALSE);
476*8975f5c5SAndroid Build Coastguard Worker     *value = display->queryAttrib(attribute);
477*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
478*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
479*8975f5c5SAndroid Build Coastguard Worker }
480*8975f5c5SAndroid Build Coastguard Worker 
QueryStreamKHR(Thread * thread,Display * display,Stream * streamObject,EGLenum attribute,EGLint * value)481*8975f5c5SAndroid Build Coastguard Worker EGLBoolean QueryStreamKHR(Thread *thread,
482*8975f5c5SAndroid Build Coastguard Worker                           Display *display,
483*8975f5c5SAndroid Build Coastguard Worker                           Stream *streamObject,
484*8975f5c5SAndroid Build Coastguard Worker                           EGLenum attribute,
485*8975f5c5SAndroid Build Coastguard Worker                           EGLint *value)
486*8975f5c5SAndroid Build Coastguard Worker {
487*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglQueryStreamKHR",
488*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
489*8975f5c5SAndroid Build Coastguard Worker     switch (attribute)
490*8975f5c5SAndroid Build Coastguard Worker     {
491*8975f5c5SAndroid Build Coastguard Worker         case EGL_STREAM_STATE_KHR:
492*8975f5c5SAndroid Build Coastguard Worker             *value = streamObject->getState();
493*8975f5c5SAndroid Build Coastguard Worker             break;
494*8975f5c5SAndroid Build Coastguard Worker         case EGL_CONSUMER_LATENCY_USEC_KHR:
495*8975f5c5SAndroid Build Coastguard Worker             *value = streamObject->getConsumerLatency();
496*8975f5c5SAndroid Build Coastguard Worker             break;
497*8975f5c5SAndroid Build Coastguard Worker         case EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR:
498*8975f5c5SAndroid Build Coastguard Worker             *value = streamObject->getConsumerAcquireTimeout();
499*8975f5c5SAndroid Build Coastguard Worker             break;
500*8975f5c5SAndroid Build Coastguard Worker         default:
501*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
502*8975f5c5SAndroid Build Coastguard Worker     }
503*8975f5c5SAndroid Build Coastguard Worker 
504*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
505*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
506*8975f5c5SAndroid Build Coastguard Worker }
507*8975f5c5SAndroid Build Coastguard Worker 
QueryStreamu64KHR(Thread * thread,Display * display,Stream * streamObject,EGLenum attribute,EGLuint64KHR * value)508*8975f5c5SAndroid Build Coastguard Worker EGLBoolean QueryStreamu64KHR(Thread *thread,
509*8975f5c5SAndroid Build Coastguard Worker                              Display *display,
510*8975f5c5SAndroid Build Coastguard Worker                              Stream *streamObject,
511*8975f5c5SAndroid Build Coastguard Worker                              EGLenum attribute,
512*8975f5c5SAndroid Build Coastguard Worker                              EGLuint64KHR *value)
513*8975f5c5SAndroid Build Coastguard Worker {
514*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglQueryStreamu64KHR",
515*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
516*8975f5c5SAndroid Build Coastguard Worker     switch (attribute)
517*8975f5c5SAndroid Build Coastguard Worker     {
518*8975f5c5SAndroid Build Coastguard Worker         case EGL_PRODUCER_FRAME_KHR:
519*8975f5c5SAndroid Build Coastguard Worker             *value = streamObject->getProducerFrame();
520*8975f5c5SAndroid Build Coastguard Worker             break;
521*8975f5c5SAndroid Build Coastguard Worker         case EGL_CONSUMER_FRAME_KHR:
522*8975f5c5SAndroid Build Coastguard Worker             *value = streamObject->getConsumerFrame();
523*8975f5c5SAndroid Build Coastguard Worker             break;
524*8975f5c5SAndroid Build Coastguard Worker         default:
525*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
526*8975f5c5SAndroid Build Coastguard Worker     }
527*8975f5c5SAndroid Build Coastguard Worker 
528*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
529*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
530*8975f5c5SAndroid Build Coastguard Worker }
531*8975f5c5SAndroid Build Coastguard Worker 
QuerySurfacePointerANGLE(Thread * thread,Display * display,SurfaceID surfaceID,EGLint attribute,void ** value)532*8975f5c5SAndroid Build Coastguard Worker EGLBoolean QuerySurfacePointerANGLE(Thread *thread,
533*8975f5c5SAndroid Build Coastguard Worker                                     Display *display,
534*8975f5c5SAndroid Build Coastguard Worker                                     SurfaceID surfaceID,
535*8975f5c5SAndroid Build Coastguard Worker                                     EGLint attribute,
536*8975f5c5SAndroid Build Coastguard Worker                                     void **value)
537*8975f5c5SAndroid Build Coastguard Worker {
538*8975f5c5SAndroid Build Coastguard Worker     Surface *eglSurface = display->getSurface(surfaceID);
539*8975f5c5SAndroid Build Coastguard Worker 
540*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
541*8975f5c5SAndroid Build Coastguard Worker                                           "eglQuerySurfacePointerANGLE", GetDisplayIfValid(display),
542*8975f5c5SAndroid Build Coastguard Worker                                           EGL_FALSE);
543*8975f5c5SAndroid Build Coastguard Worker     Error error = eglSurface->querySurfacePointerANGLE(attribute, value);
544*8975f5c5SAndroid Build Coastguard Worker     if (error.isError())
545*8975f5c5SAndroid Build Coastguard Worker     {
546*8975f5c5SAndroid Build Coastguard Worker         thread->setError(error, "eglQuerySurfacePointerANGLE",
547*8975f5c5SAndroid Build Coastguard Worker                          GetSurfaceIfValid(display, surfaceID));
548*8975f5c5SAndroid Build Coastguard Worker         return EGL_FALSE;
549*8975f5c5SAndroid Build Coastguard Worker     }
550*8975f5c5SAndroid Build Coastguard Worker 
551*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
552*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
553*8975f5c5SAndroid Build Coastguard Worker }
554*8975f5c5SAndroid Build Coastguard Worker 
SetBlobCacheFuncsANDROID(Thread * thread,Display * display,EGLSetBlobFuncANDROID set,EGLGetBlobFuncANDROID get)555*8975f5c5SAndroid Build Coastguard Worker void SetBlobCacheFuncsANDROID(Thread *thread,
556*8975f5c5SAndroid Build Coastguard Worker                               Display *display,
557*8975f5c5SAndroid Build Coastguard Worker                               EGLSetBlobFuncANDROID set,
558*8975f5c5SAndroid Build Coastguard Worker                               EGLGetBlobFuncANDROID get)
559*8975f5c5SAndroid Build Coastguard Worker {
560*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL(thread, display->prepareForCall(), "eglSetBlobCacheFuncsANDROID",
561*8975f5c5SAndroid Build Coastguard Worker                                    GetDisplayIfValid(display));
562*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
563*8975f5c5SAndroid Build Coastguard Worker     display->setBlobCacheFuncs(set, get);
564*8975f5c5SAndroid Build Coastguard Worker }
565*8975f5c5SAndroid Build Coastguard Worker 
SignalSyncKHR(Thread * thread,Display * display,SyncID syncID,EGLenum mode)566*8975f5c5SAndroid Build Coastguard Worker EGLBoolean SignalSyncKHR(Thread *thread, Display *display, SyncID syncID, EGLenum mode)
567*8975f5c5SAndroid Build Coastguard Worker {
568*8975f5c5SAndroid Build Coastguard Worker     gl::Context *currentContext = thread->getContext();
569*8975f5c5SAndroid Build Coastguard Worker     Sync *syncObject            = display->getSync(syncID);
570*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, syncObject->signal(display, currentContext, mode),
571*8975f5c5SAndroid Build Coastguard Worker                          "eglSignalSyncKHR", GetSyncIfValid(display, syncID), EGL_FALSE);
572*8975f5c5SAndroid Build Coastguard Worker 
573*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
574*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
575*8975f5c5SAndroid Build Coastguard Worker }
576*8975f5c5SAndroid Build Coastguard Worker 
StreamAttribKHR(Thread * thread,Display * display,Stream * streamObject,EGLenum attribute,EGLint value)577*8975f5c5SAndroid Build Coastguard Worker EGLBoolean StreamAttribKHR(Thread *thread,
578*8975f5c5SAndroid Build Coastguard Worker                            Display *display,
579*8975f5c5SAndroid Build Coastguard Worker                            Stream *streamObject,
580*8975f5c5SAndroid Build Coastguard Worker                            EGLenum attribute,
581*8975f5c5SAndroid Build Coastguard Worker                            EGLint value)
582*8975f5c5SAndroid Build Coastguard Worker {
583*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglStreamAttribKHR",
584*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
585*8975f5c5SAndroid Build Coastguard Worker     switch (attribute)
586*8975f5c5SAndroid Build Coastguard Worker     {
587*8975f5c5SAndroid Build Coastguard Worker         case EGL_CONSUMER_LATENCY_USEC_KHR:
588*8975f5c5SAndroid Build Coastguard Worker             streamObject->setConsumerLatency(value);
589*8975f5c5SAndroid Build Coastguard Worker             break;
590*8975f5c5SAndroid Build Coastguard Worker         case EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR:
591*8975f5c5SAndroid Build Coastguard Worker             streamObject->setConsumerAcquireTimeout(value);
592*8975f5c5SAndroid Build Coastguard Worker             break;
593*8975f5c5SAndroid Build Coastguard Worker         default:
594*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
595*8975f5c5SAndroid Build Coastguard Worker     }
596*8975f5c5SAndroid Build Coastguard Worker 
597*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
598*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
599*8975f5c5SAndroid Build Coastguard Worker }
600*8975f5c5SAndroid Build Coastguard Worker 
StreamConsumerAcquireKHR(Thread * thread,Display * display,Stream * streamObject)601*8975f5c5SAndroid Build Coastguard Worker EGLBoolean StreamConsumerAcquireKHR(Thread *thread, Display *display, Stream *streamObject)
602*8975f5c5SAndroid Build Coastguard Worker {
603*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
604*8975f5c5SAndroid Build Coastguard Worker                                           "eglStreamConsumerAcquireKHR", GetDisplayIfValid(display),
605*8975f5c5SAndroid Build Coastguard Worker                                           EGL_FALSE);
606*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, streamObject->consumerAcquire(thread->getContext()),
607*8975f5c5SAndroid Build Coastguard Worker                          "eglStreamConsumerAcquireKHR", GetStreamIfValid(display, streamObject),
608*8975f5c5SAndroid Build Coastguard Worker                          EGL_FALSE);
609*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
610*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
611*8975f5c5SAndroid Build Coastguard Worker }
612*8975f5c5SAndroid Build Coastguard Worker 
StreamConsumerGLTextureExternalKHR(Thread * thread,Display * display,Stream * streamObject)613*8975f5c5SAndroid Build Coastguard Worker EGLBoolean StreamConsumerGLTextureExternalKHR(Thread *thread,
614*8975f5c5SAndroid Build Coastguard Worker                                               Display *display,
615*8975f5c5SAndroid Build Coastguard Worker                                               Stream *streamObject)
616*8975f5c5SAndroid Build Coastguard Worker {
617*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
618*8975f5c5SAndroid Build Coastguard Worker                                           "eglStreamConsumerGLTextureExternalKHR",
619*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
620*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(
621*8975f5c5SAndroid Build Coastguard Worker         thread, streamObject->createConsumerGLTextureExternal(AttributeMap(), thread->getContext()),
622*8975f5c5SAndroid Build Coastguard Worker         "eglStreamConsumerGLTextureExternalKHR", GetStreamIfValid(display, streamObject),
623*8975f5c5SAndroid Build Coastguard Worker         EGL_FALSE);
624*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
625*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
626*8975f5c5SAndroid Build Coastguard Worker }
627*8975f5c5SAndroid Build Coastguard Worker 
StreamConsumerGLTextureExternalAttribsNV(Thread * thread,Display * display,Stream * streamObject,const AttributeMap & attributes)628*8975f5c5SAndroid Build Coastguard Worker EGLBoolean StreamConsumerGLTextureExternalAttribsNV(Thread *thread,
629*8975f5c5SAndroid Build Coastguard Worker                                                     Display *display,
630*8975f5c5SAndroid Build Coastguard Worker                                                     Stream *streamObject,
631*8975f5c5SAndroid Build Coastguard Worker                                                     const AttributeMap &attributes)
632*8975f5c5SAndroid Build Coastguard Worker {
633*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
634*8975f5c5SAndroid Build Coastguard Worker                                           "eglStreamConsumerGLTextureExternalAttribsNV",
635*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
636*8975f5c5SAndroid Build Coastguard Worker 
637*8975f5c5SAndroid Build Coastguard Worker     gl::Context *context = gl::GetValidGlobalContext();
638*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, streamObject->createConsumerGLTextureExternal(attributes, context),
639*8975f5c5SAndroid Build Coastguard Worker                          "eglStreamConsumerGLTextureExternalAttribsNV",
640*8975f5c5SAndroid Build Coastguard Worker                          GetStreamIfValid(display, streamObject), EGL_FALSE);
641*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
642*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
643*8975f5c5SAndroid Build Coastguard Worker }
644*8975f5c5SAndroid Build Coastguard Worker 
StreamConsumerReleaseKHR(Thread * thread,Display * display,Stream * streamObject)645*8975f5c5SAndroid Build Coastguard Worker EGLBoolean StreamConsumerReleaseKHR(Thread *thread, Display *display, Stream *streamObject)
646*8975f5c5SAndroid Build Coastguard Worker {
647*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
648*8975f5c5SAndroid Build Coastguard Worker                                           "eglStreamConsumerReleaseKHR", GetDisplayIfValid(display),
649*8975f5c5SAndroid Build Coastguard Worker                                           EGL_FALSE);
650*8975f5c5SAndroid Build Coastguard Worker 
651*8975f5c5SAndroid Build Coastguard Worker     gl::Context *context = gl::GetValidGlobalContext();
652*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, streamObject->consumerRelease(context),
653*8975f5c5SAndroid Build Coastguard Worker                          "eglStreamConsumerReleaseKHR", GetStreamIfValid(display, streamObject),
654*8975f5c5SAndroid Build Coastguard Worker                          EGL_FALSE);
655*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
656*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
657*8975f5c5SAndroid Build Coastguard Worker }
658*8975f5c5SAndroid Build Coastguard Worker 
SwapBuffersWithDamageKHR(Thread * thread,Display * display,SurfaceID surfaceID,const EGLint * rects,EGLint n_rects)659*8975f5c5SAndroid Build Coastguard Worker EGLBoolean SwapBuffersWithDamageKHR(Thread *thread,
660*8975f5c5SAndroid Build Coastguard Worker                                     Display *display,
661*8975f5c5SAndroid Build Coastguard Worker                                     SurfaceID surfaceID,
662*8975f5c5SAndroid Build Coastguard Worker                                     const EGLint *rects,
663*8975f5c5SAndroid Build Coastguard Worker                                     EGLint n_rects)
664*8975f5c5SAndroid Build Coastguard Worker {
665*8975f5c5SAndroid Build Coastguard Worker     Surface *eglSurface = display->getSurface(surfaceID);
666*8975f5c5SAndroid Build Coastguard Worker 
667*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
668*8975f5c5SAndroid Build Coastguard Worker                                           "eglSwapBuffersWithDamageKHR", GetDisplayIfValid(display),
669*8975f5c5SAndroid Build Coastguard Worker                                           EGL_FALSE);
670*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, eglSurface->swapWithDamage(thread->getContext(), rects, n_rects),
671*8975f5c5SAndroid Build Coastguard Worker                          "eglSwapBuffersWithDamageKHR", GetSurfaceIfValid(display, surfaceID),
672*8975f5c5SAndroid Build Coastguard Worker                          EGL_FALSE);
673*8975f5c5SAndroid Build Coastguard Worker 
674*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
675*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
676*8975f5c5SAndroid Build Coastguard Worker }
677*8975f5c5SAndroid Build Coastguard Worker 
PrepareSwapBuffersANGLE(Thread * thread,Display * display,SurfaceID surfaceID)678*8975f5c5SAndroid Build Coastguard Worker EGLBoolean PrepareSwapBuffersANGLE(Thread *thread, Display *display, SurfaceID surfaceID)
679*8975f5c5SAndroid Build Coastguard Worker {
680*8975f5c5SAndroid Build Coastguard Worker     Surface *eglSurface = display->getSurface(surfaceID);
681*8975f5c5SAndroid Build Coastguard Worker 
682*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
683*8975f5c5SAndroid Build Coastguard Worker                                           "eglPrepareSwapBuffersANGLE", GetDisplayIfValid(display),
684*8975f5c5SAndroid Build Coastguard Worker                                           EGL_FALSE);
685*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, eglSurface->prepareSwap(thread->getContext()),
686*8975f5c5SAndroid Build Coastguard Worker                          "eglPrepareSwapBuffersANGLE", eglSurface, EGL_FALSE);
687*8975f5c5SAndroid Build Coastguard Worker 
688*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
689*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
690*8975f5c5SAndroid Build Coastguard Worker }
691*8975f5c5SAndroid Build Coastguard Worker 
WaitSyncKHR(Thread * thread,Display * display,SyncID syncID,EGLint flags)692*8975f5c5SAndroid Build Coastguard Worker EGLint WaitSyncKHR(Thread *thread, Display *display, SyncID syncID, EGLint flags)
693*8975f5c5SAndroid Build Coastguard Worker {
694*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglWaitSync",
695*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
696*8975f5c5SAndroid Build Coastguard Worker     gl::Context *currentContext = thread->getContext();
697*8975f5c5SAndroid Build Coastguard Worker     Sync *syncObject            = display->getSync(syncID);
698*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, syncObject->serverWait(display, currentContext, flags),
699*8975f5c5SAndroid Build Coastguard Worker                          "eglWaitSync", GetSyncIfValid(display, syncID), EGL_FALSE);
700*8975f5c5SAndroid Build Coastguard Worker 
701*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
702*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
703*8975f5c5SAndroid Build Coastguard Worker }
704*8975f5c5SAndroid Build Coastguard Worker 
CreateDeviceANGLE(Thread * thread,EGLint device_type,void * native_device,const EGLAttrib * attrib_list)705*8975f5c5SAndroid Build Coastguard Worker EGLDeviceEXT CreateDeviceANGLE(Thread *thread,
706*8975f5c5SAndroid Build Coastguard Worker                                EGLint device_type,
707*8975f5c5SAndroid Build Coastguard Worker                                void *native_device,
708*8975f5c5SAndroid Build Coastguard Worker                                const EGLAttrib *attrib_list)
709*8975f5c5SAndroid Build Coastguard Worker {
710*8975f5c5SAndroid Build Coastguard Worker     Device *device = nullptr;
711*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, Device::CreateDevice(device_type, native_device, &device),
712*8975f5c5SAndroid Build Coastguard Worker                          "eglCreateDeviceANGLE", GetThreadIfValid(thread), EGL_NO_DEVICE_EXT);
713*8975f5c5SAndroid Build Coastguard Worker 
714*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
715*8975f5c5SAndroid Build Coastguard Worker     return device;
716*8975f5c5SAndroid Build Coastguard Worker }
717*8975f5c5SAndroid Build Coastguard Worker 
ReleaseDeviceANGLE(Thread * thread,Device * dev)718*8975f5c5SAndroid Build Coastguard Worker EGLBoolean ReleaseDeviceANGLE(Thread *thread, Device *dev)
719*8975f5c5SAndroid Build Coastguard Worker {
720*8975f5c5SAndroid Build Coastguard Worker     SafeDelete(dev);
721*8975f5c5SAndroid Build Coastguard Worker 
722*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
723*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
724*8975f5c5SAndroid Build Coastguard Worker }
725*8975f5c5SAndroid Build Coastguard Worker 
CreateStreamProducerD3DTextureANGLE(Thread * thread,Display * display,Stream * streamObject,const AttributeMap & attributes)726*8975f5c5SAndroid Build Coastguard Worker EGLBoolean CreateStreamProducerD3DTextureANGLE(Thread *thread,
727*8975f5c5SAndroid Build Coastguard Worker                                                Display *display,
728*8975f5c5SAndroid Build Coastguard Worker                                                Stream *streamObject,
729*8975f5c5SAndroid Build Coastguard Worker                                                const AttributeMap &attributes)
730*8975f5c5SAndroid Build Coastguard Worker {
731*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
732*8975f5c5SAndroid Build Coastguard Worker                                           "eglCreateStreamProducerD3DTextureANGLE",
733*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
734*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, streamObject->createProducerD3D11Texture(attributes),
735*8975f5c5SAndroid Build Coastguard Worker                          "eglCreateStreamProducerD3DTextureANGLE",
736*8975f5c5SAndroid Build Coastguard Worker                          GetStreamIfValid(display, streamObject), EGL_FALSE);
737*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
738*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
739*8975f5c5SAndroid Build Coastguard Worker }
740*8975f5c5SAndroid Build Coastguard Worker 
StreamPostD3DTextureANGLE(Thread * thread,Display * display,Stream * streamObject,void * texture,const AttributeMap & attributes)741*8975f5c5SAndroid Build Coastguard Worker EGLBoolean StreamPostD3DTextureANGLE(Thread *thread,
742*8975f5c5SAndroid Build Coastguard Worker                                      Display *display,
743*8975f5c5SAndroid Build Coastguard Worker                                      Stream *streamObject,
744*8975f5c5SAndroid Build Coastguard Worker                                      void *texture,
745*8975f5c5SAndroid Build Coastguard Worker                                      const AttributeMap &attributes)
746*8975f5c5SAndroid Build Coastguard Worker {
747*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
748*8975f5c5SAndroid Build Coastguard Worker                                           "eglStreamPostD3DTextureANGLE",
749*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
750*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, streamObject->postD3D11Texture(texture, attributes),
751*8975f5c5SAndroid Build Coastguard Worker                          "eglStreamPostD3DTextureANGLE", GetStreamIfValid(display, streamObject),
752*8975f5c5SAndroid Build Coastguard Worker                          EGL_FALSE);
753*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
754*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
755*8975f5c5SAndroid Build Coastguard Worker }
756*8975f5c5SAndroid Build Coastguard Worker 
GetMscRateANGLE(Thread * thread,Display * display,SurfaceID surfaceID,EGLint * numerator,EGLint * denominator)757*8975f5c5SAndroid Build Coastguard Worker EGLBoolean GetMscRateANGLE(Thread *thread,
758*8975f5c5SAndroid Build Coastguard Worker                            Display *display,
759*8975f5c5SAndroid Build Coastguard Worker                            SurfaceID surfaceID,
760*8975f5c5SAndroid Build Coastguard Worker                            EGLint *numerator,
761*8975f5c5SAndroid Build Coastguard Worker                            EGLint *denominator)
762*8975f5c5SAndroid Build Coastguard Worker {
763*8975f5c5SAndroid Build Coastguard Worker     Surface *eglSurface = display->getSurface(surfaceID);
764*8975f5c5SAndroid Build Coastguard Worker 
765*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglGetMscRateANGLE",
766*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
767*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, eglSurface->getMscRate(numerator, denominator),
768*8975f5c5SAndroid Build Coastguard Worker                          "eglGetMscRateANGLE", GetSurfaceIfValid(display, surfaceID), EGL_FALSE);
769*8975f5c5SAndroid Build Coastguard Worker 
770*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
771*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
772*8975f5c5SAndroid Build Coastguard Worker }
773*8975f5c5SAndroid Build Coastguard Worker 
GetSyncValuesCHROMIUM(Thread * thread,Display * display,SurfaceID surfaceID,EGLuint64KHR * ust,EGLuint64KHR * msc,EGLuint64KHR * sbc)774*8975f5c5SAndroid Build Coastguard Worker EGLBoolean GetSyncValuesCHROMIUM(Thread *thread,
775*8975f5c5SAndroid Build Coastguard Worker                                  Display *display,
776*8975f5c5SAndroid Build Coastguard Worker                                  SurfaceID surfaceID,
777*8975f5c5SAndroid Build Coastguard Worker                                  EGLuint64KHR *ust,
778*8975f5c5SAndroid Build Coastguard Worker                                  EGLuint64KHR *msc,
779*8975f5c5SAndroid Build Coastguard Worker                                  EGLuint64KHR *sbc)
780*8975f5c5SAndroid Build Coastguard Worker {
781*8975f5c5SAndroid Build Coastguard Worker     Surface *eglSurface = display->getSurface(surfaceID);
782*8975f5c5SAndroid Build Coastguard Worker 
783*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
784*8975f5c5SAndroid Build Coastguard Worker                                           "eglGetSyncValuesCHROMIUM", GetDisplayIfValid(display),
785*8975f5c5SAndroid Build Coastguard Worker                                           EGL_FALSE);
786*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, eglSurface->getSyncValues(ust, msc, sbc),
787*8975f5c5SAndroid Build Coastguard Worker                          "eglGetSyncValuesCHROMIUM", GetSurfaceIfValid(display, surfaceID),
788*8975f5c5SAndroid Build Coastguard Worker                          EGL_FALSE);
789*8975f5c5SAndroid Build Coastguard Worker 
790*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
791*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
792*8975f5c5SAndroid Build Coastguard Worker }
793*8975f5c5SAndroid Build Coastguard Worker 
ProgramCacheGetAttribANGLE(Thread * thread,Display * display,EGLenum attrib)794*8975f5c5SAndroid Build Coastguard Worker EGLint ProgramCacheGetAttribANGLE(Thread *thread, Display *display, EGLenum attrib)
795*8975f5c5SAndroid Build Coastguard Worker {
796*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
797*8975f5c5SAndroid Build Coastguard Worker                                           "eglProgramCacheGetAttribANGLE",
798*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), 0);
799*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
800*8975f5c5SAndroid Build Coastguard Worker     return display->programCacheGetAttrib(attrib);
801*8975f5c5SAndroid Build Coastguard Worker }
802*8975f5c5SAndroid Build Coastguard Worker 
ProgramCacheQueryANGLE(Thread * thread,Display * display,EGLint index,void * key,EGLint * keysize,void * binary,EGLint * binarysize)803*8975f5c5SAndroid Build Coastguard Worker void ProgramCacheQueryANGLE(Thread *thread,
804*8975f5c5SAndroid Build Coastguard Worker                             Display *display,
805*8975f5c5SAndroid Build Coastguard Worker                             EGLint index,
806*8975f5c5SAndroid Build Coastguard Worker                             void *key,
807*8975f5c5SAndroid Build Coastguard Worker                             EGLint *keysize,
808*8975f5c5SAndroid Build Coastguard Worker                             void *binary,
809*8975f5c5SAndroid Build Coastguard Worker                             EGLint *binarysize)
810*8975f5c5SAndroid Build Coastguard Worker {
811*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL(thread, display->prepareForCall(), "eglProgramCacheQueryANGLE",
812*8975f5c5SAndroid Build Coastguard Worker                                    GetDisplayIfValid(display));
813*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY(thread, display->programCacheQuery(index, key, keysize, binary, binarysize),
814*8975f5c5SAndroid Build Coastguard Worker                   "eglProgramCacheQueryANGLE", GetDisplayIfValid(display));
815*8975f5c5SAndroid Build Coastguard Worker 
816*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
817*8975f5c5SAndroid Build Coastguard Worker }
818*8975f5c5SAndroid Build Coastguard Worker 
ProgramCachePopulateANGLE(Thread * thread,Display * display,const void * key,EGLint keysize,const void * binary,EGLint binarysize)819*8975f5c5SAndroid Build Coastguard Worker void ProgramCachePopulateANGLE(Thread *thread,
820*8975f5c5SAndroid Build Coastguard Worker                                Display *display,
821*8975f5c5SAndroid Build Coastguard Worker                                const void *key,
822*8975f5c5SAndroid Build Coastguard Worker                                EGLint keysize,
823*8975f5c5SAndroid Build Coastguard Worker                                const void *binary,
824*8975f5c5SAndroid Build Coastguard Worker                                EGLint binarysize)
825*8975f5c5SAndroid Build Coastguard Worker {
826*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL(thread, display->prepareForCall(),
827*8975f5c5SAndroid Build Coastguard Worker                                    "eglProgramCachePopulateANGLE", GetDisplayIfValid(display));
828*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY(thread, display->programCachePopulate(key, keysize, binary, binarysize),
829*8975f5c5SAndroid Build Coastguard Worker                   "eglProgramCachePopulateANGLE", GetDisplayIfValid(display));
830*8975f5c5SAndroid Build Coastguard Worker 
831*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
832*8975f5c5SAndroid Build Coastguard Worker }
833*8975f5c5SAndroid Build Coastguard Worker 
ProgramCacheResizeANGLE(Thread * thread,Display * display,EGLint limit,EGLint mode)834*8975f5c5SAndroid Build Coastguard Worker EGLint ProgramCacheResizeANGLE(Thread *thread, Display *display, EGLint limit, EGLint mode)
835*8975f5c5SAndroid Build Coastguard Worker {
836*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
837*8975f5c5SAndroid Build Coastguard Worker                                           "eglProgramCacheResizeANGLE", GetDisplayIfValid(display),
838*8975f5c5SAndroid Build Coastguard Worker                                           0);
839*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
840*8975f5c5SAndroid Build Coastguard Worker     return display->programCacheResize(limit, mode);
841*8975f5c5SAndroid Build Coastguard Worker }
842*8975f5c5SAndroid Build Coastguard Worker 
QueryStringiANGLE(Thread * thread,Display * display,EGLint name,EGLint index)843*8975f5c5SAndroid Build Coastguard Worker const char *QueryStringiANGLE(Thread *thread, Display *display, EGLint name, EGLint index)
844*8975f5c5SAndroid Build Coastguard Worker {
845*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglQueryStringiANGLE",
846*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), nullptr);
847*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
848*8975f5c5SAndroid Build Coastguard Worker     return display->queryStringi(name, index);
849*8975f5c5SAndroid Build Coastguard Worker }
850*8975f5c5SAndroid Build Coastguard Worker 
SwapBuffersWithFrameTokenANGLE(Thread * thread,Display * display,SurfaceID surfaceID,EGLFrameTokenANGLE frametoken)851*8975f5c5SAndroid Build Coastguard Worker EGLBoolean SwapBuffersWithFrameTokenANGLE(Thread *thread,
852*8975f5c5SAndroid Build Coastguard Worker                                           Display *display,
853*8975f5c5SAndroid Build Coastguard Worker                                           SurfaceID surfaceID,
854*8975f5c5SAndroid Build Coastguard Worker                                           EGLFrameTokenANGLE frametoken)
855*8975f5c5SAndroid Build Coastguard Worker {
856*8975f5c5SAndroid Build Coastguard Worker     Surface *eglSurface = display->getSurface(surfaceID);
857*8975f5c5SAndroid Build Coastguard Worker 
858*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
859*8975f5c5SAndroid Build Coastguard Worker                                           "eglSwapBuffersWithFrameTokenANGLE",
860*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
861*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, eglSurface->swapWithFrameToken(thread->getContext(), frametoken),
862*8975f5c5SAndroid Build Coastguard Worker                          "eglSwapBuffersWithFrameTokenANGLE", GetDisplayIfValid(display),
863*8975f5c5SAndroid Build Coastguard Worker                          EGL_FALSE);
864*8975f5c5SAndroid Build Coastguard Worker 
865*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
866*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
867*8975f5c5SAndroid Build Coastguard Worker }
868*8975f5c5SAndroid Build Coastguard Worker 
ReleaseHighPowerGPUANGLE(Thread * thread,Display * display,gl::ContextID contextID)869*8975f5c5SAndroid Build Coastguard Worker void ReleaseHighPowerGPUANGLE(Thread *thread, Display *display, gl::ContextID contextID)
870*8975f5c5SAndroid Build Coastguard Worker {
871*8975f5c5SAndroid Build Coastguard Worker     gl::Context *context = display->getContext(contextID);
872*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL(thread, display->prepareForCall(), "eglReleaseHighPowerGPUANGLE",
873*8975f5c5SAndroid Build Coastguard Worker                                    GetDisplayIfValid(display));
874*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY(thread, context->releaseHighPowerGPU(), "eglReleaseHighPowerGPUANGLE",
875*8975f5c5SAndroid Build Coastguard Worker                   GetDisplayIfValid(display));
876*8975f5c5SAndroid Build Coastguard Worker 
877*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
878*8975f5c5SAndroid Build Coastguard Worker }
879*8975f5c5SAndroid Build Coastguard Worker 
ReacquireHighPowerGPUANGLE(Thread * thread,Display * display,gl::ContextID contextID)880*8975f5c5SAndroid Build Coastguard Worker void ReacquireHighPowerGPUANGLE(Thread *thread, Display *display, gl::ContextID contextID)
881*8975f5c5SAndroid Build Coastguard Worker {
882*8975f5c5SAndroid Build Coastguard Worker     gl::Context *context = display->getContext(contextID);
883*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL(thread, display->prepareForCall(),
884*8975f5c5SAndroid Build Coastguard Worker                                    "eglReacquireHighPowerGPUANGLE", GetDisplayIfValid(display));
885*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY(thread, context->reacquireHighPowerGPU(), "eglReacquireHighPowerGPUANGLE",
886*8975f5c5SAndroid Build Coastguard Worker                   GetDisplayIfValid(display));
887*8975f5c5SAndroid Build Coastguard Worker 
888*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
889*8975f5c5SAndroid Build Coastguard Worker }
890*8975f5c5SAndroid Build Coastguard Worker 
HandleGPUSwitchANGLE(Thread * thread,Display * display)891*8975f5c5SAndroid Build Coastguard Worker void HandleGPUSwitchANGLE(Thread *thread, Display *display)
892*8975f5c5SAndroid Build Coastguard Worker {
893*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL(thread, display->prepareForCall(), "eglHandleGPUSwitchANGLE",
894*8975f5c5SAndroid Build Coastguard Worker                                    GetDisplayIfValid(display));
895*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY(thread, display->handleGPUSwitch(), "eglHandleGPUSwitchANGLE",
896*8975f5c5SAndroid Build Coastguard Worker                   GetDisplayIfValid(display));
897*8975f5c5SAndroid Build Coastguard Worker 
898*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
899*8975f5c5SAndroid Build Coastguard Worker }
900*8975f5c5SAndroid Build Coastguard Worker 
ForceGPUSwitchANGLE(Thread * thread,Display * display,EGLint gpuIDHigh,EGLint gpuIDLow)901*8975f5c5SAndroid Build Coastguard Worker void ForceGPUSwitchANGLE(Thread *thread, Display *display, EGLint gpuIDHigh, EGLint gpuIDLow)
902*8975f5c5SAndroid Build Coastguard Worker {
903*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL(thread, display->prepareForCall(), "eglForceGPUSwitchANGLE",
904*8975f5c5SAndroid Build Coastguard Worker                                    GetDisplayIfValid(display));
905*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY(thread, display->forceGPUSwitch(gpuIDHigh, gpuIDLow), "eglForceGPUSwitchANGLE",
906*8975f5c5SAndroid Build Coastguard Worker                   GetDisplayIfValid(display));
907*8975f5c5SAndroid Build Coastguard Worker 
908*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
909*8975f5c5SAndroid Build Coastguard Worker }
910*8975f5c5SAndroid Build Coastguard Worker 
WaitUntilWorkScheduledANGLE(Thread * thread,Display * display)911*8975f5c5SAndroid Build Coastguard Worker void WaitUntilWorkScheduledANGLE(Thread *thread, Display *display)
912*8975f5c5SAndroid Build Coastguard Worker {
913*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL(thread, display->prepareForCall(),
914*8975f5c5SAndroid Build Coastguard Worker                                    "eglWaitUntilWorkScheduledANGLE", GetDisplayIfValid(display));
915*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY(thread, display->waitUntilWorkScheduled(), "eglWaitUntilWorkScheduledANGLE",
916*8975f5c5SAndroid Build Coastguard Worker                   GetDisplayIfValid(display));
917*8975f5c5SAndroid Build Coastguard Worker 
918*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
919*8975f5c5SAndroid Build Coastguard Worker }
920*8975f5c5SAndroid Build Coastguard Worker 
QueryDisplayAttribANGLE(Thread * thread,Display * display,EGLint attribute,EGLAttrib * value)921*8975f5c5SAndroid Build Coastguard Worker EGLBoolean QueryDisplayAttribANGLE(Thread *thread,
922*8975f5c5SAndroid Build Coastguard Worker                                    Display *display,
923*8975f5c5SAndroid Build Coastguard Worker                                    EGLint attribute,
924*8975f5c5SAndroid Build Coastguard Worker                                    EGLAttrib *value)
925*8975f5c5SAndroid Build Coastguard Worker {
926*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
927*8975f5c5SAndroid Build Coastguard Worker                                           "eglQueryDisplayAttribEXT", GetDisplayIfValid(display),
928*8975f5c5SAndroid Build Coastguard Worker                                           EGL_FALSE);
929*8975f5c5SAndroid Build Coastguard Worker     *value = display->queryAttrib(attribute);
930*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
931*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
932*8975f5c5SAndroid Build Coastguard Worker }
933*8975f5c5SAndroid Build Coastguard Worker 
LockSurfaceKHR(Thread * thread,egl::Display * display,SurfaceID surfaceID,const AttributeMap & attributes)934*8975f5c5SAndroid Build Coastguard Worker EGLBoolean LockSurfaceKHR(Thread *thread,
935*8975f5c5SAndroid Build Coastguard Worker                           egl::Display *display,
936*8975f5c5SAndroid Build Coastguard Worker                           SurfaceID surfaceID,
937*8975f5c5SAndroid Build Coastguard Worker                           const AttributeMap &attributes)
938*8975f5c5SAndroid Build Coastguard Worker {
939*8975f5c5SAndroid Build Coastguard Worker     Surface *surface = display->getSurface(surfaceID);
940*8975f5c5SAndroid Build Coastguard Worker 
941*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglLockSurfaceKHR",
942*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
943*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, surface->lockSurfaceKHR(display, attributes), "eglLockSurfaceKHR",
944*8975f5c5SAndroid Build Coastguard Worker                          GetSurfaceIfValid(display, surfaceID), EGL_FALSE);
945*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
946*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
947*8975f5c5SAndroid Build Coastguard Worker }
948*8975f5c5SAndroid Build Coastguard Worker 
UnlockSurfaceKHR(Thread * thread,egl::Display * display,SurfaceID surfaceID)949*8975f5c5SAndroid Build Coastguard Worker EGLBoolean UnlockSurfaceKHR(Thread *thread, egl::Display *display, SurfaceID surfaceID)
950*8975f5c5SAndroid Build Coastguard Worker {
951*8975f5c5SAndroid Build Coastguard Worker     Surface *surface = display->getSurface(surfaceID);
952*8975f5c5SAndroid Build Coastguard Worker 
953*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglUnlockSurfaceKHR",
954*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
955*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, surface->unlockSurfaceKHR(display), "eglQuerySurface64KHR",
956*8975f5c5SAndroid Build Coastguard Worker                          GetSurfaceIfValid(display, surfaceID), EGL_FALSE);
957*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
958*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
959*8975f5c5SAndroid Build Coastguard Worker }
960*8975f5c5SAndroid Build Coastguard Worker 
QuerySurface64KHR(Thread * thread,egl::Display * display,SurfaceID surfaceID,EGLint attribute,EGLAttribKHR * value)961*8975f5c5SAndroid Build Coastguard Worker EGLBoolean QuerySurface64KHR(Thread *thread,
962*8975f5c5SAndroid Build Coastguard Worker                              egl::Display *display,
963*8975f5c5SAndroid Build Coastguard Worker                              SurfaceID surfaceID,
964*8975f5c5SAndroid Build Coastguard Worker                              EGLint attribute,
965*8975f5c5SAndroid Build Coastguard Worker                              EGLAttribKHR *value)
966*8975f5c5SAndroid Build Coastguard Worker {
967*8975f5c5SAndroid Build Coastguard Worker     Surface *surface = display->getSurface(surfaceID);
968*8975f5c5SAndroid Build Coastguard Worker 
969*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(), "eglQuerySurface64KHR",
970*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), EGL_FALSE);
971*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(
972*8975f5c5SAndroid Build Coastguard Worker         thread, QuerySurfaceAttrib64KHR(display, thread->getContext(), surface, attribute, value),
973*8975f5c5SAndroid Build Coastguard Worker         "eglQuerySurface64KHR", GetSurfaceIfValid(display, surfaceID), EGL_FALSE);
974*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
975*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
976*8975f5c5SAndroid Build Coastguard Worker }
977*8975f5c5SAndroid Build Coastguard Worker 
ExportVkImageANGLE(Thread * thread,egl::Display * display,egl::ImageID imageID,void * vk_image,void * vk_image_create_info)978*8975f5c5SAndroid Build Coastguard Worker EGLBoolean ExportVkImageANGLE(Thread *thread,
979*8975f5c5SAndroid Build Coastguard Worker                               egl::Display *display,
980*8975f5c5SAndroid Build Coastguard Worker                               egl::ImageID imageID,
981*8975f5c5SAndroid Build Coastguard Worker                               void *vk_image,
982*8975f5c5SAndroid Build Coastguard Worker                               void *vk_image_create_info)
983*8975f5c5SAndroid Build Coastguard Worker {
984*8975f5c5SAndroid Build Coastguard Worker     Image *image = display->getImage(imageID);
985*8975f5c5SAndroid Build Coastguard Worker 
986*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
987*8975f5c5SAndroid Build Coastguard Worker                                           "eglExportVkImageANGLE", GetDisplayIfValid(display),
988*8975f5c5SAndroid Build Coastguard Worker                                           EGL_FALSE);
989*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, image->exportVkImage(vk_image, vk_image_create_info),
990*8975f5c5SAndroid Build Coastguard Worker                          "eglExportVkImageANGLE", GetImageIfValid(display, imageID), EGL_FALSE);
991*8975f5c5SAndroid Build Coastguard Worker 
992*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
993*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
994*8975f5c5SAndroid Build Coastguard Worker }
995*8975f5c5SAndroid Build Coastguard Worker 
SetDamageRegionKHR(Thread * thread,egl::Display * display,SurfaceID surfaceID,EGLint * rects,EGLint n_rects)996*8975f5c5SAndroid Build Coastguard Worker EGLBoolean SetDamageRegionKHR(Thread *thread,
997*8975f5c5SAndroid Build Coastguard Worker                               egl::Display *display,
998*8975f5c5SAndroid Build Coastguard Worker                               SurfaceID surfaceID,
999*8975f5c5SAndroid Build Coastguard Worker                               EGLint *rects,
1000*8975f5c5SAndroid Build Coastguard Worker                               EGLint n_rects)
1001*8975f5c5SAndroid Build Coastguard Worker {
1002*8975f5c5SAndroid Build Coastguard Worker     Surface *surface = display->getSurface(surfaceID);
1003*8975f5c5SAndroid Build Coastguard Worker 
1004*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
1005*8975f5c5SAndroid Build Coastguard Worker                                           "eglSetDamageRegionKHR", GetDisplayIfValid(display),
1006*8975f5c5SAndroid Build Coastguard Worker                                           EGL_FALSE);
1007*8975f5c5SAndroid Build Coastguard Worker     surface->setDamageRegion(rects, n_rects);
1008*8975f5c5SAndroid Build Coastguard Worker 
1009*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
1010*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
1011*8975f5c5SAndroid Build Coastguard Worker }
1012*8975f5c5SAndroid Build Coastguard Worker 
QueryDmaBufFormatsEXT(Thread * thread,egl::Display * display,EGLint max_formats,EGLint * formats,EGLint * num_formats)1013*8975f5c5SAndroid Build Coastguard Worker EGLBoolean QueryDmaBufFormatsEXT(Thread *thread,
1014*8975f5c5SAndroid Build Coastguard Worker                                  egl::Display *display,
1015*8975f5c5SAndroid Build Coastguard Worker                                  EGLint max_formats,
1016*8975f5c5SAndroid Build Coastguard Worker                                  EGLint *formats,
1017*8975f5c5SAndroid Build Coastguard Worker                                  EGLint *num_formats)
1018*8975f5c5SAndroid Build Coastguard Worker {
1019*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
1020*8975f5c5SAndroid Build Coastguard Worker                                           "eglQueryDmaBufFormatsEXT", GetDisplayIfValid(display),
1021*8975f5c5SAndroid Build Coastguard Worker                                           EGL_FALSE);
1022*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, display->queryDmaBufFormats(max_formats, formats, num_formats),
1023*8975f5c5SAndroid Build Coastguard Worker                          "eglQueryDmaBufFormatsEXT", GetDisplayIfValid(display), EGL_FALSE);
1024*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
1025*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
1026*8975f5c5SAndroid Build Coastguard Worker }
1027*8975f5c5SAndroid Build Coastguard Worker 
QueryDmaBufModifiersEXT(Thread * thread,egl::Display * display,EGLint format,EGLint max_modifiers,EGLuint64KHR * modifiers,EGLBoolean * external_only,EGLint * num_modifiers)1028*8975f5c5SAndroid Build Coastguard Worker EGLBoolean QueryDmaBufModifiersEXT(Thread *thread,
1029*8975f5c5SAndroid Build Coastguard Worker                                    egl::Display *display,
1030*8975f5c5SAndroid Build Coastguard Worker                                    EGLint format,
1031*8975f5c5SAndroid Build Coastguard Worker                                    EGLint max_modifiers,
1032*8975f5c5SAndroid Build Coastguard Worker                                    EGLuint64KHR *modifiers,
1033*8975f5c5SAndroid Build Coastguard Worker                                    EGLBoolean *external_only,
1034*8975f5c5SAndroid Build Coastguard Worker                                    EGLint *num_modifiers)
1035*8975f5c5SAndroid Build Coastguard Worker {
1036*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
1037*8975f5c5SAndroid Build Coastguard Worker                                           "eglQueryDmaBufModifiersEXT", GetDisplayIfValid(display),
1038*8975f5c5SAndroid Build Coastguard Worker                                           EGL_FALSE);
1039*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread,
1040*8975f5c5SAndroid Build Coastguard Worker                          display->queryDmaBufModifiers(format, max_modifiers, modifiers,
1041*8975f5c5SAndroid Build Coastguard Worker                                                        external_only, num_modifiers),
1042*8975f5c5SAndroid Build Coastguard Worker                          "eglQueryDmaBufModifiersEXT", GetDisplayIfValid(display), EGL_FALSE);
1043*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
1044*8975f5c5SAndroid Build Coastguard Worker     return EGL_TRUE;
1045*8975f5c5SAndroid Build Coastguard Worker }
1046*8975f5c5SAndroid Build Coastguard Worker 
CopyMetalSharedEventANGLE(Thread * thread,Display * display,SyncID syncID)1047*8975f5c5SAndroid Build Coastguard Worker void *CopyMetalSharedEventANGLE(Thread *thread, Display *display, SyncID syncID)
1048*8975f5c5SAndroid Build Coastguard Worker {
1049*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL_RETURN(thread, display->prepareForCall(),
1050*8975f5c5SAndroid Build Coastguard Worker                                           "eglCopyMetalSharedEventANGLE",
1051*8975f5c5SAndroid Build Coastguard Worker                                           GetDisplayIfValid(display), nullptr);
1052*8975f5c5SAndroid Build Coastguard Worker     void *result     = nullptr;
1053*8975f5c5SAndroid Build Coastguard Worker     Sync *syncObject = display->getSync(syncID);
1054*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_RETURN(thread, syncObject->copyMetalSharedEventANGLE(display, &result),
1055*8975f5c5SAndroid Build Coastguard Worker                          "eglCopyMetalSharedEventANGLE", GetSyncIfValid(display, syncID), nullptr);
1056*8975f5c5SAndroid Build Coastguard Worker 
1057*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
1058*8975f5c5SAndroid Build Coastguard Worker     return result;
1059*8975f5c5SAndroid Build Coastguard Worker }
1060*8975f5c5SAndroid Build Coastguard Worker 
AcquireExternalContextANGLE(Thread * thread,egl::Display * display,SurfaceID drawAndReadPacked)1061*8975f5c5SAndroid Build Coastguard Worker void AcquireExternalContextANGLE(Thread *thread, egl::Display *display, SurfaceID drawAndReadPacked)
1062*8975f5c5SAndroid Build Coastguard Worker {
1063*8975f5c5SAndroid Build Coastguard Worker     Surface *eglSurface = display->getSurface(drawAndReadPacked);
1064*8975f5c5SAndroid Build Coastguard Worker 
1065*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL(thread, display->prepareForCall(),
1066*8975f5c5SAndroid Build Coastguard Worker                                    "eglAcquireExternalContextANGLE", GetDisplayIfValid(display));
1067*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY(thread, thread->getContext()->acquireExternalContext(eglSurface),
1068*8975f5c5SAndroid Build Coastguard Worker                   "eglAcquireExternalContextANGLE", GetDisplayIfValid(display));
1069*8975f5c5SAndroid Build Coastguard Worker 
1070*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
1071*8975f5c5SAndroid Build Coastguard Worker }
1072*8975f5c5SAndroid Build Coastguard Worker 
ReleaseExternalContextANGLE(Thread * thread,egl::Display * display)1073*8975f5c5SAndroid Build Coastguard Worker void ReleaseExternalContextANGLE(Thread *thread, egl::Display *display)
1074*8975f5c5SAndroid Build Coastguard Worker {
1075*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY_PREPARE_FOR_CALL(thread, display->prepareForCall(),
1076*8975f5c5SAndroid Build Coastguard Worker                                    "eglReleaseExternalContextANGLE", GetDisplayIfValid(display));
1077*8975f5c5SAndroid Build Coastguard Worker     ANGLE_EGL_TRY(thread, thread->getContext()->releaseExternalContext(),
1078*8975f5c5SAndroid Build Coastguard Worker                   "eglReleaseExternalContextANGLE", GetDisplayIfValid(display));
1079*8975f5c5SAndroid Build Coastguard Worker 
1080*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
1081*8975f5c5SAndroid Build Coastguard Worker }
1082*8975f5c5SAndroid Build Coastguard Worker 
SetValidationEnabledANGLE(Thread * thread,EGLBoolean validationState)1083*8975f5c5SAndroid Build Coastguard Worker void SetValidationEnabledANGLE(Thread *thread, EGLBoolean validationState)
1084*8975f5c5SAndroid Build Coastguard Worker {
1085*8975f5c5SAndroid Build Coastguard Worker     SetEGLValidationEnabled(validationState != EGL_FALSE);
1086*8975f5c5SAndroid Build Coastguard Worker     thread->setSuccess();
1087*8975f5c5SAndroid Build Coastguard Worker }
1088*8975f5c5SAndroid Build Coastguard Worker 
1089*8975f5c5SAndroid Build Coastguard Worker }  // namespace egl
1090