diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 528385468bc..e29bf233785 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -228,9 +228,8 @@ gfxPlatform::gfxPlatform() #endif mBidiNumeralOption = UNINITIALIZED_VALUE; - uint32_t canvasMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA); - uint32_t contentMask = 0; - InitCanvasBackend(canvasMask, contentMask); + uint32_t backendMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA); + InitCanvasBackend(backendMask); } gfxPlatform* @@ -1185,30 +1184,25 @@ gfxPlatform::AppendPrefLang(eFontPrefLang aPrefLangs[], uint32_t& aLen, eFontPre } void -gfxPlatform::InitBackendPrefs(uint32_t aCanvasBitmask, uint32_t aContentBitmask) +gfxPlatform::InitCanvasBackend(uint32_t aBackendBitmask) { - mPreferredCanvasBackend = GetCanvasBackendPref(aCanvasBitmask); - mFallbackCanvasBackend = GetCanvasBackendPref(aCanvasBitmask & ~(1 << mPreferredCanvasBackend)); - mContentBackend = GetBackendPref("gfx.content.azure.enabled", "gfx.content.azure.backend", aContentBitmask); + if (!Preferences::GetBool("gfx.canvas.azure.enabled", false)) { + mPreferredCanvasBackend = BACKEND_NONE; + mFallbackCanvasBackend = BACKEND_NONE; + return; + } + + mPreferredCanvasBackend = GetCanvasBackendPref(aBackendBitmask); + mFallbackCanvasBackend = GetCanvasBackendPref(aBackendBitmask & ~(1 << mPreferredCanvasBackend)); } /* static */ BackendType gfxPlatform::GetCanvasBackendPref(uint32_t aBackendBitmask) { - return GetBackendPref("gfx.canvas.azure.enabled", "gfx.canvas.azure.backends", aBackendBitmask); -} - -/* static */ BackendType -gfxPlatform::GetBackendPref(const char* aEnabledPrefName, const char* aBackendPrefName, uint32_t aBackendBitmask) -{ - if (!Preferences::GetBool(aEnabledPref, false)) { - return BACKEND_NONE; - } - if (!gBackendList) { gBackendList = new nsTArray(); nsCString prefString; - if (NS_SUCCEEDED(Preferences::GetCString(aBackendPref, &prefString))) { + if (NS_SUCCEEDED(Preferences::GetCString("gfx.canvas.azure.backends", &prefString))) { ParseString(prefString, ',', *gBackendList); } } diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 3dfb3b5d464..88f06234c24 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -202,7 +202,7 @@ public: void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj) { aObj.DefineProperty("AzureCanvasBackend", GetBackendName(mPreferredCanvasBackend)); aObj.DefineProperty("AzureFallbackCanvasBackend", GetBackendName(mFallbackCanvasBackend)); - aObj.DefineProperty("AzureContentBackend", GetBackendName(mContentBackend)); + aObj.DefineProperty("AzureContentBackend", GetBackendName(GetContentBackend())); } mozilla::gfx::BackendType GetPreferredCanvasBackend() { @@ -478,35 +478,17 @@ protected: * The backend used is determined by aBackendBitmask and the order specified * by the gfx.canvas.azure.backends pref. */ - void InitBackendPrefs(uint32_t aCanvasBitmask, uint32_t aContentBitmask); - + void InitCanvasBackend(uint32_t aBackendBitmask); /** * returns the first backend named in the pref gfx.canvas.azure.backends * which is a component of aBackendBitmask, a bitmask of backend types */ static mozilla::gfx::BackendType GetCanvasBackendPref(uint32_t aBackendBitmask); - - /** - * returns the first backend named in the pref gfx.content.azure.backend - * which is a component of aBackendBitmask, a bitmask of backend types - */ - static mozilla::gfx::BackendType GetContentBackendPref(uint32_t aBackendBitmask); - - /** - * Checks the aEnabledPrefName pref and returns BACKEND_NONE if the pref is - * not enabled. Otherwise it will return the first backend named in - * aBackendPrefName allowed by aBackendBitmask, a bitmask of backend types. - */ - static mozilla::gfx::BackendType GetBackendPref(const char* aEnabledPrefName, - const char* aBackendPrefName, - uint32_t aBackendBitmask); - /** - * Decode the backend enumberation from a string. - */ static mozilla::gfx::BackendType BackendTypeForName(const nsCString& aName); - mozilla::gfx::BackendType GetContentBackend() { - return mContentBackend; + virtual mozilla::gfx::BackendType GetContentBackend() + { + return mozilla::gfx::BACKEND_NONE; } int8_t mAllowDownloadableFonts; @@ -541,8 +523,6 @@ private: mozilla::gfx::BackendType mPreferredCanvasBackend; // The fallback draw target backend to use for canvas, if the preferred backend fails mozilla::gfx::BackendType mFallbackCanvasBackend; - // The backend to use for content - mozilla::gfx::BackendType mContentBackend; mozilla::widget::GfxInfoCollector mAzureCanvasBackendCollector; bool mWorkAroundDriverBugs; diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index 5c18301d2a8..7da29d8c3e9 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -93,9 +93,6 @@ gfxPlatformGtk::gfxPlatformGtk() gCodepointsWithNoFonts = new gfxSparseBitSet(); UpdateFontList(); #endif - uint32_t canvasMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA); - uint32_t contentMask = (1 << BACKEND_CAIRO); - InitCanvasBackend(canvasMask, contentMask); } gfxPlatformGtk::~gfxPlatformGtk() @@ -148,7 +145,14 @@ gfxPlatformGtk::CreateOffscreenSurface(const gfxIntSize& size, // we should try to match GdkScreen *gdkScreen = gdk_screen_get_default(); if (gdkScreen) { - if (UseXRender()) { + if (!UseXRender()) { + // We're not going to use XRender, so we don't need to + // search for a render format + newSurface = new gfxImageSurface(size, imageFormat); + // The gfxImageSurface ctor zeroes this for us, no need to + // waste time clearing again + needsClear = false; + } else { Screen *screen = gdk_x11_screen_get_xscreen(gdkScreen); XRenderPictFormat* xrenderFormat = gfxXlibSurface::FindRenderFormat(DisplayOfScreen(screen), @@ -157,13 +161,6 @@ gfxPlatformGtk::CreateOffscreenSurface(const gfxIntSize& size, if (xrenderFormat) { newSurface = gfxXlibSurface::Create(screen, xrenderFormat, size); } - } else { - // We're not going to use XRender, so we don't need to - // search for a render format - newSurface = new gfxImageSurface(size, imageFormat); - // The gfxImageSurface ctor zeroes this for us, no need to - // waste time clearing again - needsClear = false; } } #endif diff --git a/gfx/thebes/gfxPlatformGtk.h b/gfx/thebes/gfxPlatformGtk.h index 89eccb6502b..6f1226eebd2 100644 --- a/gfx/thebes/gfxPlatformGtk.h +++ b/gfx/thebes/gfxPlatformGtk.h @@ -111,10 +111,6 @@ public: // this, we'll only disable this for maemo. return true; #elif defined(MOZ_X11) - if (GetContentBackend() != BACKEND_NONE && - GetContentBackend() != BACKEND_CAIRO) - return false; - return sUseXRender; #else return false; diff --git a/gfx/thebes/gfxPlatformMac.cpp b/gfx/thebes/gfxPlatformMac.cpp index 1ff27be1be8..93a4fb589e0 100644 --- a/gfx/thebes/gfxPlatformMac.cpp +++ b/gfx/thebes/gfxPlatformMac.cpp @@ -70,9 +70,8 @@ gfxPlatformMac::gfxPlatformMac() } mFontAntiAliasingThreshold = ReadAntiAliasingThreshold(); - uint32_t canvasMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA) | (1 << BACKEND_COREGRAPHICS); - uint32_t contentMask = 0; - InitBackendPrefs(canvasMask, contentMask); + uint32_t backendMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA) | (1 << BACKEND_COREGRAPHICS); + InitCanvasBackend(backendMask); } gfxPlatformMac::~gfxPlatformMac() diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index 29914e1447a..feda89450ad 100644 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -516,16 +516,13 @@ gfxWindowsPlatform::UpdateRenderMode() } #endif - uint32_t canvasMask = 1 << BACKEND_CAIRO; - uint32_t contentMask; + uint32_t backendMask = 1 << BACKEND_CAIRO; if (mRenderMode == RENDER_DIRECT2D) { - canvasMask |= 1 << BACKEND_DIRECT2D; - contentMask = BACKEND_DIRECT2D; + backendMask |= 1 << BACKEND_DIRECT2D; } else { - canvasMask |= 1 << BACKEND_SKIA; - contentMask = 0; + backendMask |= 1 << BACKEND_SKIA; } - InitBackendPrefs(canvasMask, contentMask); + InitCanvasBackend(backendMask); } void diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index 7c97ced37eb..844f917306f 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -243,6 +243,13 @@ public: static bool IsRunningInWindows8Metro(); protected: + virtual mozilla::gfx::BackendType GetContentBackend() + { + return UseAzureContentDrawing() && mRenderMode == RENDER_DIRECT2D ? + mozilla::gfx::BACKEND_DIRECT2D : + mozilla::gfx::BACKEND_NONE; + } + RenderMode mRenderMode; int8_t mUseClearTypeForDownloadableFonts; diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 8b2b6ba2bc6..6c99e2d53d2 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -241,14 +241,16 @@ pref("gfx.canvas.azure.enabled", true); // comma separated list of backends to use in order of preference // e.g., pref("gfx.canvas.azure.backends", "direct2d,skia,cairo"); pref("gfx.canvas.azure.backends", "direct2d,cairo"); -pref("gfx.content.azure.backend", "direct2d"); pref("gfx.content.azure.enabled", true); #else #ifdef XP_MACOSX pref("gfx.canvas.azure.backends", "cg"); #else +#ifdef ANDROID pref("gfx.canvas.azure.backends", "cairo"); -pref("gfx.content.azure.backend", "cairo"); +#else +pref("gfx.canvas.azure.backends", "cairo"); +#endif #endif #endif