Bug 764125; remove AzureEnabled from gfxInfo and replace with backend check. r=roc

This commit is contained in:
Nicholas Cameron 2012-07-26 13:56:42 +12:00
parent 85e074219d
commit f371c79e75
12 changed files with 30 additions and 57 deletions

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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<DrawTarget>
gfxPlatform::CreateDrawTargetForBackend(BackendType aBackend, const IntSize& aSize, SurfaceFormat aFormat)
{
BackendType backend;
if (!SupportsAzure(backend)) {
if (!SupportsAzureCanvas(backend)) {
return NULL;
}
@ -703,7 +703,7 @@ RefPtr<DrawTarget>
gfxPlatform::CreateOffscreenDrawTarget(const IntSize& aSize, SurfaceFormat aFormat)
{
BackendType backend;
if (!SupportsAzure(backend)) {
if (!SupportsAzureCanvas(backend)) {
return NULL;
}
@ -721,21 +721,19 @@ RefPtr<DrawTarget>
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));
}

View File

@ -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<PRUint32> mCJKPrefLangs;
nsCOMPtr<nsIObserver> mSRGBOverrideObserver;
nsCOMPtr<nsIObserver> mFontPrefsObserver;
mozilla::widget::GfxInfoCollector<gfxPlatform> 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<gfxPlatform> mAzureCanvasBackendCollector;
bool mWorkAroundDriverBugs;
};

View File

@ -45,7 +45,6 @@ public:
using GfxInfoBase::GetFeatureStatus;
using GfxInfoBase::GetFeatureSuggestedDriverVersion;
using GfxInfoBase::GetWebGLParameter;
using GfxInfoBase::GetAzureEnabled;
void EnsureInitializedFromGfxInfoData();

View File

@ -45,7 +45,6 @@ public:
using GfxInfoBase::GetFeatureStatus;
using GfxInfoBase::GetFeatureSuggestedDriverVersion;
using GfxInfoBase::GetWebGLParameter;
using GfxInfoBase::GetAzureEnabled;
virtual nsresult Init();

View File

@ -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;

View File

@ -42,7 +42,6 @@ public:
using GfxInfoBase::GetFeatureStatus;
using GfxInfoBase::GetFeatureSuggestedDriverVersion;
using GfxInfoBase::GetWebGLParameter;
using GfxInfoBase::GetAzureEnabled;
virtual nsresult Init();

View File

@ -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<GfxDriverInfo>& aDriverInfo)
{

View File

@ -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);

View File

@ -41,7 +41,6 @@ public:
using GfxInfoBase::GetFeatureStatus;
using GfxInfoBase::GetFeatureSuggestedDriverVersion;
using GfxInfoBase::GetWebGLParameter;
using GfxInfoBase::GetAzureEnabled;
virtual nsresult Init();