Bug 912196 - Workaround no-alpha-with-ANGLE in WebGL, not GLContext. - r=kamidphish

This commit is contained in:
Jeff Gilbert 2014-10-08 16:30:01 -07:00
parent 0fa05e6f82
commit dd05af349c
3 changed files with 22 additions and 19 deletions

View File

@ -669,6 +669,12 @@ CreateOffscreen(GLContext* gl,
if (!baseCaps.alpha)
baseCaps.premultAlpha = true;
if (gl->IsANGLE()) {
// We can't use no-alpha formats on ANGLE yet because of:
// https://code.google.com/p/angleproject/issues/detail?id=764
baseCaps.alpha = true;
}
// we should really have this behind a
// |gfxPlatform::GetPlatform()->GetScreenDepth() == 16| check, but
// for now it's just behind a pref for testing/evaluation.
@ -928,6 +934,12 @@ WebGLContext::SetDimensions(int32_t sWidth, int32_t sHeight)
mShouldPresent = true;
if (gl->WorkAroundDriverBugs()) {
if (!mOptions.alpha && gl->Caps().alpha) {
mNeedsFakeNoAlpha = true;
}
}
MOZ_ASSERT(gl->Caps().color);
MOZ_ASSERT(gl->Caps().alpha == mOptions.alpha);
MOZ_ASSERT(gl->Caps().depth == mOptions.depth);
@ -935,12 +947,6 @@ WebGLContext::SetDimensions(int32_t sWidth, int32_t sHeight)
MOZ_ASSERT(gl->Caps().antialias == mOptions.antialias);
MOZ_ASSERT(gl->Caps().preserve == mOptions.preserveDrawingBuffer);
if (gl->WorkAroundDriverBugs() && gl->IsANGLE()) {
if (!mOptions.alpha) {
mNeedsFakeNoAlpha = true;
}
}
AssertCachedBindings();
AssertCachedState();
@ -1845,7 +1851,6 @@ bool WebGLContext::TexImageFromVideoElement(const TexImageTarget texImageTarget,
////////////////////////////////////////////////////////////////////////////////
WebGLContext::ScopedMaskWorkaround::ScopedMaskWorkaround(WebGLContext& webgl)
: mWebGL(webgl)
, mNeedsChange(NeedsChange(webgl))

View File

@ -312,12 +312,18 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
case LOCAL_GL_RED_BITS:
case LOCAL_GL_GREEN_BITS:
case LOCAL_GL_BLUE_BITS:
case LOCAL_GL_ALPHA_BITS:
case LOCAL_GL_DEPTH_BITS: {
GLint i = 0;
gl->fGetIntegerv(pname, &i);
return JS::Int32Value(i);
}
case LOCAL_GL_ALPHA_BITS: {
GLint i = 0;
if (!mNeedsFakeNoAlpha) {
gl->fGetIntegerv(pname, &i);
}
return JS::Int32Value(i);
}
case LOCAL_GL_FRAGMENT_SHADER_DERIVATIVE_HINT: {
if (IsExtensionEnabled(WebGLExtensionID::OES_standard_derivatives)) {
GLint i = 0;

View File

@ -289,7 +289,9 @@ ChooseConfig(GLContext* gl, GLLibraryEGL* egl, const SurfaceCaps& caps)
EGLConfig config = EGL_NO_CONFIG;
for (int i = 0; i < foundConfigs; i++) {
EGLConfig cur = configs[i];
if (!DoesAttribBitsMatchCapBool(egl, cur, LOCAL_EGL_DEPTH_SIZE,
if (!DoesAttribBitsMatchCapBool(egl, cur, LOCAL_EGL_ALPHA_SIZE,
caps.alpha) ||
!DoesAttribBitsMatchCapBool(egl, cur, LOCAL_EGL_DEPTH_SIZE,
caps.depth) ||
!DoesAttribBitsMatchCapBool(egl, cur, LOCAL_EGL_STENCIL_SIZE,
caps.stencil))
@ -297,16 +299,6 @@ ChooseConfig(GLContext* gl, GLLibraryEGL* egl, const SurfaceCaps& caps)
continue;
}
// We can't enforce alpha on ANGLE yet because of:
// https://code.google.com/p/angleproject/issues/detail?id=764
if (!gl->IsANGLE()) {
if (!DoesAttribBitsMatchCapBool(egl, cur, LOCAL_EGL_ALPHA_SIZE,
caps.alpha))
{
continue;
}
}
config = cur;
break;
}