Bug 1055634 - Propagate font smoothing background colors to layers. r=roc

This commit is contained in:
Markus Stange
2014-10-24 18:32:23 +02:00
parent 701787ca89
commit 4ea470fc29
16 changed files with 99 additions and 12 deletions

View File

@@ -257,6 +257,7 @@ public:
mReferenceFrame(nullptr),
mLayer(nullptr),
mIsSolidColorInVisibleRegion(false),
mFontSmoothingBackgroundColor(NS_RGBA(0,0,0,0)),
mSingleItemFixedToViewport(false),
mNeedComponentAlpha(false),
mForceTransparentSurface(false),
@@ -440,6 +441,11 @@ public:
* True if every pixel in mVisibleRegion will have color mSolidColor.
*/
bool mIsSolidColorInVisibleRegion;
/**
* The target background color for smoothing fonts that are drawn on top of
* transparent parts of the layer.
*/
nscolor mFontSmoothingBackgroundColor;
/**
* True if the layer contains exactly one item that returned true for
* ShouldFixToViewport.
@@ -900,6 +906,7 @@ public:
PaintedDisplayItemLayerUserData() :
mMaskClipCount(0),
mForcedBackgroundColor(NS_RGBA(0,0,0,0)),
mFontSmoothingBackgroundColor(NS_RGBA(0,0,0,0)),
mXScale(1.f), mYScale(1.f),
mAppUnitsPerDevPixel(0),
mTranslation(0, 0),
@@ -918,6 +925,12 @@ public:
*/
nscolor mForcedBackgroundColor;
/**
* The target background color for smoothing fonts that are drawn on top of
* transparent parts of the layer.
*/
nscolor mFontSmoothingBackgroundColor;
/**
* The resolution scale used.
*/
@@ -2213,6 +2226,8 @@ ContainerState::PopPaintedLayerData()
}
userData->mForcedBackgroundColor = backgroundColor;
userData->mFontSmoothingBackgroundColor = data->mFontSmoothingBackgroundColor;
// use a mask layer for rounded rect clipping.
// data->mCommonClipCount may be -1 if we haven't put any actual
// drawable items in this layer (i.e. it's only catching events).
@@ -2378,6 +2393,15 @@ PaintedLayerData::Accumulate(ContainerState* aState,
mImage = nullptr;
}
bool isFirstVisibleItem = mVisibleRegion.IsEmpty();
if (isFirstVisibleItem) {
nscolor fontSmoothingBGColor;
if (aItem->ProvidesFontSmoothingBackgroundColor(aState->mBuilder,
&fontSmoothingBGColor)) {
mFontSmoothingBackgroundColor = fontSmoothingBGColor;
}
}
nscolor uniformColor;
bool isUniform = aItem->IsUniform(aState->mBuilder, &uniformColor);
@@ -2397,7 +2421,7 @@ PaintedLayerData::Accumulate(ContainerState* aState,
}
}
if (isUniform) {
if (mVisibleRegion.IsEmpty()) {
if (isFirstVisibleItem) {
// This color is all we have
mSolidColor = uniformColor;
mIsSolidColorInVisibleRegion = true;
@@ -4469,6 +4493,11 @@ FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer,
DrawForcedBackgroundColor(aContext, aLayer, userData->mForcedBackgroundColor);
}
if (NS_GET_A(userData->mFontSmoothingBackgroundColor) > 0) {
aContext->SetFontSmoothingBackgroundColor(
Color::FromABGR(userData->mFontSmoothingBackgroundColor));
}
// make the origin of the context coincide with the origin of the
// PaintedLayer
gfxContextMatrixAutoSaveRestore saveMatrix(aContext);
@@ -4524,6 +4553,8 @@ FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer,
entry->mCommonClipCount);
}
aContext->SetFontSmoothingBackgroundColor(Color());
bool isActiveLayerManager = !aLayer->Manager()->IsInactiveLayerManager();
if (presContext->GetPaintFlashing() && isActiveLayerManager) {