Bug 1229202 (part 3) - Make gfxContextAutoDisableSubpixelAntialiasing take a DrawTarget instead of a gfxContext. r=mattwoodrow.

This commit is contained in:
Nicholas Nethercote 2015-12-02 15:32:16 -08:00
parent 386f2f87f8
commit 5169a5a9d8
6 changed files with 17 additions and 15 deletions

View File

@ -660,17 +660,19 @@ private:
};
class gfxContextAutoDisableSubpixelAntialiasing {
class DrawTargetAutoDisableSubpixelAntialiasing {
public:
gfxContextAutoDisableSubpixelAntialiasing(gfxContext *aContext, bool aDisable)
typedef mozilla::gfx::DrawTarget DrawTarget;
DrawTargetAutoDisableSubpixelAntialiasing(DrawTarget *aDT, bool aDisable)
{
if (aDisable) {
mDT = aContext->GetDrawTarget();
mDT = aDT;
mSubpixelAntialiasingEnabled = mDT->GetPermitSubpixelAA();
mDT->SetPermitSubpixelAA(false);
}
}
~gfxContextAutoDisableSubpixelAntialiasing()
~DrawTargetAutoDisableSubpixelAntialiasing()
{
if (mDT) {
mDT->SetPermitSubpixelAA(mSubpixelAntialiasingEnabled);
@ -678,7 +680,7 @@ public:
}
private:
RefPtr<mozilla::gfx::DrawTarget> mDT;
RefPtr<DrawTarget> mDT;
bool mSubpixelAntialiasingEnabled;
};

View File

@ -626,7 +626,8 @@ nsPageFrame::PaintHeaderFooter(nsRenderingContext& aRenderingContext,
nsRect rect(aPt, mRect.Size());
aRenderingContext.ThebesContext()->SetColor(Color(0.f, 0.f, 0.f));
gfxContextAutoDisableSubpixelAntialiasing disable(aRenderingContext.ThebesContext(), aDisableSubpixelAA);
DrawTargetAutoDisableSubpixelAntialiasing
disable(aRenderingContext.GetDrawTarget(), aDisableSubpixelAA);
// Get the FontMetrics to determine width.height of strings
RefPtr<nsFontMetrics> fontMet;

View File

@ -4790,9 +4790,9 @@ nsDisplayText::Paint(nsDisplayListBuilder* aBuilder,
extraVisible.Inflate(appUnitsPerDevPixel, appUnitsPerDevPixel);
nsTextFrame* f = static_cast<nsTextFrame*>(mFrame);
gfxContext* ctx = aCtx->ThebesContext();
gfxContextAutoDisableSubpixelAntialiasing disable(ctx,
DrawTargetAutoDisableSubpixelAntialiasing disable(aCtx->GetDrawTarget(),
mDisableSubpixelAA);
gfxContext* ctx = aCtx->ThebesContext();
gfxContextAutoSaveRestore save(ctx);
gfxRect pixelVisible =

View File

@ -3211,10 +3211,8 @@ void
nsDisplaySVGText::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx)
{
gfxContext* ctx = aCtx->ThebesContext();
gfxContextAutoDisableSubpixelAntialiasing
disable(ctx, mDisableSubpixelAA);
DrawTargetAutoDisableSubpixelAntialiasing
disable(aCtx->GetDrawTarget(), mDisableSubpixelAA);
uint32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
@ -3229,6 +3227,7 @@ nsDisplaySVGText::Paint(nsDisplayListBuilder* aBuilder,
gfxMatrix tm = nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(mFrame) *
gfxMatrix::Translation(devPixelOffset);
gfxContext* ctx = aCtx->ThebesContext();
ctx->Save();
static_cast<SVGTextFrame*>(mFrame)->PaintSVG(*ctx, tm);
ctx->Restore();

View File

@ -320,7 +320,7 @@ void
nsDisplayXULTextBox::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx)
{
gfxContextAutoDisableSubpixelAntialiasing disable(aCtx->ThebesContext(),
DrawTargetAutoDisableSubpixelAntialiasing disable(aCtx->GetDrawTarget(),
mDisableSubpixelAA);
// Paint the text shadow before doing any foreground stuff

View File

@ -2802,8 +2802,8 @@ public:
virtual void Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx) override
{
gfxContext* ctx = aCtx->ThebesContext();
gfxContextAutoDisableSubpixelAntialiasing disable(ctx, mDisableSubpixelAA);
DrawTargetAutoDisableSubpixelAntialiasing disable(aCtx->GetDrawTarget(),
mDisableSubpixelAA);
DrawResult result = static_cast<nsTreeBodyFrame*>(mFrame)
->PaintTreeBody(*aCtx, mVisibleRect, ToReferenceFrame());