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