2012-03-17 02:24:12 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef GLLIBRARYEGL_H_
|
|
|
|
#define GLLIBRARYEGL_H_
|
|
|
|
|
2012-03-22 03:14:14 +04:00
|
|
|
#if defined(MOZ_X11)
|
|
|
|
#include "mozilla/X11Util.h"
|
|
|
|
#endif
|
|
|
|
|
2012-03-17 02:24:12 +04:00
|
|
|
#include "GLLibraryLoader.h"
|
2015-10-12 06:21:03 +03:00
|
|
|
#include "mozilla/StaticMutex.h"
|
2014-05-31 08:39:16 +04:00
|
|
|
#include "mozilla/ThreadLocal.h"
|
2012-06-06 06:08:30 +04:00
|
|
|
#include "nsIFile.h"
|
2014-10-15 07:20:16 +04:00
|
|
|
#include "GeckoProfiler.h"
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2013-09-04 16:14:52 +04:00
|
|
|
#include <bitset>
|
2015-02-13 06:00:41 +03:00
|
|
|
#include <vector>
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2015-09-24 22:21:05 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
#ifndef WIN32_LEAN_AND_MEAN
|
|
|
|
#define WIN32_LEAN_AND_MEAN 1
|
|
|
|
#endif
|
2012-03-22 03:14:14 +04:00
|
|
|
|
2015-09-24 22:21:05 +03:00
|
|
|
#include <windows.h>
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2015-09-24 22:21:05 +03:00
|
|
|
typedef HDC EGLNativeDisplayType;
|
|
|
|
typedef HBITMAP EGLNativePixmapType;
|
|
|
|
typedef HWND EGLNativeWindowType;
|
2012-03-22 03:14:14 +04:00
|
|
|
#else
|
2015-09-24 22:21:05 +03:00
|
|
|
typedef void* EGLNativeDisplayType;
|
|
|
|
typedef void* EGLNativePixmapType;
|
|
|
|
typedef void* EGLNativeWindowType;
|
|
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
// We only need to explicitly dlopen egltrace
|
|
|
|
// on android as we can use LD_PRELOAD or other tricks
|
|
|
|
// on other platforms. We look for it in /data/local
|
|
|
|
// as that's writeable by all users
|
|
|
|
//
|
|
|
|
// This should really go in GLLibraryEGL.cpp but we currently reference
|
|
|
|
// APITRACE_LIB in GLContextProviderEGL.cpp. Further refactoring
|
|
|
|
// will come in subsequent patches on Bug 732865
|
|
|
|
#define APITRACE_LIB "/data/local/tmp/egltrace.so"
|
|
|
|
#endif
|
2012-03-17 02:24:12 +04:00
|
|
|
#endif
|
|
|
|
|
2012-03-22 03:14:14 +04:00
|
|
|
#if defined(MOZ_X11)
|
|
|
|
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)mozilla::DefaultXDisplay())
|
2012-03-17 02:24:12 +04:00
|
|
|
#else
|
|
|
|
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
|
|
|
|
#endif
|
|
|
|
|
2016-07-16 01:12:46 +03:00
|
|
|
namespace angle {
|
|
|
|
class Platform;
|
|
|
|
}
|
|
|
|
|
2012-03-17 02:24:12 +04:00
|
|
|
namespace mozilla {
|
2015-10-12 06:21:03 +03:00
|
|
|
|
|
|
|
namespace gfx {
|
|
|
|
class DataSourceSurface;
|
|
|
|
}
|
|
|
|
|
2012-03-17 02:24:12 +04:00
|
|
|
namespace gl {
|
|
|
|
|
2015-10-12 06:21:03 +03:00
|
|
|
class GLContext;
|
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
void BeforeEGLCall(const char* funcName);
|
|
|
|
void AfterEGLCall(const char* funcName);
|
|
|
|
|
2012-03-17 02:24:12 +04:00
|
|
|
class GLLibraryEGL
|
|
|
|
{
|
|
|
|
public:
|
2014-10-09 03:32:50 +04:00
|
|
|
GLLibraryEGL()
|
2017-03-04 03:49:49 +03:00
|
|
|
: mSymbols{nullptr}
|
|
|
|
, mInitialized(false)
|
|
|
|
, mEGLLibrary(nullptr)
|
|
|
|
, mEGLDisplay(EGL_NO_DISPLAY)
|
|
|
|
, mIsANGLE(false)
|
|
|
|
, mIsWARP(false)
|
|
|
|
{ }
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2015-11-13 00:41:45 +03:00
|
|
|
void InitClientExtensions();
|
|
|
|
void InitDisplayExtensions();
|
2012-06-13 01:39:18 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Known GL extensions that can be queried by
|
|
|
|
* IsExtensionSupported. The results of this are cached, and as
|
|
|
|
* such it's safe to use this even in performance critical code.
|
|
|
|
* If you add to this array, remember to add to the string names
|
|
|
|
* in GLContext.cpp.
|
|
|
|
*/
|
|
|
|
enum EGLExtensions {
|
|
|
|
KHR_image_base,
|
|
|
|
KHR_image_pixmap,
|
|
|
|
KHR_gl_texture_2D_image,
|
|
|
|
KHR_lock_surface,
|
|
|
|
ANGLE_surface_d3d_texture_2d_share_handle,
|
|
|
|
EXT_create_context_robustness,
|
|
|
|
KHR_image,
|
2012-06-13 01:39:43 +04:00
|
|
|
KHR_fence_sync,
|
2014-04-22 03:59:30 +04:00
|
|
|
ANDROID_native_fence_sync,
|
2015-07-20 02:03:10 +03:00
|
|
|
EGL_ANDROID_image_crop,
|
2015-07-10 21:47:48 +03:00
|
|
|
ANGLE_platform_angle,
|
|
|
|
ANGLE_platform_angle_d3d,
|
2017-02-20 04:44:50 +03:00
|
|
|
ANGLE_d3d_share_handle_client_buffer,
|
2017-02-10 07:31:36 +03:00
|
|
|
KHR_create_context,
|
2012-06-13 01:39:18 +04:00
|
|
|
Extensions_Max
|
|
|
|
};
|
|
|
|
|
2014-03-04 06:47:43 +04:00
|
|
|
bool IsExtensionSupported(EGLExtensions aKnownExtension) const {
|
2012-06-13 01:39:18 +04:00
|
|
|
return mAvailableExtensions[aKnownExtension];
|
|
|
|
}
|
|
|
|
|
|
|
|
void MarkExtensionUnsupported(EGLExtensions aKnownExtension) {
|
2013-09-04 16:14:52 +04:00
|
|
|
mAvailableExtensions[aKnownExtension] = false;
|
2012-06-13 01:39:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2013-09-04 16:14:52 +04:00
|
|
|
std::bitset<Extensions_Max> mAvailableExtensions;
|
2012-06-13 01:39:18 +04:00
|
|
|
|
|
|
|
public:
|
2017-03-04 03:49:49 +03:00
|
|
|
GLLibraryLoader::PlatformLookupFunction GetLookupFunction() const {
|
|
|
|
return (GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress;
|
|
|
|
}
|
2012-06-13 01:39:18 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
////
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
#define PROFILE_CALL PROFILER_LABEL_FUNC(js::ProfileEntry::Category::GRAPHICS);
|
|
|
|
#else
|
|
|
|
#define PROFILE_CALL
|
|
|
|
#endif
|
2015-07-10 21:47:48 +03:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
#ifndef MOZ_FUNCTION_NAME
|
|
|
|
# ifdef __GNUC__
|
|
|
|
# define MOZ_FUNCTION_NAME __PRETTY_FUNCTION__
|
|
|
|
# elif defined(_MSC_VER)
|
|
|
|
# define MOZ_FUNCTION_NAME __FUNCTION__
|
|
|
|
# else
|
|
|
|
# define MOZ_FUNCTION_NAME __func__ // defined in C99, supported in various C++ compilers. Just raw function name.
|
|
|
|
# endif
|
|
|
|
#endif
|
2014-10-09 03:32:50 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
#define BEFORE_CALL BeforeEGLCall(MOZ_FUNCTION_NAME);
|
|
|
|
#define AFTER_CALL AfterEGLCall(MOZ_FUNCTION_NAME);
|
|
|
|
#else
|
|
|
|
#define BEFORE_CALL
|
|
|
|
#define AFTER_CALL
|
|
|
|
#endif
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
#define WRAP(X) \
|
|
|
|
{ \
|
|
|
|
PROFILE_CALL \
|
|
|
|
BEFORE_CALL \
|
|
|
|
const auto ret = mSymbols. X ; \
|
|
|
|
AFTER_CALL \
|
|
|
|
return ret; \
|
2012-03-17 02:24:12 +04:00
|
|
|
}
|
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
#define VOID_WRAP(X) \
|
|
|
|
{ \
|
|
|
|
PROFILE_CALL \
|
|
|
|
BEFORE_CALL \
|
|
|
|
mSymbols. X ; \
|
|
|
|
AFTER_CALL \
|
2012-03-17 02:24:12 +04:00
|
|
|
}
|
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLDisplay fGetDisplay(void* display_id) const
|
|
|
|
WRAP( fGetDisplay(display_id) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLDisplay fGetPlatformDisplayEXT(EGLenum platform, void* native_display, const EGLint* attrib_list) const
|
|
|
|
WRAP( fGetPlatformDisplayEXT(platform, native_display, attrib_list) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fTerminate(EGLDisplay display) const
|
|
|
|
WRAP( fTerminate(display) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLSurface fGetCurrentSurface(EGLint id) const
|
|
|
|
WRAP( fGetCurrentSurface(id) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLContext fGetCurrentContext() const
|
|
|
|
WRAP( fGetCurrentContext() )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) const
|
|
|
|
WRAP( fMakeCurrent(dpy, draw, read, ctx) )
|
2017-02-20 04:44:50 +03:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fDestroyContext(EGLDisplay dpy, EGLContext ctx) const
|
|
|
|
WRAP( fDestroyContext(dpy, ctx) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLContext fCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list) const
|
|
|
|
WRAP( fCreateContext(dpy, config, share_context, attrib_list) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fDestroySurface(EGLDisplay dpy, EGLSurface surface) const
|
|
|
|
WRAP( fDestroySurface(dpy, surface) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLSurface fCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list) const
|
|
|
|
WRAP( fCreateWindowSurface(dpy, config, win, attrib_list) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLSurface fCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list) const
|
|
|
|
WRAP( fCreatePbufferSurface(dpy, config, attrib_list) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLSurface fCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) const
|
|
|
|
WRAP( fCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLSurface fCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list) const
|
|
|
|
WRAP( fCreatePixmapSurface(dpy, config, pixmap, attrib_list) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fBindAPI(EGLenum api) const
|
|
|
|
WRAP( fBindAPI(api) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor) const
|
|
|
|
WRAP( fInitialize(dpy, major, minor) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config) const
|
|
|
|
WRAP( fChooseConfig(dpy, attrib_list, configs, config_size, num_config) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLint fGetError() const
|
|
|
|
WRAP( fGetError() )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value) const
|
|
|
|
WRAP( fGetConfigAttrib(dpy, config, attribute, value) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fGetConfigs(EGLDisplay dpy, EGLConfig* configs, EGLint config_size, EGLint* num_config) const
|
|
|
|
WRAP( fGetConfigs(dpy, configs, config_size, num_config) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fWaitNative(EGLint engine) const
|
|
|
|
WRAP( fWaitNative(engine) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLCastToRelevantPtr fGetProcAddress(const char* procname) const
|
|
|
|
WRAP( fGetProcAddress(procname) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fSwapBuffers(EGLDisplay dpy, EGLSurface surface) const
|
|
|
|
WRAP( fSwapBuffers(dpy, surface) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) const
|
|
|
|
WRAP( fCopyBuffers(dpy, surface, target) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
const GLubyte* fQueryString(EGLDisplay dpy, EGLint name) const
|
|
|
|
WRAP( fQueryString(dpy, name) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value) const
|
|
|
|
WRAP( fQueryContext(dpy, ctx, attribute, value) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) const
|
|
|
|
WRAP( fBindTexImage(dpy, surface, buffer) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) const
|
|
|
|
WRAP( fReleaseTexImage(dpy, surface, buffer) )
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLImage fCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint* attrib_list) const
|
|
|
|
WRAP( fCreateImageKHR(dpy, ctx, target, buffer, attrib_list) )
|
2012-06-13 01:39:43 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fDestroyImage(EGLDisplay dpy, EGLImage image) const
|
|
|
|
WRAP( fDestroyImageKHR(dpy, image) )
|
2012-06-13 01:39:43 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fLockSurface(EGLDisplay dpy, EGLSurface surface, const EGLint* attrib_list) const
|
|
|
|
WRAP( fLockSurfaceKHR(dpy, surface, attrib_list) )
|
2012-06-13 01:39:43 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fUnlockSurface(EGLDisplay dpy, EGLSurface surface) const
|
|
|
|
WRAP( fUnlockSurfaceKHR(dpy, surface) )
|
2012-06-13 01:39:43 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* value) const
|
|
|
|
WRAP( fQuerySurface(dpy, surface, attribute, value) )
|
2012-06-13 08:20:27 +04:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLBoolean fQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void** value) const
|
|
|
|
WRAP( fQuerySurfacePointerANGLE(dpy, surface, attribute, value) )
|
2016-07-16 01:12:46 +03:00
|
|
|
|
2017-03-04 06:24:51 +03:00
|
|
|
EGLSync fCreateSync(EGLDisplay dpy, EGLenum type, const EGLint* attrib_list) const
|
|
|
|
WRAP( fCreateSyncKHR(dpy, type, attrib_list) )
|
|
|
|
|
|
|
|
EGLBoolean fDestroySync(EGLDisplay dpy, EGLSync sync) const
|
|
|
|
WRAP( fDestroySyncKHR(dpy, sync) )
|
|
|
|
|
|
|
|
EGLint fClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout) const
|
|
|
|
WRAP( fClientWaitSyncKHR(dpy, sync, flags, timeout) )
|
|
|
|
|
|
|
|
EGLBoolean fGetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLint* value) const
|
|
|
|
WRAP( fGetSyncAttribKHR(dpy, sync, attribute, value) )
|
|
|
|
|
|
|
|
EGLint fDupNativeFenceFDANDROID(EGLDisplay dpy, EGLSync sync) const
|
|
|
|
WRAP( fDupNativeFenceFDANDROID(dpy, sync) )
|
|
|
|
|
|
|
|
void fANGLEPlatformInitialize(angle::Platform* platform) const
|
|
|
|
VOID_WRAP( fANGLEPlatformInitialize(platform) )
|
|
|
|
|
|
|
|
void fANGLEPlatformShutdown() const
|
|
|
|
VOID_WRAP( fANGLEPlatformShutdown() )
|
|
|
|
|
|
|
|
#undef WRAP
|
|
|
|
#undef VOID_WRAP
|
|
|
|
#undef PROFILE_CALL
|
|
|
|
#undef BEFORE_CALL
|
|
|
|
#undef AFTER_CALL
|
|
|
|
#undef MOZ_FUNCTION_NAME
|
|
|
|
|
|
|
|
////
|
2016-07-16 01:12:46 +03:00
|
|
|
|
2012-03-17 02:24:12 +04:00
|
|
|
EGLDisplay Display() {
|
2016-04-22 02:32:18 +03:00
|
|
|
MOZ_ASSERT(mInitialized);
|
2012-03-17 02:24:12 +04:00
|
|
|
return mEGLDisplay;
|
|
|
|
}
|
|
|
|
|
2014-03-04 06:47:43 +04:00
|
|
|
bool IsANGLE() const {
|
2016-04-22 02:32:18 +03:00
|
|
|
MOZ_ASSERT(mInitialized);
|
2012-03-17 02:24:12 +04:00
|
|
|
return mIsANGLE;
|
|
|
|
}
|
|
|
|
|
2015-07-23 20:11:04 +03:00
|
|
|
bool IsWARP() const {
|
2016-04-22 02:32:18 +03:00
|
|
|
MOZ_ASSERT(mInitialized);
|
2015-07-23 20:11:04 +03:00
|
|
|
return mIsWARP;
|
|
|
|
}
|
|
|
|
|
2012-03-17 02:24:12 +04:00
|
|
|
bool HasKHRImageBase() {
|
2012-06-13 01:39:18 +04:00
|
|
|
return IsExtensionSupported(KHR_image) || IsExtensionSupported(KHR_image_base);
|
2012-03-17 02:24:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool HasKHRImagePixmap() {
|
2012-06-13 01:39:18 +04:00
|
|
|
return IsExtensionSupported(KHR_image) || IsExtensionSupported(KHR_image_pixmap);
|
2012-03-17 02:24:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool HasKHRImageTexture2D() {
|
2012-06-13 01:39:18 +04:00
|
|
|
return IsExtensionSupported(KHR_gl_texture_2D_image);
|
2012-03-17 02:24:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool HasANGLESurfaceD3DTexture2DShareHandle() {
|
2012-06-13 01:39:18 +04:00
|
|
|
return IsExtensionSupported(ANGLE_surface_d3d_texture_2d_share_handle);
|
2012-03-17 02:24:12 +04:00
|
|
|
}
|
|
|
|
|
2015-10-12 06:21:03 +03:00
|
|
|
bool ReadbackEGLImage(EGLImage image, gfx::DataSourceSurface* out_surface);
|
|
|
|
|
2016-06-11 05:01:00 +03:00
|
|
|
bool EnsureInitialized(bool forceAccel, nsACString* const out_failureId);
|
2012-03-17 02:24:12 +04:00
|
|
|
|
|
|
|
void DumpEGLConfig(EGLConfig cfg);
|
|
|
|
void DumpEGLConfigs();
|
|
|
|
|
2017-03-04 03:49:49 +03:00
|
|
|
private:
|
2012-03-17 02:24:12 +04:00
|
|
|
struct {
|
2017-03-04 03:49:49 +03:00
|
|
|
EGLCastToRelevantPtr (GLAPIENTRY * fGetProcAddress)(const char* procname);
|
|
|
|
EGLDisplay (GLAPIENTRY * fGetDisplay)(void* display_id);
|
|
|
|
EGLDisplay (GLAPIENTRY * fGetPlatformDisplayEXT)(EGLenum platform,
|
|
|
|
void* native_display,
|
|
|
|
const EGLint* attrib_list);
|
|
|
|
EGLBoolean (GLAPIENTRY * fTerminate)(EGLDisplay dpy);
|
|
|
|
EGLSurface (GLAPIENTRY * fGetCurrentSurface)(EGLint);
|
|
|
|
EGLContext (GLAPIENTRY * fGetCurrentContext)(void);
|
|
|
|
EGLBoolean (GLAPIENTRY * fMakeCurrent)(EGLDisplay dpy, EGLSurface draw,
|
|
|
|
EGLSurface read, EGLContext ctx);
|
|
|
|
EGLBoolean (GLAPIENTRY * fDestroyContext)(EGLDisplay dpy, EGLContext ctx);
|
|
|
|
EGLContext (GLAPIENTRY * fCreateContext)(EGLDisplay dpy, EGLConfig config,
|
|
|
|
EGLContext share_context,
|
|
|
|
const EGLint* attrib_list);
|
|
|
|
EGLBoolean (GLAPIENTRY * fDestroySurface)(EGLDisplay dpy, EGLSurface surface);
|
|
|
|
EGLSurface (GLAPIENTRY * fCreateWindowSurface)(EGLDisplay dpy, EGLConfig config,
|
|
|
|
EGLNativeWindowType win,
|
|
|
|
const EGLint* attrib_list);
|
|
|
|
EGLSurface (GLAPIENTRY * fCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config,
|
|
|
|
const EGLint* attrib_list);
|
|
|
|
EGLSurface (GLAPIENTRY * fCreatePbufferFromClientBuffer)(EGLDisplay dpy,
|
|
|
|
EGLenum buftype,
|
|
|
|
EGLClientBuffer buffer,
|
|
|
|
EGLConfig config,
|
|
|
|
const EGLint* attrib_list);
|
|
|
|
EGLSurface (GLAPIENTRY * fCreatePixmapSurface)(EGLDisplay dpy, EGLConfig config,
|
|
|
|
EGLNativePixmapType pixmap,
|
|
|
|
const EGLint* attrib_list);
|
|
|
|
EGLBoolean (GLAPIENTRY * fBindAPI)(EGLenum api);
|
|
|
|
EGLBoolean (GLAPIENTRY * fInitialize)(EGLDisplay dpy, EGLint* major,
|
|
|
|
EGLint* minor);
|
|
|
|
EGLBoolean (GLAPIENTRY * fChooseConfig)(EGLDisplay dpy, const EGLint* attrib_list,
|
|
|
|
EGLConfig* configs, EGLint config_size,
|
|
|
|
EGLint* num_config);
|
|
|
|
EGLint (GLAPIENTRY * fGetError)(void);
|
|
|
|
EGLBoolean (GLAPIENTRY * fGetConfigAttrib)(EGLDisplay dpy, EGLConfig config,
|
|
|
|
EGLint attribute, EGLint* value);
|
|
|
|
EGLBoolean (GLAPIENTRY * fGetConfigs)(EGLDisplay dpy, EGLConfig* configs,
|
|
|
|
EGLint config_size, EGLint* num_config);
|
|
|
|
EGLBoolean (GLAPIENTRY * fWaitNative)(EGLint engine);
|
|
|
|
EGLBoolean (GLAPIENTRY * fSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
|
|
|
|
EGLBoolean (GLAPIENTRY * fCopyBuffers)(EGLDisplay dpy, EGLSurface surface,
|
|
|
|
EGLNativePixmapType target);
|
|
|
|
const GLubyte* (GLAPIENTRY * fQueryString)(EGLDisplay, EGLint name);
|
|
|
|
EGLBoolean (GLAPIENTRY * fQueryContext)(EGLDisplay dpy, EGLContext ctx,
|
|
|
|
EGLint attribute, EGLint* value);
|
|
|
|
EGLBoolean (GLAPIENTRY * fBindTexImage)(EGLDisplay, EGLSurface surface,
|
|
|
|
EGLint buffer);
|
|
|
|
EGLBoolean (GLAPIENTRY * fReleaseTexImage)(EGLDisplay, EGLSurface surface,
|
|
|
|
EGLint buffer);
|
|
|
|
EGLImage (GLAPIENTRY * fCreateImageKHR)(EGLDisplay dpy, EGLContext ctx,
|
|
|
|
EGLenum target, EGLClientBuffer buffer,
|
|
|
|
const EGLint* attrib_list);
|
|
|
|
EGLBoolean (GLAPIENTRY * fDestroyImageKHR)(EGLDisplay dpy, EGLImage image);
|
2012-03-17 02:24:12 +04:00
|
|
|
// New extension which allow us to lock texture and get raw image pointer
|
2017-03-04 03:49:49 +03:00
|
|
|
EGLBoolean (GLAPIENTRY * fLockSurfaceKHR)(EGLDisplay dpy, EGLSurface surface,
|
|
|
|
const EGLint* attrib_list);
|
|
|
|
EGLBoolean (GLAPIENTRY * fUnlockSurfaceKHR)(EGLDisplay dpy, EGLSurface surface);
|
|
|
|
EGLBoolean (GLAPIENTRY * fQuerySurface)(EGLDisplay dpy, EGLSurface surface,
|
|
|
|
EGLint attribute, EGLint* value);
|
|
|
|
EGLBoolean (GLAPIENTRY * fQuerySurfacePointerANGLE)(EGLDisplay dpy,
|
|
|
|
EGLSurface surface,
|
|
|
|
EGLint attribute,
|
|
|
|
void** value);
|
|
|
|
EGLSync (GLAPIENTRY * fCreateSyncKHR)(EGLDisplay dpy, EGLenum type,
|
|
|
|
const EGLint* attrib_list);
|
|
|
|
EGLBoolean (GLAPIENTRY * fDestroySyncKHR)(EGLDisplay dpy, EGLSync sync);
|
|
|
|
EGLint (GLAPIENTRY * fClientWaitSyncKHR)(EGLDisplay dpy, EGLSync sync,
|
|
|
|
EGLint flags,
|
|
|
|
EGLTime timeout);
|
|
|
|
EGLBoolean (GLAPIENTRY * fGetSyncAttribKHR)(EGLDisplay dpy, EGLSync sync,
|
|
|
|
EGLint attribute, EGLint* value);
|
|
|
|
EGLint (GLAPIENTRY * fDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSync sync);
|
|
|
|
void (GLAPIENTRY * fANGLEPlatformInitialize)(angle::Platform* platform);
|
|
|
|
void (GLAPIENTRY * fANGLEPlatformShutdown)();
|
2012-03-17 02:24:12 +04:00
|
|
|
} mSymbols;
|
|
|
|
|
2017-03-04 03:49:49 +03:00
|
|
|
public:
|
2014-05-31 08:39:16 +04:00
|
|
|
#ifdef MOZ_B2G
|
|
|
|
EGLContext CachedCurrentContext() {
|
|
|
|
return sCurrentContext.get();
|
|
|
|
}
|
|
|
|
void UnsetCachedCurrentContext() {
|
|
|
|
sCurrentContext.set(nullptr);
|
|
|
|
}
|
|
|
|
void SetCachedCurrentContext(EGLContext aCtx) {
|
|
|
|
sCurrentContext.set(aCtx);
|
|
|
|
}
|
|
|
|
bool CachedCurrentContextMatches() {
|
|
|
|
return sCurrentContext.get() == fGetCurrentContext();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-11-23 22:11:22 +03:00
|
|
|
static MOZ_THREAD_LOCAL(EGLContext) sCurrentContext;
|
2014-05-31 08:39:16 +04:00
|
|
|
public:
|
|
|
|
|
|
|
|
#else
|
|
|
|
EGLContext CachedCurrentContext() {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
void UnsetCachedCurrentContext() {}
|
|
|
|
void SetCachedCurrentContext(EGLContext aCtx) { }
|
|
|
|
bool CachedCurrentContextMatches() { return true; }
|
|
|
|
#endif
|
|
|
|
|
2012-03-17 02:24:12 +04:00
|
|
|
private:
|
|
|
|
bool mInitialized;
|
|
|
|
PRLibrary* mEGLLibrary;
|
|
|
|
EGLDisplay mEGLDisplay;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<GLContext> mReadbackGL;
|
2012-03-17 02:24:12 +04:00
|
|
|
|
|
|
|
bool mIsANGLE;
|
2015-07-23 20:11:04 +03:00
|
|
|
bool mIsWARP;
|
2015-10-12 06:21:03 +03:00
|
|
|
static StaticMutex sMutex;
|
2012-03-17 02:24:12 +04:00
|
|
|
};
|
|
|
|
|
2013-10-11 17:16:44 +04:00
|
|
|
extern GLLibraryEGL sEGLLibrary;
|
|
|
|
#define EGL_DISPLAY() sEGLLibrary.Display()
|
|
|
|
|
2012-03-17 02:24:12 +04:00
|
|
|
} /* namespace gl */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
|
|
|
#endif /* GLLIBRARYEGL_H_ */
|
|
|
|
|