Bug 624970. Display DirectWrite version in about:support. r=joe, a=joe

This commit is contained in:
John Daggett 2011-01-14 21:57:17 +09:00
parent d987bacdd1
commit 5c42411612
7 changed files with 68 additions and 2 deletions

View File

@ -691,6 +691,43 @@ gfxWindowsPlatform::WindowsOSVersion()
return winVersion;
}
void
gfxWindowsPlatform::GetDLLVersion(PRUnichar *aDLLPath, nsAString& aVersion)
{
DWORD versInfoSize, vers[4] = {0};
// version info not available case
aVersion.Assign(NS_LITERAL_STRING("0.0.0.0"));
versInfoSize = GetFileVersionInfoSizeW(aDLLPath, NULL);
nsAutoTArray<BYTE,512> versionInfo;
if (!versionInfo.AppendElements(PRUint32(versInfoSize))) {
return;
}
if (!GetFileVersionInfoW(aDLLPath, NULL, versInfoSize,
LPBYTE(versionInfo.Elements()))) {
return;
}
UINT len;
VS_FIXEDFILEINFO *fileInfo;
if (!VerQueryValue(LPBYTE(versionInfo.Elements()), TEXT("\\"),
(LPVOID *)&fileInfo , &len)) {
return;
}
DWORD fileVersMS = fileInfo->dwFileVersionMS;
DWORD fileVersLS = fileInfo->dwFileVersionLS;
vers[0] = HIWORD(fileVersMS);
vers[1] = LOWORD(fileVersMS);
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::FontsPrefsChanged(nsIPrefBranch *aPrefBranch, const char *aPref)
{

View File

@ -227,6 +227,8 @@ public:
static PRInt32 WindowsOSVersion();
static void GetDLLVersion(PRUnichar *aDLLPath, nsAString& aVersion);
virtual void FontsPrefsChanged(nsIPrefBranch *aPrefBranch, const char *aPref);
#ifdef CAIRO_HAS_DWRITE_FONT

View File

@ -233,12 +233,16 @@ function populateGraphicsSection() {
]));
var dwEnabled = false;
var dwriteEnabledStr = dwEnabled.toString();
var dwriteVersion;
try {
dwEnabled = gfxInfo.DWriteEnabled;
dwriteVersion = gfxInfo.DWriteVersion;
dwriteEnabledStr = dwEnabled.toString() + " (" + dwriteVersion + ")";
} catch(e) {}
trGraphics.push(createParentElement("tr", [
createHeader(bundle.GetStringFromName("directWriteEnabled")),
createElement("td", dwEnabled),
createElement("td", dwriteEnabledStr),
]));
var webglrenderer;

View File

@ -40,7 +40,7 @@
/* NOTE: this interface is completely undesigned, not stable and likely to change */
[scriptable, uuid(d2bfa0fd-8f73-4660-9609-f999680243b1)]
[scriptable, uuid(5c5de1e7-f7f4-46b4-9ced-03ab1f869eaf)]
interface nsIGfxInfo : nsISupports
{
/*
@ -48,6 +48,7 @@ interface nsIGfxInfo : nsISupports
*/
readonly attribute boolean D2DEnabled;
readonly attribute boolean DWriteEnabled;
readonly attribute DOMString DWriteVersion;
/**
* The name of the display adapter.

View File

@ -71,6 +71,13 @@ GfxInfo::GetDWriteEnabled(PRBool *aEnabled)
return NS_ERROR_FAILURE;
}
/* readonly attribute DOMString DWriteVersion; */
NS_IMETHODIMP
GfxInfo::GetDWriteVersion(nsAString & aDwriteVersion)
{
return NS_ERROR_FAILURE;
}
void
GfxInfo::Init()
{

View File

@ -106,6 +106,13 @@ GfxInfo::GetDWriteEnabled(PRBool *aEnabled)
return NS_ERROR_FAILURE;
}
/* readonly attribute DOMString DWriteVersion; */
NS_IMETHODIMP
GfxInfo::GetDWriteVersion(nsAString & aDwriteVersion)
{
return NS_ERROR_FAILURE;
}
/* readonly attribute DOMString adapterDescription; */
NS_IMETHODIMP
GfxInfo::GetAdapterDescription(nsAString & aAdapterDescription)

View File

@ -74,6 +74,14 @@ GfxInfo::GetDWriteEnabled(PRBool *aEnabled)
return NS_OK;
}
/* readonly attribute DOMString DWriteVersion; */
NS_IMETHODIMP
GfxInfo::GetDWriteVersion(nsAString & aDwriteVersion)
{
gfxWindowsPlatform::GetPlatform()->GetDLLVersion(L"dwrite.dll", aDwriteVersion);
return NS_OK;
}
/* 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)