2010-06-09 15:27:29 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2010-06-09 15:27:29 -07:00
|
|
|
|
2013-09-04 05:14:52 -07:00
|
|
|
#include "GLContext.h"
|
2011-10-10 22:50:08 -07:00
|
|
|
#include "mozilla/Util.h"
|
2012-03-12 08:43:14 -07:00
|
|
|
// please add new includes below Qt, otherwise it break Qt build due malloc wrapper conflicts
|
2012-03-08 16:01:12 -08:00
|
|
|
|
2011-08-24 09:15:58 -07:00
|
|
|
#if defined(XP_UNIX)
|
2010-06-09 15:27:29 -07:00
|
|
|
|
2012-06-27 17:15:32 -07:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2010-06-09 15:27:29 -07:00
|
|
|
#include <gdk/gdkx.h>
|
|
|
|
// we're using default display for now
|
|
|
|
#define GET_NATIVE_WINDOW(aWidget) (EGLNativeWindowType)GDK_WINDOW_XID((GdkWindow *) aWidget->GetNativeData(NS_NATIVE_WINDOW))
|
|
|
|
#elif defined(MOZ_WIDGET_QT)
|
2011-08-24 09:15:58 -07:00
|
|
|
#include <QtOpenGL/QGLContext>
|
2010-06-23 02:24:22 -07:00
|
|
|
#define GLdouble_defined 1
|
2010-06-09 15:27:29 -07:00
|
|
|
// we're using default display for now
|
2011-08-24 09:15:58 -07:00
|
|
|
#define GET_NATIVE_WINDOW(aWidget) (EGLNativeWindowType)static_cast<QWidget*>(aWidget->GetNativeData(NS_NATIVE_SHELLWIDGET))->winId()
|
2011-11-10 16:17:46 -08:00
|
|
|
#elif defined(MOZ_WIDGET_GONK)
|
|
|
|
#define GET_NATIVE_WINDOW(aWidget) ((EGLNativeWindowType)aWidget->GetNativeData(NS_NATIVE_WINDOW))
|
2012-11-19 09:58:38 -08:00
|
|
|
#include "HwcComposer2D.h"
|
2013-05-07 20:58:22 -07:00
|
|
|
#include "libdisplay/GonkDisplay.h"
|
2010-06-09 15:27:29 -07:00
|
|
|
#endif
|
|
|
|
|
2011-08-24 09:15:58 -07:00
|
|
|
#if defined(MOZ_X11)
|
2010-06-09 15:27:29 -07:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
2010-07-18 22:01:14 -07:00
|
|
|
#include "mozilla/X11Util.h"
|
2010-06-23 02:24:31 -07:00
|
|
|
#include "gfxXlibSurface.h"
|
2011-08-24 09:15:58 -07:00
|
|
|
#endif
|
2010-06-09 15:27:29 -07:00
|
|
|
|
2011-08-24 09:15:58 -07:00
|
|
|
#if defined(ANDROID)
|
2010-06-25 17:52:37 -07:00
|
|
|
/* from widget */
|
2011-11-10 16:17:46 -08:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
2010-06-25 17:52:37 -07:00
|
|
|
#include "AndroidBridge.h"
|
2012-07-20 12:20:51 -07:00
|
|
|
#include "nsSurfaceTexture.h"
|
2011-11-10 16:17:46 -08:00
|
|
|
#endif
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
#include <android/log.h>
|
2012-06-12 21:20:27 -07:00
|
|
|
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args)
|
|
|
|
|
|
|
|
# if defined(MOZ_WIDGET_GONK)
|
|
|
|
# include "cutils/properties.h"
|
|
|
|
# include <ui/GraphicBuffer.h>
|
|
|
|
|
|
|
|
using namespace android;
|
|
|
|
# endif
|
|
|
|
|
2012-01-20 06:18:56 -08:00
|
|
|
#endif
|
|
|
|
|
2012-01-12 22:23:02 -08:00
|
|
|
#define GLES2_LIB "libGLESv2.so"
|
2012-01-20 06:18:56 -08:00
|
|
|
#define GLES2_LIB2 "libGLESv2.so.2"
|
2010-06-09 15:27:29 -07:00
|
|
|
|
2010-08-06 22:09:18 -07:00
|
|
|
#elif defined(XP_WIN)
|
|
|
|
|
2012-06-05 19:08:30 -07:00
|
|
|
#include "nsIFile.h"
|
2010-08-06 22:09:18 -07:00
|
|
|
|
2012-03-16 15:24:12 -07:00
|
|
|
#define GLES2_LIB "libGLESv2.dll"
|
|
|
|
|
2010-08-06 22:09:18 -07:00
|
|
|
#ifndef WIN32_LEAN_AND_MEAN
|
|
|
|
#define WIN32_LEAN_AND_MEAN 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
// a little helper
|
|
|
|
class AutoDestroyHWND {
|
|
|
|
public:
|
2013-07-20 01:48:55 -07:00
|
|
|
AutoDestroyHWND(HWND aWnd = nullptr)
|
2010-08-06 22:09:18 -07:00
|
|
|
: mWnd(aWnd)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~AutoDestroyHWND() {
|
|
|
|
if (mWnd) {
|
|
|
|
::DestroyWindow(mWnd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
operator HWND() {
|
|
|
|
return mWnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
HWND forget() {
|
|
|
|
HWND w = mWnd;
|
2013-07-20 01:48:55 -07:00
|
|
|
mWnd = nullptr;
|
2010-08-06 22:09:18 -07:00
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
|
|
|
HWND operator=(HWND aWnd) {
|
|
|
|
if (mWnd && mWnd != aWnd) {
|
|
|
|
::DestroyWindow(mWnd);
|
|
|
|
}
|
|
|
|
mWnd = aWnd;
|
|
|
|
return mWnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
HWND mWnd;
|
|
|
|
};
|
|
|
|
|
2010-06-09 15:27:29 -07:00
|
|
|
#else
|
|
|
|
|
|
|
|
#error "Platform not recognized"
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2012-03-12 08:43:14 -07:00
|
|
|
#include "mozilla/Preferences.h"
|
2011-01-13 05:20:50 -08:00
|
|
|
#include "gfxUtils.h"
|
2011-08-31 07:27:05 -07:00
|
|
|
#include "gfxFailure.h"
|
2010-06-23 08:50:51 -07:00
|
|
|
#include "gfxASurface.h"
|
2010-09-09 13:40:11 -07:00
|
|
|
#include "gfxImageSurface.h"
|
2010-07-01 09:30:38 -07:00
|
|
|
#include "gfxPlatform.h"
|
2010-06-09 15:27:29 -07:00
|
|
|
#include "GLContextProvider.h"
|
2012-03-16 15:24:12 -07:00
|
|
|
#include "GLLibraryEGL.h"
|
2010-06-09 15:27:29 -07:00
|
|
|
#include "nsDebug.h"
|
2010-11-26 13:41:53 -08:00
|
|
|
#include "nsThreadUtils.h"
|
2010-06-09 15:27:29 -07:00
|
|
|
|
|
|
|
#include "nsIWidget.h"
|
|
|
|
|
2011-03-02 12:50:36 -08:00
|
|
|
#include "gfxCrashReporterUtils.h"
|
|
|
|
|
2013-07-04 10:25:50 -07:00
|
|
|
using namespace mozilla::gfx;
|
2012-07-20 12:20:51 -07:00
|
|
|
|
2013-08-25 16:56:53 -07:00
|
|
|
#if defined(MOZ_WIDGET_GONK)
|
2011-01-13 05:20:50 -08:00
|
|
|
static bool gUseBackingSurface = true;
|
|
|
|
#else
|
2010-11-26 13:41:53 -08:00
|
|
|
static bool gUseBackingSurface = false;
|
2011-01-13 05:20:50 -08:00
|
|
|
#endif
|
2010-11-26 13:41:53 -08:00
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
extern nsIntRect gScreenBounds;
|
|
|
|
#endif
|
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
#define EGL_DISPLAY() sEGLLibrary.Display()
|
|
|
|
|
2010-06-09 15:27:29 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
2012-03-16 15:24:12 -07:00
|
|
|
static GLLibraryEGL sEGLLibrary;
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2011-01-06 14:07:12 -08:00
|
|
|
#define ADD_ATTR_2(_array, _k, _v) do { \
|
|
|
|
(_array).AppendElement(_k); \
|
|
|
|
(_array).AppendElement(_v); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ADD_ATTR_1(_array, _k) do { \
|
|
|
|
(_array).AppendElement(_k); \
|
|
|
|
} while (0)
|
|
|
|
|
2012-10-01 13:01:35 -07:00
|
|
|
#ifndef MOZ_ANDROID_OMTC
|
2011-09-22 22:58:15 -07:00
|
|
|
static EGLSurface
|
2010-12-13 14:36:35 -08:00
|
|
|
CreateSurfaceForWindow(nsIWidget *aWidget, EGLConfig config);
|
2012-06-19 21:12:30 -07:00
|
|
|
#endif
|
|
|
|
|
2011-09-22 22:58:15 -07:00
|
|
|
static bool
|
|
|
|
CreateConfig(EGLConfig* aConfig);
|
2011-01-13 05:20:50 -08:00
|
|
|
#ifdef MOZ_X11
|
2011-07-27 04:00:17 -07:00
|
|
|
|
2011-01-13 05:20:50 -08:00
|
|
|
static EGLConfig
|
2012-07-30 07:20:58 -07:00
|
|
|
CreateEGLSurfaceForXSurface(gfxASurface* aSurface, EGLConfig* aConfig = nullptr);
|
2011-01-13 05:20:50 -08:00
|
|
|
#endif
|
2010-12-13 14:36:35 -08:00
|
|
|
|
2011-12-14 16:57:09 -08:00
|
|
|
static EGLint gContextAttribs[] = {
|
|
|
|
LOCAL_EGL_CONTEXT_CLIENT_VERSION, 2,
|
|
|
|
LOCAL_EGL_NONE
|
|
|
|
};
|
|
|
|
|
|
|
|
static EGLint gContextAttribsRobustness[] = {
|
|
|
|
LOCAL_EGL_CONTEXT_CLIENT_VERSION, 2,
|
|
|
|
//LOCAL_EGL_CONTEXT_ROBUST_ACCESS_EXT, LOCAL_EGL_TRUE,
|
|
|
|
LOCAL_EGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_EXT, LOCAL_EGL_LOSE_CONTEXT_ON_RESET_EXT,
|
|
|
|
LOCAL_EGL_NONE
|
|
|
|
};
|
|
|
|
|
2010-07-18 22:01:14 -07:00
|
|
|
static int
|
|
|
|
next_power_of_two(int v)
|
|
|
|
{
|
|
|
|
v--;
|
|
|
|
v |= v >> 1;
|
|
|
|
v |= v >> 2;
|
|
|
|
v |= v >> 4;
|
|
|
|
v |= v >> 8;
|
|
|
|
v |= v >> 16;
|
|
|
|
v++;
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
is_power_of_two(int v)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(v >= 0, "bad value");
|
|
|
|
|
|
|
|
if (v == 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return (v & (v-1)) == 0;
|
|
|
|
}
|
|
|
|
|
2010-06-09 15:27:29 -07:00
|
|
|
class GLContextEGL : public GLContext
|
|
|
|
{
|
2010-07-01 09:30:38 -07:00
|
|
|
friend class TextureImageEGL;
|
|
|
|
|
2011-06-09 18:18:43 -07:00
|
|
|
static already_AddRefed<GLContextEGL>
|
2013-02-13 15:26:24 -08:00
|
|
|
CreateGLContext(const SurfaceCaps& caps,
|
2013-02-21 11:54:25 -08:00
|
|
|
GLContextEGL *shareContext,
|
2013-02-13 15:26:24 -08:00
|
|
|
bool isOffscreen,
|
|
|
|
EGLConfig config,
|
|
|
|
EGLSurface surface)
|
2011-06-09 18:18:43 -07:00
|
|
|
{
|
2013-02-13 15:26:24 -08:00
|
|
|
if (sEGLLibrary.fBindAPI(LOCAL_EGL_OPENGL_ES_API) == LOCAL_EGL_FALSE) {
|
|
|
|
NS_WARNING("Failed to bind API to GLES!");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
EGLContext eglShareContext = shareContext ? shareContext->mContext
|
|
|
|
: EGL_NO_CONTEXT;
|
|
|
|
EGLint* attribs = sEGLLibrary.HasRobustness() ? gContextAttribsRobustness
|
|
|
|
: gContextAttribs;
|
|
|
|
|
|
|
|
EGLContext context = sEGLLibrary.fCreateContext(EGL_DISPLAY(),
|
|
|
|
config,
|
|
|
|
eglShareContext,
|
|
|
|
attribs);
|
|
|
|
if (!context && shareContext) {
|
|
|
|
shareContext = nullptr;
|
|
|
|
context = sEGLLibrary.fCreateContext(EGL_DISPLAY(),
|
|
|
|
config,
|
|
|
|
EGL_NO_CONTEXT,
|
|
|
|
attribs);
|
2013-02-27 20:56:29 -08:00
|
|
|
}
|
|
|
|
if (!context) {
|
|
|
|
NS_WARNING("Failed to create EGLContext!");
|
|
|
|
return nullptr;
|
2011-06-09 18:18:43 -07:00
|
|
|
}
|
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
nsRefPtr<GLContextEGL> glContext = new GLContextEGL(caps,
|
|
|
|
shareContext,
|
|
|
|
isOffscreen,
|
|
|
|
config,
|
|
|
|
surface,
|
|
|
|
context);
|
2011-06-09 18:18:43 -07:00
|
|
|
|
|
|
|
if (!glContext->Init())
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2011-06-09 18:18:43 -07:00
|
|
|
|
|
|
|
return glContext.forget();
|
|
|
|
}
|
|
|
|
|
2010-06-09 15:27:29 -07:00
|
|
|
public:
|
2013-02-13 15:26:24 -08:00
|
|
|
GLContextEGL(const SurfaceCaps& caps,
|
|
|
|
GLContext* shareContext,
|
|
|
|
bool isOffscreen,
|
|
|
|
EGLConfig config,
|
|
|
|
EGLSurface surface,
|
|
|
|
EGLContext context)
|
|
|
|
: GLContext(caps, shareContext, isOffscreen)
|
|
|
|
, mConfig(config)
|
|
|
|
, mSurface(surface)
|
|
|
|
, mCurSurface(surface)
|
|
|
|
, mContext(context)
|
2012-07-30 07:20:58 -07:00
|
|
|
, mPlatformContext(nullptr)
|
|
|
|
, mThebesSurface(nullptr)
|
2011-10-17 07:59:28 -07:00
|
|
|
, mBound(false)
|
|
|
|
, mIsPBuffer(false)
|
|
|
|
, mIsDoubleBuffered(false)
|
2012-03-21 17:16:31 -07:00
|
|
|
, mCanBindToTexture(false)
|
2012-05-31 18:30:08 -07:00
|
|
|
, mShareWithEGLImage(false)
|
2012-08-01 11:57:54 -07:00
|
|
|
, mTemporaryEGLImageTexture(0)
|
2010-08-06 22:09:18 -07:00
|
|
|
{
|
|
|
|
// any EGL contexts will always be GLESv2
|
2013-08-01 16:43:27 -07:00
|
|
|
SetProfileVersion(ContextProfile::OpenGLES, 200);
|
2010-09-09 13:40:11 -07:00
|
|
|
|
2012-02-21 13:15:39 -08:00
|
|
|
#ifdef DEBUG
|
2010-09-09 13:40:11 -07:00
|
|
|
printf_stderr("Initializing context %p surface %p on display %p\n", mContext, mSurface, EGL_DISPLAY());
|
2012-08-24 12:42:45 -07:00
|
|
|
#endif
|
2013-09-11 06:10:33 -07:00
|
|
|
#if defined(MOZ_WIDGET_GONK)
|
2013-02-13 15:26:24 -08:00
|
|
|
if (!mIsOffscreen) {
|
2012-11-19 09:58:38 -08:00
|
|
|
mHwc = HwcComposer2D::GetInstance();
|
|
|
|
MOZ_ASSERT(!mHwc->Initialized());
|
2012-08-24 12:42:45 -07:00
|
|
|
|
2012-11-19 09:58:38 -08:00
|
|
|
if (mHwc->Init(EGL_DISPLAY(), mSurface)) {
|
|
|
|
NS_WARNING("HWComposer initialization failed!");
|
|
|
|
mHwc = nullptr;
|
|
|
|
}
|
2012-08-24 12:42:45 -07:00
|
|
|
}
|
2010-09-13 08:53:52 -07:00
|
|
|
#endif
|
2010-08-06 22:09:18 -07:00
|
|
|
}
|
2010-06-09 15:27:29 -07:00
|
|
|
|
|
|
|
~GLContextEGL()
|
|
|
|
{
|
2012-08-01 11:57:54 -07:00
|
|
|
if (MakeCurrent()) {
|
|
|
|
if (mTemporaryEGLImageTexture != 0) {
|
|
|
|
fDeleteTextures(1, &mTemporaryEGLImageTexture);
|
|
|
|
mTemporaryEGLImageTexture = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-21 12:41:24 -07:00
|
|
|
MarkDestroyed();
|
2010-08-06 22:09:18 -07:00
|
|
|
|
2010-06-23 02:24:22 -07:00
|
|
|
// If mGLWidget is non-null, then we've been given it by the GL context provider,
|
|
|
|
// and it's managed by the widget implementation. In this case, We can't destroy
|
|
|
|
// our contexts.
|
2011-08-24 09:15:58 -07:00
|
|
|
if (mPlatformContext)
|
2010-06-23 02:24:22 -07:00
|
|
|
return;
|
|
|
|
|
2012-02-21 13:15:39 -08:00
|
|
|
#ifdef DEBUG
|
2010-09-09 13:40:11 -07:00
|
|
|
printf_stderr("Destroying context %p surface %p on display %p\n", mContext, mSurface, EGL_DISPLAY());
|
2010-09-13 08:53:52 -07:00
|
|
|
#endif
|
2010-09-09 13:40:11 -07:00
|
|
|
|
2010-07-18 22:01:14 -07:00
|
|
|
sEGLLibrary.fDestroyContext(EGL_DISPLAY(), mContext);
|
2011-09-14 12:14:43 -07:00
|
|
|
if (mSurface && !mPlatformContext) {
|
2011-08-23 13:48:27 -07:00
|
|
|
sEGLLibrary.fDestroySurface(EGL_DISPLAY(), mSurface);
|
|
|
|
}
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
GLContextType GetContextType() {
|
|
|
|
return ContextTypeEGL;
|
2010-06-09 15:27:29 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool Init()
|
2010-06-09 15:27:29 -07:00
|
|
|
{
|
2012-02-29 13:55:46 -08:00
|
|
|
#if defined(ANDROID)
|
|
|
|
// We can't use LoadApitraceLibrary here because the GLContext
|
|
|
|
// expects its own handle to the GL library
|
|
|
|
if (!OpenLibrary(APITRACE_LIB))
|
|
|
|
#endif
|
|
|
|
if (!OpenLibrary(GLES2_LIB)) {
|
2012-01-20 06:18:56 -08:00
|
|
|
#if defined(XP_UNIX)
|
2012-02-29 13:55:46 -08:00
|
|
|
if (!OpenLibrary(GLES2_LIB2)) {
|
|
|
|
NS_WARNING("Couldn't load GLES2 LIB.");
|
|
|
|
return false;
|
|
|
|
}
|
2012-01-20 06:18:56 -08:00
|
|
|
#endif
|
2012-02-29 13:55:46 -08:00
|
|
|
}
|
2010-06-09 15:27:29 -07:00
|
|
|
|
2012-06-12 21:20:27 -07:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
char propValue[PROPERTY_VALUE_MAX];
|
|
|
|
property_get("ro.build.version.sdk", propValue, "0");
|
|
|
|
if (atoi(propValue) < 15)
|
|
|
|
gUseBackingSurface = false;
|
|
|
|
#endif
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool current = MakeCurrent();
|
2011-08-31 07:27:05 -07:00
|
|
|
if (!current) {
|
|
|
|
gfx::LogFailure(NS_LITERAL_CSTRING(
|
|
|
|
"Couldn't get device attachments for device."));
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2011-08-31 07:27:05 -07:00
|
|
|
}
|
|
|
|
|
2012-07-23 13:39:29 -07:00
|
|
|
SetupLookupFunction();
|
2013-03-04 16:44:31 -08:00
|
|
|
if (!InitWithPrefix("gl", true))
|
|
|
|
return false;
|
2011-10-26 14:36:18 -07:00
|
|
|
|
|
|
|
PR_STATIC_ASSERT(sizeof(GLint) >= sizeof(int32_t));
|
2012-09-27 23:57:33 -07:00
|
|
|
mMaxTextureImageSize = INT32_MAX;
|
2011-12-14 16:57:09 -08:00
|
|
|
|
2012-05-31 18:30:08 -07:00
|
|
|
mShareWithEGLImage = sEGLLibrary.HasKHRImageBase() &&
|
|
|
|
sEGLLibrary.HasKHRImageTexture2D() &&
|
|
|
|
IsExtensionSupported(OES_EGL_image);
|
|
|
|
|
2013-03-04 16:44:31 -08:00
|
|
|
return true;
|
2010-09-09 13:40:11 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsDoubleBuffered() {
|
2010-09-09 13:40:11 -07:00
|
|
|
return mIsDoubleBuffered;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetIsDoubleBuffered(bool aIsDB) {
|
2010-09-09 13:40:11 -07:00
|
|
|
mIsDoubleBuffered = aIsDB;
|
2010-06-09 15:27:29 -07:00
|
|
|
}
|
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
virtual EGLContext GetEGLContext() {
|
|
|
|
return mContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual GLLibraryEGL* GetLibraryEGL() {
|
|
|
|
return &sEGLLibrary;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-18 19:57:29 -08:00
|
|
|
bool SupportsRobustness()
|
|
|
|
{
|
2011-12-14 16:57:09 -08:00
|
|
|
return sEGLLibrary.HasRobustness();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool IsANGLE()
|
|
|
|
{
|
|
|
|
return sEGLLibrary.IsANGLE();
|
2011-11-18 19:57:29 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool BindTexImage()
|
2010-06-23 02:24:31 -07:00
|
|
|
{
|
2010-06-24 03:04:28 -07:00
|
|
|
if (!mSurface)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-06-23 02:24:31 -07:00
|
|
|
|
2010-06-24 03:04:28 -07:00
|
|
|
if (mBound && !ReleaseTexImage())
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-06-24 03:04:28 -07:00
|
|
|
|
2010-07-18 22:01:14 -07:00
|
|
|
EGLBoolean success = sEGLLibrary.fBindTexImage(EGL_DISPLAY(),
|
2010-06-24 03:04:28 -07:00
|
|
|
(EGLSurface)mSurface, LOCAL_EGL_BACK_BUFFER);
|
|
|
|
if (success == LOCAL_EGL_FALSE)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-06-23 02:24:31 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
mBound = true;
|
|
|
|
return true;
|
2010-06-23 02:24:31 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ReleaseTexImage()
|
2010-06-23 02:24:31 -07:00
|
|
|
{
|
|
|
|
if (!mBound)
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2010-06-23 02:24:31 -07:00
|
|
|
|
2010-07-18 22:01:14 -07:00
|
|
|
if (!mSurface)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-06-23 02:24:31 -07:00
|
|
|
|
2010-06-24 03:04:28 -07:00
|
|
|
EGLBoolean success;
|
2010-07-18 22:01:14 -07:00
|
|
|
success = sEGLLibrary.fReleaseTexImage(EGL_DISPLAY(),
|
|
|
|
(EGLSurface)mSurface,
|
|
|
|
LOCAL_EGL_BACK_BUFFER);
|
2010-06-24 03:04:28 -07:00
|
|
|
if (success == LOCAL_EGL_FALSE)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-06-23 02:24:31 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
mBound = false;
|
|
|
|
return true;
|
2010-06-23 02:24:31 -07:00
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
EGLImage CreateEGLImageForNativeBuffer(void* buffer) MOZ_OVERRIDE
|
2012-07-16 19:12:58 -07:00
|
|
|
{
|
|
|
|
EGLint attrs[] = {
|
2012-07-19 21:14:14 -07:00
|
|
|
LOCAL_EGL_IMAGE_PRESERVED, LOCAL_EGL_TRUE,
|
2012-07-16 19:12:58 -07:00
|
|
|
LOCAL_EGL_NONE, LOCAL_EGL_NONE
|
|
|
|
};
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
return sEGLLibrary.fCreateImage(EGL_DISPLAY(),
|
|
|
|
EGL_NO_CONTEXT,
|
|
|
|
LOCAL_EGL_NATIVE_BUFFER_ANDROID,
|
|
|
|
buffer, attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DestroyEGLImage(EGLImage image) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
sEGLLibrary.fDestroyImage(EGL_DISPLAY(), image);
|
|
|
|
}
|
2013-04-17 13:56:03 -07:00
|
|
|
|
|
|
|
EGLImage GetNullEGLImage() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
if (!mNullGraphicBuffer.get()) {
|
|
|
|
mNullGraphicBuffer
|
|
|
|
= new android::GraphicBuffer(
|
|
|
|
1, 1,
|
|
|
|
PIXEL_FORMAT_RGB_565,
|
|
|
|
GRALLOC_USAGE_SW_READ_NEVER | GRALLOC_USAGE_SW_WRITE_NEVER);
|
|
|
|
EGLint attrs[] = {
|
|
|
|
LOCAL_EGL_NONE, LOCAL_EGL_NONE
|
|
|
|
};
|
|
|
|
mNullEGLImage = sEGLLibrary.fCreateImage(EGL_DISPLAY(),
|
|
|
|
EGL_NO_CONTEXT,
|
|
|
|
LOCAL_EGL_NATIVE_BUFFER_ANDROID,
|
|
|
|
mNullGraphicBuffer->getNativeBuffer(),
|
|
|
|
attrs);
|
|
|
|
}
|
|
|
|
return mNullEGLImage;
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
#endif
|
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
virtual void MakeCurrent_EGLSurface(void* surf) {
|
|
|
|
EGLSurface eglSurface = (EGLSurface)surf;
|
|
|
|
if (!eglSurface)
|
|
|
|
eglSurface = mSurface;
|
|
|
|
|
|
|
|
if (eglSurface == mCurSurface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Else, surface changed...
|
|
|
|
mCurSurface = eglSurface;
|
|
|
|
MakeCurrent(true);
|
|
|
|
}
|
|
|
|
|
2012-05-12 16:23:56 -07:00
|
|
|
bool MakeCurrentImpl(bool aForce = false) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool succeeded = true;
|
2010-06-23 01:02:12 -07:00
|
|
|
|
|
|
|
// Assume that EGL has the same problem as WGL does,
|
|
|
|
// where MakeCurrent with an already-current context is
|
|
|
|
// still expensive.
|
2011-08-23 13:48:27 -07:00
|
|
|
#ifndef MOZ_WIDGET_QT
|
2011-08-26 16:23:02 -07:00
|
|
|
if (!mSurface) {
|
2012-02-15 13:02:39 -08:00
|
|
|
// We need to be able to bind NO_SURFACE when we don't
|
|
|
|
// have access to a surface. We won't be drawing to the screen
|
|
|
|
// but we will be able to do things like resource releases.
|
|
|
|
succeeded = sEGLLibrary.fMakeCurrent(EGL_DISPLAY(),
|
|
|
|
EGL_NO_SURFACE, EGL_NO_SURFACE,
|
2012-03-28 15:00:41 -07:00
|
|
|
EGL_NO_CONTEXT);
|
2012-02-15 13:02:39 -08:00
|
|
|
if (!succeeded && sEGLLibrary.fGetError() == LOCAL_EGL_CONTEXT_LOST) {
|
|
|
|
mContextLost = true;
|
|
|
|
NS_WARNING("EGL context has been lost.");
|
|
|
|
}
|
|
|
|
NS_ASSERTION(succeeded, "Failed to make GL context current!");
|
|
|
|
return succeeded;
|
2011-08-26 16:23:02 -07:00
|
|
|
}
|
2011-08-24 09:15:58 -07:00
|
|
|
#endif
|
2012-05-12 16:23:56 -07:00
|
|
|
if (aForce || sEGLLibrary.fGetCurrentContext() != mContext) {
|
2012-03-21 17:16:31 -07:00
|
|
|
#ifdef MOZ_WIDGET_QT
|
2012-05-12 16:23:56 -07:00
|
|
|
// Shared Qt GL context need to be informed about context switch
|
|
|
|
if (mSharedContext) {
|
|
|
|
QGLContext* qglCtx = static_cast<QGLContext*>(static_cast<GLContextEGL*>(mSharedContext.get())->mPlatformContext);
|
|
|
|
if (qglCtx) {
|
|
|
|
qglCtx->doneCurrent();
|
|
|
|
}
|
2012-03-21 17:16:31 -07:00
|
|
|
}
|
|
|
|
#endif
|
2012-05-12 16:23:56 -07:00
|
|
|
succeeded = sEGLLibrary.fMakeCurrent(EGL_DISPLAY(),
|
2013-02-13 15:26:24 -08:00
|
|
|
mCurSurface, mCurSurface,
|
2012-05-12 16:23:56 -07:00
|
|
|
mContext);
|
2012-08-01 11:57:54 -07:00
|
|
|
|
|
|
|
int eglError = sEGLLibrary.fGetError();
|
|
|
|
if (!succeeded) {
|
|
|
|
if (eglError == LOCAL_EGL_CONTEXT_LOST) {
|
|
|
|
mContextLost = true;
|
|
|
|
NS_WARNING("EGL context has been lost.");
|
|
|
|
} else {
|
|
|
|
NS_WARNING("Failed to make GL context current!");
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf_stderr("EGL Error: 0x%04x\n", eglError);
|
|
|
|
#endif
|
|
|
|
}
|
2012-05-12 16:23:56 -07:00
|
|
|
}
|
2010-06-23 01:02:12 -07:00
|
|
|
}
|
2010-06-09 15:27:29 -07:00
|
|
|
|
|
|
|
return succeeded;
|
|
|
|
}
|
|
|
|
|
2012-08-21 20:30:20 -07:00
|
|
|
virtual bool IsCurrent() {
|
|
|
|
return sEGLLibrary.fGetCurrentContext() == mContext;
|
|
|
|
}
|
|
|
|
|
2010-12-13 14:36:35 -08:00
|
|
|
#ifdef MOZ_WIDGET_QT
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool
|
2010-12-13 14:36:35 -08:00
|
|
|
RenewSurface() {
|
|
|
|
/* We don't support renewing on QT because we don't create the surface ourselves */
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-12-13 14:36:35 -08:00
|
|
|
}
|
|
|
|
#else
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool
|
2010-12-13 14:36:35 -08:00
|
|
|
RenewSurface() {
|
2012-06-12 07:24:31 -07:00
|
|
|
sEGLLibrary.fMakeCurrent(EGL_DISPLAY(), EGL_NO_SURFACE, EGL_NO_SURFACE,
|
|
|
|
EGL_NO_CONTEXT);
|
|
|
|
if (!mSurface) {
|
2012-10-01 13:01:35 -07:00
|
|
|
#ifdef MOZ_ANDROID_OMTC
|
2013-02-28 10:28:23 -08:00
|
|
|
mSurface = mozilla::AndroidBridge::Bridge()->ProvideEGLSurface();
|
2013-01-10 08:21:10 -08:00
|
|
|
if (!mSurface) {
|
|
|
|
return false;
|
|
|
|
}
|
2012-05-29 10:46:37 -07:00
|
|
|
#else
|
2012-06-12 07:24:31 -07:00
|
|
|
EGLConfig config;
|
|
|
|
CreateConfig(&config);
|
2013-07-20 01:48:55 -07:00
|
|
|
mSurface = CreateSurfaceForWindow(nullptr, config);
|
2012-05-29 10:46:37 -07:00
|
|
|
#endif
|
2012-06-12 07:24:31 -07:00
|
|
|
}
|
2010-12-13 14:36:35 -08:00
|
|
|
return sEGLLibrary.fMakeCurrent(EGL_DISPLAY(),
|
|
|
|
mSurface, mSurface,
|
|
|
|
mContext);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-08-23 13:48:27 -07:00
|
|
|
virtual void
|
|
|
|
ReleaseSurface() {
|
2011-09-14 12:14:43 -07:00
|
|
|
if (mSurface && !mPlatformContext) {
|
2011-08-23 13:48:27 -07:00
|
|
|
sEGLLibrary.fMakeCurrent(EGL_DISPLAY(), EGL_NO_SURFACE, EGL_NO_SURFACE,
|
|
|
|
EGL_NO_CONTEXT);
|
|
|
|
sEGLLibrary.fDestroySurface(EGL_DISPLAY(), mSurface);
|
2013-07-20 01:48:55 -07:00
|
|
|
mSurface = nullptr;
|
2011-08-23 13:48:27 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool SetupLookupFunction()
|
2010-06-09 15:27:29 -07:00
|
|
|
{
|
2012-02-09 11:05:11 -08:00
|
|
|
mLookupFunc = (PlatformLookupFunction)sEGLLibrary.mSymbols.fGetProcAddress;
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2010-06-09 15:27:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void *GetNativeData(NativeDataType aType)
|
|
|
|
{
|
|
|
|
switch (aType) {
|
|
|
|
case NativeGLContext:
|
|
|
|
return mContext;
|
|
|
|
|
|
|
|
default:
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-06-09 15:27:29 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool SwapBuffers()
|
2010-06-25 17:52:37 -07:00
|
|
|
{
|
2011-09-14 12:14:43 -07:00
|
|
|
if (mSurface && !mPlatformContext) {
|
2012-08-24 12:42:45 -07:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2013-10-04 11:01:22 -07:00
|
|
|
if (!mIsOffscreen) {
|
|
|
|
if (mHwc) {
|
|
|
|
return mHwc->Render(EGL_DISPLAY(), mSurface);
|
|
|
|
} else {
|
|
|
|
return GetGonkDisplay()->SwapBuffers(EGL_DISPLAY(), mSurface);
|
|
|
|
}
|
|
|
|
} else
|
2012-08-24 12:42:45 -07:00
|
|
|
#endif
|
|
|
|
return sEGLLibrary.fSwapBuffers(EGL_DISPLAY(), mSurface);
|
2011-08-23 13:48:27 -07:00
|
|
|
} else {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2011-08-23 13:48:27 -07:00
|
|
|
}
|
2010-06-25 17:52:37 -07:00
|
|
|
}
|
2011-07-06 11:00:47 -07:00
|
|
|
// GLContext interface - returns Tiled Texture Image in our case
|
2010-07-01 09:30:38 -07:00
|
|
|
virtual already_AddRefed<TextureImage>
|
|
|
|
CreateTextureImage(const nsIntSize& aSize,
|
|
|
|
TextureImage::ContentType aContentType,
|
2010-11-12 12:02:20 -08:00
|
|
|
GLenum aWrapMode,
|
2013-08-07 15:38:21 -07:00
|
|
|
TextureImage::Flags aFlags = TextureImage::NoFlags,
|
2013-09-24 13:45:13 -07:00
|
|
|
TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
|
2010-07-01 09:30:38 -07:00
|
|
|
|
2011-07-06 11:00:47 -07:00
|
|
|
// a function to generate Tiles for Tiled Texture Image
|
|
|
|
virtual already_AddRefed<TextureImage>
|
|
|
|
TileGenFunc(const nsIntSize& aSize,
|
|
|
|
TextureImage::ContentType aContentType,
|
2013-08-07 15:38:21 -07:00
|
|
|
TextureImage::Flags aFlags = TextureImage::NoFlags,
|
2013-09-24 13:45:13 -07:00
|
|
|
TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown) MOZ_OVERRIDE;
|
2010-07-18 22:01:14 -07:00
|
|
|
// hold a reference to the given surface
|
|
|
|
// for the lifetime of this context.
|
|
|
|
void HoldSurface(gfxASurface *aSurf) {
|
|
|
|
mThebesSurface = aSurf;
|
|
|
|
}
|
|
|
|
|
2011-08-24 09:15:58 -07:00
|
|
|
void SetPlatformContext(void *context) {
|
|
|
|
mPlatformContext = context;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EGLContext Context() {
|
|
|
|
return mContext;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool BindTex2DOffscreen(GLContext *aOffscreen);
|
2010-07-18 22:01:14 -07:00
|
|
|
void UnbindTex2DOffscreen(GLContext *aOffscreen);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ResizeOffscreen(const gfxIntSize& aNewSize);
|
2010-07-18 22:01:14 -07:00
|
|
|
void BindOffscreenFramebuffer();
|
|
|
|
|
|
|
|
static already_AddRefed<GLContextEGL>
|
2013-02-13 15:26:24 -08:00
|
|
|
CreateEGLPixmapOffscreenContext(const gfxIntSize& size);
|
2010-07-18 22:01:14 -07:00
|
|
|
|
|
|
|
static already_AddRefed<GLContextEGL>
|
2013-02-13 15:26:24 -08:00
|
|
|
CreateEGLPBufferOffscreenContext(const gfxIntSize& size);
|
2011-01-06 14:07:12 -08:00
|
|
|
|
2012-11-26 14:23:27 -08:00
|
|
|
virtual SharedTextureHandle CreateSharedHandle(SharedTextureShareType shareType,
|
|
|
|
void* buffer,
|
|
|
|
SharedTextureBufferType bufferType);
|
|
|
|
virtual void UpdateSharedHandle(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle);
|
|
|
|
virtual void ReleaseSharedHandle(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle);
|
|
|
|
virtual bool GetSharedHandleDetails(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle,
|
|
|
|
SharedHandleDetails& details);
|
|
|
|
virtual bool AttachSharedHandle(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle);
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2010-07-18 22:01:14 -07:00
|
|
|
protected:
|
|
|
|
friend class GLContextProviderEGL;
|
|
|
|
|
2010-06-09 15:27:29 -07:00
|
|
|
EGLConfig mConfig;
|
|
|
|
EGLSurface mSurface;
|
2013-02-13 15:26:24 -08:00
|
|
|
EGLSurface mCurSurface;
|
2010-06-09 15:27:29 -07:00
|
|
|
EGLContext mContext;
|
2011-08-24 09:15:58 -07:00
|
|
|
void *mPlatformContext;
|
2010-07-18 22:01:14 -07:00
|
|
|
nsRefPtr<gfxASurface> mThebesSurface;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mBound;
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsPBuffer;
|
|
|
|
bool mIsDoubleBuffered;
|
2012-03-21 17:16:31 -07:00
|
|
|
bool mCanBindToTexture;
|
2012-05-31 18:30:08 -07:00
|
|
|
bool mShareWithEGLImage;
|
2012-08-24 12:42:45 -07:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2012-11-19 09:58:38 -08:00
|
|
|
nsRefPtr<HwcComposer2D> mHwc;
|
2013-04-20 07:08:18 -07:00
|
|
|
|
|
|
|
/* mNullEGLImage and mNullGraphicBuffer are a hack to unattach a gralloc buffer
|
|
|
|
* from a texture, which we don't know how to do otherwise (at least in the
|
|
|
|
* TEXTURE_EXTERNAL case --- in the TEXTURE_2D case we could also use TexImage2D).
|
|
|
|
*
|
|
|
|
* So mNullGraphicBuffer will be initialized once to be a 1x1 gralloc buffer,
|
|
|
|
* and mNullEGLImage will be initialized once to be an EGLImage wrapping it.
|
|
|
|
*
|
|
|
|
* This happens in GetNullEGLImage().
|
|
|
|
*/
|
2013-04-17 13:56:03 -07:00
|
|
|
EGLImage mNullEGLImage;
|
|
|
|
android::sp<android::GraphicBuffer> mNullGraphicBuffer;
|
2012-08-24 12:42:45 -07:00
|
|
|
#endif
|
2011-01-31 13:10:57 -08:00
|
|
|
|
2012-08-01 11:57:54 -07:00
|
|
|
// A dummy texture ID that can be used when we need a texture object whose
|
|
|
|
// images we're going to define with EGLImageTargetTexture2D.
|
|
|
|
GLuint mTemporaryEGLImageTexture;
|
|
|
|
|
2011-01-31 13:10:57 -08:00
|
|
|
static EGLSurface CreatePBufferSurfaceTryingPowerOfTwo(EGLConfig config,
|
|
|
|
EGLenum bindToTextureFormat,
|
|
|
|
gfxIntSize& pbsize)
|
|
|
|
{
|
|
|
|
nsTArray<EGLint> pbattrs(16);
|
2012-07-30 07:20:58 -07:00
|
|
|
EGLSurface surface = nullptr;
|
2011-01-31 13:10:57 -08:00
|
|
|
|
|
|
|
TRY_AGAIN_POWER_OF_TWO:
|
|
|
|
pbattrs.Clear();
|
|
|
|
pbattrs.AppendElement(LOCAL_EGL_WIDTH); pbattrs.AppendElement(pbsize.width);
|
|
|
|
pbattrs.AppendElement(LOCAL_EGL_HEIGHT); pbattrs.AppendElement(pbsize.height);
|
|
|
|
|
|
|
|
if (bindToTextureFormat != LOCAL_EGL_NONE) {
|
|
|
|
pbattrs.AppendElement(LOCAL_EGL_TEXTURE_TARGET);
|
|
|
|
pbattrs.AppendElement(LOCAL_EGL_TEXTURE_2D);
|
|
|
|
|
|
|
|
pbattrs.AppendElement(LOCAL_EGL_TEXTURE_FORMAT);
|
|
|
|
pbattrs.AppendElement(bindToTextureFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
pbattrs.AppendElement(LOCAL_EGL_NONE);
|
|
|
|
|
|
|
|
surface = sEGLLibrary.fCreatePbufferSurface(EGL_DISPLAY(), config, &pbattrs[0]);
|
|
|
|
if (!surface) {
|
|
|
|
if (!is_power_of_two(pbsize.width) ||
|
|
|
|
!is_power_of_two(pbsize.height))
|
|
|
|
{
|
|
|
|
if (!is_power_of_two(pbsize.width))
|
|
|
|
pbsize.width = next_power_of_two(pbsize.width);
|
|
|
|
if (!is_power_of_two(pbsize.height))
|
|
|
|
pbsize.height = next_power_of_two(pbsize.height);
|
|
|
|
|
|
|
|
NS_WARNING("Failed to create pbuffer, trying power of two dims");
|
|
|
|
goto TRY_AGAIN_POWER_OF_TWO;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_WARNING("Failed to create pbuffer surface");
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2011-01-31 13:10:57 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return surface;
|
|
|
|
}
|
2010-06-09 15:27:29 -07:00
|
|
|
};
|
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-09-04 05:14:52 -07:00
|
|
|
enum SharedHandleType {
|
|
|
|
SharedHandleType_Image
|
2012-07-20 12:20:51 -07:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2013-09-04 05:14:52 -07:00
|
|
|
, SharedHandleType_SurfaceTexture
|
2012-07-20 12:20:51 -07:00
|
|
|
#endif
|
2013-09-04 05:14:52 -07:00
|
|
|
};
|
2012-07-20 12:20:51 -07:00
|
|
|
|
|
|
|
class SharedTextureHandleWrapper
|
2012-05-31 18:30:08 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-07-20 12:20:51 -07:00
|
|
|
SharedTextureHandleWrapper(SharedHandleType aHandleType) : mHandleType(aHandleType)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~SharedTextureHandleWrapper()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SharedHandleType Type() { return mHandleType; }
|
|
|
|
|
|
|
|
SharedHandleType mHandleType;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
|
|
|
|
class SurfaceTextureWrapper: public SharedTextureHandleWrapper
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SurfaceTextureWrapper(nsSurfaceTexture* aSurfaceTexture) :
|
2013-09-04 05:14:52 -07:00
|
|
|
SharedTextureHandleWrapper(SharedHandleType_SurfaceTexture)
|
2012-07-20 12:20:51 -07:00
|
|
|
, mSurfaceTexture(aSurfaceTexture)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~SurfaceTextureWrapper() {
|
2012-07-30 07:20:58 -07:00
|
|
|
mSurfaceTexture = nullptr;
|
2012-07-20 12:20:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsSurfaceTexture* SurfaceTexture() { return mSurfaceTexture; }
|
|
|
|
|
|
|
|
nsRefPtr<nsSurfaceTexture> mSurfaceTexture;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MOZ_WIDGET_ANDROID
|
|
|
|
|
|
|
|
class EGLTextureWrapper : public SharedTextureHandleWrapper
|
|
|
|
{
|
|
|
|
public:
|
2012-08-01 11:57:54 -07:00
|
|
|
EGLTextureWrapper() :
|
2013-09-04 05:14:52 -07:00
|
|
|
SharedTextureHandleWrapper(SharedHandleType_Image)
|
2012-07-30 07:20:58 -07:00
|
|
|
, mEGLImage(nullptr)
|
|
|
|
, mSyncObject(nullptr)
|
2012-05-31 18:30:08 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-01 11:57:54 -07:00
|
|
|
// Args are the active GL context, and a texture in that GL
|
|
|
|
// context for which to create an EGLImage. After the EGLImage
|
|
|
|
// is created, the texture is unused by EGLTextureWrapper.
|
|
|
|
bool CreateEGLImage(GLContextEGL *ctx, GLuint texture) {
|
|
|
|
MOZ_ASSERT(!mEGLImage && texture && sEGLLibrary.HasKHRImageBase());
|
2012-05-31 18:30:08 -07:00
|
|
|
static const EGLint eglAttributes[] = {
|
|
|
|
LOCAL_EGL_NONE
|
|
|
|
};
|
2013-02-13 15:26:24 -08:00
|
|
|
EGLContext eglContext = (EGLContext)ctx->GetEGLContext();
|
|
|
|
mEGLImage = sEGLLibrary.fCreateImage(EGL_DISPLAY(), eglContext, LOCAL_EGL_GL_TEXTURE_2D,
|
2012-08-01 11:57:54 -07:00
|
|
|
(EGLClientBuffer)texture, eglAttributes);
|
2012-05-31 18:30:08 -07:00
|
|
|
if (!mEGLImage) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf_stderr("Could not create EGL images: ERROR (0x%04x)\n", sEGLLibrary.fGetError());
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~EGLTextureWrapper() {
|
|
|
|
if (mEGLImage) {
|
|
|
|
sEGLLibrary.fDestroyImage(EGL_DISPLAY(), mEGLImage);
|
2012-07-30 07:20:58 -07:00
|
|
|
mEGLImage = nullptr;
|
2012-05-31 18:30:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const EGLImage GetEGLImage() {
|
|
|
|
return mEGLImage;
|
|
|
|
}
|
|
|
|
|
2012-08-01 11:57:54 -07:00
|
|
|
// Insert a sync point on the given context, which should be the current active
|
|
|
|
// context.
|
|
|
|
bool MakeSync(GLContext *ctx) {
|
2012-07-30 07:20:58 -07:00
|
|
|
MOZ_ASSERT(mSyncObject == nullptr);
|
2012-07-17 18:20:28 -07:00
|
|
|
|
|
|
|
if (sEGLLibrary.IsExtensionSupported(GLLibraryEGL::KHR_fence_sync)) {
|
2012-07-30 07:20:58 -07:00
|
|
|
mSyncObject = sEGLLibrary.fCreateSync(EGL_DISPLAY(), LOCAL_EGL_SYNC_FENCE, nullptr);
|
2012-07-17 18:20:28 -07:00
|
|
|
// We need to flush to make sure the sync object enters the command stream;
|
|
|
|
// we can't use EGL_SYNC_FLUSH_COMMANDS_BIT at wait time, because the wait
|
|
|
|
// happens on a different thread/context.
|
2012-08-01 11:57:54 -07:00
|
|
|
ctx->fFlush();
|
2012-07-17 18:20:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mSyncObject == EGL_NO_SYNC) {
|
|
|
|
// we failed to create one, so just do a finish
|
2012-08-01 11:57:54 -07:00
|
|
|
ctx->fFinish();
|
2012-07-17 18:20:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WaitSync() {
|
|
|
|
if (!mSyncObject) {
|
|
|
|
// if we have no sync object, then we did a Finish() earlier
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-26 18:31:42 -07:00
|
|
|
// wait at most 1 second; this should really be never/rarely hit
|
|
|
|
const uint64_t ns_per_ms = 1000 * 1000;
|
|
|
|
EGLTime timeout = 1000 * ns_per_ms;
|
|
|
|
|
|
|
|
EGLint result = sEGLLibrary.fClientWaitSync(EGL_DISPLAY(), mSyncObject, 0, timeout);
|
2012-07-17 18:20:28 -07:00
|
|
|
sEGLLibrary.fDestroySync(EGL_DISPLAY(), mSyncObject);
|
2012-07-30 07:20:58 -07:00
|
|
|
mSyncObject = nullptr;
|
2012-07-17 18:20:28 -07:00
|
|
|
|
|
|
|
return result == LOCAL_EGL_CONDITION_SATISFIED;
|
|
|
|
}
|
|
|
|
|
2012-05-31 18:30:08 -07:00
|
|
|
private:
|
|
|
|
EGLImage mEGLImage;
|
2012-07-17 18:20:28 -07:00
|
|
|
EGLSync mSyncObject;
|
2012-05-31 18:30:08 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2012-11-26 14:23:27 -08:00
|
|
|
GLContextEGL::UpdateSharedHandle(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle)
|
2012-05-31 18:30:08 -07:00
|
|
|
{
|
2012-11-26 14:23:27 -08:00
|
|
|
if (shareType != SameProcess) {
|
2012-05-31 18:30:08 -07:00
|
|
|
NS_ERROR("Implementation not available for this sharing type");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-26 14:23:27 -08:00
|
|
|
SharedTextureHandleWrapper* wrapper = reinterpret_cast<SharedTextureHandleWrapper*>(sharedHandle);
|
2012-07-20 12:20:51 -07:00
|
|
|
|
2013-09-04 05:14:52 -07:00
|
|
|
NS_ASSERTION(wrapper->Type() == SharedHandleType_Image, "Expected EGLImage shared handle");
|
2012-05-31 18:30:08 -07:00
|
|
|
NS_ASSERTION(mShareWithEGLImage, "EGLImage not supported or disabled in runtime");
|
|
|
|
|
2012-07-20 12:20:51 -07:00
|
|
|
EGLTextureWrapper* wrap = reinterpret_cast<EGLTextureWrapper*>(wrapper);
|
2012-05-31 18:30:08 -07:00
|
|
|
// We need to copy the current GLContext drawing buffer to the texture
|
|
|
|
// exported by the EGLImage. Need to save both the read FBO and the texture
|
|
|
|
// binding, because we're going to munge them to do this.
|
2013-02-13 15:26:24 -08:00
|
|
|
ScopedBindTexture autoTex(this, mTemporaryEGLImageTexture);
|
2012-08-01 11:57:54 -07:00
|
|
|
fEGLImageTargetTexture2D(LOCAL_GL_TEXTURE_2D, wrap->GetEGLImage());
|
2012-05-31 18:30:08 -07:00
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
// CopyTexSubImage2D, is ~2x slower than simple FBO render to texture with
|
|
|
|
// draw quads, but if we want that, we need to assure that our default
|
|
|
|
// framebuffer is texture-backed.
|
|
|
|
gfxIntSize size = OffscreenSize();
|
|
|
|
BlitFramebufferToTexture(0, mTemporaryEGLImageTexture, size, size);
|
2012-05-31 18:30:08 -07:00
|
|
|
|
2012-07-26 18:31:42 -07:00
|
|
|
// Make sure our copy is finished, so that we can be ready to draw
|
|
|
|
// in different thread GLContext. If we have KHR_fence_sync, then
|
|
|
|
// we insert a sync object, otherwise we have to do a GuaranteeResolve.
|
2012-08-01 11:57:54 -07:00
|
|
|
wrap->MakeSync(this);
|
2012-05-31 18:30:08 -07:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:20:51 -07:00
|
|
|
SharedTextureHandle
|
2012-11-26 14:23:27 -08:00
|
|
|
GLContextEGL::CreateSharedHandle(SharedTextureShareType shareType,
|
|
|
|
void* buffer,
|
|
|
|
SharedTextureBufferType bufferType)
|
2012-07-20 12:20:51 -07:00
|
|
|
{
|
2013-02-13 15:26:24 -08:00
|
|
|
// Both EGLImage and SurfaceTexture only support same-process currently, but
|
2012-07-20 12:20:51 -07:00
|
|
|
// it's possible to make SurfaceTexture work across processes. We should do that.
|
2012-11-26 14:23:27 -08:00
|
|
|
if (shareType != SameProcess)
|
2012-07-25 02:27:00 -07:00
|
|
|
return 0;
|
2012-07-20 12:20:51 -07:00
|
|
|
|
2012-11-26 14:23:27 -08:00
|
|
|
switch (bufferType) {
|
2012-07-20 12:20:51 -07:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
case SharedTextureBufferType::SurfaceTexture:
|
|
|
|
if (!IsExtensionSupported(GLContext::OES_EGL_image_external)) {
|
|
|
|
NS_WARNING("Missing GL_OES_EGL_image_external");
|
2012-07-25 02:27:00 -07:00
|
|
|
return 0;
|
2012-07-20 12:20:51 -07:00
|
|
|
}
|
|
|
|
|
2012-11-26 14:23:27 -08:00
|
|
|
return (SharedTextureHandle) new SurfaceTextureWrapper(reinterpret_cast<nsSurfaceTexture*>(buffer));
|
2012-07-20 12:20:51 -07:00
|
|
|
#endif
|
|
|
|
case SharedTextureBufferType::TextureID: {
|
|
|
|
if (!mShareWithEGLImage)
|
2012-07-25 02:27:00 -07:00
|
|
|
return 0;
|
2012-07-20 12:20:51 -07:00
|
|
|
|
2012-11-26 14:23:27 -08:00
|
|
|
GLuint texture = (uintptr_t)buffer;
|
2012-08-01 11:57:54 -07:00
|
|
|
EGLTextureWrapper* tex = new EGLTextureWrapper();
|
|
|
|
if (!tex->CreateEGLImage(this, texture)) {
|
2012-07-20 12:20:51 -07:00
|
|
|
NS_ERROR("EGLImage creation for EGLTextureWrapper failed");
|
|
|
|
delete tex;
|
2012-07-25 02:27:00 -07:00
|
|
|
return 0;
|
2012-07-20 12:20:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return (SharedTextureHandle)tex;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
NS_ERROR("Unknown shared texture buffer type");
|
2012-07-25 02:27:00 -07:00
|
|
|
return 0;
|
2012-07-20 12:20:51 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 14:23:27 -08:00
|
|
|
void GLContextEGL::ReleaseSharedHandle(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle)
|
2012-05-31 18:30:08 -07:00
|
|
|
{
|
2012-11-26 14:23:27 -08:00
|
|
|
if (shareType != SameProcess) {
|
2012-05-31 18:30:08 -07:00
|
|
|
NS_ERROR("Implementation not available for this sharing type");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-26 14:23:27 -08:00
|
|
|
SharedTextureHandleWrapper* wrapper = reinterpret_cast<SharedTextureHandleWrapper*>(sharedHandle);
|
2012-07-20 12:20:51 -07:00
|
|
|
|
2012-07-20 12:20:51 -07:00
|
|
|
switch (wrapper->Type()) {
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2013-09-04 05:14:52 -07:00
|
|
|
case SharedHandleType_SurfaceTexture:
|
2012-07-20 12:20:51 -07:00
|
|
|
delete wrapper;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2013-09-04 05:14:52 -07:00
|
|
|
case SharedHandleType_Image: {
|
2012-07-20 12:20:51 -07:00
|
|
|
NS_ASSERTION(mShareWithEGLImage, "EGLImage not supported or disabled in runtime");
|
|
|
|
|
2012-11-26 14:23:27 -08:00
|
|
|
EGLTextureWrapper* wrap = (EGLTextureWrapper*)sharedHandle;
|
2012-07-20 12:20:51 -07:00
|
|
|
delete wrap;
|
|
|
|
break;
|
2012-07-20 12:20:51 -07:00
|
|
|
}
|
2012-07-20 12:20:51 -07:00
|
|
|
|
|
|
|
default:
|
|
|
|
NS_ERROR("Unknown shared handle type");
|
2012-11-26 14:23:27 -08:00
|
|
|
return;
|
2012-07-20 12:20:51 -07:00
|
|
|
}
|
2012-07-20 12:20:51 -07:00
|
|
|
}
|
|
|
|
|
2012-11-26 14:23:27 -08:00
|
|
|
bool GLContextEGL::GetSharedHandleDetails(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle,
|
|
|
|
SharedHandleDetails& details)
|
2012-07-20 12:20:51 -07:00
|
|
|
{
|
2012-11-26 14:23:27 -08:00
|
|
|
if (shareType != SameProcess)
|
2012-07-20 12:20:51 -07:00
|
|
|
return false;
|
|
|
|
|
2012-11-26 14:23:27 -08:00
|
|
|
SharedTextureHandleWrapper* wrapper = reinterpret_cast<SharedTextureHandleWrapper*>(sharedHandle);
|
2012-07-20 12:20:51 -07:00
|
|
|
|
|
|
|
switch (wrapper->Type()) {
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2013-09-04 05:14:52 -07:00
|
|
|
case SharedHandleType_SurfaceTexture: {
|
2012-07-20 12:20:51 -07:00
|
|
|
SurfaceTextureWrapper* surfaceWrapper = reinterpret_cast<SurfaceTextureWrapper*>(wrapper);
|
|
|
|
|
2012-11-26 14:23:27 -08:00
|
|
|
details.mTarget = LOCAL_GL_TEXTURE_EXTERNAL;
|
2013-07-04 10:25:50 -07:00
|
|
|
details.mTextureFormat = FORMAT_R8G8B8A8;
|
2012-11-26 14:23:27 -08:00
|
|
|
surfaceWrapper->SurfaceTexture()->GetTransformMatrix(details.mTextureTransform);
|
2012-07-20 12:20:51 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-09-04 05:14:52 -07:00
|
|
|
case SharedHandleType_Image:
|
2012-11-26 14:23:27 -08:00
|
|
|
details.mTarget = LOCAL_GL_TEXTURE_2D;
|
2013-07-04 10:25:50 -07:00
|
|
|
details.mTextureFormat = FORMAT_R8G8B8A8;
|
2012-07-20 12:20:51 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
NS_ERROR("Unknown shared handle type");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2012-05-31 18:30:08 -07:00
|
|
|
}
|
|
|
|
|
2012-11-26 14:23:27 -08:00
|
|
|
bool GLContextEGL::AttachSharedHandle(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle)
|
2012-05-31 18:30:08 -07:00
|
|
|
{
|
2012-11-26 14:23:27 -08:00
|
|
|
if (shareType != SameProcess)
|
2012-05-31 18:30:08 -07:00
|
|
|
return false;
|
|
|
|
|
2012-11-26 14:23:27 -08:00
|
|
|
SharedTextureHandleWrapper* wrapper = reinterpret_cast<SharedTextureHandleWrapper*>(sharedHandle);
|
2012-07-20 12:20:51 -07:00
|
|
|
|
|
|
|
switch (wrapper->Type()) {
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2013-09-04 05:14:52 -07:00
|
|
|
case SharedHandleType_SurfaceTexture: {
|
2012-07-20 12:20:51 -07:00
|
|
|
#ifndef DEBUG
|
|
|
|
/**
|
|
|
|
* NOTE: SurfaceTexture spams us if there are any existing GL errors, so we'll clear
|
|
|
|
* them here in order to avoid that.
|
|
|
|
*/
|
|
|
|
GetAndClearError();
|
|
|
|
#endif
|
|
|
|
SurfaceTextureWrapper* surfaceTextureWrapper = reinterpret_cast<SurfaceTextureWrapper*>(wrapper);
|
|
|
|
|
|
|
|
// FIXME: SurfaceTexture provides a transform matrix which is supposed to
|
|
|
|
// be applied to the texture coordinates. We should return that here
|
|
|
|
// so we can render correctly. Bug 775083
|
|
|
|
surfaceTextureWrapper->SurfaceTexture()->UpdateTexImage();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif // MOZ_WIDGET_ANDROID
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-09-04 05:14:52 -07:00
|
|
|
case SharedHandleType_Image: {
|
2012-07-20 12:20:51 -07:00
|
|
|
NS_ASSERTION(mShareWithEGLImage, "EGLImage not supported or disabled in runtime");
|
|
|
|
|
2012-11-26 14:23:27 -08:00
|
|
|
EGLTextureWrapper* wrap = (EGLTextureWrapper*)sharedHandle;
|
2012-07-30 08:07:23 -07:00
|
|
|
wrap->WaitSync();
|
2012-07-20 12:20:51 -07:00
|
|
|
fEGLImageTargetTexture2D(LOCAL_GL_TEXTURE_2D, wrap->GetEGLImage());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
NS_ERROR("Unknown shared handle type");
|
|
|
|
return false;
|
|
|
|
}
|
2012-05-31 18:30:08 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2010-07-18 22:01:14 -07:00
|
|
|
GLContextEGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
|
|
|
{
|
2013-02-13 15:26:24 -08:00
|
|
|
return ResizeScreenBuffer(aNewSize);
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GLContextEGL *
|
|
|
|
GetGlobalContextEGL()
|
|
|
|
{
|
|
|
|
return static_cast<GLContextEGL*>(GLContextProviderEGL::GetGlobalContext());
|
|
|
|
}
|
|
|
|
|
2010-11-26 13:41:53 -08:00
|
|
|
static GLenum
|
2013-09-24 13:45:13 -07:00
|
|
|
GLFormatForImage(gfxImageFormat aFormat)
|
2010-11-26 13:41:53 -08:00
|
|
|
{
|
|
|
|
switch (aFormat) {
|
2013-09-24 13:45:13 -07:00
|
|
|
case gfxImageFormatARGB32:
|
|
|
|
case gfxImageFormatRGB24:
|
2012-03-22 11:37:47 -07:00
|
|
|
// Thebes only supports RGBX, not packed RGB.
|
2010-11-26 13:41:53 -08:00
|
|
|
return LOCAL_GL_RGBA;
|
2013-09-24 13:45:13 -07:00
|
|
|
case gfxImageFormatRGB16_565:
|
2010-11-26 13:41:53 -08:00
|
|
|
return LOCAL_GL_RGB;
|
2013-09-24 13:45:13 -07:00
|
|
|
case gfxImageFormatA8:
|
2012-06-25 19:43:31 -07:00
|
|
|
return LOCAL_GL_LUMINANCE;
|
2010-11-26 13:41:53 -08:00
|
|
|
default:
|
|
|
|
NS_WARNING("Unknown GL format for Image format");
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GLenum
|
2013-09-24 13:45:13 -07:00
|
|
|
GLTypeForImage(gfxImageFormat aFormat)
|
2010-11-26 13:41:53 -08:00
|
|
|
{
|
|
|
|
switch (aFormat) {
|
2013-09-24 13:45:13 -07:00
|
|
|
case gfxImageFormatARGB32:
|
|
|
|
case gfxImageFormatRGB24:
|
|
|
|
case gfxImageFormatA8:
|
2010-11-26 13:41:53 -08:00
|
|
|
return LOCAL_GL_UNSIGNED_BYTE;
|
2013-09-24 13:45:13 -07:00
|
|
|
case gfxImageFormatRGB16_565:
|
2010-11-26 13:41:53 -08:00
|
|
|
return LOCAL_GL_UNSIGNED_SHORT_5_6_5;
|
|
|
|
default:
|
|
|
|
NS_WARNING("Unknown GL format for Image format");
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
class TextureImageEGL
|
|
|
|
: public TextureImage
|
2010-07-01 09:30:38 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
TextureImageEGL(GLuint aTexture,
|
|
|
|
const nsIntSize& aSize,
|
2010-11-12 12:02:20 -08:00
|
|
|
GLenum aWrapMode,
|
2010-07-01 09:30:38 -07:00
|
|
|
ContentType aContentType,
|
2012-05-09 13:55:31 -07:00
|
|
|
GLContext* aContext,
|
2012-07-23 16:58:37 -07:00
|
|
|
Flags aFlags = TextureImage::NoFlags,
|
2013-08-07 15:38:21 -07:00
|
|
|
TextureState aTextureState = Created,
|
2013-09-24 13:45:13 -07:00
|
|
|
TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown)
|
2012-05-09 13:55:31 -07:00
|
|
|
: TextureImage(aSize, aWrapMode, aContentType, aFlags)
|
2010-07-01 09:30:38 -07:00
|
|
|
, mGLContext(aContext)
|
2013-08-07 15:38:21 -07:00
|
|
|
, mUpdateFormat(aImageFormat)
|
2012-07-30 07:20:58 -07:00
|
|
|
, mEGLImage(nullptr)
|
2012-06-19 21:12:30 -07:00
|
|
|
, mTexture(aTexture)
|
2012-07-30 07:20:58 -07:00
|
|
|
, mSurface(nullptr)
|
|
|
|
, mConfig(nullptr)
|
2012-07-23 16:58:37 -07:00
|
|
|
, mTextureState(aTextureState)
|
2011-10-17 07:59:28 -07:00
|
|
|
, mBound(false)
|
2010-11-26 13:41:53 -08:00
|
|
|
{
|
2013-09-24 13:45:13 -07:00
|
|
|
if (mUpdateFormat == gfxImageFormatUnknown) {
|
2013-08-07 15:38:21 -07:00
|
|
|
mUpdateFormat = gfxPlatform::GetPlatform()->OptimalFormatForContent(GetContentType());
|
|
|
|
}
|
2010-11-26 13:41:53 -08:00
|
|
|
|
|
|
|
if (gUseBackingSurface) {
|
2013-09-24 13:45:13 -07:00
|
|
|
if (mUpdateFormat != gfxImageFormatARGB32) {
|
2013-07-04 10:25:50 -07:00
|
|
|
mTextureFormat = FORMAT_R8G8B8X8;
|
2011-01-13 05:20:50 -08:00
|
|
|
} else {
|
2013-07-04 10:25:50 -07:00
|
|
|
mTextureFormat = FORMAT_R8G8B8A8;
|
2011-01-13 05:20:50 -08:00
|
|
|
}
|
2011-08-03 20:18:31 -07:00
|
|
|
Resize(aSize);
|
2011-01-13 05:20:50 -08:00
|
|
|
} else {
|
2013-09-24 13:45:13 -07:00
|
|
|
if (mUpdateFormat == gfxImageFormatRGB16_565) {
|
2013-07-04 10:25:50 -07:00
|
|
|
mTextureFormat = FORMAT_R8G8B8X8;
|
2013-09-24 13:45:13 -07:00
|
|
|
} else if (mUpdateFormat == gfxImageFormatRGB24) {
|
2012-03-22 11:37:47 -07:00
|
|
|
// RGB24 means really RGBX for Thebes, which means we have to
|
|
|
|
// use the right shader and ignore the uninitialized alpha
|
|
|
|
// value.
|
2013-07-04 10:25:50 -07:00
|
|
|
mTextureFormat = FORMAT_B8G8R8X8;
|
2012-03-22 11:37:47 -07:00
|
|
|
} else {
|
2013-07-04 10:25:50 -07:00
|
|
|
mTextureFormat = FORMAT_B8G8R8A8;
|
2011-01-13 05:20:50 -08:00
|
|
|
}
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
|
|
|
}
|
2010-07-01 09:30:38 -07:00
|
|
|
|
|
|
|
virtual ~TextureImageEGL()
|
|
|
|
{
|
2010-11-26 13:41:53 -08:00
|
|
|
GLContext *ctx = mGLContext;
|
2012-04-10 13:20:02 -07:00
|
|
|
if (ctx->IsDestroyed() || !ctx->IsOwningThreadCurrent()) {
|
2010-11-26 13:41:53 -08:00
|
|
|
ctx = ctx->GetSharedContext();
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we have a context, then we need to delete the texture;
|
|
|
|
// if we don't have a context (either real or shared),
|
|
|
|
// then they went away when the contex was deleted, because it
|
|
|
|
// was the only one that had access to it.
|
|
|
|
if (ctx && !ctx->IsDestroyed()) {
|
2011-01-05 05:48:17 -08:00
|
|
|
ctx->MakeCurrent();
|
|
|
|
ctx->fDeleteTextures(1, &mTexture);
|
2010-11-26 13:41:53 -08:00
|
|
|
ReleaseTexImage();
|
|
|
|
DestroyEGLSurface();
|
|
|
|
}
|
2010-07-01 09:30:38 -07:00
|
|
|
}
|
|
|
|
|
2012-06-12 21:20:27 -07:00
|
|
|
bool UsingDirectTexture()
|
|
|
|
{
|
|
|
|
return !!mBackingSurface;
|
|
|
|
}
|
|
|
|
|
2011-08-24 12:21:53 -07:00
|
|
|
virtual void GetUpdateRegion(nsIntRegion& aForRegion)
|
2011-08-19 01:36:04 -07:00
|
|
|
{
|
2011-08-23 14:12:15 -07:00
|
|
|
if (mTextureState != Valid) {
|
|
|
|
// if the texture hasn't been initialized yet, force the
|
|
|
|
// client to paint everything
|
2011-08-24 12:21:53 -07:00
|
|
|
aForRegion = nsIntRect(nsIntPoint(0, 0), mSize);
|
2011-08-23 14:12:15 -07:00
|
|
|
}
|
2012-06-12 21:20:27 -07:00
|
|
|
|
|
|
|
if (UsingDirectTexture()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We can only draw a rectangle, not subregions due to
|
|
|
|
// the way that our texture upload functions work. If
|
|
|
|
// needed, we /could/ do multiple texture uploads if we have
|
|
|
|
// non-overlapping rects, but that's a tradeoff.
|
|
|
|
aForRegion = nsIntRegion(aForRegion.GetBounds());
|
2011-08-24 12:21:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual gfxASurface* BeginUpdate(nsIntRegion& aRegion)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!mUpdateSurface, "BeginUpdate() without EndUpdate()?");
|
|
|
|
|
|
|
|
// determine the region the client will need to repaint
|
|
|
|
GetUpdateRegion(aRegion);
|
|
|
|
mUpdateRect = aRegion.GetBounds();
|
2010-11-26 13:41:53 -08:00
|
|
|
|
|
|
|
//printf_stderr("BeginUpdate with updateRect [%d %d %d %d]\n", mUpdateRect.x, mUpdateRect.y, mUpdateRect.width, mUpdateRect.height);
|
|
|
|
if (!nsIntRect(nsIntPoint(0, 0), mSize).Contains(mUpdateRect)) {
|
|
|
|
NS_ERROR("update outside of image");
|
2013-07-20 01:48:55 -07:00
|
|
|
return nullptr;
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
2010-11-16 20:49:09 -08:00
|
|
|
|
2010-11-26 13:41:53 -08:00
|
|
|
if (mBackingSurface) {
|
2013-04-20 07:08:18 -07:00
|
|
|
mUpdateSurface = mBackingSurface;
|
2011-01-17 23:21:12 -08:00
|
|
|
return mUpdateSurface;
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
2010-07-01 09:30:38 -07:00
|
|
|
|
2010-11-26 13:41:53 -08:00
|
|
|
//printf_stderr("creating image surface %dx%d format %d\n", mUpdateRect.width, mUpdateRect.height, mUpdateFormat);
|
|
|
|
|
2011-01-17 23:21:12 -08:00
|
|
|
mUpdateSurface =
|
2010-11-26 13:41:53 -08:00
|
|
|
new gfxImageSurface(gfxIntSize(mUpdateRect.width, mUpdateRect.height),
|
|
|
|
mUpdateFormat);
|
|
|
|
|
2011-01-17 23:21:12 -08:00
|
|
|
mUpdateSurface->SetDeviceOffset(gfxPoint(-mUpdateRect.x, -mUpdateRect.y));
|
2010-11-16 20:49:09 -08:00
|
|
|
|
2011-01-17 23:21:12 -08:00
|
|
|
return mUpdateSurface;
|
2010-07-01 09:30:38 -07:00
|
|
|
}
|
|
|
|
|
2011-01-17 23:22:25 -08:00
|
|
|
virtual void EndUpdate()
|
2010-07-01 09:30:38 -07:00
|
|
|
{
|
2011-01-17 23:21:12 -08:00
|
|
|
NS_ASSERTION(!!mUpdateSurface, "EndUpdate() without BeginUpdate()?");
|
2010-07-01 09:30:38 -07:00
|
|
|
|
2011-01-17 23:21:12 -08:00
|
|
|
if (mBackingSurface && mUpdateSurface == mBackingSurface) {
|
2010-07-01 09:30:38 -07:00
|
|
|
#ifdef MOZ_X11
|
2013-09-24 13:45:13 -07:00
|
|
|
if (mBackingSurface->GetType() == gfxSurfaceTypeXlib) {
|
2012-07-30 19:54:21 -07:00
|
|
|
FinishX(DefaultXDisplay());
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
2010-09-09 13:40:11 -07:00
|
|
|
#endif
|
|
|
|
|
2010-11-26 13:41:53 -08:00
|
|
|
mBackingSurface->SetDeviceOffset(gfxPoint(0, 0));
|
2011-07-26 13:52:03 -07:00
|
|
|
mTextureState = Valid;
|
2012-07-30 07:20:58 -07:00
|
|
|
mUpdateSurface = nullptr;
|
2011-01-17 23:22:25 -08:00
|
|
|
return;
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
//printf_stderr("EndUpdate: slow path");
|
|
|
|
|
|
|
|
// This is the slower path -- we didn't have any way to set up
|
|
|
|
// a fast mapping between our cairo target surface and the GL
|
|
|
|
// texture, so we have to upload data.
|
|
|
|
|
|
|
|
// Undo the device offset that BeginUpdate set; doesn't much
|
|
|
|
// matter for us here, but important if we ever do anything
|
|
|
|
// directly with the surface.
|
2011-01-17 23:21:12 -08:00
|
|
|
mUpdateSurface->SetDeviceOffset(gfxPoint(0, 0));
|
2010-11-26 13:41:53 -08:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
nsRefPtr<gfxImageSurface> uploadImage = nullptr;
|
2010-11-26 13:41:53 -08:00
|
|
|
gfxIntSize updateSize(mUpdateRect.width, mUpdateRect.height);
|
|
|
|
|
2013-09-24 13:45:13 -07:00
|
|
|
NS_ASSERTION(mUpdateSurface->GetType() == gfxSurfaceTypeImage &&
|
2011-01-17 23:21:12 -08:00
|
|
|
mUpdateSurface->GetSize() == updateSize,
|
2010-11-26 13:41:53 -08:00
|
|
|
"Upload image isn't an image surface when one is expected, or is wrong size!");
|
|
|
|
|
2011-01-17 23:21:12 -08:00
|
|
|
uploadImage = static_cast<gfxImageSurface*>(mUpdateSurface.get());
|
2010-11-26 13:41:53 -08:00
|
|
|
|
|
|
|
if (!uploadImage) {
|
2011-01-17 23:22:25 -08:00
|
|
|
return;
|
2010-09-09 13:40:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
mGLContext->MakeCurrent();
|
|
|
|
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
|
2010-11-16 20:49:09 -08:00
|
|
|
|
2011-07-26 13:52:03 -07:00
|
|
|
if (mTextureState != Valid) {
|
2010-11-26 13:41:53 -08:00
|
|
|
NS_ASSERTION(mUpdateRect.x == 0 && mUpdateRect.y == 0 &&
|
|
|
|
mUpdateRect.Size() == mSize,
|
|
|
|
"Bad initial update on non-created texture!");
|
|
|
|
|
|
|
|
mGLContext->fTexImage2D(LOCAL_GL_TEXTURE_2D,
|
|
|
|
0,
|
|
|
|
GLFormatForImage(mUpdateFormat),
|
|
|
|
mUpdateRect.width,
|
|
|
|
mUpdateRect.height,
|
|
|
|
0,
|
|
|
|
GLFormatForImage(uploadImage->Format()),
|
|
|
|
GLTypeForImage(uploadImage->Format()),
|
|
|
|
uploadImage->Data());
|
|
|
|
} else {
|
2010-11-16 20:49:09 -08:00
|
|
|
mGLContext->fTexSubImage2D(LOCAL_GL_TEXTURE_2D,
|
|
|
|
0,
|
|
|
|
mUpdateRect.x,
|
|
|
|
mUpdateRect.y,
|
|
|
|
mUpdateRect.width,
|
|
|
|
mUpdateRect.height,
|
2010-11-26 13:41:53 -08:00
|
|
|
GLFormatForImage(uploadImage->Format()),
|
|
|
|
GLTypeForImage(uploadImage->Format()),
|
|
|
|
uploadImage->Data());
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
mUpdateSurface = nullptr;
|
2011-07-26 13:52:03 -07:00
|
|
|
mTextureState = Valid;
|
2011-01-17 23:22:25 -08:00
|
|
|
return; // mTexture is bound
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
|
|
|
|
2011-07-06 11:00:47 -07:00
|
|
|
virtual bool DirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion, const nsIntPoint& aFrom /* = nsIntPoint(0, 0) */)
|
2010-12-16 23:50:26 -08:00
|
|
|
{
|
|
|
|
nsIntRect bounds = aRegion.GetBounds();
|
2011-07-06 11:00:47 -07:00
|
|
|
|
2011-01-17 17:32:40 -08:00
|
|
|
nsIntRegion region;
|
2011-07-26 13:52:03 -07:00
|
|
|
if (mTextureState != Valid) {
|
2010-12-16 23:50:26 -08:00
|
|
|
bounds = nsIntRect(0, 0, mSize.width, mSize.height);
|
2011-01-17 17:32:40 -08:00
|
|
|
region = nsIntRegion(bounds);
|
|
|
|
} else {
|
|
|
|
region = aRegion;
|
2010-12-16 23:50:26 -08:00
|
|
|
}
|
|
|
|
|
2013-07-04 10:25:50 -07:00
|
|
|
mTextureFormat =
|
2013-04-20 07:08:18 -07:00
|
|
|
mGLContext->UploadSurfaceToTexture(aSurf,
|
|
|
|
region,
|
|
|
|
mTexture,
|
|
|
|
mTextureState == Created,
|
|
|
|
bounds.TopLeft() + aFrom,
|
|
|
|
false);
|
2011-01-13 05:20:50 -08:00
|
|
|
|
2011-07-26 13:52:03 -07:00
|
|
|
mTextureState = Valid;
|
2010-12-16 23:50:26 -08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-04-07 16:58:08 -07:00
|
|
|
virtual void BindTexture(GLenum aTextureUnit)
|
|
|
|
{
|
2011-08-03 20:18:31 -07:00
|
|
|
// Ensure the texture is allocated before it is used.
|
|
|
|
if (mTextureState == Created) {
|
|
|
|
Resize(mSize);
|
|
|
|
}
|
|
|
|
|
2013-04-20 07:08:18 -07:00
|
|
|
mGLContext->fActiveTexture(aTextureUnit);
|
|
|
|
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
|
|
|
|
mGLContext->fActiveTexture(LOCAL_GL_TEXTURE0);
|
2011-04-07 16:58:08 -07:00
|
|
|
}
|
|
|
|
|
2011-08-03 20:18:31 -07:00
|
|
|
virtual GLuint GetTextureID()
|
|
|
|
{
|
|
|
|
// Ensure the texture is allocated before it is used.
|
|
|
|
if (mTextureState == Created) {
|
|
|
|
Resize(mSize);
|
|
|
|
}
|
2011-07-06 11:00:47 -07:00
|
|
|
return mTexture;
|
|
|
|
};
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool InUpdate() const { return !!mUpdateSurface; }
|
2010-11-26 13:41:53 -08:00
|
|
|
|
|
|
|
virtual void Resize(const nsIntSize& aSize)
|
|
|
|
{
|
2011-01-17 23:21:12 -08:00
|
|
|
NS_ASSERTION(!mUpdateSurface, "Resize() while in update?");
|
2010-11-26 13:41:53 -08:00
|
|
|
|
2011-07-26 13:52:03 -07:00
|
|
|
if (mSize == aSize && mTextureState != Created)
|
2010-11-26 13:41:53 -08:00
|
|
|
return;
|
|
|
|
|
2011-01-13 05:20:50 -08:00
|
|
|
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
|
2012-06-12 21:20:27 -07:00
|
|
|
|
2011-07-26 13:51:56 -07:00
|
|
|
// Try to generate a backin surface first if we have the ability
|
|
|
|
if (gUseBackingSurface) {
|
2010-11-26 13:41:53 -08:00
|
|
|
CreateBackingSurface(gfxIntSize(aSize.width, aSize.height));
|
2011-07-26 13:51:56 -07:00
|
|
|
}
|
|
|
|
|
2012-06-12 21:20:27 -07:00
|
|
|
if (!UsingDirectTexture()) {
|
2011-07-26 13:51:56 -07:00
|
|
|
// If we don't have a backing surface or failed to obtain one,
|
|
|
|
// use the GL Texture failsafe
|
2010-11-16 20:49:09 -08:00
|
|
|
mGLContext->fTexImage2D(LOCAL_GL_TEXTURE_2D,
|
|
|
|
0,
|
2010-11-26 13:41:53 -08:00
|
|
|
GLFormatForImage(mUpdateFormat),
|
|
|
|
aSize.width,
|
|
|
|
aSize.height,
|
2010-11-16 20:49:09 -08:00
|
|
|
0,
|
2010-11-26 13:41:53 -08:00
|
|
|
GLFormatForImage(mUpdateFormat),
|
|
|
|
GLTypeForImage(mUpdateFormat),
|
2013-07-20 01:48:55 -07:00
|
|
|
nullptr);
|
2010-11-16 20:49:09 -08:00
|
|
|
}
|
2010-09-09 13:40:11 -07:00
|
|
|
|
2011-07-26 13:52:03 -07:00
|
|
|
mTextureState = Allocated;
|
2010-11-26 13:41:53 -08:00
|
|
|
mSize = aSize;
|
2010-07-01 09:30:38 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool BindTexImage()
|
2010-07-22 13:29:37 -07:00
|
|
|
{
|
2010-11-26 13:41:53 -08:00
|
|
|
if (mBound && !ReleaseTexImage())
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-11-26 13:41:53 -08:00
|
|
|
|
|
|
|
EGLBoolean success =
|
|
|
|
sEGLLibrary.fBindTexImage(EGL_DISPLAY(),
|
|
|
|
(EGLSurface)mSurface,
|
|
|
|
LOCAL_EGL_BACK_BUFFER);
|
|
|
|
|
|
|
|
if (success == LOCAL_EGL_FALSE)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-11-26 13:41:53 -08:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
mBound = true;
|
|
|
|
return true;
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ReleaseTexImage()
|
2010-11-26 13:41:53 -08:00
|
|
|
{
|
|
|
|
if (!mBound)
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2010-11-26 13:41:53 -08:00
|
|
|
|
|
|
|
EGLBoolean success =
|
|
|
|
sEGLLibrary.fReleaseTexImage(EGL_DISPLAY(),
|
|
|
|
(EGLSurface)mSurface,
|
|
|
|
LOCAL_EGL_BACK_BUFFER);
|
|
|
|
|
|
|
|
if (success == LOCAL_EGL_FALSE)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-11-26 13:41:53 -08:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
mBound = false;
|
|
|
|
return true;
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual already_AddRefed<gfxASurface> GetBackingSurface()
|
|
|
|
{
|
2011-09-16 13:22:44 -07:00
|
|
|
nsRefPtr<gfxASurface> copy = mBackingSurface;
|
|
|
|
return copy.forget();
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool CreateEGLSurface(gfxASurface* aSurface)
|
2010-11-26 13:41:53 -08:00
|
|
|
{
|
2011-01-13 05:20:50 -08:00
|
|
|
#ifdef MOZ_X11
|
2010-11-26 13:41:53 -08:00
|
|
|
if (!aSurface) {
|
|
|
|
NS_WARNING("no surface");
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
|
|
|
|
2013-09-24 13:45:13 -07:00
|
|
|
if (aSurface->GetType() != gfxSurfaceTypeXlib) {
|
2010-11-26 13:41:53 -08:00
|
|
|
NS_WARNING("wrong surface type, must be xlib");
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mSurface) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
|
|
|
|
2011-01-13 05:20:50 -08:00
|
|
|
EGLSurface surface = CreateEGLSurfaceForXSurface(aSurface, &mConfig);
|
2010-11-26 13:41:53 -08:00
|
|
|
|
|
|
|
if (!surface) {
|
|
|
|
NS_WARNING("couldn't find X config for surface");
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
mSurface = surface;
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2010-11-26 13:41:53 -08:00
|
|
|
#else
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-11-26 13:41:53 -08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void DestroyEGLSurface(void)
|
|
|
|
{
|
|
|
|
if (!mSurface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sEGLLibrary.fDestroySurface(EGL_DISPLAY(), mSurface);
|
2012-07-30 07:20:58 -07:00
|
|
|
mSurface = nullptr;
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool CreateBackingSurface(const gfxIntSize& aSize)
|
2010-11-26 13:41:53 -08:00
|
|
|
{
|
|
|
|
ReleaseTexImage();
|
|
|
|
DestroyEGLSurface();
|
2012-07-30 07:20:58 -07:00
|
|
|
mBackingSurface = nullptr;
|
2010-11-26 13:41:53 -08:00
|
|
|
|
2012-02-18 11:21:48 -08:00
|
|
|
#ifdef MOZ_X11
|
2010-11-26 13:41:53 -08:00
|
|
|
Display* dpy = DefaultXDisplay();
|
|
|
|
XRenderPictFormat* renderFMT =
|
|
|
|
gfxXlibSurface::FindRenderFormat(dpy, mUpdateFormat);
|
|
|
|
|
|
|
|
nsRefPtr<gfxXlibSurface> xsurface =
|
|
|
|
gfxXlibSurface::Create(DefaultScreenOfDisplay(dpy),
|
|
|
|
renderFMT,
|
|
|
|
gfxIntSize(aSize.width, aSize.height));
|
|
|
|
|
|
|
|
XSync(dpy, False);
|
2012-07-30 07:20:58 -07:00
|
|
|
mConfig = nullptr;
|
2010-11-26 13:41:53 -08:00
|
|
|
|
2012-07-18 13:41:49 -07:00
|
|
|
if (sEGLLibrary.HasKHRImagePixmap() &&
|
|
|
|
mGLContext->IsExtensionSupported(GLContext::OES_EGL_image))
|
|
|
|
{
|
2012-06-12 14:36:10 -07:00
|
|
|
mEGLImage =
|
|
|
|
sEGLLibrary.fCreateImage(EGL_DISPLAY(),
|
|
|
|
EGL_NO_CONTEXT,
|
2012-07-19 21:14:14 -07:00
|
|
|
LOCAL_EGL_NATIVE_PIXMAP,
|
2012-06-12 14:36:10 -07:00
|
|
|
(EGLClientBuffer)xsurface->XDrawable(),
|
2012-07-30 07:20:58 -07:00
|
|
|
nullptr);
|
2012-06-12 14:36:10 -07:00
|
|
|
|
|
|
|
if (!mEGLImage) {
|
2010-11-26 13:41:53 -08:00
|
|
|
printf_stderr("couldn't create EGL image: ERROR (0x%04x)\n", sEGLLibrary.fGetError());
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
|
|
|
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
|
2012-07-19 21:14:14 -07:00
|
|
|
mGLContext->fEGLImageTargetTexture2D(LOCAL_GL_TEXTURE_2D, mEGLImage);
|
2012-06-12 14:36:10 -07:00
|
|
|
sEGLLibrary.fDestroyImage(EGL_DISPLAY(), mEGLImage);
|
2012-07-30 07:20:58 -07:00
|
|
|
mEGLImage = nullptr;
|
2010-11-26 13:41:53 -08:00
|
|
|
} else {
|
|
|
|
if (!CreateEGLSurface(xsurface)) {
|
|
|
|
printf_stderr("ProviderEGL Failed create EGL surface: ERROR (0x%04x)\n", sEGLLibrary.fGetError());
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!BindTexImage()) {
|
|
|
|
printf_stderr("ProviderEGL Failed to bind teximage: ERROR (0x%04x)\n", sEGLLibrary.fGetError());
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mBackingSurface = xsurface;
|
2012-06-12 21:20:27 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return mBackingSurface != nullptr;
|
2010-11-26 13:41:53 -08:00
|
|
|
#endif
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return mBackingSurface != nullptr;
|
2010-11-26 13:41:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2013-09-24 13:45:13 -07:00
|
|
|
typedef gfxImageFormat ImageFormat;
|
2010-07-22 13:29:37 -07:00
|
|
|
|
2010-07-01 09:30:38 -07:00
|
|
|
GLContext* mGLContext;
|
2010-09-09 13:40:11 -07:00
|
|
|
|
|
|
|
nsIntRect mUpdateRect;
|
2010-11-26 13:41:53 -08:00
|
|
|
ImageFormat mUpdateFormat;
|
2012-06-12 21:20:27 -07:00
|
|
|
bool mUsingDirectTexture;
|
2010-11-26 13:41:53 -08:00
|
|
|
nsRefPtr<gfxASurface> mBackingSurface;
|
2011-01-17 23:21:12 -08:00
|
|
|
nsRefPtr<gfxASurface> mUpdateSurface;
|
2012-06-12 21:20:27 -07:00
|
|
|
EGLImage mEGLImage;
|
|
|
|
GLuint mTexture;
|
2010-11-26 13:41:53 -08:00
|
|
|
EGLSurface mSurface;
|
|
|
|
EGLConfig mConfig;
|
2011-07-26 13:52:03 -07:00
|
|
|
TextureState mTextureState;
|
2010-11-26 13:41:53 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mBound;
|
2011-10-05 11:20:33 -07:00
|
|
|
|
|
|
|
virtual void ApplyFilter()
|
|
|
|
{
|
|
|
|
mGLContext->ApplyFilterToBoundTexture(mFilter);
|
|
|
|
}
|
2010-07-01 09:30:38 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
already_AddRefed<TextureImage>
|
|
|
|
GLContextEGL::CreateTextureImage(const nsIntSize& aSize,
|
|
|
|
TextureImage::ContentType aContentType,
|
2010-11-12 12:02:20 -08:00
|
|
|
GLenum aWrapMode,
|
2013-08-07 15:38:21 -07:00
|
|
|
TextureImage::Flags aFlags,
|
|
|
|
TextureImage::ImageFormat aImageFormat)
|
2011-07-06 11:00:47 -07:00
|
|
|
{
|
2013-08-07 15:38:21 -07:00
|
|
|
nsRefPtr<TextureImage> t = new gl::TiledTextureImage(this, aSize, aContentType, aFlags, aImageFormat);
|
2011-07-06 11:00:47 -07:00
|
|
|
return t.forget();
|
2012-03-11 14:41:03 -07:00
|
|
|
}
|
2011-07-06 11:00:47 -07:00
|
|
|
|
|
|
|
already_AddRefed<TextureImage>
|
|
|
|
GLContextEGL::TileGenFunc(const nsIntSize& aSize,
|
2013-05-09 14:02:48 -07:00
|
|
|
TextureImage::ContentType aContentType,
|
2013-08-07 15:38:21 -07:00
|
|
|
TextureImage::Flags aFlags,
|
|
|
|
TextureImage::ImageFormat aImageFormat)
|
2010-07-01 09:30:38 -07:00
|
|
|
{
|
|
|
|
MakeCurrent();
|
|
|
|
|
|
|
|
GLuint texture;
|
|
|
|
fGenTextures(1, &texture);
|
|
|
|
|
2010-11-26 13:41:53 -08:00
|
|
|
nsRefPtr<TextureImageEGL> teximage =
|
2013-08-07 15:38:21 -07:00
|
|
|
new TextureImageEGL(texture, aSize, LOCAL_GL_CLAMP_TO_EDGE, aContentType,
|
|
|
|
this, aFlags, TextureImage::Created, aImageFormat);
|
2012-06-14 11:57:26 -07:00
|
|
|
|
|
|
|
teximage->BindTexture(LOCAL_GL_TEXTURE0);
|
2010-11-26 13:41:53 -08:00
|
|
|
|
2012-05-09 13:55:31 -07:00
|
|
|
GLint texfilter = aFlags & TextureImage::UseNearestFilter ? LOCAL_GL_NEAREST : LOCAL_GL_LINEAR;
|
2010-07-01 09:30:38 -07:00
|
|
|
fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, texfilter);
|
|
|
|
fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, texfilter);
|
2011-07-06 11:00:47 -07:00
|
|
|
fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
|
|
|
|
fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
|
2010-07-01 09:30:38 -07:00
|
|
|
|
|
|
|
return teximage.forget();
|
|
|
|
}
|
|
|
|
|
2013-02-21 11:54:25 -08:00
|
|
|
static nsRefPtr<GLContext> gGlobalContext;
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
static const EGLint kEGLConfigAttribsOffscreenPBuffer[] = {
|
|
|
|
LOCAL_EGL_SURFACE_TYPE, LOCAL_EGL_PBUFFER_BIT,
|
|
|
|
LOCAL_EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT,
|
|
|
|
LOCAL_EGL_NONE
|
|
|
|
};
|
|
|
|
|
2011-09-22 22:58:15 -07:00
|
|
|
static const EGLint kEGLConfigAttribsRGB16[] = {
|
|
|
|
LOCAL_EGL_SURFACE_TYPE, LOCAL_EGL_WINDOW_BIT,
|
|
|
|
LOCAL_EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT,
|
|
|
|
LOCAL_EGL_RED_SIZE, 5,
|
|
|
|
LOCAL_EGL_GREEN_SIZE, 6,
|
|
|
|
LOCAL_EGL_BLUE_SIZE, 5,
|
|
|
|
LOCAL_EGL_ALPHA_SIZE, 0,
|
|
|
|
LOCAL_EGL_NONE
|
|
|
|
};
|
|
|
|
|
2012-07-07 07:06:59 -07:00
|
|
|
static const EGLint kEGLConfigAttribsRGB24[] = {
|
|
|
|
LOCAL_EGL_SURFACE_TYPE, LOCAL_EGL_WINDOW_BIT,
|
|
|
|
LOCAL_EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT,
|
|
|
|
LOCAL_EGL_RED_SIZE, 8,
|
|
|
|
LOCAL_EGL_GREEN_SIZE, 8,
|
|
|
|
LOCAL_EGL_BLUE_SIZE, 8,
|
2013-02-13 15:26:24 -08:00
|
|
|
LOCAL_EGL_ALPHA_SIZE, 0,
|
2012-07-07 07:06:59 -07:00
|
|
|
LOCAL_EGL_NONE
|
|
|
|
};
|
2011-09-22 22:58:15 -07:00
|
|
|
|
|
|
|
static const EGLint kEGLConfigAttribsRGBA32[] = {
|
|
|
|
LOCAL_EGL_SURFACE_TYPE, LOCAL_EGL_WINDOW_BIT,
|
|
|
|
LOCAL_EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT,
|
|
|
|
LOCAL_EGL_RED_SIZE, 8,
|
|
|
|
LOCAL_EGL_GREEN_SIZE, 8,
|
|
|
|
LOCAL_EGL_BLUE_SIZE, 8,
|
|
|
|
LOCAL_EGL_ALPHA_SIZE, 8,
|
2013-05-07 20:58:22 -07:00
|
|
|
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
|
|
|
LOCAL_EGL_FRAMEBUFFER_TARGET_ANDROID, LOCAL_EGL_TRUE,
|
|
|
|
#endif
|
2011-09-22 22:58:15 -07:00
|
|
|
LOCAL_EGL_NONE
|
|
|
|
};
|
2010-06-25 17:52:37 -07:00
|
|
|
|
2011-09-22 22:58:15 -07:00
|
|
|
static bool
|
2012-08-22 08:56:38 -07:00
|
|
|
CreateConfig(EGLConfig* aConfig, int32_t depth)
|
2011-09-22 22:58:15 -07:00
|
|
|
{
|
2010-07-18 22:01:14 -07:00
|
|
|
EGLConfig configs[64];
|
2012-07-07 07:06:59 -07:00
|
|
|
const EGLint* attribs;
|
2012-03-08 16:01:12 -08:00
|
|
|
EGLint ncfg = ArrayLength(configs);
|
|
|
|
|
2012-07-07 07:06:59 -07:00
|
|
|
switch (depth) {
|
|
|
|
case 16:
|
|
|
|
attribs = kEGLConfigAttribsRGB16;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
attribs = kEGLConfigAttribsRGB24;
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
attribs = kEGLConfigAttribsRGBA32;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_ERROR("Unknown pixel depth");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-03-08 16:01:12 -08:00
|
|
|
if (!sEGLLibrary.fChooseConfig(EGL_DISPLAY(), attribs,
|
|
|
|
configs, ncfg, &ncfg) ||
|
|
|
|
ncfg < 1) {
|
|
|
|
return false;
|
|
|
|
}
|
2010-06-09 15:27:29 -07:00
|
|
|
|
2012-03-08 16:01:12 -08:00
|
|
|
for (int j = 0; j < ncfg; ++j) {
|
|
|
|
EGLConfig config = configs[j];
|
|
|
|
EGLint r, g, b, a;
|
|
|
|
|
|
|
|
if (sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config,
|
|
|
|
LOCAL_EGL_RED_SIZE, &r) &&
|
|
|
|
sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config,
|
|
|
|
LOCAL_EGL_GREEN_SIZE, &g) &&
|
|
|
|
sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config,
|
|
|
|
LOCAL_EGL_BLUE_SIZE, &b) &&
|
|
|
|
sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config,
|
|
|
|
LOCAL_EGL_ALPHA_SIZE, &a) &&
|
|
|
|
((depth == 16 && r == 5 && g == 6 && b == 5) ||
|
2012-07-07 07:06:59 -07:00
|
|
|
(depth == 24 && r == 8 && g == 8 && b == 8) ||
|
|
|
|
(depth == 32 && r == 8 && g == 8 && b == 8 && a == 8)))
|
2011-09-22 22:58:15 -07:00
|
|
|
{
|
2012-03-08 16:01:12 -08:00
|
|
|
*aConfig = config;
|
|
|
|
return true;
|
2010-09-09 13:40:11 -07:00
|
|
|
}
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
2011-09-22 22:58:15 -07:00
|
|
|
return false;
|
2010-12-13 14:36:35 -08:00
|
|
|
}
|
|
|
|
|
2012-03-29 19:47:22 -07:00
|
|
|
// Return true if a suitable EGLConfig was found and pass it out
|
|
|
|
// through aConfig. Return false otherwise.
|
|
|
|
//
|
|
|
|
// NB: It's entirely legal for the returned EGLConfig to be valid yet
|
|
|
|
// have the value null.
|
|
|
|
static bool
|
|
|
|
CreateConfig(EGLConfig* aConfig)
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t depth = gfxPlatform::GetPlatform()->GetScreenDepth();
|
2012-03-29 19:47:22 -07:00
|
|
|
if (!CreateConfig(aConfig, depth)) {
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
// Bug 736005
|
|
|
|
// Android doesn't always support 16 bit so also try 24 bit
|
|
|
|
if (depth == 16) {
|
|
|
|
return CreateConfig(aConfig, 24);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-01 13:01:35 -07:00
|
|
|
// When MOZ_ANDROID_OMTC is defined,
|
2012-06-19 21:12:30 -07:00
|
|
|
// use mozilla::AndroidBridge::Bridge()->ProvideEGLSurface() instead.
|
2012-10-01 13:01:35 -07:00
|
|
|
#ifndef MOZ_ANDROID_OMTC
|
2011-09-22 22:58:15 -07:00
|
|
|
static EGLSurface
|
2010-12-13 14:36:35 -08:00
|
|
|
CreateSurfaceForWindow(nsIWidget *aWidget, EGLConfig config)
|
|
|
|
{
|
|
|
|
EGLSurface surface;
|
|
|
|
|
2012-02-21 13:15:39 -08:00
|
|
|
#ifdef DEBUG
|
2010-09-09 13:40:11 -07:00
|
|
|
sEGLLibrary.DumpEGLConfig(config);
|
|
|
|
#endif
|
|
|
|
|
2013-02-19 09:35:38 -08:00
|
|
|
#if !defined(MOZ_WIDGET_ANDROID)
|
2010-09-08 15:19:11 -07:00
|
|
|
surface = sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config, GET_NATIVE_WINDOW(aWidget), 0);
|
2010-06-25 17:52:37 -07:00
|
|
|
#endif
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
gScreenBounds.x = 0;
|
|
|
|
gScreenBounds.y = 0;
|
|
|
|
sEGLLibrary.fQuerySurface(EGL_DISPLAY(), surface, LOCAL_EGL_WIDTH, &gScreenBounds.width);
|
|
|
|
sEGLLibrary.fQuerySurface(EGL_DISPLAY(), surface, LOCAL_EGL_HEIGHT, &gScreenBounds.height);
|
|
|
|
#endif
|
|
|
|
|
2010-12-13 14:36:35 -08:00
|
|
|
return surface;
|
|
|
|
}
|
2012-06-19 21:12:30 -07:00
|
|
|
#endif
|
2010-12-13 14:36:35 -08:00
|
|
|
|
|
|
|
already_AddRefed<GLContext>
|
|
|
|
GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget)
|
|
|
|
{
|
|
|
|
if (!sEGLLibrary.EnsureInitialized()) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-12-13 14:36:35 -08:00
|
|
|
}
|
|
|
|
|
2012-04-11 21:18:35 -07:00
|
|
|
bool doubleBuffered = true;
|
|
|
|
|
2013-02-27 20:56:29 -08:00
|
|
|
bool hasNativeContext = aWidget->HasGLContext();
|
2013-02-13 15:26:24 -08:00
|
|
|
EGLContext eglContext = sEGLLibrary.fGetCurrentContext();
|
2013-02-27 20:56:29 -08:00
|
|
|
if (hasNativeContext && eglContext) {
|
2013-02-13 15:26:24 -08:00
|
|
|
void* platformContext = eglContext;
|
2013-02-27 20:56:29 -08:00
|
|
|
SurfaceCaps caps = SurfaceCaps::Any();
|
2012-04-11 21:18:35 -07:00
|
|
|
#ifdef MOZ_WIDGET_QT
|
2013-02-27 20:56:29 -08:00
|
|
|
int depth = gfxPlatform::GetPlatform()->GetScreenDepth();
|
2012-04-11 21:18:35 -07:00
|
|
|
QGLContext* context = const_cast<QGLContext*>(QGLContext::currentContext());
|
|
|
|
if (context && context->device()) {
|
|
|
|
depth = context->device()->depth();
|
|
|
|
}
|
2013-02-27 20:56:29 -08:00
|
|
|
const QGLFormat& format = context->format();
|
|
|
|
doubleBuffered = format.doubleBuffer();
|
2012-04-11 21:18:35 -07:00
|
|
|
platformContext = context;
|
2013-02-27 20:56:29 -08:00
|
|
|
caps.bpp16 = depth == 16 ? true : false;
|
|
|
|
caps.alpha = format.rgba();
|
|
|
|
caps.depth = format.depth();
|
|
|
|
caps.stencil = format.stencil();
|
2012-04-11 21:18:35 -07:00
|
|
|
#endif
|
2013-02-13 15:26:24 -08:00
|
|
|
EGLConfig config = EGL_NO_CONFIG;
|
|
|
|
EGLSurface surface = sEGLLibrary.fGetCurrentSurface(LOCAL_EGL_DRAW);
|
2012-04-11 21:18:35 -07:00
|
|
|
nsRefPtr<GLContextEGL> glContext =
|
2013-02-13 15:26:24 -08:00
|
|
|
new GLContextEGL(caps,
|
|
|
|
gGlobalContext, false,
|
|
|
|
config, surface, eglContext);
|
2012-04-11 21:18:35 -07:00
|
|
|
|
|
|
|
if (!glContext->Init())
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2012-04-11 21:18:35 -07:00
|
|
|
|
2012-06-12 21:20:27 -07:00
|
|
|
glContext->MakeCurrent();
|
2012-04-11 21:18:35 -07:00
|
|
|
glContext->SetIsDoubleBuffered(doubleBuffered);
|
2013-02-21 11:54:25 -08:00
|
|
|
glContext->SetPlatformContext(platformContext);
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2012-04-11 21:18:35 -07:00
|
|
|
if (!gGlobalContext) {
|
|
|
|
gGlobalContext = glContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
return glContext.forget();
|
|
|
|
}
|
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
EGLConfig config;
|
2011-09-22 22:58:15 -07:00
|
|
|
if (!CreateConfig(&config)) {
|
2010-12-13 14:36:35 -08:00
|
|
|
printf_stderr("Failed to create EGL config!\n");
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-12-13 14:36:35 -08:00
|
|
|
}
|
|
|
|
|
2012-10-01 13:01:35 -07:00
|
|
|
#ifdef MOZ_ANDROID_OMTC
|
2012-02-06 13:53:09 -08:00
|
|
|
mozilla::AndroidBridge::Bridge()->RegisterCompositor();
|
2013-02-28 10:28:23 -08:00
|
|
|
EGLSurface surface = mozilla::AndroidBridge::Bridge()->ProvideEGLSurface();
|
2012-05-29 10:46:37 -07:00
|
|
|
#else
|
|
|
|
EGLSurface surface = CreateSurfaceForWindow(aWidget, config);
|
2012-02-06 13:53:09 -08:00
|
|
|
#endif
|
|
|
|
|
2010-06-09 15:27:29 -07:00
|
|
|
if (!surface) {
|
2013-02-13 15:26:24 -08:00
|
|
|
printf_stderr("Failed to create EGLSurface!\n");
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-06-09 15:27:29 -07:00
|
|
|
}
|
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
GLContextEGL* shareContext = GetGlobalContextEGL();
|
|
|
|
SurfaceCaps caps = SurfaceCaps::Any();
|
2011-06-09 18:18:43 -07:00
|
|
|
nsRefPtr<GLContextEGL> glContext =
|
2013-02-13 15:26:24 -08:00
|
|
|
GLContextEGL::CreateGLContext(caps,
|
|
|
|
shareContext, false,
|
|
|
|
config, surface);
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2011-06-09 18:18:43 -07:00
|
|
|
if (!glContext) {
|
2013-02-13 15:26:24 -08:00
|
|
|
sEGLLibrary.fDestroySurface(EGL_DISPLAY(), surface);
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-06-09 15:27:29 -07:00
|
|
|
}
|
|
|
|
|
2012-06-12 21:20:27 -07:00
|
|
|
glContext->MakeCurrent();
|
2012-04-11 21:18:35 -07:00
|
|
|
glContext->SetIsDoubleBuffered(doubleBuffered);
|
2010-09-09 13:40:11 -07:00
|
|
|
|
2010-07-18 22:01:14 -07:00
|
|
|
return glContext.forget();
|
2010-06-09 15:27:29 -07:00
|
|
|
}
|
|
|
|
|
2010-07-18 22:01:14 -07:00
|
|
|
already_AddRefed<GLContextEGL>
|
2013-02-13 15:26:24 -08:00
|
|
|
GLContextEGL::CreateEGLPBufferOffscreenContext(const gfxIntSize& size)
|
2010-06-09 15:27:29 -07:00
|
|
|
{
|
|
|
|
EGLConfig config;
|
|
|
|
EGLSurface surface;
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
const EGLint numConfigs = 1; // We only need one.
|
|
|
|
EGLConfig configs[numConfigs];
|
|
|
|
EGLint foundConfigs = 0;
|
2010-07-18 22:01:14 -07:00
|
|
|
if (!sEGLLibrary.fChooseConfig(EGL_DISPLAY(),
|
2013-02-13 15:26:24 -08:00
|
|
|
kEGLConfigAttribsOffscreenPBuffer,
|
2010-07-18 22:01:14 -07:00
|
|
|
configs, numConfigs,
|
2011-01-31 13:10:54 -08:00
|
|
|
&foundConfigs)
|
|
|
|
|| foundConfigs == 0)
|
2010-07-18 22:01:14 -07:00
|
|
|
{
|
2013-02-13 15:26:24 -08:00
|
|
|
NS_WARNING("No EGL Config for minimal PBuffer!");
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
2010-06-09 15:27:29 -07:00
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
// We absolutely don't care, so just pick the first one.
|
2010-06-09 15:27:29 -07:00
|
|
|
config = configs[0];
|
2013-02-13 15:26:24 -08:00
|
|
|
if (GLContext::DebugMode())
|
|
|
|
sEGLLibrary.DumpEGLConfig(config);
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
gfxIntSize pbSize(size);
|
2011-01-31 13:10:57 -08:00
|
|
|
surface = GLContextEGL::CreatePBufferSurfaceTryingPowerOfTwo(config,
|
2013-02-13 15:26:24 -08:00
|
|
|
LOCAL_EGL_NONE,
|
|
|
|
pbSize);
|
2012-03-12 15:10:38 -07:00
|
|
|
if (!surface) {
|
|
|
|
NS_WARNING("Failed to create PBuffer for context!");
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2012-03-12 15:10:38 -07:00
|
|
|
}
|
2010-06-09 15:27:29 -07:00
|
|
|
|
2012-02-06 19:00:21 -08:00
|
|
|
GLContextEGL* shareContext = GetGlobalContextEGL();
|
2013-02-13 15:26:24 -08:00
|
|
|
SurfaceCaps dummyCaps = SurfaceCaps::Any();
|
|
|
|
nsRefPtr<GLContextEGL> glContext =
|
|
|
|
GLContextEGL::CreateGLContext(dummyCaps,
|
|
|
|
shareContext, true,
|
|
|
|
config, surface);
|
|
|
|
if (!glContext) {
|
2012-03-12 15:10:38 -07:00
|
|
|
NS_WARNING("Failed to create GLContext from PBuffer");
|
2010-07-18 22:01:14 -07:00
|
|
|
sEGLLibrary.fDestroySurface(EGL_DISPLAY(), surface);
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-06-09 15:27:29 -07:00
|
|
|
}
|
|
|
|
|
2010-07-18 22:01:14 -07:00
|
|
|
if (!glContext->Init()) {
|
2012-03-12 15:10:38 -07:00
|
|
|
NS_WARNING("Failed to initialize GLContext!");
|
2013-02-13 15:26:24 -08:00
|
|
|
// GLContextEGL::dtor will destroy |surface| for us.
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
2010-06-09 15:27:29 -07:00
|
|
|
|
2010-07-18 22:01:14 -07:00
|
|
|
return glContext.forget();
|
|
|
|
}
|
|
|
|
|
2010-10-04 04:21:32 -07:00
|
|
|
#ifdef MOZ_X11
|
2011-01-13 05:20:50 -08:00
|
|
|
EGLSurface
|
2012-04-30 17:03:08 -07:00
|
|
|
CreateEGLSurfaceForXSurface(gfxASurface* aSurface, EGLConfig* aConfig)
|
2010-10-04 04:21:32 -07:00
|
|
|
{
|
2011-01-13 05:20:50 -08:00
|
|
|
gfxXlibSurface* xsurface = static_cast<gfxXlibSurface*>(aSurface);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool opaque =
|
2013-09-24 13:45:13 -07:00
|
|
|
aSurface->GetContentType() == GFX_CONTENT_COLOR;
|
2011-01-13 05:20:50 -08:00
|
|
|
|
|
|
|
static EGLint pixmap_config_rgb[] = {
|
|
|
|
LOCAL_EGL_TEXTURE_TARGET, LOCAL_EGL_TEXTURE_2D,
|
|
|
|
LOCAL_EGL_TEXTURE_FORMAT, LOCAL_EGL_TEXTURE_RGB,
|
|
|
|
LOCAL_EGL_NONE
|
|
|
|
};
|
|
|
|
|
|
|
|
static EGLint pixmap_config_rgba[] = {
|
|
|
|
LOCAL_EGL_TEXTURE_TARGET, LOCAL_EGL_TEXTURE_2D,
|
|
|
|
LOCAL_EGL_TEXTURE_FORMAT, LOCAL_EGL_TEXTURE_RGBA,
|
|
|
|
LOCAL_EGL_NONE
|
|
|
|
};
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
EGLSurface surface = nullptr;
|
2011-01-13 05:20:50 -08:00
|
|
|
if (aConfig && *aConfig) {
|
|
|
|
if (opaque)
|
|
|
|
surface = sEGLLibrary.fCreatePixmapSurface(EGL_DISPLAY(), *aConfig,
|
2011-08-24 09:15:58 -07:00
|
|
|
(EGLNativePixmapType)xsurface->XDrawable(),
|
2011-01-13 05:20:50 -08:00
|
|
|
pixmap_config_rgb);
|
|
|
|
else
|
|
|
|
surface = sEGLLibrary.fCreatePixmapSurface(EGL_DISPLAY(), *aConfig,
|
2011-08-24 09:15:58 -07:00
|
|
|
(EGLNativePixmapType)xsurface->XDrawable(),
|
2011-01-13 05:20:50 -08:00
|
|
|
pixmap_config_rgba);
|
|
|
|
|
|
|
|
if (surface != EGL_NO_SURFACE)
|
|
|
|
return surface;
|
|
|
|
}
|
2010-10-04 04:21:32 -07:00
|
|
|
|
|
|
|
EGLConfig configs[32];
|
|
|
|
int numConfigs = 32;
|
|
|
|
|
2011-01-13 05:20:50 -08:00
|
|
|
static EGLint pixmap_config[] = {
|
2010-10-04 04:21:32 -07:00
|
|
|
LOCAL_EGL_SURFACE_TYPE, LOCAL_EGL_PIXMAP_BIT,
|
|
|
|
LOCAL_EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT,
|
2012-04-30 17:03:08 -07:00
|
|
|
LOCAL_EGL_DEPTH_SIZE, 0,
|
2010-10-04 04:21:32 -07:00
|
|
|
LOCAL_EGL_BIND_TO_TEXTURE_RGB, LOCAL_EGL_TRUE,
|
|
|
|
LOCAL_EGL_NONE
|
|
|
|
};
|
|
|
|
|
2011-01-13 05:20:50 -08:00
|
|
|
if (!sEGLLibrary.fChooseConfig(EGL_DISPLAY(),
|
2013-04-20 07:08:18 -07:00
|
|
|
pixmap_config,
|
2013-02-27 20:56:29 -08:00
|
|
|
configs, numConfigs, &numConfigs)
|
|
|
|
|| numConfigs == 0)
|
|
|
|
{
|
|
|
|
NS_WARNING("No EGL Config for pixmap!");
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2013-02-27 20:56:29 -08:00
|
|
|
}
|
2010-10-04 04:21:32 -07:00
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
for (i = 0; i < numConfigs; ++i) {
|
|
|
|
if (opaque)
|
|
|
|
surface = sEGLLibrary.fCreatePixmapSurface(EGL_DISPLAY(), configs[i],
|
2011-08-24 09:15:58 -07:00
|
|
|
(EGLNativePixmapType)xsurface->XDrawable(),
|
2010-10-04 04:21:32 -07:00
|
|
|
pixmap_config_rgb);
|
|
|
|
else
|
|
|
|
surface = sEGLLibrary.fCreatePixmapSurface(EGL_DISPLAY(), configs[i],
|
2011-08-24 09:15:58 -07:00
|
|
|
(EGLNativePixmapType)xsurface->XDrawable(),
|
2010-10-04 04:21:32 -07:00
|
|
|
pixmap_config_rgba);
|
|
|
|
|
|
|
|
if (surface != EGL_NO_SURFACE)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!surface) {
|
2013-02-27 20:56:29 -08:00
|
|
|
NS_WARNING("Failed to CreatePixmapSurface!");
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-10-04 04:21:32 -07:00
|
|
|
}
|
|
|
|
|
2011-01-13 05:20:50 -08:00
|
|
|
if (aConfig)
|
|
|
|
*aConfig = configs[i];
|
2010-10-04 04:21:32 -07:00
|
|
|
|
2011-01-13 05:20:50 -08:00
|
|
|
return surface;
|
2010-10-04 04:21:32 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-07-18 22:01:14 -07:00
|
|
|
already_AddRefed<GLContextEGL>
|
2013-02-13 15:26:24 -08:00
|
|
|
GLContextEGL::CreateEGLPixmapOffscreenContext(const gfxIntSize& size)
|
2010-07-18 22:01:14 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
gfxASurface *thebesSurface = nullptr;
|
2010-07-18 22:01:14 -07:00
|
|
|
EGLNativePixmapType pixmap = 0;
|
|
|
|
|
|
|
|
#ifdef MOZ_X11
|
|
|
|
nsRefPtr<gfxXlibSurface> xsurface =
|
|
|
|
gfxXlibSurface::Create(DefaultScreenOfDisplay(DefaultXDisplay()),
|
|
|
|
gfxXlibSurface::FindRenderFormat(DefaultXDisplay(),
|
2013-09-24 13:45:13 -07:00
|
|
|
gfxImageFormatRGB24),
|
2013-02-13 15:26:24 -08:00
|
|
|
size);
|
2011-01-13 05:20:50 -08:00
|
|
|
|
|
|
|
// XSync required after gfxXlibSurface::Create, otherwise EGL will fail with BadDrawable error
|
|
|
|
XSync(DefaultXDisplay(), False);
|
2010-07-18 22:01:14 -07:00
|
|
|
if (xsurface->CairoStatus() != 0)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-07-18 22:01:14 -07:00
|
|
|
|
|
|
|
thebesSurface = xsurface;
|
2011-08-24 09:15:58 -07:00
|
|
|
pixmap = (EGLNativePixmapType)xsurface->XDrawable();
|
2010-07-18 22:01:14 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!pixmap) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2011-01-06 14:07:12 -08:00
|
|
|
EGLSurface surface = 0;
|
2010-07-18 22:01:14 -07:00
|
|
|
EGLConfig config = 0;
|
|
|
|
|
2010-10-04 04:21:32 -07:00
|
|
|
#ifdef MOZ_X11
|
2012-04-30 17:03:08 -07:00
|
|
|
surface = CreateEGLSurfaceForXSurface(thebesSurface, &config);
|
2010-10-04 04:21:32 -07:00
|
|
|
#endif
|
|
|
|
if (!config) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
MOZ_ASSERT(surface);
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
GLContextEGL* shareContext = GetGlobalContextEGL();
|
|
|
|
SurfaceCaps dummyCaps = SurfaceCaps::Any();
|
2013-02-21 11:54:25 -08:00
|
|
|
nsRefPtr<GLContextEGL> glContext =
|
2013-02-27 20:56:29 -08:00
|
|
|
GLContextEGL::CreateGLContext(dummyCaps,
|
|
|
|
shareContext, true,
|
|
|
|
config, surface);
|
2013-02-13 15:26:24 -08:00
|
|
|
if (!glContext) {
|
|
|
|
NS_WARNING("Failed to create GLContext from XSurface");
|
|
|
|
sEGLLibrary.fDestroySurface(EGL_DISPLAY(), surface);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!glContext->Init()) {
|
|
|
|
NS_WARNING("Failed to initialize GLContext!");
|
|
|
|
// GLContextEGL::dtor will destroy |surface| for us.
|
|
|
|
return nullptr;
|
|
|
|
}
|
2010-07-18 22:01:14 -07:00
|
|
|
|
|
|
|
glContext->HoldSurface(thebesSurface);
|
|
|
|
|
|
|
|
return glContext.forget();
|
|
|
|
}
|
|
|
|
|
2013-08-25 16:56:53 -07:00
|
|
|
// Under EGL, on Android, pbuffers are supported fine, though
|
2010-07-18 22:01:14 -07:00
|
|
|
// often without the ability to texture from them directly.
|
|
|
|
already_AddRefed<GLContext>
|
2013-02-13 15:26:24 -08:00
|
|
|
GLContextProviderEGL::CreateOffscreen(const gfxIntSize& size,
|
|
|
|
const SurfaceCaps& caps,
|
|
|
|
ContextFlags flags)
|
2010-07-18 22:01:14 -07:00
|
|
|
{
|
|
|
|
if (!sEGLLibrary.EnsureInitialized()) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
gfxIntSize dummySize = gfxIntSize(16, 16);
|
|
|
|
nsRefPtr<GLContextEGL> glContext;
|
|
|
|
#if defined(MOZ_X11)
|
|
|
|
glContext = GLContextEGL::CreateEGLPixmapOffscreenContext(dummySize);
|
|
|
|
#else
|
|
|
|
glContext = GLContextEGL::CreateEGLPBufferOffscreenContext(dummySize);
|
|
|
|
#endif
|
2011-10-19 12:09:57 -07:00
|
|
|
|
|
|
|
if (!glContext)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2011-10-19 12:09:57 -07:00
|
|
|
|
2013-09-04 05:14:52 -07:00
|
|
|
if (flags & ContextFlagsGlobal)
|
2013-02-13 15:26:24 -08:00
|
|
|
return glContext.forget();
|
2011-06-09 18:18:43 -07:00
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
if (!glContext->InitOffscreen(size, caps))
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2012-03-02 09:28:06 -08:00
|
|
|
|
2011-06-09 18:18:43 -07:00
|
|
|
return glContext.forget();
|
2010-06-09 15:27:29 -07:00
|
|
|
}
|
|
|
|
|
2013-04-16 19:21:06 -07:00
|
|
|
SharedTextureHandle
|
2013-09-04 05:14:52 -07:00
|
|
|
GLContextProviderEGL::CreateSharedHandle(SharedTextureShareType shareType,
|
2013-04-16 19:21:06 -07:00
|
|
|
void* buffer,
|
2013-09-04 05:14:52 -07:00
|
|
|
SharedTextureBufferType bufferType)
|
2013-04-16 19:21:06 -07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-30 22:03:27 -07:00
|
|
|
already_AddRefed<gfxASurface>
|
2013-09-04 05:14:52 -07:00
|
|
|
GLContextProviderEGL::GetSharedHandleAsSurface(SharedTextureShareType shareType,
|
2013-04-30 22:03:27 -07:00
|
|
|
SharedTextureHandle sharedHandle)
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2012-06-14 08:59:40 -07:00
|
|
|
// Don't want a global context on Android as 1) share groups across 2 threads fail on many Tegra drivers (bug 759225)
|
|
|
|
// and 2) some mobile devices have a very strict limit on global number of GL contexts (bug 754257)
|
2012-11-20 18:45:13 -08:00
|
|
|
// and 3) each EGL context eats 750k on B2G (bug 813783)
|
2012-11-22 10:53:11 -08:00
|
|
|
GLContext *
|
|
|
|
GLContextProviderEGL::GetGlobalContext(const ContextFlags)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2010-07-19 21:05:42 -07:00
|
|
|
void
|
|
|
|
GLContextProviderEGL::Shutdown()
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
gGlobalContext = nullptr;
|
2010-07-19 21:05:42 -07:00
|
|
|
}
|
|
|
|
|
2010-06-09 15:27:29 -07:00
|
|
|
} /* namespace gl */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|