Bug 847714 - Halve drawing buffer sizes until resize succeeds - r=bjacob

This commit is contained in:
Jeff Gilbert 2013-03-06 17:36:59 -08:00
Родитель b7dca43e54
Коммит 90a55f136a
1 изменённых файлов: 37 добавлений и 5 удалений

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

@ -381,9 +381,24 @@ WebGLContext::SetDimensions(int32_t width, int32_t height)
if (gl) { if (gl) {
MakeContextCurrent(); MakeContextCurrent();
gl->ResizeOffscreen(gfxIntSize(width, height)); // Doesn't matter if it succeeds (soft-fail) bool success = false;
while (width && height) {
gfxIntSize size(width, height);
if (gl->ResizeOffscreen(size)) {
success = true;
break;
}
width /= 2;
height /= 2;
}
// It's unlikely that we'll get a proper-sized context if we recreate if we didn't on resize // It's unlikely that we'll get a proper-sized context if we recreate if we didn't on resize
if (!success) {
ForceLoseContext();
return NS_OK;
}
// everything's good, we're done here // everything's good, we're done here
mWidth = gl->OffscreenSize().width; mWidth = gl->OffscreenSize().width;
mHeight = gl->OffscreenSize().height; mHeight = gl->OffscreenSize().height;
@ -505,12 +520,19 @@ WebGLContext::SetDimensions(int32_t width, int32_t height)
} }
#endif #endif
gfxIntSize size(width, height);
#ifdef XP_WIN #ifdef XP_WIN
// if we want EGL, try it now // if we want EGL, try it now
if (!gl && (preferEGL || useANGLE) && !preferOpenGL) { if (!gl && (preferEGL || useANGLE) && !preferOpenGL) {
gl = gl::GLContextProviderEGL::CreateOffscreen(size, caps); while (width && height) {
gfxIntSize size(width, height);
gl = gl::GLContextProviderEGL::CreateOffscreen(size, caps);
if (gl)
break;
width /= 2;
height /= 2;
}
if (!gl || !InitAndValidateGL()) { if (!gl || !InitAndValidateGL()) {
GenerateWarning("Error during ANGLE OpenGL ES initialization"); GenerateWarning("Error during ANGLE OpenGL ES initialization");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -523,7 +545,17 @@ WebGLContext::SetDimensions(int32_t width, int32_t height)
GLContext::ContextFlags flag = useMesaLlvmPipe GLContext::ContextFlags flag = useMesaLlvmPipe
? GLContext::ContextFlagsMesaLLVMPipe ? GLContext::ContextFlagsMesaLLVMPipe
: GLContext::ContextFlagsNone; : GLContext::ContextFlagsNone;
gl = gl::GLContextProvider::CreateOffscreen(size, caps, flag);
while (width && height) {
gfxIntSize size(width, height);
gl = gl::GLContextProvider::CreateOffscreen(size, caps, flag);
if (gl)
break;
width /= 2;
height /= 2;
}
if (gl && !InitAndValidateGL()) { if (gl && !InitAndValidateGL()) {
GenerateWarning("Error during %s initialization", GenerateWarning("Error during %s initialization",
useMesaLlvmPipe ? "Mesa LLVMpipe" : "OpenGL"); useMesaLlvmPipe ? "Mesa LLVMpipe" : "OpenGL");