From 92bc8c263111f9393706d8efbc7be0c1a9fae52d Mon Sep 17 00:00:00 2001 From: Joe Drew Date: Fri, 27 Aug 2010 22:44:37 -0400 Subject: [PATCH] Bug 591139 - Disable hardware acceleration in safe mode. r=bas a=blocking2.0:beta5+ --- gfx/thebes/gfxWindowsPlatform.cpp | 11 +++++++++-- widget/src/windows/nsWindow.cpp | 9 ++++++++- widget/src/xpwidgets/nsBaseWidget.cpp | 8 +++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index 4cdd5f23f189..a285e71696f3 100644 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -54,6 +54,7 @@ #include "nsIWindowsRegKey.h" #include "nsILocalFile.h" #include "plbase64.h" +#include "nsIXULRuntime.h" #ifdef MOZ_FT2_FONTS #include "ft2build.h" @@ -237,7 +238,12 @@ gfxWindowsPlatform::gfxWindowsPlatform() if (NS_FAILED(rv)) d2dDisabled = PR_FALSE; - if (isVistaOrHigher && !d2dDisabled) { + nsCOMPtr xr = do_GetService("@mozilla.org/xre/runtime;1"); + PRBool safeMode = PR_FALSE; + if (xr) + xr->GetInSafeMode(&safeMode); + + if (isVistaOrHigher && !d2dDisabled && !safeMode) { // We need a DWriteFactory to work. HMODULE d3d10module = LoadLibraryA("d3d10_1.dll"); D3D10CreateDevice1Func createD3DDevice = (D3D10CreateDevice1Func) @@ -319,7 +325,8 @@ gfxWindowsPlatform::gfxWindowsPlatform() #endif PRInt32 rmode; - if (NS_SUCCEEDED(pref->GetIntPref("mozilla.widget.render-mode", &rmode))) { + if (!safeMode && + NS_SUCCEEDED(pref->GetIntPref("mozilla.widget.render-mode", &rmode))) { if (rmode >= 0 && rmode < RENDER_MODE_MAX) { #ifdef CAIRO_HAS_DWRITE_FONT if (rmode != RENDER_DIRECT2D && !useDirectWrite) { diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 7dda03ea4f7b..32864f24541f 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -226,6 +226,8 @@ #include "nsICrashReporter.h" #endif +#include "nsIXULRuntime.h" + using namespace mozilla::widget; /************************************************************** @@ -3231,7 +3233,12 @@ nsWindow::GetLayerManager() &preferOpenGL); } - if (disableAcceleration) + nsCOMPtr xr = do_GetService("@mozilla.org/xre/runtime;1"); + PRBool safeMode = PR_FALSE; + if (xr) + xr->GetInSafeMode(&safeMode); + + if (disableAcceleration || safeMode) mUseAcceleratedRendering = PR_FALSE; else if (accelerateByDefault) mUseAcceleratedRendering = PR_TRUE; diff --git a/widget/src/xpwidgets/nsBaseWidget.cpp b/widget/src/xpwidgets/nsBaseWidget.cpp index 4eb09311b79a..d78f979f9a6e 100644 --- a/widget/src/xpwidgets/nsBaseWidget.cpp +++ b/widget/src/xpwidgets/nsBaseWidget.cpp @@ -51,6 +51,7 @@ #include "nsIPrefBranch2.h" #include "BasicLayers.h" #include "LayerManagerOGL.h" +#include "nsIXULRuntime.h" #ifdef DEBUG #include "nsIObserver.h" @@ -772,7 +773,12 @@ LayerManager* nsBaseWidget::GetLayerManager() &disableAcceleration); } - if (disableAcceleration) + nsCOMPtr xr = do_GetService("@mozilla.org/xre/runtime;1"); + PRBool safeMode = PR_FALSE; + if (xr) + xr->GetInSafeMode(&safeMode); + + if (disableAcceleration || safeMode) mUseAcceleratedRendering = PR_FALSE; else if (accelerateByDefault) mUseAcceleratedRendering = PR_TRUE;