Bug 941095 - Part 2: Disable subpixelaa + component alpha. r=mattwoodrow

--HG--
extra : rebase_source : 7e3a0d3710fb29b47615cc0254135d3b44637ed8
This commit is contained in:
Benoit Girard 2013-12-13 13:53:18 -05:00
parent 63dbe4cee0
commit ecabcc60cf
4 changed files with 29 additions and 14 deletions

View File

@ -1494,10 +1494,12 @@ PrintInfo(nsACString& aTo, LayerComposite* aLayerComposite)
void
SetAntialiasingFlags(Layer* aLayer, gfxContext* aTarget)
{
bool permitSubpixelAA = !(aLayer->GetContentFlags() & Layer::CONTENT_DISABLE_SUBPIXEL_AA);
if (!aTarget->IsCairo()) {
RefPtr<DrawTarget> dt = aTarget->GetDrawTarget();
if (dt->GetFormat() != FORMAT_B8G8R8A8) {
dt->SetPermitSubpixelAA(permitSubpixelAA);
return;
}
@ -1507,20 +1509,22 @@ SetAntialiasingFlags(Layer* aLayer, gfxContext* aTarget)
transformedBounds.RoundOut();
IntRect intTransformedBounds;
transformedBounds.ToIntRect(&intTransformedBounds);
dt->SetPermitSubpixelAA(!(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
dt->GetOpaqueRect().Contains(intTransformedBounds));
permitSubpixelAA &= !(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
dt->GetOpaqueRect().Contains(intTransformedBounds);
dt->SetPermitSubpixelAA(permitSubpixelAA);
} else {
nsRefPtr<gfxASurface> surface = aTarget->CurrentSurface();
if (surface->GetContentType() != GFX_CONTENT_COLOR_ALPHA) {
// Destination doesn't have alpha channel; no need to set any special flags
surface->SetSubpixelAntialiasingEnabled(permitSubpixelAA);
return;
}
const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds();
surface->SetSubpixelAntialiasingEnabled(
!(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
permitSubpixelAA &= !(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
surface->GetOpaqueRect().Contains(
aTarget->UserToDevice(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height))));
aTarget->UserToDevice(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height)));
surface->SetSubpixelAntialiasingEnabled(permitSubpixelAA);
}
}

View File

@ -684,7 +684,13 @@ public:
* transaction where there is no possibility of redrawing the content, so the
* implementation should be ready for that.
*/
CONTENT_MAY_CHANGE_TRANSFORM = 0x08
CONTENT_MAY_CHANGE_TRANSFORM = 0x08,
/**
* Disable subpixel AA for this layer. This is used if the display isn't suited
* for subpixel AA like hidpi or rotated content.
*/
CONTENT_DISABLE_SUBPIXEL_AA = 0x10
};
/**
* CONSTRUCTION PHASE ONLY

View File

@ -1798,13 +1798,18 @@ ContainerState::PopThebesLayerData()
// mask layer for image and color layers
SetupMaskLayer(layer, data->mItemClip);
}
uint32_t flags;
uint32_t flags = 0;
nsIWidget* widget = mContainerReferenceFrame->PresContext()->GetRootWidget();
// Disable subpixelAA on hidpi
bool hidpi = widget && widget->GetDefaultScale().scale >= 2;
if (hidpi) {
flags |= Layer::CONTENT_DISABLE_SUBPIXEL_AA;
}
if (isOpaque && !data->mForceTransparentSurface) {
flags = Layer::CONTENT_OPAQUE;
} else if (data->mNeedComponentAlpha) {
flags = Layer::CONTENT_COMPONENT_ALPHA;
} else {
flags = 0;
flags |= Layer::CONTENT_OPAQUE;
} else if (data->mNeedComponentAlpha && !hidpi) {
flags |= Layer::CONTENT_COMPONENT_ALPHA;
}
layer->SetContentFlags(flags);

View File

@ -22,8 +22,8 @@ fails-if(Android&&AndroidVersion!=17) == rotatex-perspective-3a.html rotatex-per
skip-if(B2G) == preserve3d-4a.html green-rect.html
fuzzy-if(Android&&AndroidVersion>=15,4,300) == preserve3d-5a.html preserve3d-5-ref.html
== scale3d-z.html scalez-1-ref.html
fuzzy-if(winWidget,102,580) fuzzy-if(d2d,143,681) fuzzy-if(OSX==10.8,145,752) == scale3d-all.html scale3d-1-ref.html # subpixel AA
fuzzy-if(winWidget,102,580) fuzzy-if(d2d,143,681) fuzzy-if(OSX==10.8,145,752) == scale3d-all-separate.html scale3d-1-ref.html # subpixel AA
fuzzy-if(winWidget,102,580) fuzzy-if(d2d,143,681) fuzzy-if(OSX==10.8,224,924) fuzzy-if(OSX==10.9,224,924) == scale3d-all.html scale3d-1-ref.html # subpixel AA
fuzzy-if(winWidget,102,580) fuzzy-if(d2d,143,681) fuzzy-if(OSX==10.8,224,924) fuzzy-if(OSX==10.9,224,924) == scale3d-all-separate.html scale3d-1-ref.html # subpixel AA
== scale3d-xz.html scale3d-1-ref.html
== translatez-1a.html translatez-1-ref.html
!= translatez-1b.html translatez-1-ref.html