Bug 1019405 - Fix offscreen rendering for top level Layer manager. r=jgilbert

This commit is contained in:
Tatiana Meshkova 2014-06-03 20:41:00 +02:00
Родитель f003b05320
Коммит b6333c93ee
1 изменённых файлов: 18 добавлений и 3 удалений

Просмотреть файл

@ -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;