Bug 789367 - Add content preference for GTK platform; r=nrc

This commit is contained in:
Anthony Jones 2012-09-16 20:23:00 -07:00
Родитель 8d096dbc2e
Коммит a84827280d
9 изменённых файлов: 78 добавлений и 44 удалений

Просмотреть файл

@ -232,7 +232,7 @@ GLXLibrary::EnsureInitialized(bool aUseMesaLLVMPipe)
(GLLibraryLoader::PlatformLookupFunction)&xGetProcAddress))
{
#ifdef MOZ_WIDGET_GTK
mUseTextureFromPixmap = gfxPlatformGtk::UseXRender();
mUseTextureFromPixmap = gfxPlatformGtk::GetPlatform()->UseXRender();
#else
mUseTextureFromPixmap = true;
#endif

Просмотреть файл

@ -228,8 +228,9 @@ gfxPlatform::gfxPlatform()
#endif
mBidiNumeralOption = UNINITIALIZED_VALUE;
uint32_t backendMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA);
InitCanvasBackend(backendMask);
uint32_t canvasMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA);
uint32_t contentMask = 0;
InitBackendPrefs(canvasMask, contentMask);
}
gfxPlatform*
@ -1184,25 +1185,36 @@ gfxPlatform::AppendPrefLang(eFontPrefLang aPrefLangs[], uint32_t& aLen, eFontPre
}
void
gfxPlatform::InitCanvasBackend(uint32_t aBackendBitmask)
gfxPlatform::InitBackendPrefs(uint32_t aCanvasBitmask, uint32_t aContentBitmask)
{
if (!Preferences::GetBool("gfx.canvas.azure.enabled", false)) {
mPreferredCanvasBackend = BACKEND_NONE;
mFallbackCanvasBackend = BACKEND_NONE;
return;
}
mPreferredCanvasBackend = GetCanvasBackendPref(aBackendBitmask);
mFallbackCanvasBackend = GetCanvasBackendPref(aBackendBitmask & ~(1 << mPreferredCanvasBackend));
mPreferredCanvasBackend = GetCanvasBackendPref(aCanvasBitmask);
mFallbackCanvasBackend = GetCanvasBackendPref(aCanvasBitmask & ~(1 << mPreferredCanvasBackend));
mContentBackend = GetContentBackendPref(aContentBitmask);
}
/* static */ BackendType
gfxPlatform::GetCanvasBackendPref(uint32_t aBackendBitmask)
{
return GetBackendPref("gfx.canvas.azure.enabled", "gfx.canvas.azure.backends", aBackendBitmask);
}
/* static */ BackendType
gfxPlatform::GetContentBackendPref(uint32_t aBackendBitmask)
{
return GetBackendPref("gfx.content.azure.enabled", "gfx.content.azure.backends", aBackendBitmask);
}
/* static */ BackendType
gfxPlatform::GetBackendPref(const char* aEnabledPrefName, const char* aBackendPrefName, uint32_t aBackendBitmask)
{
if (!Preferences::GetBool(aEnabledPrefName, false)) {
return BACKEND_NONE;
}
if (!gBackendList) {
gBackendList = new nsTArray<nsCString>();
nsCString prefString;
if (NS_SUCCEEDED(Preferences::GetCString("gfx.canvas.azure.backends", &prefString))) {
if (NS_SUCCEEDED(Preferences::GetCString(aBackendPrefName, &prefString))) {
ParseString(prefString, ',', *gBackendList);
}
}

Просмотреть файл

@ -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(GetContentBackend()));
aObj.DefineProperty("AzureContentBackend", GetBackendName(mContentBackend));
}
mozilla::gfx::BackendType GetPreferredCanvasBackend() {
@ -478,17 +478,35 @@ protected:
* The backend used is determined by aBackendBitmask and the order specified
* by the gfx.canvas.azure.backends pref.
*/
void InitCanvasBackend(uint32_t aBackendBitmask);
void InitBackendPrefs(uint32_t aCanvasBitmask, uint32_t aContentBitmask);
/**
* 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);
virtual mozilla::gfx::BackendType GetContentBackend()
{
return mozilla::gfx::BACKEND_NONE;
mozilla::gfx::BackendType GetContentBackend() {
return mContentBackend;
}
int8_t mAllowDownloadableFonts;
@ -523,6 +541,8 @@ 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<gfxPlatform> mAzureCanvasBackendCollector;
bool mWorkAroundDriverBugs;

Просмотреть файл

@ -93,6 +93,9 @@ gfxPlatformGtk::gfxPlatformGtk()
gCodepointsWithNoFonts = new gfxSparseBitSet();
UpdateFontList();
#endif
uint32_t canvasMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA);
uint32_t contentMask = (1 << BACKEND_CAIRO);
InitBackendPrefs(canvasMask, contentMask);
}
gfxPlatformGtk::~gfxPlatformGtk()
@ -145,14 +148,7 @@ gfxPlatformGtk::CreateOffscreenSurface(const gfxIntSize& size,
// we should try to match
GdkScreen *gdkScreen = gdk_screen_get_default();
if (gdkScreen) {
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 {
if (UseXRender()) {
Screen *screen = gdk_x11_screen_get_xscreen(gdkScreen);
XRenderPictFormat* xrenderFormat =
gfxXlibSurface::FindRenderFormat(DisplayOfScreen(screen),
@ -161,6 +157,13 @@ 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

Просмотреть файл

@ -98,7 +98,7 @@ public:
static int32_t GetDPI();
static bool UseXRender() {
bool UseXRender() {
#if defined(MOZ_X11) && defined(MOZ_PLATFORM_MAEMO)
// XRender is not accelerated on the Maemo at the moment, and
// X server pixman is out of our control; it's likely to be
@ -111,6 +111,10 @@ public:
// this, we'll only disable this for maemo.
return true;
#elif defined(MOZ_X11)
if (GetContentBackend() != mozilla::gfx::BACKEND_NONE &&
GetContentBackend() != mozilla::gfx::BACKEND_CAIRO)
return false;
return sUseXRender;
#else
return false;

Просмотреть файл

@ -70,8 +70,9 @@ gfxPlatformMac::gfxPlatformMac()
}
mFontAntiAliasingThreshold = ReadAntiAliasingThreshold();
uint32_t backendMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA) | (1 << BACKEND_COREGRAPHICS);
InitCanvasBackend(backendMask);
uint32_t canvasMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA) | (1 << BACKEND_COREGRAPHICS);
uint32_t contentMask = 0;
InitBackendPrefs(canvasMask, contentMask);
}
gfxPlatformMac::~gfxPlatformMac()

Просмотреть файл

@ -516,13 +516,16 @@ gfxWindowsPlatform::UpdateRenderMode()
}
#endif
uint32_t backendMask = 1 << BACKEND_CAIRO;
uint32_t canvasMask = 1 << BACKEND_CAIRO;
uint32_t contentMask;
if (mRenderMode == RENDER_DIRECT2D) {
backendMask |= 1 << BACKEND_DIRECT2D;
canvasMask |= 1 << BACKEND_DIRECT2D;
contentMask = BACKEND_DIRECT2D;
} else {
backendMask |= 1 << BACKEND_SKIA;
canvasMask |= 1 << BACKEND_SKIA;
contentMask = 0;
}
InitCanvasBackend(backendMask);
InitBackendPrefs(canvasMask, contentMask);
}
void

Просмотреть файл

@ -243,13 +243,6 @@ 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;

Просмотреть файл

@ -241,16 +241,14 @@ 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.backends", "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");
#else
pref("gfx.canvas.azure.backends", "cairo");
#endif
pref("gfx.content.azure.backends", "cairo");
#endif
#endif