Bug 747274 - Add a pref (default to true on Android) to forcibly use nearest pixel filtering for background drawing. r=jrmuizel,ajuma a=blassey

This commit is contained in:
George Wright 2012-04-23 11:50:29 -04:00
parent 65ffa9d016
commit 97e5839e99
3 changed files with 31 additions and 0 deletions

View File

@ -168,6 +168,20 @@ nsLayoutUtils::Are3DTransformsEnabled()
return s3DTransformsEnabled;
}
bool
nsLayoutUtils::UseBackgroundNearestFiltering()
{
static bool sUseBackgroundNearestFilteringEnabled;
static bool sUseBackgroundNearestFilteringPrefInitialised = false;
if (!sUseBackgroundNearestFilteringPrefInitialised) {
sUseBackgroundNearestFilteringPrefInitialised = true;
sUseBackgroundNearestFilteringEnabled = mozilla::Preferences::GetBool("gfx.filter.nearest.force-enabled", false);
}
return sUseBackgroundNearestFilteringEnabled;
}
void
nsLayoutUtils::UnionChildOverflow(nsIFrame* aFrame,
nsOverflowAreas& aOverflowAreas)
@ -3734,6 +3748,11 @@ nsLayoutUtils::DrawBackgroundImage(nsRenderingContext* aRenderingContext,
PRUint32 aImageFlags)
{
SAMPLE_LABEL("layout", "nsLayoutUtils::DrawBackgroundImage");
if (UseBackgroundNearestFiltering()) {
aGraphicsFilter = gfxPattern::FILTER_NEAREST;
}
return DrawImageInternal(aRenderingContext, aImage, aGraphicsFilter,
aDest, aFill, aAnchor, aDirty,
aImageSize, aImageFlags);

View File

@ -1496,6 +1496,12 @@ public:
*/
static bool Are3DTransformsEnabled();
/**
* Checks if we should forcibly use nearest pixel filtering for the
* background.
*/
static bool UseBackgroundNearestFiltering();
/**
* Unions the overflow areas of all non-popup children of aFrame with
* aOverflowAreas.

View File

@ -212,6 +212,12 @@ pref("gfx.downloadable_fonts.enabled", true);
pref("gfx.downloadable_fonts.fallback_delay", 3000);
pref("gfx.downloadable_fonts.sanitize", true);
#ifdef ANDROID
pref("gfx.filter.nearest.force-enabled", true);
#else
pref("gfx.filter.nearest.force-enabled", false);
#endif
// whether to always search all font cmaps during system font fallback
pref("gfx.font_rendering.fallback.always_use_cmaps", false);