mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 13:55:43 +00:00
Bug 720467 - Switch to using FBOs for WebGL, and support sharing textures between EGL contexts. r=jgilbert
This commit is contained in:
parent
c3f7963154
commit
265d0f9331
@ -981,7 +981,8 @@ public:
|
||||
|
||||
static already_AddRefed<GLContextEGL>
|
||||
CreateEGLPBufferOffscreenContext(const gfxIntSize& aSize,
|
||||
const ContextFormat& aFormat);
|
||||
const ContextFormat& aFormat,
|
||||
bool bufferUnused = false);
|
||||
|
||||
void SetOffscreenSize(const gfxIntSize &aRequestedSize,
|
||||
const gfxIntSize &aActualSize)
|
||||
@ -991,6 +992,9 @@ public:
|
||||
}
|
||||
|
||||
void *GetD3DShareHandle() {
|
||||
if (!mPBufferCanBindToTexture)
|
||||
return nsnull;
|
||||
|
||||
if (!sEGLLibrary.HasANGLESurfaceD3DTexture2DShareHandle()) {
|
||||
return nsnull;
|
||||
}
|
||||
@ -2062,7 +2066,8 @@ FillPBufferAttribs(nsTArray<EGLint>& aAttrs,
|
||||
|
||||
already_AddRefed<GLContextEGL>
|
||||
GLContextEGL::CreateEGLPBufferOffscreenContext(const gfxIntSize& aSize,
|
||||
const ContextFormat& aFormat)
|
||||
const ContextFormat& aFormat,
|
||||
bool bufferUnused)
|
||||
{
|
||||
EGLConfig config;
|
||||
EGLSurface surface;
|
||||
@ -2139,9 +2144,11 @@ TRY_ATTRIBS_AGAIN:
|
||||
|
||||
sEGLLibrary.fBindAPI(LOCAL_EGL_OPENGL_ES_API);
|
||||
|
||||
GLContextEGL* shareContext = GetGlobalContextEGL();
|
||||
context = sEGLLibrary.fCreateContext(EGL_DISPLAY(),
|
||||
config,
|
||||
EGL_NO_CONTEXT,
|
||||
shareContext ? shareContext->mContext
|
||||
: EGL_NO_CONTEXT,
|
||||
sEGLLibrary.HasRobustness() ? gContextAttribsRobustness
|
||||
: gContextAttribs);
|
||||
if (!context) {
|
||||
@ -2150,7 +2157,7 @@ TRY_ATTRIBS_AGAIN:
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsRefPtr<GLContextEGL> glContext = new GLContextEGL(aFormat, nsnull,
|
||||
nsRefPtr<GLContextEGL> glContext = new GLContextEGL(aFormat, shareContext,
|
||||
config, surface, context,
|
||||
true);
|
||||
|
||||
@ -2158,9 +2165,11 @@ TRY_ATTRIBS_AGAIN:
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
glContext->SetOffscreenSize(aSize, pbsize);
|
||||
glContext->mIsPBuffer = true;
|
||||
glContext->mPBufferCanBindToTexture = configCanBindToTexture;
|
||||
if (!bufferUnused) {
|
||||
glContext->SetOffscreenSize(aSize, pbsize);
|
||||
glContext->mIsPBuffer = true;
|
||||
glContext->mPBufferCanBindToTexture = configCanBindToTexture;
|
||||
}
|
||||
|
||||
return glContext.forget();
|
||||
}
|
||||
@ -2321,12 +2330,12 @@ GLContextProviderEGL::CreateOffscreen(const gfxIntSize& aSize,
|
||||
|
||||
#if defined(ANDROID) || defined(XP_WIN)
|
||||
nsRefPtr<GLContextEGL> glContext =
|
||||
GLContextEGL::CreateEGLPBufferOffscreenContext(aSize, aFormat);
|
||||
GLContextEGL::CreateEGLPBufferOffscreenContext(gfxIntSize(16, 16), aFormat, true);
|
||||
|
||||
if (!glContext)
|
||||
return nsnull;
|
||||
|
||||
if (!glContext->ResizeOffscreenFBO(glContext->OffscreenActualSize(), false))
|
||||
if (!glContext->ResizeOffscreenFBO(aSize, true))
|
||||
return nsnull;
|
||||
|
||||
return glContext.forget();
|
||||
@ -2408,10 +2417,12 @@ GLContextProviderEGL::GetGlobalContext()
|
||||
static bool triedToCreateContext = false;
|
||||
if (!triedToCreateContext && !gGlobalContext) {
|
||||
triedToCreateContext = true;
|
||||
gGlobalContext =
|
||||
GLContextEGL::CreateEGLPixmapOffscreenContext(gfxIntSize(16, 16),
|
||||
ContextFormat(ContextFormat::BasicRGB24),
|
||||
false);
|
||||
// Don't assign directly to gGlobalContext here, because
|
||||
// CreateOffscreen can call us re-entrantly.
|
||||
nsRefPtr<GLContext> ctx =
|
||||
GLContextProviderEGL::CreateOffscreen(gfxIntSize(16, 16),
|
||||
ContextFormat(ContextFormat::BasicRGB24));
|
||||
gGlobalContext = ctx;
|
||||
if (gGlobalContext)
|
||||
gGlobalContext->SetIsGlobalSharedContext(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user