b=929508; implement gfxWindowsPlatform::GetScreenDepth; r=jrmuizel
authorVladimir Vukicevic <vladimir@pobox.com>
Wed, 18 Dec 2013 13:09:10 -0500
changeset 161067 72232ad1e83da3519c2d4784c48dd84de05182cb
parent 161066 0d36904aa4bd44e4b118a3832bd2b20c652de485
child 161068 8048271b130dc7c8b8934ac36732808759baeaef
push id25866
push userryanvm@gmail.com
push dateThu, 19 Dec 2013 02:15:01 +0000
treeherdermozilla-central@940c52e93281 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs929508
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
b=929508; implement gfxWindowsPlatform::GetScreenDepth; r=jrmuizel
gfx/thebes/gfxWindowsPlatform.cpp
gfx/thebes/gfxWindowsPlatform.h
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -1480,16 +1480,36 @@ gfxWindowsPlatform::GetD3D11Device()
 }
 
 bool
 gfxWindowsPlatform::IsOptimus()
 {
   return GetModuleHandleA("nvumdshim.dll");
 }
 
+int
+gfxWindowsPlatform::GetScreenDepth() const
+{
+    // if the system doesn't have all displays with the same
+    // pixel format, just return 24 and move on with life.
+    if (!GetSystemMetrics(SM_SAMEDISPLAYFORMAT))
+        return 24;
+
+    HDC hdc = GetDC(nullptr);
+    if (!hdc)
+        return 24;
+
+    int depth = GetDeviceCaps(hdc, BITSPIXEL) *
+                GetDeviceCaps(hdc, PLANES);
+
+    ReleaseDC(nullptr, hdc);
+
+    return depth;
+}
+
 IDXGIAdapter1*
 gfxWindowsPlatform::GetDXGIAdapter()
 {
   if (mAdapter) {
     return mAdapter;
   }
 
   nsModuleHandle dxgiModule(LoadLibrarySystem32(L"dxgi.dll"));
--- a/gfx/thebes/gfxWindowsPlatform.h
+++ b/gfx/thebes/gfxWindowsPlatform.h
@@ -148,16 +148,18 @@ public:
 
         /* Use Direct2D rendering */
         RENDER_DIRECT2D,
 
         /* max */
         RENDER_MODE_MAX
     };
 
+    int GetScreenDepth() const;
+
     RenderMode GetRenderMode() { return mRenderMode; }
     void SetRenderMode(RenderMode rmode) { mRenderMode = rmode; }
 
     /**
      * Updates render mode with relation to the current preferences and
      * available devices.
      */
     void UpdateRenderMode();