From f371c79e7535f5a80f98b3d82569fe112fd3f9ff Mon Sep 17 00:00:00 2001 From: Nicholas Cameron Date: Thu, 26 Jul 2012 13:56:42 +1200 Subject: [PATCH] Bug 764125; remove AzureEnabled from gfxInfo and replace with backend check. r=roc --- .../src/nsCanvasRenderingContext2DAzure.cpp | 9 +------ content/canvas/test/test_canvas.html | 3 ++- gfx/layers/d3d10/LayerManagerD3D10.cpp | 2 +- gfx/thebes/gfxPlatform.cpp | 26 +++++++++++-------- gfx/thebes/gfxPlatform.h | 24 ++++++++--------- widget/android/GfxInfo.h | 1 - widget/cocoa/GfxInfo.h | 1 - widget/nsIGfxInfo.idl | 1 - widget/windows/GfxInfo.h | 1 - widget/xpwidgets/GfxInfoBase.cpp | 16 ------------ widget/xpwidgets/GfxInfoBase.h | 2 -- widget/xpwidgets/GfxInfoX11.h | 1 - 12 files changed, 30 insertions(+), 57 deletions(-) diff --git a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp index 04358c19e1c..5c037ff45ff 100644 --- a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp @@ -552,15 +552,8 @@ namespace dom { bool AzureCanvasEnabled() { - static bool checkedPref = false; - static bool azureEnabled; - if (!checkedPref) { - azureEnabled = Preferences::GetBool("gfx.canvas.azure.enabled", false); - checkedPref = true; - } - BackendType dontCare; - return azureEnabled && gfxPlatform::GetPlatform()->SupportsAzure(dontCare); + return gfxPlatform::GetPlatform()->SupportsAzureCanvas(dontCare); } } diff --git a/content/canvas/test/test_canvas.html b/content/canvas/test/test_canvas.html index 39847dd7e85..96702461807 100644 --- a/content/canvas/test/test_canvas.html +++ b/content/canvas/test/test_canvas.html @@ -44,7 +44,8 @@ function IsAzureEnabled() { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - enabled = Components.classes["@mozilla.org/gfx/info;1"].getService(Components.interfaces.nsIGfxInfo).AzureEnabled; + var backend = Components.classes["@mozilla.org/gfx/info;1"].getService(Components.interfaces.nsIGfxInfo).getInfo().AzureBackend; + enabled = (backend != "none"); } catch (e) { } return enabled; diff --git a/gfx/layers/d3d10/LayerManagerD3D10.cpp b/gfx/layers/d3d10/LayerManagerD3D10.cpp index c20461ed813..6b61cf4436b 100644 --- a/gfx/layers/d3d10/LayerManagerD3D10.cpp +++ b/gfx/layers/d3d10/LayerManagerD3D10.cpp @@ -487,7 +487,7 @@ LayerManagerD3D10::CreateDrawTarget(const IntSize &aSize, BackendType backend; if ((aFormat != FORMAT_B8G8R8A8 && aFormat != FORMAT_B8G8R8X8) || - !gfxPlatform::GetPlatform()->SupportsAzure(backend) || + !gfxPlatform::GetPlatform()->SupportsAzureCanvas(backend) || backend != BACKEND_DIRECT2D) { return LayerManager::CreateDrawTarget(aSize, aFormat); } diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 2a0ff79600c..526e1ee241f 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -213,7 +213,7 @@ static const char *gPrefLangNames[] = { }; gfxPlatform::gfxPlatform() - : mAzureBackendCollector(this, &gfxPlatform::GetAzureBackendInfo) + : mAzureCanvasBackendCollector(this, &gfxPlatform::GetAzureCanvasBackendInfo) { mUseHarfBuzzScripts = UNINITIALIZED_VALUE; mAllowDownloadableFonts = UNINITIALIZED_VALUE; @@ -674,7 +674,7 @@ RefPtr gfxPlatform::CreateDrawTargetForBackend(BackendType aBackend, const IntSize& aSize, SurfaceFormat aFormat) { BackendType backend; - if (!SupportsAzure(backend)) { + if (!SupportsAzureCanvas(backend)) { return NULL; } @@ -703,7 +703,7 @@ RefPtr gfxPlatform::CreateOffscreenDrawTarget(const IntSize& aSize, SurfaceFormat aFormat) { BackendType backend; - if (!SupportsAzure(backend)) { + if (!SupportsAzureCanvas(backend)) { return NULL; } @@ -721,21 +721,19 @@ RefPtr gfxPlatform::CreateDrawTargetForData(unsigned char* aData, const IntSize& aSize, int32_t aStride, SurfaceFormat aFormat) { BackendType backend; - if (!SupportsAzure(backend)) { + if (!SupportsAzureCanvas(backend)) { return NULL; } return Factory::CreateDrawTargetForData(backend, aData, aSize, aStride, aFormat); } bool -gfxPlatform::SupportsAzure(BackendType& aBackend) +gfxPlatform::SupportsAzureCanvas(BackendType& aBackend) { - if (mPreferredCanvasBackend != BACKEND_NONE) { - aBackend = mPreferredCanvasBackend; - return true; - } - - return false; + NS_ASSERTION(mFallbackCanvasBackend == BACKEND_NONE || mPreferredCanvasBackend != BACKEND_NONE, + "fallback backend with no preferred backend"); + aBackend = mPreferredCanvasBackend; + return mPreferredCanvasBackend != BACKEND_NONE; } /* static */ BackendType @@ -1175,6 +1173,12 @@ gfxPlatform::AppendPrefLang(eFontPrefLang aPrefLangs[], PRUint32& aLen, eFontPre void gfxPlatform::InitCanvasBackend(PRUint32 aBackendBitmask) { + if (!Preferences::GetBool("gfx.canvas.azure.enabled", false)) { + mPreferredCanvasBackend = BACKEND_NONE; + mFallbackCanvasBackend = BACKEND_NONE; + return; + } + mPreferredCanvasBackend = GetCanvasBackendPref(aBackendBitmask); mFallbackCanvasBackend = GetCanvasBackendPref(aBackendBitmask & ~(1 << mPreferredCanvasBackend)); } diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index ac17bb31751..a453666a8f4 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -130,7 +130,7 @@ GetBackendName(mozilla::gfx::BackendType aBackend) case mozilla::gfx::BACKEND_NONE: return "none"; } - MOZ_NOT_REACHED("Incomplet switch"); + MOZ_NOT_REACHED("Incomplete switch"); } class THEBES_API gfxPlatform { @@ -196,14 +196,11 @@ public: int32_t aStride, mozilla::gfx::SurfaceFormat aFormat); // aBackend will be set to the preferred backend for Azure canvas - bool SupportsAzure(mozilla::gfx::BackendType& aBackend); + bool SupportsAzureCanvas(mozilla::gfx::BackendType& aBackend); // aObj will contain the preferred backend for Azure canvas - void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj) { - mozilla::gfx::BackendType backend; - if (SupportsAzure(backend)) { - aObj.DefineProperty("AzureBackend", GetBackendName(backend)); - } + void GetAzureCanvasBackendInfo(mozilla::widget::InfoObject &aObj) { + aObj.DefineProperty("AzureBackend", GetBackendName(mPreferredCanvasBackend)); } /* @@ -496,11 +493,6 @@ protected: // which scripts should be shaped with harfbuzz PRInt32 mUseHarfBuzzScripts; - // The preferred draw target backend to use for canvas - mozilla::gfx::BackendType mPreferredCanvasBackend; - // The fallback draw target backend to use for canvas, if the preferred backend fails - mozilla::gfx::BackendType mFallbackCanvasBackend; - private: /** * Start up Thebes. @@ -513,7 +505,13 @@ private: nsTArray mCJKPrefLangs; nsCOMPtr mSRGBOverrideObserver; nsCOMPtr mFontPrefsObserver; - mozilla::widget::GfxInfoCollector mAzureBackendCollector; + + // The preferred draw target backend to use for canvas + mozilla::gfx::BackendType mPreferredCanvasBackend; + // The fallback draw target backend to use for canvas, if the preferred backend fails + mozilla::gfx::BackendType mFallbackCanvasBackend; + + mozilla::widget::GfxInfoCollector mAzureCanvasBackendCollector; bool mWorkAroundDriverBugs; }; diff --git a/widget/android/GfxInfo.h b/widget/android/GfxInfo.h index f3467fb4767..44c52577e92 100644 --- a/widget/android/GfxInfo.h +++ b/widget/android/GfxInfo.h @@ -45,7 +45,6 @@ public: using GfxInfoBase::GetFeatureStatus; using GfxInfoBase::GetFeatureSuggestedDriverVersion; using GfxInfoBase::GetWebGLParameter; - using GfxInfoBase::GetAzureEnabled; void EnsureInitializedFromGfxInfoData(); diff --git a/widget/cocoa/GfxInfo.h b/widget/cocoa/GfxInfo.h index 542ac96808b..b1b7aaad9b6 100644 --- a/widget/cocoa/GfxInfo.h +++ b/widget/cocoa/GfxInfo.h @@ -45,7 +45,6 @@ public: using GfxInfoBase::GetFeatureStatus; using GfxInfoBase::GetFeatureSuggestedDriverVersion; using GfxInfoBase::GetWebGLParameter; - using GfxInfoBase::GetAzureEnabled; virtual nsresult Init(); diff --git a/widget/nsIGfxInfo.idl b/widget/nsIGfxInfo.idl index 89998ae370b..45504c941ef 100644 --- a/widget/nsIGfxInfo.idl +++ b/widget/nsIGfxInfo.idl @@ -16,7 +16,6 @@ interface nsIGfxInfo : nsISupports */ readonly attribute boolean D2DEnabled; readonly attribute boolean DWriteEnabled; - readonly attribute boolean AzureEnabled; readonly attribute DOMString DWriteVersion; readonly attribute DOMString cleartypeParameters; diff --git a/widget/windows/GfxInfo.h b/widget/windows/GfxInfo.h index 42f61e8cee8..af82666b61d 100644 --- a/widget/windows/GfxInfo.h +++ b/widget/windows/GfxInfo.h @@ -42,7 +42,6 @@ public: using GfxInfoBase::GetFeatureStatus; using GfxInfoBase::GetFeatureSuggestedDriverVersion; using GfxInfoBase::GetWebGLParameter; - using GfxInfoBase::GetAzureEnabled; virtual nsresult Init(); diff --git a/widget/xpwidgets/GfxInfoBase.cpp b/widget/xpwidgets/GfxInfoBase.cpp index 8cdb70c149e..31bec7c9072 100644 --- a/widget/xpwidgets/GfxInfoBase.cpp +++ b/widget/xpwidgets/GfxInfoBase.cpp @@ -724,22 +724,6 @@ GfxInfoBase::GetWebGLParameter(const nsAString& aParam, return GfxInfoWebGL::GetWebGLParameter(aParam, aResult); } -nsresult -GfxInfoBase::GetAzureEnabled(bool *aEnabled) -{ - static bool azure = false; - static bool azureInited = false; - - if (!azureInited) { - azure = mozilla::Preferences::GetBool("gfx.canvas.azure.enabled", false); - azureInited = true; - } - - *aEnabled = azure; - - return NS_OK; -} - void GfxInfoBase::EvaluateDownloadedBlacklist(nsTArray& aDriverInfo) { diff --git a/widget/xpwidgets/GfxInfoBase.h b/widget/xpwidgets/GfxInfoBase.h index e3e89c9e133..69953268057 100644 --- a/widget/xpwidgets/GfxInfoBase.h +++ b/widget/xpwidgets/GfxInfoBase.h @@ -41,12 +41,10 @@ public: // using GfxInfoBase::GetFeatureStatus; // using GfxInfoBase::GetFeatureSuggestedDriverVersion; // using GfxInfoBase::GetWebGLParameter; - // using GfxInfoBase::GetAzureEnabled; // to import the relevant methods into their namespace. NS_IMETHOD GetFeatureStatus(PRInt32 aFeature, PRInt32 *_retval); NS_IMETHOD GetFeatureSuggestedDriverVersion(PRInt32 aFeature, nsAString & _retval); NS_IMETHOD GetWebGLParameter(const nsAString & aParam, nsAString & _retval); - NS_IMETHOD GetAzureEnabled(bool *aAzureEnabled); NS_IMETHOD GetFailures(PRUint32 *failureCount, char ***failures); NS_IMETHOD_(void) LogFailure(const nsACString &failure); diff --git a/widget/xpwidgets/GfxInfoX11.h b/widget/xpwidgets/GfxInfoX11.h index df900227446..44a6d5319eb 100644 --- a/widget/xpwidgets/GfxInfoX11.h +++ b/widget/xpwidgets/GfxInfoX11.h @@ -41,7 +41,6 @@ public: using GfxInfoBase::GetFeatureStatus; using GfxInfoBase::GetFeatureSuggestedDriverVersion; using GfxInfoBase::GetWebGLParameter; - using GfxInfoBase::GetAzureEnabled; virtual nsresult Init();