Bug 1229202 (part 3) - Make gfxContextAutoDisableSubpixelAntialiasing take a DrawTarget instead of a gfxContext. r=mattwoodrow.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 02 Dec 2015 15:32:16 -0800
changeset 275288 45f90e71e3fbe4d05949e43e6f80db7a5dac7101
parent 275287 5f78854c2c7233b9dc6692f2b652e9ae36c61b07
child 275289 ef3fe4b3354887b0228de77ec7b70e4218280e48
push id68809
push usernnethercote@mozilla.com
push dateWed, 02 Dec 2015 23:53:23 +0000
treeherdermozilla-inbound@3e1abfc084f0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1229202
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1229202 (part 3) - Make gfxContextAutoDisableSubpixelAntialiasing take a DrawTarget instead of a gfxContext. r=mattwoodrow.
gfx/thebes/gfxContext.h
layout/generic/nsPageFrame.cpp
layout/generic/nsTextFrame.cpp
layout/svg/SVGTextFrame.cpp
layout/xul/nsTextBoxFrame.cpp
layout/xul/tree/nsTreeBodyFrame.cpp
--- a/gfx/thebes/gfxContext.h
+++ b/gfx/thebes/gfxContext.h
@@ -655,35 +655,37 @@ public:
     }
 
 private:
     gfxContext *mContext;
     gfxMatrix   mMatrix;
 };
 
 
-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);
         }
     }
 
 private:
-    RefPtr<mozilla::gfx::DrawTarget> mDT;
+    RefPtr<DrawTarget> mDT;
     bool mSubpixelAntialiasingEnabled;
 };
 
 /* This class lives on the stack and allows gfxContext users to easily, and
  * performantly get a gfx::Pattern to use for drawing in their current context.
  */
 class PatternFromState
 {
--- a/layout/generic/nsPageFrame.cpp
+++ b/layout/generic/nsPageFrame.cpp
@@ -621,17 +621,18 @@ nsPageFrame::PaintHeaderFooter(nsRenderi
       mPD->mPrintSettings = pc->GetPrintSettings();
     if (!mPD->mPrintSettings)
       return;
   }
 
   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;
   pc->DeviceContext()->GetMetricsFor(mPD->mHeadFootFont, nullptr, false,
                                      gfxFont::eHorizontal,
                                      pc->GetUserFontSet(),
                                      pc->GetTextPerfMetrics(),
                                      *getter_AddRefs(fontMet));
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -4785,19 +4785,19 @@ nsDisplayText::Paint(nsDisplayListBuilde
   // Add 1 pixel of dirty area around mVisibleRect to allow us to paint
   // antialiased pixels beyond the measured text extents.
   // This is temporary until we do this in the actual calculation of text extents.
   nsRect extraVisible = mVisibleRect;
   nscoord appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
   extraVisible.Inflate(appUnitsPerDevPixel, appUnitsPerDevPixel);
   nsTextFrame* f = static_cast<nsTextFrame*>(mFrame);
 
+  DrawTargetAutoDisableSubpixelAntialiasing disable(aCtx->GetDrawTarget(),
+                                                    mDisableSubpixelAA);
   gfxContext* ctx = aCtx->ThebesContext();
-  gfxContextAutoDisableSubpixelAntialiasing disable(ctx,
-                                                    mDisableSubpixelAA);
   gfxContextAutoSaveRestore save(ctx);
 
   gfxRect pixelVisible =
     nsLayoutUtils::RectToGfxRect(extraVisible, appUnitsPerDevPixel);
   pixelVisible.Inflate(2);
   pixelVisible.RoundOut();
 
   ctx->NewPath();
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -3206,34 +3206,33 @@ nsDisplaySVGText::HitTest(nsDisplayListB
     aOutFrames->AppendElement(target);
   }
 }
 
 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();
 
   // ToReferenceFrame includes our mRect offset, but painting takes
   // account of that too. To avoid double counting, we subtract that
   // here.
   nsPoint offset = ToReferenceFrame() - mFrame->GetPosition();
 
   gfxPoint devPixelOffset =
     nsLayoutUtils::PointToGfxPoint(offset, appUnitsPerDevPixel);
 
   gfxMatrix tm = nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(mFrame) *
                    gfxMatrix::Translation(devPixelOffset);
 
+  gfxContext* ctx = aCtx->ThebesContext();
   ctx->Save();
   static_cast<SVGTextFrame*>(mFrame)->PaintSVG(*ctx, tm);
   ctx->Restore();
 }
 
 // ---------------------------------------------------------------------
 // nsQueryFrame methods
 
--- a/layout/xul/nsTextBoxFrame.cpp
+++ b/layout/xul/nsTextBoxFrame.cpp
@@ -315,17 +315,17 @@ PaintTextShadowCallback(nsRenderingConte
   reinterpret_cast<nsDisplayXULTextBox*>(aData)->
            PaintTextToContext(aCtx, aShadowOffset, &aShadowColor);
 }
 
 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
   nsRect drawRect = static_cast<nsTextBoxFrame*>(mFrame)->mTextDrawRect +
                     ToReferenceFrame();
   nsLayoutUtils::PaintTextShadow(mFrame, aCtx,
                                  drawRect, mVisibleRect,
                                  mFrame->StyleColor()->mColor,
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -2797,18 +2797,18 @@ public:
     }
 
     nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
   }
 
   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());
 
     nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
   }
 
   NS_DISPLAY_DECL_NAME("XULTreeBody", TYPE_XUL_TREE_BODY)