From 723aae06e95177b10eab4d9061c799c5fda89e90 Mon Sep 17 00:00:00 2001 From: John Daggett Date: Fri, 25 Feb 2011 10:31:16 +0900 Subject: [PATCH] Bug 630201. Don't use DirectWrite for pre-RTM versions of Windows 7. r=bas, a=joedrew --- gfx/thebes/gfxWindowsPlatform.cpp | 35 +++++++++++++++++++++++++++++-- gfx/thebes/gfxWindowsPlatform.h | 2 +- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index 453cce82798..eda8a2be619 100644 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -408,6 +408,29 @@ gfxWindowsPlatform::VerifyD2DDevice(PRBool aAttemptForce) #endif } +// bug 630201 - older pre-RTM versions of Direct2D/DirectWrite cause odd +// crashers so blacklist them altogether + +#ifdef CAIRO_HAS_DWRITE_FONT +#define WINDOWS7_RTM_BUILD 7600 + +static PRBool +AllowDirectWrite() +{ + PRInt32 winVers, buildNum; + + winVers = gfxWindowsPlatform::WindowsOSVersion(&buildNum); + if (winVers == gfxWindowsPlatform::kWindows7 && + buildNum < WINDOWS7_RTM_BUILD) + { + // don't use Direct2D/DirectWrite on older versions of Windows 7 + return PR_FALSE; + } + + return PR_TRUE; +} +#endif + gfxPlatformFontList* gfxWindowsPlatform::CreatePlatformFontList() { @@ -417,7 +440,7 @@ gfxWindowsPlatform::CreatePlatformFontList() pfl = new gfxFT2FontList(); #else #ifdef CAIRO_HAS_DWRITE_FONT - if (GetDWriteFactory()) { + if (AllowDirectWrite() && GetDWriteFactory()) { pfl = new gfxDWriteFontList(); if (NS_SUCCEEDED(pfl->InitFontList())) { return pfl; @@ -677,9 +700,10 @@ gfxWindowsPlatform::UseClearTypeAlways() } PRInt32 -gfxWindowsPlatform::WindowsOSVersion() +gfxWindowsPlatform::WindowsOSVersion(PRInt32 *aBuildNum) { static PRInt32 winVersion = UNINITIALIZED_VALUE; + static PRInt32 buildNum = UNINITIALIZED_VALUE; OSVERSIONINFO vinfo; @@ -687,10 +711,17 @@ gfxWindowsPlatform::WindowsOSVersion() vinfo.dwOSVersionInfoSize = sizeof (vinfo); if (!GetVersionEx(&vinfo)) { winVersion = kWindowsUnknown; + buildNum = 0; } else { winVersion = PRInt32(vinfo.dwMajorVersion << 16) + vinfo.dwMinorVersion; + buildNum = PRInt32(vinfo.dwBuildNumber); } } + + if (aBuildNum) { + *aBuildNum = buildNum; + } + return winVersion; } diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index 6933944615d..6cf741e64aa 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -232,7 +232,7 @@ public: kWindows7 = 0x60001 }; - static PRInt32 WindowsOSVersion(); + static PRInt32 WindowsOSVersion(PRInt32 *aBuildNum = nsnull); static void GetDLLVersion(const PRUnichar *aDLLPath, nsAString& aVersion);