From 00bd67cec6f90a19ff6a7709ccad87c08a1791f3 Mon Sep 17 00:00:00 2001 From: John Daggett Date: Mon, 31 Jan 2011 11:15:12 +0900 Subject: [PATCH] Bug 629611. Add font cache size info to about:support. r=bas,joedrew a=joedrew --- gfx/thebes/gfxWindowsPlatform.cpp | 33 +++++++++++++++++++++++++++++++ gfx/thebes/gfxWindowsPlatform.h | 2 ++ widget/src/windows/GfxInfo.cpp | 8 +++++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index bac3b9615a6..80da373b6e1 100644 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -76,6 +76,9 @@ #endif #endif +#include +#include + #ifdef CAIRO_HAS_D2D_SURFACE #include "gfxD2DSurface.h" @@ -728,6 +731,36 @@ gfxWindowsPlatform::GetDLLVersion(const PRUnichar *aDLLPath, nsAString& aVersion aVersion.Assign(NS_ConvertUTF8toUTF16(buf)); } +void +gfxWindowsPlatform::GetFontCacheSize(nsAString& aSize) +{ + WIN32_FIND_DATAW findFileData; + HANDLE file; + LARGE_INTEGER fileSize; + WCHAR path[MAX_PATH]; + + aSize.Assign(L"n/a"); + + if (FAILED(SHGetFolderPathW(NULL, CSIDL_WINDOWS, NULL, 0, path))) { + return; + } + + PathAppendW(path, + L"ServiceProfiles\\LocalService\\AppData\\Local\\FontCache-*-*.dat"); + file = FindFirstFileW(path, &findFileData); + if (file == INVALID_HANDLE_VALUE) { + return; + } + + WCHAR size[256]; + + double sizeMB = (double(findFileData.nFileSizeLow) + + findFileData.nFileSizeHigh * (double(MAXDWORD) + 1)) + / 1000000.0; + swprintf(size, L"%.2f MB", sizeMB); + aSize.Assign(size); +} + void gfxWindowsPlatform::FontsPrefsChanged(nsIPrefBranch *aPrefBranch, const char *aPref) { diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index cfc471cd887..1c9547e0a20 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -229,6 +229,8 @@ public: static void GetDLLVersion(const PRUnichar *aDLLPath, nsAString& aVersion); + static void GetFontCacheSize(nsAString& aSize); + virtual void FontsPrefsChanged(nsIPrefBranch *aPrefBranch, const char *aPref); #ifdef CAIRO_HAS_DWRITE_FONT diff --git a/widget/src/windows/GfxInfo.cpp b/widget/src/windows/GfxInfo.cpp index b392143491a..ced63d83ede 100644 --- a/widget/src/windows/GfxInfo.cpp +++ b/widget/src/windows/GfxInfo.cpp @@ -102,7 +102,13 @@ GfxInfo::GetDWriteEnabled(PRBool *aEnabled) NS_IMETHODIMP GfxInfo::GetDWriteVersion(nsAString & aDwriteVersion) { - gfxWindowsPlatform::GetPlatform()->GetDLLVersion(L"dwrite.dll", aDwriteVersion); + nsAutoString str; + gfxWindowsPlatform::GetPlatform()->GetDLLVersion(L"dwrite.dll", str); + aDwriteVersion.Assign(str); + aDwriteVersion.Append(L", font cache "); + gfxWindowsPlatform::GetPlatform()->GetFontCacheSize(str); + aDwriteVersion.Append(str); + return NS_OK; }