From c47bd89d8a6cd91dca1d9bf5ee3ee3a05dad0118 Mon Sep 17 00:00:00 2001 From: Doug Sherk Date: Mon, 31 Oct 2011 17:49:55 -0700 Subject: [PATCH] Bug 697757 - WebGL context fix for alpha being improperly set on OSX. r=jgilbert If we request alpha and it isn't enabled, or we request it off and it gets enabled, we now fail the pbuffer creation and fall back to FBOs. This is bad for performance but allows us to pass the conformance test in this case. --- content/canvas/test/webgl/failing_tests_mac.txt | 2 -- gfx/thebes/GLContextProviderCGL.mm | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/content/canvas/test/webgl/failing_tests_mac.txt b/content/canvas/test/webgl/failing_tests_mac.txt index 88026278032f..28146bff1391 100644 --- a/content/canvas/test/webgl/failing_tests_mac.txt +++ b/content/canvas/test/webgl/failing_tests_mac.txt @@ -1,4 +1,3 @@ -conformance/context/context-attributes-alpha-depth-stencil-antialias.html conformance/context/premultiplyalpha-test.html conformance/glsl/misc/glsl-function-nodes.html conformance/glsl/misc/glsl-long-variable-names.html @@ -6,7 +5,6 @@ conformance/glsl/misc/shader-with-256-character-identifier.frag.html conformance/glsl/misc/shader-with-long-line.html conformance/programs/program-test.html conformance/state/gl-object-get-calls.html -conformance/textures/tex-input-validation.html conformance/textures/texture-mips.html conformance/textures/texture-npot.html conformance/more/conformance/quickCheckAPI-S_V.html diff --git a/gfx/thebes/GLContextProviderCGL.mm b/gfx/thebes/GLContextProviderCGL.mm index dabb014bdb67..e3cabb81c21d 100644 --- a/gfx/thebes/GLContextProviderCGL.mm +++ b/gfx/thebes/GLContextProviderCGL.mm @@ -497,6 +497,20 @@ CreateOffscreenPBufferContext(const gfxIntSize& aSize, return nsnull; } + // If we ask for any of these to be on/off and we get the opposite, we stop + // creating a pbuffer and instead create an FBO. + GLint alphaBits, depthBits, stencilBits; + [pbFormat getValues: &alphaBits forAttribute: NSOpenGLPFAAlphaSize forVirtualScreen: 0]; + [pbFormat getValues: &depthBits forAttribute: NSOpenGLPFADepthSize forVirtualScreen: 0]; + [pbFormat getValues: &stencilBits forAttribute: NSOpenGLPFAStencilSize forVirtualScreen: 0]; + if ((alphaBits && !aFormat.alpha) || (!alphaBits && aFormat.alpha) || + (depthBits && !aFormat.alpha) || (!depthBits && aFormat.depth) || + (stencilBits && !aFormat.stencil) || (!stencilBits && aFormat.stencil)) + { + [pbFormat release]; + return nsnull; + } + NSOpenGLPixelBuffer *pb = [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:LOCAL_GL_TEXTURE_2D textureInternalFormat:(aFormat.alpha ? LOCAL_GL_RGBA : LOCAL_GL_RGB)