Bug 594874 - GfxInfo blocklist needs to be used by D3D, WebGL, OpenGL - 3/3 - r=vladimir, a=blocking2.0

This commit is contained in:
Benoit Jacob 2010-09-16 12:45:23 -04:00
Родитель a37e73a500
Коммит 5f84dc7be6
1 изменённых файлов: 28 добавлений и 4 удалений

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

@ -46,6 +46,7 @@
#include "nsContentUtils.h"
#include "nsIXPConnect.h"
#include "nsDOMError.h"
#include "nsIGfxInfo.h"
#include "gfxContext.h"
#include "gfxPattern.h"
@ -313,6 +314,29 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
prefService->GetBoolPref("webgl.force_osmesa", &forceOSMesa);
if (!forceOSMesa) {
PRBool useOpenGL = PR_TRUE;
PRBool useANGLE = PR_TRUE;
nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
if (gfxInfo) {
PRInt32 status;
if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_WEBGL_OPENGL, &status))) {
if (status != nsIGfxInfo::FEATURE_STATUS_UNKNOWN &&
status != nsIGfxInfo::FEATURE_AVAILABLE)
{
useOpenGL = PR_FALSE;
}
}
if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_WEBGL_ANGLE, &status))) {
if (status != nsIGfxInfo::FEATURE_STATUS_UNKNOWN &&
status != nsIGfxInfo::FEATURE_AVAILABLE)
{
useANGLE = PR_FALSE;
}
}
}
#ifdef XP_WIN
// On Windows, we may have a choice of backends, including straight
// OpenGL, D3D through ANGLE via EGL, or straight EGL/GLES2.
@ -321,7 +345,7 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
bool preferEGL = PR_GetEnv("MOZ_WEBGL_PREFER_EGL") != nsnull;
// if we want EGL, try it first
if (!gl && preferEGL) {
if (!gl && preferEGL && useANGLE) {
gl = gl::GLContextProviderEGL::CreateOffscreen(gfxIntSize(width, height), format);
if (gl && !InitAndValidateGL()) {
gl = nsnull;
@ -329,7 +353,7 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
}
// if it failed, then try the default provider, whatever that is
if (!gl) {
if (!gl && useOpenGL) {
gl = gl::GLContextProvider::CreateOffscreen(gfxIntSize(width, height), format);
if (gl && !InitAndValidateGL()) {
gl = nsnull;
@ -337,7 +361,7 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
}
// if that failed, and we weren't already preferring EGL, try it now.
if (!gl && !preferEGL) {
if (!gl && !preferEGL && useANGLE) {
gl = gl::GLContextProviderEGL::CreateOffscreen(gfxIntSize(width, height), format);
if (gl && !InitAndValidateGL()) {
gl = nsnull;
@ -345,7 +369,7 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
}
#else
// other platforms just use whatever the default is
if (!gl) {
if (!gl && useOpenGL) {
gl = gl::GLContextProvider::CreateOffscreen(gfxIntSize(width, height), format);
if (gl && !InitAndValidateGL()) {
gl = nsnull;