diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index e0a03a838a48..e6ef98e59fd0 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -114,6 +114,15 @@ CompositorOGL::CreateContext() } #endif + // Allow to create offscreen GL context for main Layer Manager + if (!context && PR_GetEnv("MOZ_LAYERS_PREFER_OFFSCREEN")) { + SurfaceCaps caps = SurfaceCaps::ForRGB(); + caps.preserve = false; + caps.bpp16 = gfxPlatform::GetPlatform()->GetOffscreenFormat() == gfxImageFormat::RGB16_565; + context = GLContextProvider::CreateOffscreen(gfxIntSize(mSurfaceSize.width, + mSurfaceSize.height), caps); + } + if (!context) context = gl::GLContextProvider::CreateForWindow(mWidget); @@ -571,9 +580,15 @@ CompositorOGL::PrepareViewport(const gfx::IntSize& aSize, // Matrix to transform (0, 0, aWidth, aHeight) to viewport space (-1.0, 1.0, // 2, 2) and flip the contents. Matrix viewMatrix; - viewMatrix.Translate(-1.0, 1.0); - viewMatrix.Scale(2.0f / float(aSize.width), 2.0f / float(aSize.height)); - viewMatrix.Scale(1.0f, -1.0f); + if (mGLContext->IsOffscreen()) { + // In case of rendering via GL Offscreen context, disable Y-Flipping + viewMatrix.Translate(-1.0, -1.0); + viewMatrix.Scale(2.0f / float(aSize.width), 2.0f / float(aSize.height)); + } else { + viewMatrix.Translate(-1.0, 1.0); + viewMatrix.Scale(2.0f / float(aSize.width), 2.0f / float(aSize.height)); + viewMatrix.Scale(1.0f, -1.0f); + } viewMatrix = aWorldTransform * viewMatrix;