diff --git a/gfx/layers/d3d9/LayerManagerD3D9.cpp b/gfx/layers/d3d9/LayerManagerD3D9.cpp index 761c991e0737..f21b2a440c46 100644 --- a/gfx/layers/d3d9/LayerManagerD3D9.cpp +++ b/gfx/layers/d3d9/LayerManagerD3D9.cpp @@ -70,6 +70,7 @@ LayerManagerD3D9::Initialize() { nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); + /* XXX: this preference and blacklist code should move out of the layer manager */ PRBool forceAccelerate = PR_FALSE; if (prefs) { // we should use AddBoolPrefVarCache diff --git a/gfx/layers/opengl/LayerManagerOGL.cpp b/gfx/layers/opengl/LayerManagerOGL.cpp index 8cd42d1ed54b..3f0166c07849 100644 --- a/gfx/layers/opengl/LayerManagerOGL.cpp +++ b/gfx/layers/opengl/LayerManagerOGL.cpp @@ -61,8 +61,6 @@ #include "nsIPrefService.h" #include "nsIPrefBranch2.h" -#include "nsIGfxInfo.h" - namespace mozilla { namespace layers { @@ -154,25 +152,6 @@ already_AddRefed LayerManagerOGL::CreateContext() { nsRefPtr context; - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); - - PRBool forceAccelerate = PR_FALSE; - if (prefs) { - // we should use AddBoolPrefVarCache - prefs->GetBoolPref("layers.acceleration.force-enabled", - &forceAccelerate); - } - - nsCOMPtr gfxInfo = do_GetService("@mozilla.org/gfx/info;1"); - if (gfxInfo) { - PRInt32 status; - if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_OPENGL_LAYERS, &status))) { - if (status != nsIGfxInfo::FEATURE_NO_INFO && !forceAccelerate) { - NS_WARNING("OpenGL-accelerated layers are not supported on this system."); - return nsnull; - } - } - } #ifdef XP_WIN if (PR_GetEnv("MOZ_LAYERS_PREFER_EGL")) { diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index bdfaf14afb9a..04eac0698a38 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -181,6 +181,7 @@ #include "LayerManagerD3D10.h" #endif #include "LayerManagerOGL.h" +#include "nsIGfxInfo.h" #endif #include "BasicLayers.h" @@ -3284,6 +3285,7 @@ struct LayerManagerPrefs { {} PRBool mAccelerateByDefault; PRBool mDisableAcceleration; + PRBool mForceAcceleration; PRBool mPreferOpenGL; PRBool mPreferD3D9; }; @@ -3295,6 +3297,8 @@ GetLayerManagerPrefs(LayerManagerPrefs* aManagerPrefs) if (prefs) { prefs->GetBoolPref("layers.acceleration.disabled", &aManagerPrefs->mDisableAcceleration); + prefs->GetBoolPref("layers.acceleration.force-enabled", + &aManagerPrefs->mForceAcceleration); prefs->GetBoolPref("layers.prefer-opengl", &aManagerPrefs->mPreferOpenGL); prefs->GetBoolPref("layers.prefer-d3d9", @@ -3383,10 +3387,22 @@ nsWindow::GetLayerManager(LayerManagerPersistence aPersistence, bool* aAllowReta } #endif if (!mLayerManager && prefs.mPreferOpenGL) { - nsRefPtr layerManager = - new mozilla::layers::LayerManagerOGL(this); - if (layerManager->Initialize()) { - mLayerManager = layerManager; + nsCOMPtr gfxInfo = do_GetService("@mozilla.org/gfx/info;1"); + PRInt32 status = nsIGfxInfo::FEATURE_NO_INFO; + + if (gfxInfo && !prefs.mForceAcceleration) { + gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_OPENGL_LAYERS, &status); + } + + if (status == nsIGfxInfo::FEATURE_NO_INFO) { + nsRefPtr layerManager = + new mozilla::layers::LayerManagerOGL(this); + if (layerManager->Initialize()) { + mLayerManager = layerManager; + } + + } else { + NS_WARNING("OpenGL accelerated layers are not supported on this system."); } } } diff --git a/widget/src/xpwidgets/nsBaseWidget.cpp b/widget/src/xpwidgets/nsBaseWidget.cpp index 0952f25dbc10..cdfcdf79ac2e 100644 --- a/widget/src/xpwidgets/nsBaseWidget.cpp +++ b/widget/src/xpwidgets/nsBaseWidget.cpp @@ -52,6 +52,7 @@ #include "BasicLayers.h" #include "LayerManagerOGL.h" #include "nsIXULRuntime.h" +#include "nsIGfxInfo.h" #ifdef DEBUG #include "nsIObserver.h" @@ -812,7 +813,21 @@ nsBaseWidget::GetShouldAccelerate() if (disableAcceleration || safeMode) return PR_FALSE; - if (accelerateByDefault || forceAcceleration) + if (forceAcceleration) + return PR_TRUE; + + nsCOMPtr gfxInfo = do_GetService("@mozilla.org/gfx/info;1"); + if (gfxInfo) { + PRInt32 status; + if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_OPENGL_LAYERS, &status))) { + if (status != nsIGfxInfo::FEATURE_NO_INFO) { + NS_WARNING("OpenGL-accelerated layers are not supported on this system."); + return PR_FALSE; + } + } + } + + if (accelerateByDefault) return PR_TRUE; /* use the window acceleration flag */ @@ -828,7 +843,6 @@ LayerManager* nsBaseWidget::GetLayerManager(LayerManagerPersistence, bool* aAllowRetaining) { if (!mLayerManager) { - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); mUseAcceleratedRendering = GetShouldAccelerate();