Bug 717393 - Part 5: Permit subpixel AA for transparent surfaces. r=roc

This commit is contained in:
Bas Schouten 2012-05-15 16:57:51 +02:00
Родитель b887580d55
Коммит 3eed0050e2
3 изменённых файлов: 42 добавлений и 18 удалений

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

@ -599,21 +599,33 @@ static void
SetAntialiasingFlags(Layer* aLayer, gfxContext* aTarget)
{
if (!aTarget->IsCairo()) {
// Azure targets don't contain antialiasing flags at this point.
return;
}
RefPtr<DrawTarget> dt = aTarget->GetDrawTarget();
nsRefPtr<gfxASurface> surface = aTarget->CurrentSurface();
if (surface->GetContentType() != gfxASurface::CONTENT_COLOR_ALPHA) {
// Destination doesn't have alpha channel; no need to set any special flags
return;
}
if (dt->GetFormat() != FORMAT_B8G8R8A8) {
return;
}
const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds();
surface->SetSubpixelAntialiasingEnabled(
!(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
surface->GetOpaqueRect().Contains(
aTarget->UserToDevice(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height))));
const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds();
Rect transformedBounds = dt->GetTransform().TransformBounds(Rect(Float(bounds.x), Float(bounds.y),
Float(bounds.width), Float(bounds.height)));
transformedBounds.RoundOut();
IntRect intTransformedBounds;
transformedBounds.ToIntRect(&intTransformedBounds);
dt->SetPermitSubpixelAA(!(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
dt->GetOpaqueRect().Contains(intTransformedBounds));
} else {
nsRefPtr<gfxASurface> surface = aTarget->CurrentSurface();
if (surface->GetContentType() != gfxASurface::CONTENT_COLOR_ALPHA) {
// Destination doesn't have alpha channel; no need to set any special flags
return;
}
const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds();
surface->SetSubpixelAntialiasingEnabled(
!(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
surface->GetOpaqueRect().Contains(
aTarget->UserToDevice(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height))));
}
}
already_AddRefed<gfxContext>

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

@ -484,6 +484,8 @@ ThebesLayerD3D10::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode)
if (mD2DSurface) {
mD2DSurface->SetSubpixelAntialiasingEnabled(!(mContentFlags & CONTENT_COMPONENT_ALPHA));
} else if (mDrawTarget) {
mDrawTarget->SetPermitSubpixelAA(!(mContentFlags & CONTENT_COMPONENT_ALPHA));
}
LayerManagerD3D10::CallbackInfo cbInfo = mD3DManager->GetCallbackInfo();

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

@ -930,23 +930,33 @@ public:
gfxContextAutoDisableSubpixelAntialiasing(gfxContext *aContext, bool aDisable)
{
if (aDisable) {
mSurface = aContext->CurrentSurface();
if (!mSurface) {
return;
if (aContext->IsCairo()) {
mSurface = aContext->CurrentSurface();
if (!mSurface) {
return;
}
mSubpixelAntialiasingEnabled = mSurface->GetSubpixelAntialiasingEnabled();
mSurface->SetSubpixelAntialiasingEnabled(false);
} else {
mDT = aContext->GetDrawTarget();
mSubpixelAntialiasingEnabled = mDT->GetPermitSubpixelAA();
mDT->SetPermitSubpixelAA(false);
}
mSubpixelAntialiasingEnabled = mSurface->GetSubpixelAntialiasingEnabled();
mSurface->SetSubpixelAntialiasingEnabled(false);
}
}
~gfxContextAutoDisableSubpixelAntialiasing()
{
if (mSurface) {
mSurface->SetSubpixelAntialiasingEnabled(mSubpixelAntialiasingEnabled);
} else if (mDT) {
mDT->SetPermitSubpixelAA(mSubpixelAntialiasingEnabled);
}
}
private:
nsRefPtr<gfxASurface> mSurface;
mozilla::RefPtr<mozilla::gfx::DrawTarget> mDT;
bool mSubpixelAntialiasingEnabled;
};