Bug 1345222 - Fix user-set ClearType params detection. r=mchang a=lizzard
☠☠ backed out by fe3a14531fea ☠ ☠
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Fri, 10 Mar 2017 00:47:44 +0900
changeset 379097 3bc5f2964d595f91fa0144a45e704493087cec77
parent 379096 df36e8af5a74d66be235fb1aabaa83bd3c42b054
child 379098 993b574eb8289875f621f72965d3ba05f3202a1e
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmchang, lizzard
bugs1345222
milestone53.0
Bug 1345222 - Fix user-set ClearType params detection. r=mchang a=lizzard MozReview-Commit-ID: B7bCPbZ9id9
gfx/thebes/gfxWindowsPlatform.cpp
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -1166,18 +1166,20 @@ gfxWindowsPlatform::FontsPrefsChanged(co
     if (clearTextFontCaches) {
         gfxFontCache *fc = gfxFontCache::GetCache();
         if (fc) {
             fc->Flush();
         }
     }
 }
 
-#define ENHANCED_CONTRAST_REGISTRY_KEY \
-    HKEY_CURRENT_USER, "Software\\Microsoft\\Avalon.Graphics\\DISPLAY1\\EnhancedContrastLevel"
+#define DISPLAY1_REGISTRY_KEY \
+    HKEY_CURRENT_USER, "Software\\Microsoft\\Avalon.Graphics\\DISPLAY1"
+
+#define ENHANCED_CONTRAST_VALUE_NAME "EnhancedContrastLevel"
 
 void
 gfxWindowsPlatform::SetupClearTypeParams()
 {
     if (GetDWriteFactory()) {
         // any missing prefs will default to invalid (-1) and be ignored;
         // out-of-range values will also be ignored
         FLOAT gamma = -1.0;
@@ -1234,20 +1236,24 @@ gfxWindowsPlatform::SetupClearTypeParams
         RefPtr<IDWriteRenderingParams> defaultRenderingParams;
         GetDWriteFactory()->CreateRenderingParams(getter_AddRefs(defaultRenderingParams));
         // For EnhancedContrast, we override the default if the user has not set it
         // in the registry (by using the ClearType Tuner).
         if (contrast >= 0.0 && contrast <= 10.0) {
             contrast = contrast;
         } else {
             HKEY hKey;
-            if (RegOpenKeyExA(ENHANCED_CONTRAST_REGISTRY_KEY,
-                              0, KEY_READ, &hKey) == ERROR_SUCCESS)
-            {
-                contrast = defaultRenderingParams->GetEnhancedContrast();
+            LONG res = RegOpenKeyExA(DISPLAY1_REGISTRY_KEY,
+                                     0, KEY_READ, &hKey);
+            if (res == ERROR_SUCCESS) {
+                res = RegQueryValueExA(hKey, ENHANCED_CONTRAST_VALUE_NAME,
+                                       nullptr, nullptr, nullptr, nullptr);
+                if (res == ERROR_SUCCESS) {
+                    contrast = defaultRenderingParams->GetEnhancedContrast();
+                }
                 RegCloseKey(hKey);
             } else {
                 contrast = 1.0;
             }
         }
 
         // For parameters that have not been explicitly set,
         // we copy values from default params (or our overridden value for contrast)