From dcff5c97c535c388bcea47d4acfe6b22a34f4c14 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Thu, 28 Feb 2013 16:10:17 -0500 Subject: [PATCH] Bug 845571 - Turn on console debug logging when running in Metro. r=jimm --- gfx/layers/d3d10/LayerManagerD3D10.cpp | 7 +++-- gfx/thebes/gfxWindowsPlatform.cpp | 37 +++++--------------------- gfx/thebes/gfxWindowsPlatform.h | 1 - xpcom/base/nsDebugImpl.cpp | 10 ++++++- xpcom/base/nsWindowsHelpers.h | 30 +++++++++++++++++++++ 5 files changed, 50 insertions(+), 35 deletions(-) diff --git a/gfx/layers/d3d10/LayerManagerD3D10.cpp b/gfx/layers/d3d10/LayerManagerD3D10.cpp index 0a6a8ce194ba..8fe7a5a4961b 100644 --- a/gfx/layers/d3d10/LayerManagerD3D10.cpp +++ b/gfx/layers/d3d10/LayerManagerD3D10.cpp @@ -27,6 +27,7 @@ #include "gfxCrashReporterUtils.h" #ifdef MOZ_METRO #include "DXGI1_2.h" +#include "nsWindowsHelpers.h" #endif using namespace std; @@ -216,7 +217,7 @@ LayerManagerD3D10::Initialize(bool force) dxgiDevice->GetAdapter(getter_AddRefs(dxgiAdapter)); #ifdef MOZ_METRO - if (gfxWindowsPlatform::IsRunningInWindows8Metro()) { + if (IsRunningInWindowsMetro()) { nsRefPtr dxgiFactory; dxgiAdapter->GetParent(IID_PPV_ARGS(dxgiFactory.StartAssignment())); @@ -654,10 +655,12 @@ LayerManagerD3D10::VerifyBufferSize() mSwapChain->ResizeBuffers(1, rect.width, rect.height, DXGI_FORMAT_B8G8R8A8_UNORM, 0); - } else if (gfxWindowsPlatform::IsRunningInWindows8Metro()) { +#ifdef MOZ_METRO + } else if (IsRunningInWindowsMetro()) { mSwapChain->ResizeBuffers(2, rect.width, rect.height, DXGI_FORMAT_B8G8R8A8_UNORM, 0); +#endif } else { mSwapChain->ResizeBuffers(1, rect.width, rect.height, DXGI_FORMAT_B8G8R8A8_UNORM, diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index acb2479e9352..3e8cfcd30e3d 100644 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -36,6 +36,9 @@ #endif #include "gfxUserFontSet.h" +#ifdef MOZ_METRO +#include "nsWindowsHelpers.h" +#endif #include @@ -393,36 +396,6 @@ 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() { @@ -461,8 +434,10 @@ gfxWindowsPlatform::UpdateRenderMode() d2dDisabled = Preferences::GetBool("gfx.direct2d.disabled", false); d2dForceEnabled = Preferences::GetBool("gfx.direct2d.force-enabled", false); +#ifdef MOZ_METRO // In Metro mode there is no fallback available - d2dForceEnabled |= IsRunningInWindows8Metro(); + d2dForceEnabled |= IsRunningInWindowsMetro(); +#endif bool tryD2D = !d2dBlocked || d2dForceEnabled; diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index c4b6976fa9bf..ca1e16ef934e 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -240,7 +240,6 @@ public: #endif static bool IsOptimus(); - static bool IsRunningInWindows8Metro(); protected: RenderMode mRenderMode; diff --git a/xpcom/base/nsDebugImpl.cpp b/xpcom/base/nsDebugImpl.cpp index ad01d719aa9e..e751d993b0d1 100644 --- a/xpcom/base/nsDebugImpl.cpp +++ b/xpcom/base/nsDebugImpl.cpp @@ -41,6 +41,9 @@ #if defined(XP_WIN) #include #include "nsString.h" +#ifdef MOZ_METRO +#include "nsWindowsHelpers.h" +#endif #endif #if defined(XP_MACOSX) @@ -214,7 +217,12 @@ static nsAssertBehavior GetAssertBehavior() if (gAssertBehavior != NS_ASSERT_UNINITIALIZED) return gAssertBehavior; -#if defined(XP_WIN) || defined(XP_OS2) +#if defined(XP_WIN) && defined(MOZ_METRO) + if (IsRunningInWindowsMetro()) + gAssertBehavior = NS_ASSERT_WARN; + else + gAssertBehavior = NS_ASSERT_TRAP; +#elif defined(XP_WIN) || defined(XP_OS2) gAssertBehavior = NS_ASSERT_TRAP; #else gAssertBehavior = NS_ASSERT_WARN; diff --git a/xpcom/base/nsWindowsHelpers.h b/xpcom/base/nsWindowsHelpers.h index 7bc436cf1da8..4a75ea9e5e7e 100644 --- a/xpcom/base/nsWindowsHelpers.h +++ b/xpcom/base/nsWindowsHelpers.h @@ -94,6 +94,36 @@ namespace GetVersionEx(&info); return info.dwMajorVersion >= 6; } + + bool + IsRunningInWindowsMetro() + { + 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; + } } #endif