Bug 650723. Add ClearType parameter data to about:support. r=gavin,jrmuizel
☠☠ backed out by 34e7b390a99b ☠ ☠
authorJohn Daggett <jdaggett@mozilla.com>
Mon, 09 May 2011 14:56:27 +0900
changeset 69130 d34dd7156b4dd893a20cb0dc8c4c97ec8f5098a9
parent 69129 9e31df64bfd71c9a82afd7663309c050d06e4f12
child 69131 34e7b390a99bd4cf400171c42cd2161cac46eab1
push id19871
push userjdaggett@mozilla.com
push dateMon, 09 May 2011 05:59:46 +0000
treeherdermozilla-central@d34dd7156b4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin, jrmuizel
bugs650723
milestone6.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
Bug 650723. Add ClearType parameter data to about:support. r=gavin,jrmuizel
gfx/thebes/gfxWindowsPlatform.cpp
gfx/thebes/gfxWindowsPlatform.h
toolkit/content/aboutSupport.js
toolkit/locales/en-US/chrome/global/aboutSupport.properties
widget/public/nsIGfxInfo.idl
widget/src/android/GfxInfo.cpp
widget/src/android/GfxInfo.h
widget/src/cocoa/GfxInfo.h
widget/src/cocoa/GfxInfo.mm
widget/src/windows/GfxInfo.cpp
widget/src/windows/GfxInfo.h
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -780,16 +780,107 @@ gfxWindowsPlatform::GetDLLVersion(const 
     vers[2] = HIWORD(fileVersLS);
     vers[3] = LOWORD(fileVersLS);
 
     char buf[256];
     sprintf(buf, "%d.%d.%d.%d", vers[0], vers[1], vers[2], vers[3]);
     aVersion.Assign(NS_ConvertUTF8toUTF16(buf));
 }
 
+void 
+gfxWindowsPlatform::GetCleartypeParams(nsTArray<ClearTypeParameterInfo>& aParams)
+{
+    HKEY  hKey, subKey;
+    DWORD i, rv, size, type;
+    WCHAR displayName[256], subkeyName[256];
+
+    aParams.Clear();
+
+    // construct subkeys based on HKLM subkeys, assume they are same for HKCU
+    rv = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+                       L"Software\\Microsoft\\Avalon.Graphics",
+                       0, KEY_READ, &hKey);
+
+    if (rv != ERROR_SUCCESS) {
+        return;
+    }
+
+    // enumerate over subkeys
+    for (i = 0, rv = ERROR_SUCCESS; rv != ERROR_NO_MORE_ITEMS; i++) {
+        size = NS_ARRAY_LENGTH(displayName);
+        rv = RegEnumKeyExW(hKey, i, displayName, &size, NULL, NULL, NULL, NULL);
+        if (rv != ERROR_SUCCESS) {
+            continue;
+        }
+
+        ClearTypeParameterInfo ctinfo;
+        ctinfo.displayName.Assign(displayName);
+
+        DWORD subrv, value;
+        bool foundData = false;
+
+        swprintf_s(subkeyName, NS_ARRAY_LENGTH(subkeyName),
+                   L"Software\\Microsoft\\Avalon.Graphics\\%s", displayName);
+
+        // subkey for gamma, pixel structure
+        subrv = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+                              subkeyName, 0, KEY_QUERY_VALUE, &subKey);
+
+        if (subrv == ERROR_SUCCESS) {
+            size = sizeof(value);
+            subrv = RegQueryValueExW(subKey, L"GammaLevel", NULL, &type,
+                                     (LPBYTE)&value, &size);
+            if (subrv == ERROR_SUCCESS && type == REG_DWORD) {
+                foundData = true;
+                ctinfo.gamma = value;
+            }
+
+            size = sizeof(value);
+            subrv = RegQueryValueExW(subKey, L"PixelStructure", NULL, &type,
+                                     (LPBYTE)&value, &size);
+            if (subrv == ERROR_SUCCESS && type == REG_DWORD) {
+                foundData = true;
+                ctinfo.pixelStructure = value;
+            }
+
+            RegCloseKey(subKey);
+        }
+
+        // subkey for cleartype level, enhanced contrast
+        subrv = RegOpenKeyExW(HKEY_CURRENT_USER,
+                              subkeyName, 0, KEY_QUERY_VALUE, &subKey);
+
+        if (subrv == ERROR_SUCCESS) {
+            size = sizeof(value);
+            subrv = RegQueryValueExW(subKey, L"ClearTypeLevel", NULL, &type,
+                                     (LPBYTE)&value, &size);
+            if (subrv == ERROR_SUCCESS && type == REG_DWORD) {
+                foundData = true;
+                ctinfo.clearTypeLevel = value;
+            }
+      
+            size = sizeof(value);
+            subrv = RegQueryValueExW(subKey, L"EnhancedContrastLevel",
+                                     NULL, &type, (LPBYTE)&value, &size);
+            if (subrv == ERROR_SUCCESS && type == REG_DWORD) {
+                foundData = true;
+                ctinfo.enhancedContrast = value;
+            }
+
+            RegCloseKey(subKey);
+        }
+
+        if (foundData) {
+            aParams.AppendElement(ctinfo);
+        }
+    }
+
+    RegCloseKey(hKey);
+}
+
 void
 gfxWindowsPlatform::FontsPrefsChanged(nsIPrefBranch *aPrefBranch, const char *aPref)
 {
     PRBool clearTextFontCaches = PR_TRUE;
 
     gfxPlatform::FontsPrefsChanged(aPrefBranch, aPref);
 
     if (!aPref) {
@@ -825,29 +916,29 @@ gfxWindowsPlatform::SetupClearTypeParams
         FLOAT contrast = -1.0;
         FLOAT level = -1.0;
         int geometry = -1;
         int mode = -1;
         PRInt32 value;
         if (NS_SUCCEEDED(aPrefBranch->GetIntPref(GFX_CLEARTYPE_PARAMS_GAMMA,
                                                  &value))) {
             if (value >= 1000 && value <= 2200) {
-                gamma = (FLOAT)value / 1000.0;
+                gamma = FLOAT(value / 1000.0);
             }
         }
         if (NS_SUCCEEDED(aPrefBranch->GetIntPref(GFX_CLEARTYPE_PARAMS_CONTRAST,
                                                  &value))) {
             if (value >= 0 && value <= 1000) {
-                contrast = (FLOAT)value / 100.0;
+                contrast = FLOAT(value / 100.0);
             }
         }
         if (NS_SUCCEEDED(aPrefBranch->GetIntPref(GFX_CLEARTYPE_PARAMS_LEVEL,
                                                  &value))) {
             if (value >= 0 && value <= 100) {
-                level = (FLOAT)value / 100.0;
+                level = FLOAT(value / 100.0);
             }
         }
         if (NS_SUCCEEDED(aPrefBranch->GetIntPref(GFX_CLEARTYPE_PARAMS_STRUCTURE,
                                                  &value))) {
             if (value >= 0 && value <= 2) {
                 geometry = value;
             }
         }
--- a/gfx/thebes/gfxWindowsPlatform.h
+++ b/gfx/thebes/gfxWindowsPlatform.h
@@ -109,16 +109,29 @@ struct DCFromContext {
     operator HDC () {
         return dc;
     }
 
     HDC dc;
     PRBool needsRelease;
 };
 
+// ClearType parameters set by running ClearType tuner
+struct ClearTypeParameterInfo {
+    ClearTypeParameterInfo() :
+        gamma(-1), pixelStructure(-1), clearTypeLevel(-1), enhancedContrast(-1)
+    { }
+
+    nsString    displayName;  // typically just 'DISPLAY1'
+    PRInt32     gamma;
+    PRInt32     pixelStructure;
+    PRInt32     clearTypeLevel;
+    PRInt32     enhancedContrast;
+};
+
 class THEBES_API gfxWindowsPlatform : public gfxPlatform {
 public:
     gfxWindowsPlatform();
     virtual ~gfxWindowsPlatform();
     static gfxWindowsPlatform *GetPlatform() {
         return (gfxWindowsPlatform*) gfxPlatform::GetPlatform();
     }
 
@@ -231,16 +244,19 @@ public:
         kWindowsVista = 0x60000,
         kWindows7 = 0x60001
     };
 
     static PRInt32 WindowsOSVersion(PRInt32 *aBuildNum = nsnull);
 
     static void GetDLLVersion(const PRUnichar *aDLLPath, nsAString& aVersion);
 
+    // returns ClearType tuning information for each display
+    static void GetCleartypeParams(nsTArray<ClearTypeParameterInfo>& aParams);
+
     virtual void FontsPrefsChanged(nsIPrefBranch *aPrefBranch, const char *aPref);
 
     void SetupClearTypeParams(nsIPrefBranch *aPrefBranch);
 
 #ifdef CAIRO_HAS_DWRITE_FONT
     IDWriteFactory *GetDWriteFactory() { return mDWriteFactory; }
     inline PRBool DWriteEnabled() { return mUseDirectWrite; }
     inline DWRITE_MEASURING_MODE DWriteMeasuringMode() { return mMeasuringMode; }
--- a/toolkit/content/aboutSupport.js
+++ b/toolkit/content/aboutSupport.js
@@ -254,21 +254,27 @@ function populateGraphicsSection() {
         d2dEnabled = gfxInfo.D2DEnabled;
       } catch(e) {}
       pushFeatureInfoRow(trGraphics, "direct2DEnabled", gfxInfo.FEATURE_DIRECT2D, d2dEnabled);
 
       var dwEnabled = "false";
       try {
         dwEnabled = gfxInfo.DWriteEnabled + " (" + gfxInfo.DWriteVersion + ")";
       } catch(e) {}
-      trGraphics.push(createParentElement("tr", [
-        createHeader(bundle.GetStringFromName("directWriteEnabled")),
-        createElement("td", dwEnabled),
-      ]));
+      pushInfoRow(trGraphics, "directWriteEnabled", dwEnabled);  
+
+      var cleartypeParams = "";
+      try {
+        cleartypeParams = gfxInfo.cleartypeParameters;
+      } catch(e) {
+        cleartypeParams = bundle.GetStringFromName("clearTypeParametersNotFound");
+      }
+      pushInfoRow(trGraphics, "clearTypeParameters", cleartypeParams);  
     }
+
 #endif
 
     var webglrenderer;
     var webglenabled;
     try {
       webglrenderer = gfxInfo.getWebGLParameter("full-renderer");
       webglenabled = true;
     } catch (e) {
--- a/toolkit/locales/en-US/chrome/global/aboutSupport.properties
+++ b/toolkit/locales/en-US/chrome/global/aboutSupport.properties
@@ -1,10 +1,11 @@
-# LOCALIZATION NOTE In the following string, "Direct2D" is a proper noun and should not be translated.
-# Feel free to leave english strings if there are no good translations, these are only used in about:support
+# LOCALIZATION NOTE In the following strings, "Direct2D", "DirectWrite" and "ClearType" 
+# are proper nouns and should not be translated. Feel free to leave english strings if 
+# there are no good translations, these are only used in about:support
 
 # LOCALIZATION NOTE: This can be localized with a more generic term, like
 # "Graphics-accelerated Windows". It describes a number of windows, e.g.:
 # "GPU Accelerated Windows: 2/2 (Direct3D 9)"
 # "GPU Accelerated Windows: 0/2"
 acceleratedWindows = GPU Accelerated Windows
 
 # LOCALIZATION NOTE The verb "blocked" here refers to a graphics feature such as "Direct2D" or "OpenGL layers".
@@ -16,16 +17,18 @@ tryNewerDriver = Blocked for your graphi
 # LOCALIZATION NOTE The verb "blocked" here refers to a graphics feature such as "Direct2D" or "OpenGL layers".
 blockedGfxCard = Blocked for your graphics card because of unresolved driver issues.
 
 # LOCALIZATION NOTE The verb "blocked" here refers to a graphics feature such as "Direct2D" or "OpenGL layers".
 blockedOSVersion = Blocked for your operating system version.
 
 direct2DEnabled = Direct2D Enabled
 directWriteEnabled = DirectWrite Enabled
+clearTypeParameters = ClearType Parameters
+clearTypeParametersNotFound = ClearType parameters not found
 adapterDescription = Adapter Description
 adapterVendorID = Vendor ID
 adapterDeviceID = Device ID
 adapterDrivers = Adapter Drivers
 adapterRAM = Adapter RAM
 driverVersion = Driver Version
 driverDate = Driver Date
 webglRenderer = WebGL Renderer
--- a/widget/public/nsIGfxInfo.idl
+++ b/widget/public/nsIGfxInfo.idl
@@ -35,25 +35,26 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 
 /* NOTE: this interface is completely undesigned, not stable and likely to change */
 
-[scriptable, uuid(5c5de1e7-f7f4-46b4-9ced-03ab1f869eaf)]
+[scriptable, uuid(a67c77af-2952-4028-93ab-e7bc3b43cf81)]
 interface nsIGfxInfo : nsISupports
 {
   /*
    * These are win32-specific
    */
   readonly attribute boolean D2DEnabled;
   readonly attribute boolean DWriteEnabled;
   readonly attribute DOMString DWriteVersion;
+  readonly attribute DOMString cleartypeParameters;
   
   /**
    * The name of the display adapter.
    */
   readonly attribute DOMString adapterDescription;
 
   readonly attribute DOMString adapterDriver;
   
--- a/widget/src/android/GfxInfo.cpp
+++ b/widget/src/android/GfxInfo.cpp
@@ -68,16 +68,23 @@ GfxInfo::GetDWriteEnabled(PRBool *aEnabl
 
 /* readonly attribute DOMString DWriteVersion; */
 NS_IMETHODIMP
 GfxInfo::GetDWriteVersion(nsAString & aDwriteVersion)
 {
   return NS_ERROR_FAILURE;
 }
 
+/* readonly attribute DOMString cleartypeParameters; */
+NS_IMETHODIMP
+GfxInfo::GetCleartypeParameters(nsAString & aCleartypeParams)
+{
+  return NS_ERROR_FAILURE;
+}
+
 nsresult
 GfxInfo::Init()
 {
   return GfxInfoBase::Init();
 }
 
 /* readonly attribute DOMString adapterDescription; */
 NS_IMETHODIMP
--- a/widget/src/android/GfxInfo.h
+++ b/widget/src/android/GfxInfo.h
@@ -50,16 +50,17 @@ namespace widget {
 class GfxInfo : public GfxInfoBase
 {
 public:
   // We only declare the subset of nsIGfxInfo that we actually implement. The
   // rest is brought forward from GfxInfoBase.
   NS_SCRIPTABLE NS_IMETHOD GetD2DEnabled(PRBool *aD2DEnabled);
   NS_SCRIPTABLE NS_IMETHOD GetDWriteEnabled(PRBool *aDWriteEnabled);
   NS_SCRIPTABLE NS_IMETHOD GetDWriteVersion(nsAString & aDwriteVersion);
+  NS_SCRIPTABLE NS_IMETHOD GetCleartypeParameters(nsAString & aCleartypeParams);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterDescription(nsAString & aAdapterDescription);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterDriver(nsAString & aAdapterDriver);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID(PRUint32 *aAdapterVendorID);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID(PRUint32 *aAdapterDeviceID);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterRAM(nsAString & aAdapterRAM);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverVersion(nsAString & aAdapterDriverVersion);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverDate(nsAString & aAdapterDriverDate);
   using GfxInfoBase::GetFeatureStatus;
--- a/widget/src/cocoa/GfxInfo.h
+++ b/widget/src/cocoa/GfxInfo.h
@@ -50,16 +50,17 @@ namespace widget {
 class GfxInfo : public GfxInfoBase
 {
 public:
   // We only declare the subset of nsIGfxInfo that we actually implement. The
   // rest is brought forward from GfxInfoBase.
   NS_SCRIPTABLE NS_IMETHOD GetD2DEnabled(PRBool *aD2DEnabled);
   NS_SCRIPTABLE NS_IMETHOD GetDWriteEnabled(PRBool *aDWriteEnabled);
   NS_SCRIPTABLE NS_IMETHOD GetDWriteVersion(nsAString & aDwriteVersion);
+  NS_SCRIPTABLE NS_IMETHOD GetCleartypeParameters(nsAString & aCleartypeParams);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterDescription(nsAString & aAdapterDescription);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterDriver(nsAString & aAdapterDriver);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID(PRUint32 *aAdapterVendorID);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID(PRUint32 *aAdapterDeviceID);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterRAM(nsAString & aAdapterRAM);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverVersion(nsAString & aAdapterDriverVersion);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverDate(nsAString & aAdapterDriverDate);
   using GfxInfoBase::GetFeatureStatus;
--- a/widget/src/cocoa/GfxInfo.mm
+++ b/widget/src/cocoa/GfxInfo.mm
@@ -109,16 +109,23 @@ GfxInfo::GetDWriteEnabled(PRBool *aEnabl
 
 /* readonly attribute DOMString DWriteVersion; */
 NS_IMETHODIMP
 GfxInfo::GetDWriteVersion(nsAString & aDwriteVersion)
 {
   return NS_ERROR_FAILURE;
 }
 
+/* readonly attribute DOMString cleartypeParameters; */
+NS_IMETHODIMP
+GfxInfo::GetCleartypeParameters(nsAString & aCleartypeParams)
+{
+  return NS_ERROR_FAILURE;
+}
+
 /* readonly attribute DOMString adapterDescription; */
 NS_IMETHODIMP
 GfxInfo::GetAdapterDescription(nsAString & aAdapterDescription)
 {
   aAdapterDescription = mRendererIDsString;
   return NS_OK;
 }
 
--- a/widget/src/windows/GfxInfo.cpp
+++ b/widget/src/windows/GfxInfo.cpp
@@ -101,16 +101,90 @@ GfxInfo::GetDWriteEnabled(PRBool *aEnabl
 /* readonly attribute DOMString DWriteVersion; */
 NS_IMETHODIMP
 GfxInfo::GetDWriteVersion(nsAString & aDwriteVersion)
 {
   gfxWindowsPlatform::GetDLLVersion(L"dwrite.dll", aDwriteVersion);
   return NS_OK;
 }
 
+#define PIXEL_STRUCT_RGB  1
+#define PIXEL_STRUCT_BGR  2
+
+/* readonly attribute DOMString cleartypeParameters; */
+NS_IMETHODIMP
+GfxInfo::GetCleartypeParameters(nsAString & aCleartypeParams)
+{
+  nsTArray<ClearTypeParameterInfo> clearTypeParams;
+
+  gfxWindowsPlatform::GetPlatform()->GetCleartypeParams(clearTypeParams);
+  PRUint32 d, numDisplays = clearTypeParams.Length();
+  bool displayNames = (numDisplays > 1);
+  bool foundData = false;
+  nsString outStr;
+  WCHAR valStr[256];
+
+  for (d = 0; d < numDisplays; d++) {
+    ClearTypeParameterInfo& params = clearTypeParams[d];
+
+    if (displayNames) {
+      swprintf_s(valStr, NS_ARRAY_LENGTH(valStr),
+                 L"%s [ ", params.displayName.get());
+      outStr.Append(valStr);
+    }
+
+    if (params.gamma >= 0) {
+      foundData = true;
+      swprintf_s(valStr, NS_ARRAY_LENGTH(valStr),
+                 L"Gamma: %d ", params.gamma);
+      outStr.Append(valStr);
+    }
+
+    if (params.pixelStructure >= 0) {
+      foundData = true;
+      if (params.pixelStructure == PIXEL_STRUCT_RGB ||
+          params.pixelStructure == PIXEL_STRUCT_BGR)
+      {
+        swprintf_s(valStr, NS_ARRAY_LENGTH(valStr),
+                   L"Pixel Structure: %s ",
+                   (params.pixelStructure == PIXEL_STRUCT_RGB ?
+                      L"RGB" : L"BGR"));
+      } else {
+        swprintf_s(valStr, NS_ARRAY_LENGTH(valStr),
+                   L"Pixel Structure: %d ", params.pixelStructure);
+      }
+      outStr.Append(valStr);
+    }
+
+    if (params.clearTypeLevel >= 0) {
+      foundData = true;
+      swprintf_s(valStr, NS_ARRAY_LENGTH(valStr),
+                 L"ClearType Level: %d ", params.clearTypeLevel);
+      outStr.Append(valStr);
+    }
+
+    if (params.enhancedContrast >= 0) {
+      foundData = true;
+      swprintf_s(valStr, NS_ARRAY_LENGTH(valStr),
+                 L"Enhanced Contrast: %d ", params.enhancedContrast);
+      outStr.Append(valStr);
+    }
+
+    if (displayNames) {
+      outStr.Append(L"] ");
+    }
+  }
+
+  if (foundData) {
+    aCleartypeParams.Assign(outStr);
+    return NS_OK;
+  }
+  return NS_ERROR_FAILURE;
+}
+
 /* XXX: GfxInfo doesn't handle multiple GPUs. We should try to do that. Bug #591057 */
 
 static nsresult GetKeyValue(const WCHAR* keyLocation, const WCHAR* keyName, nsAString& destString, int type)
 {
   HKEY key;
   DWORD dwcbData;
   DWORD dValue;
   DWORD resultType;
--- a/widget/src/windows/GfxInfo.h
+++ b/widget/src/windows/GfxInfo.h
@@ -54,16 +54,17 @@ class GfxInfo : public GfxInfoBase
 public:
   GfxInfo();
 
   // We only declare the subset of nsIGfxInfo that we actually implement. The
   // rest is brought forward from GfxInfoBase.
   NS_SCRIPTABLE NS_IMETHOD GetD2DEnabled(PRBool *aD2DEnabled);
   NS_SCRIPTABLE NS_IMETHOD GetDWriteEnabled(PRBool *aDWriteEnabled);
   NS_SCRIPTABLE NS_IMETHOD GetDWriteVersion(nsAString & aDwriteVersion);
+  NS_SCRIPTABLE NS_IMETHOD GetCleartypeParameters(nsAString & aCleartypeParams);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterDescription(nsAString & aAdapterDescription);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterDriver(nsAString & aAdapterDriver);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID(PRUint32 *aAdapterVendorID);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID(PRUint32 *aAdapterDeviceID);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterRAM(nsAString & aAdapterRAM);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverVersion(nsAString & aAdapterDriverVersion);
   NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverDate(nsAString & aAdapterDriverDate);
   using GfxInfoBase::GetFeatureStatus;