Line data Source code
1 : /* This Source Code Form is subject to the terms of the Mozilla Public
2 : * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
4 :
5 : #ifndef GLLIBRARYEGL_H_
6 : #define GLLIBRARYEGL_H_
7 :
8 : #if defined(MOZ_X11)
9 : #include "mozilla/X11Util.h"
10 : #endif
11 :
12 : #include "GLLibraryLoader.h"
13 : #include "mozilla/StaticMutex.h"
14 : #include "mozilla/ThreadLocal.h"
15 : #include "nsIFile.h"
16 : #include "GeckoProfiler.h"
17 :
18 : #include <bitset>
19 : #include <vector>
20 :
21 : #ifdef XP_WIN
22 : #ifndef WIN32_LEAN_AND_MEAN
23 : #define WIN32_LEAN_AND_MEAN 1
24 : #endif
25 :
26 : #include <windows.h>
27 :
28 : typedef HDC EGLNativeDisplayType;
29 : typedef HBITMAP EGLNativePixmapType;
30 : typedef HWND EGLNativeWindowType;
31 : #else
32 : typedef void* EGLNativeDisplayType;
33 : typedef void* EGLNativePixmapType;
34 : typedef void* EGLNativeWindowType;
35 :
36 : #ifdef ANDROID
37 : // We only need to explicitly dlopen egltrace
38 : // on android as we can use LD_PRELOAD or other tricks
39 : // on other platforms. We look for it in /data/local
40 : // as that's writeable by all users
41 : //
42 : // This should really go in GLLibraryEGL.cpp but we currently reference
43 : // APITRACE_LIB in GLContextProviderEGL.cpp. Further refactoring
44 : // will come in subsequent patches on Bug 732865
45 : #define APITRACE_LIB "/data/local/tmp/egltrace.so"
46 : #endif
47 : #endif
48 :
49 : #if defined(MOZ_X11)
50 : #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)mozilla::DefaultXDisplay())
51 : #else
52 : #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
53 : #endif
54 :
55 : namespace angle {
56 : class Platform;
57 : }
58 :
59 : namespace mozilla {
60 :
61 : namespace gfx {
62 : class DataSourceSurface;
63 : }
64 :
65 : namespace gl {
66 :
67 : class GLContext;
68 :
69 : void BeforeEGLCall(const char* funcName);
70 : void AfterEGLCall(const char* funcName);
71 :
72 0 : class GLLibraryEGL
73 : {
74 : public:
75 3 : GLLibraryEGL()
76 3 : : mSymbols{nullptr}
77 : , mInitialized(false)
78 : , mEGLLibrary(nullptr)
79 : , mEGLDisplay(EGL_NO_DISPLAY)
80 : , mIsANGLE(false)
81 3 : , mIsWARP(false)
82 3 : { }
83 :
84 : void InitClientExtensions();
85 : void InitDisplayExtensions();
86 :
87 : /**
88 : * Known GL extensions that can be queried by
89 : * IsExtensionSupported. The results of this are cached, and as
90 : * such it's safe to use this even in performance critical code.
91 : * If you add to this array, remember to add to the string names
92 : * in GLContext.cpp.
93 : */
94 : enum EGLExtensions {
95 : KHR_image_base,
96 : KHR_image_pixmap,
97 : KHR_gl_texture_2D_image,
98 : KHR_lock_surface,
99 : ANGLE_surface_d3d_texture_2d_share_handle,
100 : EXT_create_context_robustness,
101 : KHR_image,
102 : KHR_fence_sync,
103 : ANDROID_native_fence_sync,
104 : EGL_ANDROID_image_crop,
105 : ANGLE_platform_angle,
106 : ANGLE_platform_angle_d3d,
107 : ANGLE_d3d_share_handle_client_buffer,
108 : KHR_create_context,
109 : KHR_stream,
110 : KHR_stream_consumer_gltexture,
111 : EXT_device_base,
112 : EXT_device_query,
113 : NV_stream_consumer_gltexture_yuv,
114 : ANGLE_stream_producer_d3d_texture_nv12,
115 : Extensions_Max
116 : };
117 :
118 0 : bool IsExtensionSupported(EGLExtensions aKnownExtension) const {
119 0 : return mAvailableExtensions[aKnownExtension];
120 : }
121 :
122 0 : void MarkExtensionUnsupported(EGLExtensions aKnownExtension) {
123 0 : mAvailableExtensions[aKnownExtension] = false;
124 0 : }
125 :
126 : protected:
127 : std::bitset<Extensions_Max> mAvailableExtensions;
128 :
129 : public:
130 0 : GLLibraryLoader::PlatformLookupFunction GetLookupFunction() const {
131 0 : return (GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress;
132 : }
133 :
134 : ////
135 :
136 : #ifdef MOZ_WIDGET_ANDROID
137 : #define PROFILE_CALL AUTO_PROFILER_LABEL(__func__, GRAPHICS);
138 : #else
139 : #define PROFILE_CALL
140 : #endif
141 :
142 : #ifndef MOZ_FUNCTION_NAME
143 : # ifdef __GNUC__
144 : # define MOZ_FUNCTION_NAME __PRETTY_FUNCTION__
145 : # elif defined(_MSC_VER)
146 : # define MOZ_FUNCTION_NAME __FUNCTION__
147 : # else
148 : # define MOZ_FUNCTION_NAME __func__ // defined in C99, supported in various C++ compilers. Just raw function name.
149 : # endif
150 : #endif
151 :
152 : #ifdef DEBUG
153 : #define BEFORE_CALL BeforeEGLCall(MOZ_FUNCTION_NAME);
154 : #define AFTER_CALL AfterEGLCall(MOZ_FUNCTION_NAME);
155 : #else
156 : #define BEFORE_CALL
157 : #define AFTER_CALL
158 : #endif
159 :
160 : #define WRAP(X) \
161 : { \
162 : PROFILE_CALL \
163 : BEFORE_CALL \
164 : const auto ret = mSymbols. X ; \
165 : AFTER_CALL \
166 : return ret; \
167 : }
168 :
169 : #define VOID_WRAP(X) \
170 : { \
171 : PROFILE_CALL \
172 : BEFORE_CALL \
173 : mSymbols. X ; \
174 : AFTER_CALL \
175 : }
176 :
177 0 : EGLDisplay fGetDisplay(void* display_id) const
178 0 : WRAP( fGetDisplay(display_id) )
179 :
180 0 : EGLDisplay fGetPlatformDisplayEXT(EGLenum platform, void* native_display, const EGLint* attrib_list) const
181 0 : WRAP( fGetPlatformDisplayEXT(platform, native_display, attrib_list) )
182 :
183 : EGLBoolean fTerminate(EGLDisplay display) const
184 : WRAP( fTerminate(display) )
185 :
186 : EGLSurface fGetCurrentSurface(EGLint id) const
187 : WRAP( fGetCurrentSurface(id) )
188 :
189 0 : EGLContext fGetCurrentContext() const
190 0 : WRAP( fGetCurrentContext() )
191 :
192 0 : EGLBoolean fMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) const
193 0 : WRAP( fMakeCurrent(dpy, draw, read, ctx) )
194 :
195 0 : EGLBoolean fDestroyContext(EGLDisplay dpy, EGLContext ctx) const
196 0 : WRAP( fDestroyContext(dpy, ctx) )
197 :
198 0 : EGLContext fCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list) const
199 0 : WRAP( fCreateContext(dpy, config, share_context, attrib_list) )
200 :
201 0 : EGLBoolean fDestroySurface(EGLDisplay dpy, EGLSurface surface) const
202 0 : WRAP( fDestroySurface(dpy, surface) )
203 :
204 0 : EGLSurface fCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list) const
205 0 : WRAP( fCreateWindowSurface(dpy, config, win, attrib_list) )
206 :
207 0 : EGLSurface fCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list) const
208 0 : WRAP( fCreatePbufferSurface(dpy, config, attrib_list) )
209 :
210 : EGLSurface fCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) const
211 : WRAP( fCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list) )
212 :
213 : EGLSurface fCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list) const
214 : WRAP( fCreatePixmapSurface(dpy, config, pixmap, attrib_list) )
215 :
216 0 : EGLBoolean fBindAPI(EGLenum api) const
217 0 : WRAP( fBindAPI(api) )
218 :
219 0 : EGLBoolean fInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor) const
220 0 : WRAP( fInitialize(dpy, major, minor) )
221 :
222 0 : EGLBoolean fChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config) const
223 0 : WRAP( fChooseConfig(dpy, attrib_list, configs, config_size, num_config) )
224 :
225 0 : EGLint fGetError() const
226 0 : WRAP( fGetError() )
227 :
228 0 : EGLBoolean fGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value) const
229 0 : WRAP( fGetConfigAttrib(dpy, config, attribute, value) )
230 :
231 0 : EGLBoolean fGetConfigs(EGLDisplay dpy, EGLConfig* configs, EGLint config_size, EGLint* num_config) const
232 0 : WRAP( fGetConfigs(dpy, configs, config_size, num_config) )
233 :
234 : EGLBoolean fWaitNative(EGLint engine) const
235 : WRAP( fWaitNative(engine) )
236 :
237 : EGLCastToRelevantPtr fGetProcAddress(const char* procname) const
238 : WRAP( fGetProcAddress(procname) )
239 :
240 0 : EGLBoolean fSwapBuffers(EGLDisplay dpy, EGLSurface surface) const
241 0 : WRAP( fSwapBuffers(dpy, surface) )
242 :
243 : EGLBoolean fCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) const
244 : WRAP( fCopyBuffers(dpy, surface, target) )
245 :
246 0 : const GLubyte* fQueryString(EGLDisplay dpy, EGLint name) const
247 0 : WRAP( fQueryString(dpy, name) )
248 :
249 : EGLBoolean fQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value) const
250 : WRAP( fQueryContext(dpy, ctx, attribute, value) )
251 :
252 0 : EGLBoolean fBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) const
253 0 : WRAP( fBindTexImage(dpy, surface, buffer) )
254 :
255 0 : EGLBoolean fReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) const
256 0 : WRAP( fReleaseTexImage(dpy, surface, buffer) )
257 :
258 0 : EGLImage fCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint* attrib_list) const
259 0 : WRAP( fCreateImageKHR(dpy, ctx, target, buffer, attrib_list) )
260 :
261 0 : EGLBoolean fDestroyImage(EGLDisplay dpy, EGLImage image) const
262 0 : WRAP( fDestroyImageKHR(dpy, image) )
263 :
264 : EGLBoolean fLockSurface(EGLDisplay dpy, EGLSurface surface, const EGLint* attrib_list) const
265 : WRAP( fLockSurfaceKHR(dpy, surface, attrib_list) )
266 :
267 : EGLBoolean fUnlockSurface(EGLDisplay dpy, EGLSurface surface) const
268 : WRAP( fUnlockSurfaceKHR(dpy, surface) )
269 :
270 : EGLBoolean fQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* value) const
271 : WRAP( fQuerySurface(dpy, surface, attribute, value) )
272 :
273 : EGLBoolean fQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void** value) const
274 : WRAP( fQuerySurfacePointerANGLE(dpy, surface, attribute, value) )
275 :
276 0 : EGLSync fCreateSync(EGLDisplay dpy, EGLenum type, const EGLint* attrib_list) const
277 0 : WRAP( fCreateSyncKHR(dpy, type, attrib_list) )
278 :
279 0 : EGLBoolean fDestroySync(EGLDisplay dpy, EGLSync sync) const
280 0 : WRAP( fDestroySyncKHR(dpy, sync) )
281 :
282 0 : EGLint fClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout) const
283 0 : WRAP( fClientWaitSyncKHR(dpy, sync, flags, timeout) )
284 :
285 : EGLBoolean fGetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLint* value) const
286 : WRAP( fGetSyncAttribKHR(dpy, sync, attribute, value) )
287 :
288 : EGLint fDupNativeFenceFDANDROID(EGLDisplay dpy, EGLSync sync) const
289 : WRAP( fDupNativeFenceFDANDROID(dpy, sync) )
290 :
291 : //KHR_stream
292 : EGLStreamKHR fCreateStreamKHR(EGLDisplay dpy, const EGLint* attrib_list) const
293 : WRAP( fCreateStreamKHR(dpy, attrib_list) )
294 :
295 : EGLStreamKHR fDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream) const
296 : WRAP( fDestroyStreamKHR(dpy, stream) )
297 :
298 : EGLBoolean fQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint* value) const
299 : WRAP( fQueryStreamKHR(dpy, stream, attribute, value) )
300 :
301 : // KHR_stream_consumer_gltexture
302 : EGLBoolean fStreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream) const
303 : WRAP( fStreamConsumerAcquireKHR(dpy, stream) )
304 :
305 : EGLBoolean fStreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream) const
306 : WRAP( fStreamConsumerReleaseKHR(dpy, stream) )
307 :
308 : // EXT_device_base
309 : EGLBoolean fQueryDisplayAttribEXT(EGLDisplay dpy, EGLint attribute, EGLAttrib* value) const
310 : WRAP( fQueryDisplayAttribEXT(dpy, attribute, value) )
311 :
312 : // EXT_device_query
313 : EGLBoolean fQueryDeviceAttribEXT(EGLDeviceEXT device, EGLint attribute, EGLAttrib* value) const
314 : WRAP( fQueryDeviceAttribEXT(device, attribute, value) )
315 :
316 : // NV_stream_consumer_gltexture_yuv
317 : EGLBoolean fStreamConsumerGLTextureExternalAttribsNV(EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib* attrib_list) const
318 : WRAP( fStreamConsumerGLTextureExternalAttribsNV(dpy, stream, attrib_list) )
319 :
320 : // ANGLE_stream_producer_d3d_texture_nv12
321 : EGLBoolean fCreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib* attrib_list) const
322 : WRAP( fCreateStreamProducerD3DTextureNV12ANGLE(dpy, stream, attrib_list) )
323 :
324 : EGLBoolean fStreamPostD3DTextureNV12ANGLE(EGLDisplay dpy, EGLStreamKHR stream, void* texture, const EGLAttrib* attrib_list) const
325 : WRAP( fStreamPostD3DTextureNV12ANGLE(dpy, stream, texture, attrib_list) )
326 :
327 0 : void fANGLEPlatformInitialize(angle::Platform* platform) const
328 0 : VOID_WRAP( fANGLEPlatformInitialize(platform) )
329 :
330 : void fANGLEPlatformShutdown() const
331 : VOID_WRAP( fANGLEPlatformShutdown() )
332 :
333 : #undef WRAP
334 : #undef VOID_WRAP
335 : #undef PROFILE_CALL
336 : #undef BEFORE_CALL
337 : #undef AFTER_CALL
338 : #undef MOZ_FUNCTION_NAME
339 :
340 : ////
341 :
342 0 : EGLDisplay Display() {
343 0 : MOZ_ASSERT(mInitialized);
344 0 : return mEGLDisplay;
345 : }
346 :
347 0 : bool IsANGLE() const {
348 0 : MOZ_ASSERT(mInitialized);
349 0 : return mIsANGLE;
350 : }
351 :
352 0 : bool IsWARP() const {
353 0 : MOZ_ASSERT(mInitialized);
354 0 : return mIsWARP;
355 : }
356 :
357 0 : bool HasKHRImageBase() {
358 0 : return IsExtensionSupported(KHR_image) || IsExtensionSupported(KHR_image_base);
359 : }
360 :
361 : bool HasKHRImagePixmap() {
362 : return IsExtensionSupported(KHR_image) || IsExtensionSupported(KHR_image_pixmap);
363 : }
364 :
365 0 : bool HasKHRImageTexture2D() {
366 0 : return IsExtensionSupported(KHR_gl_texture_2D_image);
367 : }
368 :
369 : bool HasANGLESurfaceD3DTexture2DShareHandle() {
370 : return IsExtensionSupported(ANGLE_surface_d3d_texture_2d_share_handle);
371 : }
372 :
373 : bool ReadbackEGLImage(EGLImage image, gfx::DataSourceSurface* out_surface);
374 :
375 : bool EnsureInitialized(bool forceAccel, nsACString* const out_failureId);
376 :
377 : void DumpEGLConfig(EGLConfig cfg);
378 : void DumpEGLConfigs();
379 :
380 : private:
381 : struct {
382 : EGLCastToRelevantPtr (GLAPIENTRY * fGetProcAddress)(const char* procname);
383 : EGLDisplay (GLAPIENTRY * fGetDisplay)(void* display_id);
384 : EGLDisplay (GLAPIENTRY * fGetPlatformDisplayEXT)(EGLenum platform,
385 : void* native_display,
386 : const EGLint* attrib_list);
387 : EGLBoolean (GLAPIENTRY * fTerminate)(EGLDisplay dpy);
388 : EGLSurface (GLAPIENTRY * fGetCurrentSurface)(EGLint);
389 : EGLContext (GLAPIENTRY * fGetCurrentContext)(void);
390 : EGLBoolean (GLAPIENTRY * fMakeCurrent)(EGLDisplay dpy, EGLSurface draw,
391 : EGLSurface read, EGLContext ctx);
392 : EGLBoolean (GLAPIENTRY * fDestroyContext)(EGLDisplay dpy, EGLContext ctx);
393 : EGLContext (GLAPIENTRY * fCreateContext)(EGLDisplay dpy, EGLConfig config,
394 : EGLContext share_context,
395 : const EGLint* attrib_list);
396 : EGLBoolean (GLAPIENTRY * fDestroySurface)(EGLDisplay dpy, EGLSurface surface);
397 : EGLSurface (GLAPIENTRY * fCreateWindowSurface)(EGLDisplay dpy, EGLConfig config,
398 : EGLNativeWindowType win,
399 : const EGLint* attrib_list);
400 : EGLSurface (GLAPIENTRY * fCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config,
401 : const EGLint* attrib_list);
402 : EGLSurface (GLAPIENTRY * fCreatePbufferFromClientBuffer)(EGLDisplay dpy,
403 : EGLenum buftype,
404 : EGLClientBuffer buffer,
405 : EGLConfig config,
406 : const EGLint* attrib_list);
407 : EGLSurface (GLAPIENTRY * fCreatePixmapSurface)(EGLDisplay dpy, EGLConfig config,
408 : EGLNativePixmapType pixmap,
409 : const EGLint* attrib_list);
410 : EGLBoolean (GLAPIENTRY * fBindAPI)(EGLenum api);
411 : EGLBoolean (GLAPIENTRY * fInitialize)(EGLDisplay dpy, EGLint* major,
412 : EGLint* minor);
413 : EGLBoolean (GLAPIENTRY * fChooseConfig)(EGLDisplay dpy, const EGLint* attrib_list,
414 : EGLConfig* configs, EGLint config_size,
415 : EGLint* num_config);
416 : EGLint (GLAPIENTRY * fGetError)(void);
417 : EGLBoolean (GLAPIENTRY * fGetConfigAttrib)(EGLDisplay dpy, EGLConfig config,
418 : EGLint attribute, EGLint* value);
419 : EGLBoolean (GLAPIENTRY * fGetConfigs)(EGLDisplay dpy, EGLConfig* configs,
420 : EGLint config_size, EGLint* num_config);
421 : EGLBoolean (GLAPIENTRY * fWaitNative)(EGLint engine);
422 : EGLBoolean (GLAPIENTRY * fSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
423 : EGLBoolean (GLAPIENTRY * fCopyBuffers)(EGLDisplay dpy, EGLSurface surface,
424 : EGLNativePixmapType target);
425 : const GLubyte* (GLAPIENTRY * fQueryString)(EGLDisplay, EGLint name);
426 : EGLBoolean (GLAPIENTRY * fQueryContext)(EGLDisplay dpy, EGLContext ctx,
427 : EGLint attribute, EGLint* value);
428 : EGLBoolean (GLAPIENTRY * fBindTexImage)(EGLDisplay, EGLSurface surface,
429 : EGLint buffer);
430 : EGLBoolean (GLAPIENTRY * fReleaseTexImage)(EGLDisplay, EGLSurface surface,
431 : EGLint buffer);
432 : EGLImage (GLAPIENTRY * fCreateImageKHR)(EGLDisplay dpy, EGLContext ctx,
433 : EGLenum target, EGLClientBuffer buffer,
434 : const EGLint* attrib_list);
435 : EGLBoolean (GLAPIENTRY * fDestroyImageKHR)(EGLDisplay dpy, EGLImage image);
436 : // New extension which allow us to lock texture and get raw image pointer
437 : EGLBoolean (GLAPIENTRY * fLockSurfaceKHR)(EGLDisplay dpy, EGLSurface surface,
438 : const EGLint* attrib_list);
439 : EGLBoolean (GLAPIENTRY * fUnlockSurfaceKHR)(EGLDisplay dpy, EGLSurface surface);
440 : EGLBoolean (GLAPIENTRY * fQuerySurface)(EGLDisplay dpy, EGLSurface surface,
441 : EGLint attribute, EGLint* value);
442 : EGLBoolean (GLAPIENTRY * fQuerySurfacePointerANGLE)(EGLDisplay dpy,
443 : EGLSurface surface,
444 : EGLint attribute,
445 : void** value);
446 : EGLSync (GLAPIENTRY * fCreateSyncKHR)(EGLDisplay dpy, EGLenum type,
447 : const EGLint* attrib_list);
448 : EGLBoolean (GLAPIENTRY * fDestroySyncKHR)(EGLDisplay dpy, EGLSync sync);
449 : EGLint (GLAPIENTRY * fClientWaitSyncKHR)(EGLDisplay dpy, EGLSync sync,
450 : EGLint flags,
451 : EGLTime timeout);
452 : EGLBoolean (GLAPIENTRY * fGetSyncAttribKHR)(EGLDisplay dpy, EGLSync sync,
453 : EGLint attribute, EGLint* value);
454 : EGLint (GLAPIENTRY * fDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSync sync);
455 : //KHR_stream
456 : EGLStreamKHR (GLAPIENTRY * fCreateStreamKHR)(EGLDisplay dpy, const EGLint* attrib_list);
457 : EGLStreamKHR (GLAPIENTRY * fDestroyStreamKHR)(EGLDisplay dpy, EGLStreamKHR stream);
458 : EGLBoolean (GLAPIENTRY * fQueryStreamKHR)(EGLDisplay dpy,
459 : EGLStreamKHR stream,
460 : EGLenum attribute,
461 : EGLint* value);
462 : // KHR_stream_consumer_gltexture
463 : EGLBoolean (GLAPIENTRY * fStreamConsumerAcquireKHR)(EGLDisplay dpy,
464 : EGLStreamKHR stream);
465 : EGLBoolean (GLAPIENTRY * fStreamConsumerReleaseKHR)(EGLDisplay dpy,
466 : EGLStreamKHR stream);
467 : // EXT_device_base
468 : EGLBoolean (GLAPIENTRY * fQueryDisplayAttribEXT)(EGLDisplay dpy,
469 : EGLint attribute,
470 : EGLAttrib* value);
471 : // EXT_device_query
472 : EGLBoolean (GLAPIENTRY * fQueryDeviceAttribEXT)(EGLDeviceEXT device,
473 : EGLint attribute,
474 : EGLAttrib* value);
475 : // NV_stream_consumer_gltexture_yuv
476 : EGLBoolean (GLAPIENTRY * fStreamConsumerGLTextureExternalAttribsNV)(EGLDisplay dpy,
477 : EGLStreamKHR stream,
478 : const EGLAttrib* attrib_list);
479 : // ANGLE_stream_producer_d3d_texture_nv12
480 : EGLBoolean (GLAPIENTRY * fCreateStreamProducerD3DTextureNV12ANGLE)(EGLDisplay dpy,
481 : EGLStreamKHR stream,
482 : const EGLAttrib* attrib_list);
483 : EGLBoolean (GLAPIENTRY * fStreamPostD3DTextureNV12ANGLE)(EGLDisplay dpy,
484 : EGLStreamKHR stream,
485 : void* texture,
486 : const EGLAttrib* attrib_list);
487 : void (GLAPIENTRY * fANGLEPlatformInitialize)(angle::Platform* platform);
488 : void (GLAPIENTRY * fANGLEPlatformShutdown)();
489 : } mSymbols;
490 :
491 : public:
492 : #ifdef MOZ_B2G
493 : EGLContext CachedCurrentContext() {
494 : return sCurrentContext.get();
495 : }
496 : void UnsetCachedCurrentContext() {
497 : sCurrentContext.set(nullptr);
498 : }
499 : void SetCachedCurrentContext(EGLContext aCtx) {
500 : sCurrentContext.set(aCtx);
501 : }
502 : bool CachedCurrentContextMatches() {
503 : return sCurrentContext.get() == fGetCurrentContext();
504 : }
505 :
506 : private:
507 : static MOZ_THREAD_LOCAL(EGLContext) sCurrentContext;
508 : public:
509 :
510 : #else
511 0 : EGLContext CachedCurrentContext() {
512 0 : return nullptr;
513 : }
514 0 : void UnsetCachedCurrentContext() {}
515 0 : void SetCachedCurrentContext(EGLContext aCtx) { }
516 0 : bool CachedCurrentContextMatches() { return true; }
517 : #endif
518 :
519 : private:
520 : bool mInitialized;
521 : PRLibrary* mEGLLibrary;
522 : EGLDisplay mEGLDisplay;
523 : RefPtr<GLContext> mReadbackGL;
524 :
525 : bool mIsANGLE;
526 : bool mIsWARP;
527 : static StaticMutex sMutex;
528 : };
529 :
530 : extern GLLibraryEGL sEGLLibrary;
531 : #define EGL_DISPLAY() sEGLLibrary.Display()
532 :
533 : } /* namespace gl */
534 : } /* namespace mozilla */
535 :
536 : #endif /* GLLIBRARYEGL_H_ */
537 :
|