Bug 747377 - Force D2D on in Metro mode. r=bas

This commit is contained in:
Brian R. Bondy 2012-07-17 21:53:12 -04:00
parent ba908b4d16
commit 365c621abf
2 changed files with 35 additions and 1 deletions

View File

@ -391,6 +391,36 @@ gfxWindowsPlatform::~gfxWindowsPlatform()
CoUninitialize();
}
/* static */ bool
gfxWindowsPlatform::IsRunningInWindows8Metro()
{
static bool alreadyChecked = false;
static bool isMetro = false;
if (alreadyChecked) {
return isMetro;
}
HMODULE user32DLL = LoadLibraryW(L"user32.dll");
if (!user32DLL) {
return false;
}
typedef BOOL (WINAPI* IsImmersiveProcessFunc)(HANDLE process);
IsImmersiveProcessFunc IsImmersiveProcessPtr =
(IsImmersiveProcessFunc)GetProcAddress(user32DLL,
"IsImmersiveProcess");
FreeLibrary(user32DLL);
if (!IsImmersiveProcessPtr) {
// isMetro is already set to false.
alreadyChecked = true;
return false;
}
isMetro = IsImmersiveProcessPtr(GetCurrentProcess());
alreadyChecked = true;
return isMetro;
}
void
gfxWindowsPlatform::UpdateRenderMode()
{
@ -429,8 +459,11 @@ gfxWindowsPlatform::UpdateRenderMode()
d2dDisabled = Preferences::GetBool("gfx.direct2d.disabled", false);
d2dForceEnabled = Preferences::GetBool("gfx.direct2d.force-enabled", false);
// In Metro mode there is no fallback available
d2dForceEnabled |= IsRunningInWindows8Metro();
bool tryD2D = !d2dBlocked || d2dForceEnabled;
// Do not ever try if d2d is explicitly disabled,
// or if we're not using DWrite fonts.
if (d2dDisabled || mUsingGDIFonts) {

View File

@ -241,6 +241,7 @@ public:
#endif
static bool IsOptimus();
static bool IsRunningInWindows8Metro();
protected:
RenderMode mRenderMode;