gfx/gl/GLLibraryEGL.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/gl/GLLibraryEGL.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,540 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef GLLIBRARYEGL_H_
     1.9 +#define GLLIBRARYEGL_H_
    1.10 +
    1.11 +#if defined(MOZ_X11)
    1.12 +#include "mozilla/X11Util.h"
    1.13 +#endif
    1.14 +
    1.15 +#include "GLLibraryLoader.h"
    1.16 +
    1.17 +#include "nsIFile.h"
    1.18 +
    1.19 +#include <bitset>
    1.20 +
    1.21 +#if defined(XP_WIN)
    1.22 +
    1.23 +#ifndef WIN32_LEAN_AND_MEAN
    1.24 +#define WIN32_LEAN_AND_MEAN 1
    1.25 +#endif
    1.26 +
    1.27 +#include <windows.h>
    1.28 +
    1.29 +typedef HDC EGLNativeDisplayType;
    1.30 +typedef HBITMAP EGLNativePixmapType;
    1.31 +typedef HWND EGLNativeWindowType;
    1.32 +
    1.33 +#define GET_NATIVE_WINDOW(aWidget) ((EGLNativeWindowType)aWidget->GetNativeData(NS_NATIVE_WINDOW))
    1.34 +
    1.35 +#else
    1.36 +typedef void *EGLNativeDisplayType;
    1.37 +typedef void *EGLNativePixmapType;
    1.38 +typedef void *EGLNativeWindowType;
    1.39 +
    1.40 +#ifdef ANDROID
    1.41 +// We only need to explicitly dlopen egltrace
    1.42 +// on android as we can use LD_PRELOAD or other tricks
    1.43 +// on other platforms. We look for it in /data/local
    1.44 +// as that's writeable by all users
    1.45 +//
    1.46 +// This should really go in GLLibraryEGL.cpp but we currently reference
    1.47 +// APITRACE_LIB in GLContextProviderEGL.cpp. Further refactoring
    1.48 +// will come in subsequent patches on Bug 732865
    1.49 +#define APITRACE_LIB "/data/local/tmp/egltrace.so"
    1.50 +
    1.51 +#ifdef MOZ_WIDGET_ANDROID
    1.52 +
    1.53 +#endif // MOZ_WIDGET_ANDROID
    1.54 +#endif // ANDROID
    1.55 +#endif
    1.56 +
    1.57 +#if defined(MOZ_X11)
    1.58 +#define EGL_DEFAULT_DISPLAY  ((EGLNativeDisplayType)mozilla::DefaultXDisplay())
    1.59 +#else
    1.60 +#define EGL_DEFAULT_DISPLAY  ((EGLNativeDisplayType)0)
    1.61 +#endif
    1.62 +
    1.63 +namespace mozilla {
    1.64 +namespace gl {
    1.65 +
    1.66 +#undef BEFORE_GL_CALL
    1.67 +#undef AFTER_GL_CALL
    1.68 +
    1.69 +#ifdef DEBUG
    1.70 +
    1.71 +#ifndef MOZ_FUNCTION_NAME
    1.72 +# ifdef __GNUC__
    1.73 +#  define MOZ_FUNCTION_NAME __PRETTY_FUNCTION__
    1.74 +# elif defined(_MSC_VER)
    1.75 +#  define MOZ_FUNCTION_NAME __FUNCTION__
    1.76 +# else
    1.77 +#  define MOZ_FUNCTION_NAME __func__  // defined in C99, supported in various C++ compilers. Just raw function name.
    1.78 +# endif
    1.79 +#endif
    1.80 +
    1.81 +#define BEFORE_GL_CALL do {          \
    1.82 +    BeforeGLCall(MOZ_FUNCTION_NAME); \
    1.83 +} while (0)
    1.84 +
    1.85 +#define AFTER_GL_CALL do {           \
    1.86 +    AfterGLCall(MOZ_FUNCTION_NAME);  \
    1.87 +} while (0)
    1.88 +// We rely on the fact that GLLibraryEGL.h #defines BEFORE_GL_CALL and
    1.89 +// AFTER_GL_CALL to nothing if !defined(DEBUG).
    1.90 +#else
    1.91 +#define BEFORE_GL_CALL
    1.92 +#define AFTER_GL_CALL
    1.93 +#endif
    1.94 +
    1.95 +class GLLibraryEGL
    1.96 +{
    1.97 +public:
    1.98 +    GLLibraryEGL() 
    1.99 +        : mInitialized(false),
   1.100 +          mEGLLibrary(nullptr),
   1.101 +          mIsANGLE(false)
   1.102 +    {
   1.103 +    }
   1.104 +
   1.105 +    void InitExtensions();
   1.106 +
   1.107 +    /**
   1.108 +     * Known GL extensions that can be queried by
   1.109 +     * IsExtensionSupported.  The results of this are cached, and as
   1.110 +     * such it's safe to use this even in performance critical code.
   1.111 +     * If you add to this array, remember to add to the string names
   1.112 +     * in GLContext.cpp.
   1.113 +     */
   1.114 +    enum EGLExtensions {
   1.115 +        KHR_image_base,
   1.116 +        KHR_image_pixmap,
   1.117 +        KHR_gl_texture_2D_image,
   1.118 +        KHR_lock_surface,
   1.119 +        ANGLE_surface_d3d_texture_2d_share_handle,
   1.120 +        EXT_create_context_robustness,
   1.121 +        KHR_image,
   1.122 +        KHR_fence_sync,
   1.123 +        Extensions_Max
   1.124 +    };
   1.125 +
   1.126 +    bool IsExtensionSupported(EGLExtensions aKnownExtension) const {
   1.127 +        return mAvailableExtensions[aKnownExtension];
   1.128 +    }
   1.129 +
   1.130 +    void MarkExtensionUnsupported(EGLExtensions aKnownExtension) {
   1.131 +        mAvailableExtensions[aKnownExtension] = false;
   1.132 +    }
   1.133 +
   1.134 +protected:
   1.135 +    std::bitset<Extensions_Max> mAvailableExtensions;
   1.136 +
   1.137 +public:
   1.138 +
   1.139 +    EGLDisplay fGetDisplay(void* display_id)
   1.140 +    {
   1.141 +        BEFORE_GL_CALL;
   1.142 +        EGLDisplay disp = mSymbols.fGetDisplay(display_id);
   1.143 +        AFTER_GL_CALL;
   1.144 +        return disp;
   1.145 +    }
   1.146 +
   1.147 +    EGLSurface fGetCurrentSurface(EGLint id)
   1.148 +    {
   1.149 +        BEFORE_GL_CALL;
   1.150 +        EGLSurface surf = mSymbols.fGetCurrentSurface(id);
   1.151 +        AFTER_GL_CALL;
   1.152 +        return surf;
   1.153 +    }
   1.154 +
   1.155 +    EGLContext fGetCurrentContext()
   1.156 +    {
   1.157 +        BEFORE_GL_CALL;
   1.158 +        EGLContext context = mSymbols.fGetCurrentContext();
   1.159 +        AFTER_GL_CALL;
   1.160 +        return context;
   1.161 +    }
   1.162 +
   1.163 +    EGLBoolean fMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
   1.164 +    {
   1.165 +        BEFORE_GL_CALL;
   1.166 +        EGLBoolean b = mSymbols.fMakeCurrent(dpy, draw, read, ctx);
   1.167 +        AFTER_GL_CALL;
   1.168 +        return b;
   1.169 +    }
   1.170 +
   1.171 +    EGLBoolean fDestroyContext(EGLDisplay dpy, EGLContext ctx)
   1.172 +    {
   1.173 +        BEFORE_GL_CALL;
   1.174 +        EGLBoolean b = mSymbols.fDestroyContext(dpy, ctx);
   1.175 +        AFTER_GL_CALL;
   1.176 +        return b;
   1.177 +    }
   1.178 +
   1.179 +    EGLContext fCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
   1.180 +    {
   1.181 +        BEFORE_GL_CALL;
   1.182 +        EGLContext ctx = mSymbols.fCreateContext(dpy, config, share_context, attrib_list);
   1.183 +        AFTER_GL_CALL;
   1.184 +        return ctx;
   1.185 +    }
   1.186 +
   1.187 +    EGLBoolean fDestroySurface(EGLDisplay dpy, EGLSurface surface)
   1.188 +    {
   1.189 +        BEFORE_GL_CALL;
   1.190 +        EGLBoolean b = mSymbols.fDestroySurface(dpy, surface);
   1.191 +        AFTER_GL_CALL;
   1.192 +        return b;
   1.193 +    }
   1.194 +
   1.195 +    EGLSurface fCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
   1.196 +    {
   1.197 +        BEFORE_GL_CALL;
   1.198 +        EGLSurface surf = mSymbols.fCreateWindowSurface(dpy, config, win, attrib_list);
   1.199 +        AFTER_GL_CALL;
   1.200 +        return surf;
   1.201 +    }
   1.202 +
   1.203 +    EGLSurface fCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
   1.204 +    {
   1.205 +        BEFORE_GL_CALL;
   1.206 +        EGLSurface surf = mSymbols.fCreatePbufferSurface(dpy, config, attrib_list);
   1.207 +        AFTER_GL_CALL;
   1.208 +        return surf;
   1.209 +    }
   1.210 +
   1.211 +    EGLSurface fCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list)
   1.212 +    {
   1.213 +        BEFORE_GL_CALL;
   1.214 +        EGLSurface surf = mSymbols.fCreatePixmapSurface(dpy, config, pixmap, attrib_list);
   1.215 +        AFTER_GL_CALL;
   1.216 +        return surf;
   1.217 +    }
   1.218 +
   1.219 +    EGLBoolean fBindAPI(EGLenum api)
   1.220 +    {
   1.221 +        BEFORE_GL_CALL;
   1.222 +        EGLBoolean b = mSymbols.fBindAPI(api);
   1.223 +        AFTER_GL_CALL;
   1.224 +        return b;
   1.225 +    }
   1.226 +
   1.227 +    EGLBoolean fInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor)
   1.228 +    {
   1.229 +        BEFORE_GL_CALL;
   1.230 +        EGLBoolean b = mSymbols.fInitialize(dpy, major, minor);
   1.231 +        AFTER_GL_CALL;
   1.232 +        return b;
   1.233 +    }
   1.234 +
   1.235 +    EGLBoolean fChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
   1.236 +    {
   1.237 +        BEFORE_GL_CALL;
   1.238 +        EGLBoolean b = mSymbols.fChooseConfig(dpy, attrib_list, configs, config_size, num_config);
   1.239 +        AFTER_GL_CALL;
   1.240 +        return b;
   1.241 +    }
   1.242 +
   1.243 +    EGLint fGetError()
   1.244 +    {
   1.245 +        BEFORE_GL_CALL;
   1.246 +        EGLint i = mSymbols.fGetError();
   1.247 +        AFTER_GL_CALL;
   1.248 +        return i;
   1.249 +    }
   1.250 +
   1.251 +    EGLBoolean fGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
   1.252 +    {
   1.253 +        BEFORE_GL_CALL;
   1.254 +        EGLBoolean b = mSymbols.fGetConfigAttrib(dpy, config, attribute, value);
   1.255 +        AFTER_GL_CALL;
   1.256 +        return b;
   1.257 +    }
   1.258 +
   1.259 +    EGLBoolean fGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
   1.260 +    {
   1.261 +        BEFORE_GL_CALL;
   1.262 +        EGLBoolean b = mSymbols.fGetConfigs(dpy, configs, config_size, num_config);
   1.263 +        AFTER_GL_CALL;
   1.264 +        return b;
   1.265 +    }
   1.266 +
   1.267 +    EGLBoolean fWaitNative(EGLint engine)
   1.268 +    {
   1.269 +        BEFORE_GL_CALL;
   1.270 +        EGLBoolean b = mSymbols.fWaitNative(engine);
   1.271 +        AFTER_GL_CALL;
   1.272 +        return b;
   1.273 +    }
   1.274 +
   1.275 +    EGLCastToRelevantPtr fGetProcAddress(const char *procname)
   1.276 +    {
   1.277 +        BEFORE_GL_CALL;
   1.278 +        EGLCastToRelevantPtr p = mSymbols.fGetProcAddress(procname);
   1.279 +        AFTER_GL_CALL;
   1.280 +        return p;
   1.281 +    }
   1.282 +
   1.283 +    EGLBoolean fSwapBuffers(EGLDisplay dpy, EGLSurface surface)
   1.284 +    {
   1.285 +        BEFORE_GL_CALL;
   1.286 +        EGLBoolean b = mSymbols.fSwapBuffers(dpy, surface);
   1.287 +        AFTER_GL_CALL;
   1.288 +        return b;
   1.289 +    }
   1.290 +
   1.291 +    EGLBoolean fCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
   1.292 +    {
   1.293 +        BEFORE_GL_CALL;
   1.294 +        EGLBoolean b = mSymbols.fCopyBuffers(dpy, surface, target);
   1.295 +        AFTER_GL_CALL;
   1.296 +        return b;
   1.297 +    }
   1.298 +
   1.299 +    const GLubyte* fQueryString(EGLDisplay dpy, EGLint name)
   1.300 +    {
   1.301 +        BEFORE_GL_CALL;
   1.302 +        const GLubyte* b = mSymbols.fQueryString(dpy, name);
   1.303 +        AFTER_GL_CALL;
   1.304 +        return b;
   1.305 +    }
   1.306 +
   1.307 +    EGLBoolean fQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
   1.308 +    {
   1.309 +        BEFORE_GL_CALL;
   1.310 +        EGLBoolean b = mSymbols.fQueryContext(dpy, ctx, attribute, value);
   1.311 +        AFTER_GL_CALL;
   1.312 +        return b;
   1.313 +    }
   1.314 +
   1.315 +    EGLBoolean fBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
   1.316 +    {
   1.317 +        BEFORE_GL_CALL;
   1.318 +        EGLBoolean b = mSymbols.fBindTexImage(dpy, surface, buffer);
   1.319 +        AFTER_GL_CALL;
   1.320 +        return b;
   1.321 +    }
   1.322 +
   1.323 +    EGLBoolean fReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
   1.324 +    {
   1.325 +        BEFORE_GL_CALL;
   1.326 +        EGLBoolean b = mSymbols.fReleaseTexImage(dpy, surface, buffer);
   1.327 +        AFTER_GL_CALL;
   1.328 +        return b;
   1.329 +    }
   1.330 +
   1.331 +    EGLImage fCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
   1.332 +    {
   1.333 +         BEFORE_GL_CALL;
   1.334 +         EGLImage i = mSymbols.fCreateImage(dpy, ctx, target, buffer, attrib_list);
   1.335 +         AFTER_GL_CALL;
   1.336 +         return i;
   1.337 +    }
   1.338 +
   1.339 +    EGLBoolean fDestroyImage(EGLDisplay dpy, EGLImage image)
   1.340 +    {
   1.341 +        BEFORE_GL_CALL;
   1.342 +        EGLBoolean b = mSymbols.fDestroyImage(dpy, image);
   1.343 +        AFTER_GL_CALL;
   1.344 +        return b;
   1.345 +    }
   1.346 +
   1.347 +    // New extension which allow us to lock texture and get raw image pointer
   1.348 +    EGLBoolean fLockSurface(EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list)
   1.349 +    {
   1.350 +        BEFORE_GL_CALL;
   1.351 +        EGLBoolean b = mSymbols.fLockSurface(dpy, surface, attrib_list);
   1.352 +        AFTER_GL_CALL;
   1.353 +        return b;
   1.354 +    }
   1.355 +
   1.356 +    EGLBoolean fUnlockSurface(EGLDisplay dpy, EGLSurface surface)
   1.357 +    {
   1.358 +        BEFORE_GL_CALL;
   1.359 +        EGLBoolean b = mSymbols.fUnlockSurface(dpy, surface);
   1.360 +        AFTER_GL_CALL;
   1.361 +        return b;
   1.362 +    }
   1.363 +
   1.364 +    EGLBoolean fQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
   1.365 +    {
   1.366 +        BEFORE_GL_CALL;
   1.367 +        EGLBoolean b = mSymbols.fQuerySurface(dpy, surface, attribute, value);
   1.368 +        AFTER_GL_CALL;
   1.369 +        return b;
   1.370 +    }
   1.371 +
   1.372 +    EGLBoolean fQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value)
   1.373 +    {
   1.374 +        BEFORE_GL_CALL;
   1.375 +        EGLBoolean b = mSymbols.fQuerySurfacePointerANGLE(dpy, surface, attribute, value);
   1.376 +        AFTER_GL_CALL;
   1.377 +        return b;
   1.378 +    }
   1.379 +
   1.380 +    EGLSync fCreateSync(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
   1.381 +    {
   1.382 +        BEFORE_GL_CALL;
   1.383 +        EGLSync ret = mSymbols.fCreateSync(dpy, type, attrib_list);
   1.384 +        AFTER_GL_CALL;
   1.385 +        return ret;
   1.386 +    }
   1.387 +
   1.388 +    EGLBoolean fDestroySync(EGLDisplay dpy, EGLSync sync)
   1.389 +    {
   1.390 +        BEFORE_GL_CALL;
   1.391 +        EGLBoolean b = mSymbols.fDestroySync(dpy, sync);
   1.392 +        AFTER_GL_CALL;
   1.393 +        return b;
   1.394 +    }
   1.395 +
   1.396 +    EGLint fClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout)
   1.397 +    {
   1.398 +        BEFORE_GL_CALL;
   1.399 +        EGLint ret = mSymbols.fClientWaitSync(dpy, sync, flags, timeout);
   1.400 +        AFTER_GL_CALL;
   1.401 +        return ret;
   1.402 +    }
   1.403 +
   1.404 +    EGLBoolean fGetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLint *value)
   1.405 +    {
   1.406 +        BEFORE_GL_CALL;
   1.407 +        EGLBoolean b = mSymbols.fGetSyncAttrib(dpy, sync, attribute, value);
   1.408 +        AFTER_GL_CALL;
   1.409 +        return b;
   1.410 +    }
   1.411 +
   1.412 +
   1.413 +    EGLDisplay Display() {
   1.414 +        return mEGLDisplay;
   1.415 +    }
   1.416 +
   1.417 +    bool IsANGLE() const {
   1.418 +        return mIsANGLE;
   1.419 +    }
   1.420 +
   1.421 +    bool HasKHRImageBase() {
   1.422 +        return IsExtensionSupported(KHR_image) || IsExtensionSupported(KHR_image_base);
   1.423 +    }
   1.424 +
   1.425 +    bool HasKHRImagePixmap() {
   1.426 +        return IsExtensionSupported(KHR_image) || IsExtensionSupported(KHR_image_pixmap);
   1.427 +    }
   1.428 +
   1.429 +    bool HasKHRImageTexture2D() {
   1.430 +        return IsExtensionSupported(KHR_gl_texture_2D_image);
   1.431 +    }
   1.432 +
   1.433 +    bool HasANGLESurfaceD3DTexture2DShareHandle() {
   1.434 +        return IsExtensionSupported(ANGLE_surface_d3d_texture_2d_share_handle);
   1.435 +    }
   1.436 +
   1.437 +    bool HasRobustness() const {
   1.438 +        return IsExtensionSupported(EXT_create_context_robustness);
   1.439 +    }
   1.440 +
   1.441 +    bool EnsureInitialized();
   1.442 +
   1.443 +    void DumpEGLConfig(EGLConfig cfg);
   1.444 +    void DumpEGLConfigs();
   1.445 +
   1.446 +    struct {
   1.447 +        typedef EGLDisplay (GLAPIENTRY * pfnGetDisplay)(void *display_id);
   1.448 +        pfnGetDisplay fGetDisplay;
   1.449 +        typedef EGLSurface (GLAPIENTRY * pfnGetCurrentSurface)(EGLint);
   1.450 +        pfnGetCurrentSurface fGetCurrentSurface;
   1.451 +        typedef EGLContext (GLAPIENTRY * pfnGetCurrentContext)(void);
   1.452 +        pfnGetCurrentContext fGetCurrentContext;
   1.453 +        typedef EGLBoolean (GLAPIENTRY * pfnMakeCurrent)(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
   1.454 +        pfnMakeCurrent fMakeCurrent;
   1.455 +        typedef EGLBoolean (GLAPIENTRY * pfnDestroyContext)(EGLDisplay dpy, EGLContext ctx);
   1.456 +        pfnDestroyContext fDestroyContext;
   1.457 +        typedef EGLContext (GLAPIENTRY * pfnCreateContext)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
   1.458 +        pfnCreateContext fCreateContext;
   1.459 +        typedef EGLBoolean (GLAPIENTRY * pfnDestroySurface)(EGLDisplay dpy, EGLSurface surface);
   1.460 +        pfnDestroySurface fDestroySurface;
   1.461 +        typedef EGLSurface (GLAPIENTRY * pfnCreateWindowSurface)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
   1.462 +        pfnCreateWindowSurface fCreateWindowSurface;
   1.463 +        typedef EGLSurface (GLAPIENTRY * pfnCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
   1.464 +        pfnCreatePbufferSurface fCreatePbufferSurface;
   1.465 +        typedef EGLSurface (GLAPIENTRY * pfnCreatePixmapSurface)(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
   1.466 +        pfnCreatePixmapSurface fCreatePixmapSurface;
   1.467 +        typedef EGLBoolean (GLAPIENTRY * pfnBindAPI)(EGLenum api);
   1.468 +        pfnBindAPI fBindAPI;
   1.469 +        typedef EGLBoolean (GLAPIENTRY * pfnInitialize)(EGLDisplay dpy, EGLint *major, EGLint *minor);
   1.470 +        pfnInitialize fInitialize;
   1.471 +        typedef EGLBoolean (GLAPIENTRY * pfnChooseConfig)(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
   1.472 +        pfnChooseConfig fChooseConfig;
   1.473 +        typedef EGLint (GLAPIENTRY * pfnGetError)(void);
   1.474 +        pfnGetError fGetError;
   1.475 +        typedef EGLBoolean (GLAPIENTRY * pfnGetConfigAttrib)(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
   1.476 +        pfnGetConfigAttrib fGetConfigAttrib;
   1.477 +        typedef EGLBoolean (GLAPIENTRY * pfnGetConfigs)(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
   1.478 +        pfnGetConfigs fGetConfigs;
   1.479 +        typedef EGLBoolean (GLAPIENTRY * pfnWaitNative)(EGLint engine);
   1.480 +        pfnWaitNative fWaitNative;
   1.481 +        typedef EGLCastToRelevantPtr (GLAPIENTRY * pfnGetProcAddress)(const char *procname);
   1.482 +        pfnGetProcAddress fGetProcAddress;
   1.483 +        typedef EGLBoolean (GLAPIENTRY * pfnSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
   1.484 +        pfnSwapBuffers fSwapBuffers;
   1.485 +        typedef EGLBoolean (GLAPIENTRY * pfnCopyBuffers)(EGLDisplay dpy, EGLSurface surface,
   1.486 +                                                         EGLNativePixmapType target);
   1.487 +        pfnCopyBuffers fCopyBuffers;
   1.488 +        typedef const GLubyte* (GLAPIENTRY * pfnQueryString)(EGLDisplay, EGLint name);
   1.489 +        pfnQueryString fQueryString;
   1.490 +        typedef EGLBoolean (GLAPIENTRY * pfnQueryContext)(EGLDisplay dpy, EGLContext ctx,
   1.491 +                                                          EGLint attribute, EGLint *value);
   1.492 +        pfnQueryContext fQueryContext;
   1.493 +        typedef EGLBoolean (GLAPIENTRY * pfnBindTexImage)(EGLDisplay, EGLSurface surface, EGLint buffer);
   1.494 +        pfnBindTexImage fBindTexImage;
   1.495 +        typedef EGLBoolean (GLAPIENTRY * pfnReleaseTexImage)(EGLDisplay, EGLSurface surface, EGLint buffer);
   1.496 +        pfnReleaseTexImage fReleaseTexImage;
   1.497 +        typedef EGLImage (GLAPIENTRY * pfnCreateImage)(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
   1.498 +        pfnCreateImage fCreateImage;
   1.499 +        typedef EGLBoolean (GLAPIENTRY * pfnDestroyImage)(EGLDisplay dpy, EGLImage image);
   1.500 +        pfnDestroyImage fDestroyImage;
   1.501 +
   1.502 +        // New extension which allow us to lock texture and get raw image pointer
   1.503 +        typedef EGLBoolean (GLAPIENTRY * pfnLockSurface)(EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list);
   1.504 +        pfnLockSurface fLockSurface;
   1.505 +        typedef EGLBoolean (GLAPIENTRY * pfnUnlockSurface)(EGLDisplay dpy, EGLSurface surface);
   1.506 +        pfnUnlockSurface fUnlockSurface;
   1.507 +        typedef EGLBoolean (GLAPIENTRY * pfnQuerySurface)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
   1.508 +        pfnQuerySurface fQuerySurface;
   1.509 +
   1.510 +        typedef EGLBoolean (GLAPIENTRY * pfnQuerySurfacePointerANGLE)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
   1.511 +        pfnQuerySurfacePointerANGLE fQuerySurfacePointerANGLE;
   1.512 +
   1.513 +        typedef EGLSync (GLAPIENTRY * pfnCreateSync)(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
   1.514 +        pfnCreateSync fCreateSync;
   1.515 +        typedef EGLBoolean (GLAPIENTRY * pfnDestroySync)(EGLDisplay dpy, EGLSync sync);
   1.516 +        pfnDestroySync fDestroySync;
   1.517 +        typedef EGLint (GLAPIENTRY * pfnClientWaitSync)(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
   1.518 +        pfnClientWaitSync fClientWaitSync;
   1.519 +        typedef EGLBoolean (GLAPIENTRY * pfnGetSyncAttrib)(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLint *value);
   1.520 +        pfnGetSyncAttrib fGetSyncAttrib;
   1.521 +    } mSymbols;
   1.522 +
   1.523 +#ifdef DEBUG
   1.524 +    static void BeforeGLCall(const char* glFunction);
   1.525 +    static void AfterGLCall(const char* glFunction);
   1.526 +#endif
   1.527 +
   1.528 +private:
   1.529 +    bool mInitialized;
   1.530 +    PRLibrary* mEGLLibrary;
   1.531 +    EGLDisplay mEGLDisplay;
   1.532 +
   1.533 +    bool mIsANGLE;
   1.534 +};
   1.535 +
   1.536 +extern GLLibraryEGL sEGLLibrary;
   1.537 +#define EGL_DISPLAY()        sEGLLibrary.Display()
   1.538 +
   1.539 +} /* namespace gl */
   1.540 +} /* namespace mozilla */
   1.541 +
   1.542 +#endif /* GLLIBRARYEGL_H_ */
   1.543 +

mercurial