зеркало из https://github.com/mozilla/pjs.git
Bug 579276. Part 7: Don't retain transparent layers that would hurt text rendering. r=cjones
This commit is contained in:
Родитель
dfdadfe03a
Коммит
dba37d3134
|
@ -367,6 +367,23 @@ InheritContextFlags(gfxContext* aSource, gfxContext* aDest)
|
|||
}
|
||||
}
|
||||
|
||||
static PRBool
|
||||
ShouldRetainTransparentSurface(PRUint32 aContentFlags,
|
||||
gfxASurface* aTargetSurface)
|
||||
{
|
||||
if (aContentFlags & Layer::CONTENT_NO_TEXT)
|
||||
return PR_TRUE;
|
||||
|
||||
switch (aTargetSurface->GetTextQualityInTransparentSurfaces()) {
|
||||
case gfxASurface::TEXT_QUALITY_OK:
|
||||
return PR_TRUE;
|
||||
case gfxASurface::TEXT_QUALITY_OK_OVER_OPAQUE_PIXELS:
|
||||
return (aContentFlags & Layer::CONTENT_NO_TEXT_OVER_TRANSPARENT) != 0;
|
||||
default:
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BasicThebesLayer::Paint(gfxContext* aContext,
|
||||
LayerManager::DrawThebesLayerCallback aCallback,
|
||||
|
@ -377,15 +394,20 @@ BasicThebesLayer::Paint(gfxContext* aContext,
|
|||
"Can only draw in drawing phase");
|
||||
gfxContext* target = BasicManager()->GetTarget();
|
||||
NS_ASSERTION(target, "We shouldn't be called if there's no target");
|
||||
nsRefPtr<gfxASurface> targetSurface = aContext->CurrentSurface();
|
||||
|
||||
PRBool canUseOpaqueSurface = CanUseOpaqueSurface();
|
||||
if (!BasicManager()->IsRetained() ||
|
||||
(aOpacity == 1.0 && !canUseOpaqueSurface &&
|
||||
!ShouldRetainTransparentSurface(mContentFlags, targetSurface))) {
|
||||
mValidRegion.SetEmpty();
|
||||
mBuffer.Clear();
|
||||
|
||||
if (!BasicManager()->IsRetained()) {
|
||||
if (aOpacity != 1.0) {
|
||||
target->Save();
|
||||
ClipToContain(target, mVisibleRegion.GetBounds());
|
||||
target->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
|
||||
}
|
||||
mValidRegion.SetEmpty();
|
||||
mBuffer.Clear();
|
||||
aCallback(this, target, mVisibleRegion, nsIntRegion(), aCallbackData);
|
||||
if (aOpacity != 1.0) {
|
||||
target->PopGroupToSource();
|
||||
|
@ -395,15 +417,12 @@ BasicThebesLayer::Paint(gfxContext* aContext,
|
|||
return;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxASurface> targetSurface = aContext->CurrentSurface();
|
||||
PRBool isOpaqueContent =
|
||||
(targetSurface->AreSimilarSurfacesSensitiveToContentType() &&
|
||||
aOpacity == 1.0 &&
|
||||
CanUseOpaqueSurface());
|
||||
{
|
||||
PRBool opaqueBuffer = canUseOpaqueSurface &&
|
||||
targetSurface->AreSimilarSurfacesSensitiveToContentType();
|
||||
Buffer::ContentType contentType =
|
||||
isOpaqueContent ? gfxASurface::CONTENT_COLOR :
|
||||
gfxASurface::CONTENT_COLOR_ALPHA;
|
||||
opaqueBuffer ? gfxASurface::CONTENT_COLOR :
|
||||
gfxASurface::CONTENT_COLOR_ALPHA;
|
||||
Buffer::PaintState state = mBuffer.BeginPaint(this, contentType);
|
||||
mValidRegion.Sub(mValidRegion, state.mRegionToInvalidate);
|
||||
|
||||
|
@ -425,7 +444,7 @@ BasicThebesLayer::Paint(gfxContext* aContext,
|
|||
}
|
||||
}
|
||||
|
||||
mBuffer.DrawTo(this, isOpaqueContent, target, aOpacity);
|
||||
mBuffer.DrawTo(this, canUseOpaqueSurface, target, aOpacity);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче