diff --git a/gfx/layers/basic/BasicLayers.cpp b/gfx/layers/basic/BasicLayers.cpp index 447b5a6874b1..90ee52dd8cd6 100644 --- a/gfx/layers/basic/BasicLayers.cpp +++ b/gfx/layers/basic/BasicLayers.cpp @@ -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 dt = aTarget->GetDrawTarget(); - nsRefPtr 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 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 diff --git a/gfx/layers/d3d10/ThebesLayerD3D10.cpp b/gfx/layers/d3d10/ThebesLayerD3D10.cpp index 05c80767239a..881dcff5f1e7 100644 --- a/gfx/layers/d3d10/ThebesLayerD3D10.cpp +++ b/gfx/layers/d3d10/ThebesLayerD3D10.cpp @@ -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(); diff --git a/gfx/thebes/gfxContext.h b/gfx/thebes/gfxContext.h index ade69d2d545f..928a1c95473f 100644 --- a/gfx/thebes/gfxContext.h +++ b/gfx/thebes/gfxContext.h @@ -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 mSurface; + mozilla::RefPtr mDT; bool mSubpixelAntialiasingEnabled; };