Bug 1341101 part 4 - Specify a nsRenderingContext for nsCSSRendering::PaintStyleImageLayer r=mattwoodrow
authorRyan Hunt <rhunt@eqrion.net>
Wed, 15 Mar 2017 00:25:09 -0400
changeset 350270 88a7b38645a04e4384a7906b04d42f38995458df
parent 350269 5f5fef49b82c0c97bc403c8936f3ff7800416808
child 350271 65b02add807c5b1b482bc8924d77e6f503eab693
push id31570
push userryanvm@gmail.com
push dateWed, 29 Mar 2017 13:42:06 +0000
treeherdermozilla-central@6ea713ccc9ab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1341101
milestone55.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 1341101 part 4 - Specify a nsRenderingContext for nsCSSRendering::PaintStyleImageLayer r=mattwoodrow MozReview-Commit-ID: 5TX6IXLSC8r
layout/painting/nsCSSRendering.cpp
layout/painting/nsCSSRendering.h
layout/painting/nsCSSRenderingGradients.h
layout/painting/nsDisplayList.cpp
layout/svg/nsSVGIntegrationUtils.cpp
layout/tables/nsTableCellFrame.cpp
layout/tables/nsTablePainter.cpp
layout/xul/tree/nsTreeBodyFrame.cpp
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -1866,55 +1866,54 @@ nsCSSRendering::PaintBoxShadowInner(nsPr
                               shadowOffset);
     renderContext->Restore();
   }
 }
 
 /* static */
 nsCSSRendering::PaintBGParams
 nsCSSRendering::PaintBGParams::ForAllLayers(nsPresContext& aPresCtx,
-                                            nsRenderingContext& aRenderingCtx,
                                             const nsRect& aDirtyRect,
                                             const nsRect& aBorderArea,
                                             nsIFrame *aFrame,
                                             uint32_t aPaintFlags,
                                             float aOpacity)
 {
   MOZ_ASSERT(aFrame);
 
-  PaintBGParams result(aPresCtx, aRenderingCtx, aDirtyRect, aBorderArea,
+  PaintBGParams result(aPresCtx, aDirtyRect, aBorderArea,
                        aFrame, aPaintFlags, -1, CompositionOp::OP_OVER,
                        aOpacity);
 
   return result;
 }
 
 /* static */
 nsCSSRendering::PaintBGParams
 nsCSSRendering::PaintBGParams::ForSingleLayer(nsPresContext& aPresCtx,
-                                              nsRenderingContext& aRenderingCtx,
                                               const nsRect& aDirtyRect,
                                               const nsRect& aBorderArea,
                                               nsIFrame *aFrame,
                                               uint32_t aPaintFlags,
                                               int32_t aLayer,
                                               CompositionOp aCompositionOp,
                                               float aOpacity)
 {
   MOZ_ASSERT(aFrame && (aLayer != -1));
 
-  PaintBGParams result(aPresCtx, aRenderingCtx, aDirtyRect, aBorderArea,
+  PaintBGParams result(aPresCtx, aDirtyRect, aBorderArea,
                        aFrame, aPaintFlags, aLayer, aCompositionOp,
                        aOpacity);
 
   return result;
 }
 
 DrawResult
-nsCSSRendering::PaintStyleImageLayer(const PaintBGParams& aParams)
+nsCSSRendering::PaintStyleImageLayer(const PaintBGParams& aParams,
+                                     nsRenderingContext& aRenderingCtx)
 {
   PROFILER_LABEL("nsCSSRendering", "PaintBackground",
     js::ProfileEntry::Category::GRAPHICS);
 
   NS_PRECONDITION(aParams.frame,
                   "Frame is expected to be provided to PaintBackground");
 
   nsStyleContext *sc;
@@ -1931,17 +1930,17 @@ nsCSSRendering::PaintStyleImageLayer(con
     nsIContent* content = aParams.frame->GetContent();
     if (!content || content->GetParent()) {
       return DrawResult::SUCCESS;
     }
 
     sc = aParams.frame->StyleContext();
   }
 
-  return PaintStyleImageLayerWithSC(aParams, sc, *aParams.frame->StyleBorder());
+  return PaintStyleImageLayerWithSC(aParams, aRenderingCtx, sc, *aParams.frame->StyleBorder());
 }
 
 static bool
 IsOpaqueBorderEdge(const nsStyleBorder& aBorder, mozilla::Side aSide)
 {
   if (aBorder.GetComputedBorder().Side(aSide) == 0)
     return true;
   switch (aBorder.GetBorderStyle(aSide)) {
@@ -2410,16 +2409,17 @@ DetermineCompositionOp(const nsCSSRender
     return nsCSSRendering::GetGFXCompositeMode(layer.mComposite);
   }
 
   return nsCSSRendering::GetGFXBlendMode(layer.mBlendMode);
 }
 
 DrawResult
 nsCSSRendering::PaintStyleImageLayerWithSC(const PaintBGParams& aParams,
+                                           nsRenderingContext& aRenderingCtx,
                                            nsStyleContext *aBackgroundSC,
                                            const nsStyleBorder& aBorder)
 {
   NS_PRECONDITION(aParams.frame,
                   "Frame is expected to be provided to PaintBackground");
 
   // If we're drawing all layers, aCompositonOp is ignored, so make sure that
   // it was left at its default value.
@@ -2435,17 +2435,17 @@ nsCSSRendering::PaintStyleImageLayerWith
     if (theme && theme->ThemeSupportsWidget(&aParams.presCtx,
                                             aParams.frame,
                                             displayData->UsedAppearance())) {
       nsRect drawing(aParams.borderArea);
       theme->GetWidgetOverflow(aParams.presCtx.DeviceContext(),
                                aParams.frame, displayData->UsedAppearance(),
                                &drawing);
       drawing.IntersectRect(drawing, aParams.dirtyRect);
-      theme->DrawWidgetBackground(&aParams.renderingCtx, aParams.frame,
+      theme->DrawWidgetBackground(&aRenderingCtx, aParams.frame,
                                   displayData->UsedAppearance(), aParams.borderArea,
                                   drawing);
       return DrawResult::SUCCESS;
     }
   }
 
   // For canvas frames (in the CSS sense) we draw the background color using
   // a solid color item that gets added in nsLayoutUtils::PaintFrame,
@@ -2484,17 +2484,17 @@ nsCSSRendering::PaintStyleImageLayerWith
     return DrawResult::SUCCESS;
 
   // The 'bgClipArea' (used only by the image tiling logic, far below)
   // is the caller-provided aParams.bgClipRect if any, or else the area
   // determined by the value of 'background-clip' in
   // SetupCurrentBackgroundClip.  (Arguably it should be the
   // intersection, but that breaks the table painter -- in particular,
   // taking the intersection breaks reftests/bugs/403249-1[ab].)
-  gfxContext* ctx = aParams.renderingCtx.ThebesContext();
+  gfxContext* ctx = aRenderingCtx.ThebesContext();
   nscoord appUnitsPerPixel = aParams.presCtx.AppUnitsPerDevPixel();
   ImageLayerClipState clipState;
   if (aParams.bgClipRect) {
     clipState.mBGClipArea = *aParams.bgClipRect;
     clipState.mCustomClip = true;
     clipState.mHasRoundedCorners = false;
     SetupDirtyRects(clipState.mBGClipArea, aParams.dirtyRect, appUnitsPerPixel,
                     &clipState.mDirtyRectInAppUnits,
@@ -2627,17 +2627,17 @@ nsCSSRendering::PaintStyleImageLayerWith
         NS_ASSERTION(ctx->CurrentOp() == CompositionOp::OP_OVER,
                      "It is assumed the initial op is OP_OVER, when it is "
                      "restored later");
         ctx->SetOp(co);
       }
 
       result &=
         state.mImageRenderer.DrawLayer(&aParams.presCtx,
-                                       aParams.renderingCtx,
+                                       aRenderingCtx,
                                        state.mDestArea, state.mFillArea,
                                        state.mAnchor + paintBorderArea.TopLeft(),
                                        clipState.mDirtyRectInAppUnits,
                                        state.mRepeatSize, aParams.opacity);
 
       if (co != CompositionOp::OP_OVER) {
         ctx->SetOp(CompositionOp::OP_OVER);
       }
--- a/layout/painting/nsCSSRendering.h
+++ b/layout/painting/nsCSSRendering.h
@@ -397,83 +397,80 @@ struct nsCSSRendering {
      * When this flag is passed, painting will read properties of mask-image
      * style, instead of background-image.
      */
     PAINTBG_MASK_IMAGE = 0x08
   };
 
   struct PaintBGParams {
     nsPresContext& presCtx;
-    nsRenderingContext& renderingCtx;
     nsRect dirtyRect;
     nsRect borderArea;
     nsIFrame* frame;
     uint32_t paintFlags;
     nsRect* bgClipRect = nullptr;
     int32_t layer;                  // -1 means painting all layers; other
                                     // value means painting one specific
                                     // layer only.
     CompositionOp compositionOp;
     float opacity;
 
     static PaintBGParams ForAllLayers(nsPresContext& aPresCtx,
-                                      nsRenderingContext& aRenderingCtx,
                                       const nsRect& aDirtyRect,
                                       const nsRect& aBorderArea,
                                       nsIFrame *aFrame,
                                       uint32_t aPaintFlags,
                                       float aOpacity = 1.0);
     static PaintBGParams ForSingleLayer(nsPresContext& aPresCtx,
-                                        nsRenderingContext& aRenderingCtx,
                                         const nsRect& aDirtyRect,
                                         const nsRect& aBorderArea,
                                         nsIFrame *aFrame,
                                         uint32_t aPaintFlags,
                                         int32_t aLayer,
                                         CompositionOp aCompositionOp  = CompositionOp::OP_OVER,
                                         float aOpacity = 1.0);
 
   private:
     PaintBGParams(nsPresContext& aPresCtx,
-                  nsRenderingContext& aRenderingCtx,
                   const nsRect& aDirtyRect,
                   const nsRect& aBorderArea,
                   nsIFrame* aFrame,
                   uint32_t aPaintFlags,
                   int32_t aLayer,
                   CompositionOp aCompositionOp,
                   float aOpacity)
      : presCtx(aPresCtx),
-       renderingCtx(aRenderingCtx),
        dirtyRect(aDirtyRect),
        borderArea(aBorderArea),
        frame(aFrame),
        paintFlags(aPaintFlags),
        layer(aLayer),
        compositionOp(aCompositionOp),
        opacity(aOpacity) {}
   };
 
-  static DrawResult PaintStyleImageLayer(const PaintBGParams& aParams);
+  static DrawResult PaintStyleImageLayer(const PaintBGParams& aParams,
+                                         nsRenderingContext& aRenderingCtx);
 
 
   /**
    * Same as |PaintStyleImageLayer|, except using the provided style structs.
    * This short-circuits the code that ensures that the root element's
    * {background|mask} is drawn on the canvas.
    * The aLayer parameter allows you to paint a single layer of the
    * {background|mask}.
    * The default value for aLayer, -1, means that all layers will be painted.
    * The background color will only be painted if the back-most layer is also
    * being painted and (aParams.paintFlags & PAINTBG_MASK_IMAGE) is false.
    * aCompositionOp is only respected if a single layer is specified (aLayer != -1).
    * If all layers are painted, the image layer's blend mode (or the mask
    * layer's composition mode) will be used.
    */
   static DrawResult PaintStyleImageLayerWithSC(const PaintBGParams& aParams,
+                                               nsRenderingContext& aRenderingCtx,
                                                nsStyleContext *mBackgroundSC,
                                                const nsStyleBorder& aBorder);
 
   /**
    * Returns the rectangle covered by the given background layer image, taking
    * into account background positioning, sizing, and repetition, but not
    * clipping.
    */
--- a/layout/painting/nsCSSRenderingGradients.h
+++ b/layout/painting/nsCSSRenderingGradients.h
@@ -13,18 +13,18 @@
 
 namespace mozilla {
 
 namespace layers {
 class WebRenderDisplayItemLayer;
 } // namespace layers
 
 namespace wr {
-  class DisplayListBuilder;
-}
+class DisplayListBuilder;
+} // namespace wr
 
 // A resolved color stop, with a specific position along the gradient line and
 // a color.
 struct ColorStop {
   ColorStop(): mPosition(0), mIsMidpoint(false) {}
   ColorStop(double aPosition, bool aIsMidPoint, const Color& aColor) :
     mPosition(aPosition), mIsMidpoint(aIsMidPoint), mColor(aColor) {}
   double mPosition; // along the gradient line; 0=start, 1=end
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -3513,23 +3513,22 @@ nsDisplayBackgroundImage::PaintInternal(
   if (clip == StyleGeometryBox::Text) {
     if (!GenerateAndPushTextMask(mFrame, aCtx, mBackgroundRect, aBuilder)) {
       return;
     }
   }
 
   nsCSSRendering::PaintBGParams params =
     nsCSSRendering::PaintBGParams::ForSingleLayer(*mFrame->PresContext(),
-                                                  *aCtx,
                                                   aBounds, mBackgroundRect,
                                                   mFrame, flags, mLayer,
                                                   CompositionOp::OP_OVER);
   params.bgClipRect = aClipRect;
   image::DrawResult result =
-    nsCSSRendering::PaintStyleImageLayer(params);
+    nsCSSRendering::PaintStyleImageLayer(params, *aCtx);
 
   if (clip == StyleGeometryBox::Text) {
     ctx->PopGroupAndBlend();
   }
 
   nsDisplayBackgroundGeometry::UpdateDrawResult(this, result);
 }
 
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -459,26 +459,26 @@ PaintMaskSurface(const PaintFramesParams
       }
     } else {
       gfxContextMatrixAutoSaveRestore matRestore(maskContext);
 
       maskContext->Multiply(gfxMatrix::Translation(-devPixelOffsetToUserSpace));
       nsRenderingContext rc(maskContext);
       nsCSSRendering::PaintBGParams  params =
         nsCSSRendering::PaintBGParams::ForSingleLayer(*presContext,
-                                                      rc, aParams.dirtyRect,
+                                                      aParams.dirtyRect,
                                                       aParams.borderArea,
                                                       aParams.frame,
                                                       aParams.builder->GetBackgroundPaintFlags() |
                                                       nsCSSRendering::PAINTBG_MASK_IMAGE,
                                                       i, compositionOp,
                                                       aOpacity);
 
       result =
-        nsCSSRendering::PaintStyleImageLayerWithSC(params, aSC,
+        nsCSSRendering::PaintStyleImageLayerWithSC(params, rc, aSC,
                                               *aParams.frame->StyleBorder());
       if (result != DrawResult::SUCCESS) {
         return result;
       }
     }
   }
 
   return DrawResult::SUCCESS;
--- a/layout/tables/nsTableCellFrame.cpp
+++ b/layout/tables/nsTableCellFrame.cpp
@@ -375,20 +375,19 @@ DrawResult
 nsTableCellFrame::PaintBackground(nsRenderingContext& aRenderingContext,
                                   const nsRect&        aDirtyRect,
                                   nsPoint              aPt,
                                   uint32_t             aFlags)
 {
   nsRect rect(aPt, GetSize());
   nsCSSRendering::PaintBGParams params =
     nsCSSRendering::PaintBGParams::ForAllLayers(*PresContext(),
-                                                aRenderingContext,
                                                 aDirtyRect, rect,
                                                 this, aFlags);
-  return nsCSSRendering::PaintStyleImageLayer(params);
+  return nsCSSRendering::PaintStyleImageLayer(params, aRenderingContext);
 }
 
 // Called by nsTablePainter
 DrawResult
 nsTableCellFrame::PaintCellBackground(nsRenderingContext& aRenderingContext,
                                       const nsRect& aDirtyRect, nsPoint aPt,
                                       uint32_t aFlags)
 {
@@ -1243,14 +1242,14 @@ nsBCTableCellFrame::PaintBackground(nsRe
     myBorder.SetBorderWidth(side, borderWidth.Side(side));
   }
 
   // bypassing nsCSSRendering::PaintBackground is safe because this kind
   // of frame cannot be used for the root element
   nsRect rect(aPt, GetSize());
   nsCSSRendering::PaintBGParams params =
     nsCSSRendering::PaintBGParams::ForAllLayers(*PresContext(),
-                                                aRenderingContext, aDirtyRect,
+                                                aDirtyRect,
                                                 rect, this,
                                                 aFlags);
-  return nsCSSRendering::PaintStyleImageLayerWithSC(params, StyleContext(),
+  return nsCSSRendering::PaintStyleImageLayerWithSC(params, aRenderingContext, StyleContext(),
                                                     myBorder);
 }
--- a/layout/tables/nsTablePainter.cpp
+++ b/layout/tables/nsTablePainter.cpp
@@ -227,24 +227,23 @@ TableBackgroundPainter::PaintTableFrame(
     }
   }
 
   DrawResult result = DrawResult::SUCCESS;
 
   if (tableData.IsVisible()) {
     nsCSSRendering::PaintBGParams params =
       nsCSSRendering::PaintBGParams::ForAllLayers(*mPresContext,
-                                                  mRenderingContext,
                                                   mDirtyRect,
                                                   tableData.mRect + mRenderPt,
                                                   tableData.mFrame,
                                                   mBGPaintFlags);
 
     result &=
-      nsCSSRendering::PaintStyleImageLayerWithSC(params,
+      nsCSSRendering::PaintStyleImageLayerWithSC(params, mRenderingContext,
                                             tableData.mFrame->StyleContext(),
                                             tableData.StyleBorder(mZeroBorder));
   }
 
   return result;
 }
 
 void
@@ -568,67 +567,67 @@ TableBackgroundPainter::PaintCell(nsTabl
   // our columns. Ignore column / col group backgrounds in that case.
   bool haveColumns = !mCols.IsEmpty();
 
   DrawResult result = DrawResult::SUCCESS;
 
   //Paint column group background
   if (haveColumns && mCols[colIndex].mColGroup.IsVisible()) {
     nsCSSRendering::PaintBGParams params =
-      nsCSSRendering::PaintBGParams::ForAllLayers(*mPresContext, mRenderingContext,
+      nsCSSRendering::PaintBGParams::ForAllLayers(*mPresContext,
                                                  mDirtyRect,
                                                  mCols[colIndex].mColGroup.mRect + mRenderPt,
                                                  mCols[colIndex].mColGroup.mFrame,
                                                  mBGPaintFlags);
     params.bgClipRect = &aColBGRect;
     result &=
-      nsCSSRendering::PaintStyleImageLayerWithSC(params,
+      nsCSSRendering::PaintStyleImageLayerWithSC(params, mRenderingContext,
                                             mCols[colIndex].mColGroup.mFrame->StyleContext(),
                                             mCols[colIndex].mColGroup.StyleBorder(mZeroBorder));
   }
 
   //Paint column background
   if (haveColumns && mCols[colIndex].mCol.IsVisible()) {
     nsCSSRendering::PaintBGParams params =
-      nsCSSRendering::PaintBGParams::ForAllLayers(*mPresContext, mRenderingContext,
+      nsCSSRendering::PaintBGParams::ForAllLayers(*mPresContext,
                                                   mDirtyRect,
                                                   mCols[colIndex].mCol.mRect + mRenderPt,
                                                   mCols[colIndex].mCol.mFrame,
                                                   mBGPaintFlags);
     params.bgClipRect = &aColBGRect;
     result &=
-      nsCSSRendering::PaintStyleImageLayerWithSC(params,
+      nsCSSRendering::PaintStyleImageLayerWithSC(params, mRenderingContext,
                                             mCols[colIndex].mCol.mFrame->StyleContext(),
                                             mCols[colIndex].mCol.StyleBorder(mZeroBorder));
   }
 
   //Paint row group background
   if (aRowGroupBGData.IsVisible()) {
     nsCSSRendering::PaintBGParams params =
-      nsCSSRendering::PaintBGParams::ForAllLayers(*mPresContext, mRenderingContext,
+      nsCSSRendering::PaintBGParams::ForAllLayers(*mPresContext,
                                                   mDirtyRect,
                                                   aRowGroupBGData.mRect + mRenderPt,
                                                   aRowGroupBGData.mFrame, mBGPaintFlags);
     params.bgClipRect = &aRowGroupBGRect;
     result &=
-      nsCSSRendering::PaintStyleImageLayerWithSC(params,
+      nsCSSRendering::PaintStyleImageLayerWithSC(params, mRenderingContext,
                                             aRowGroupBGData.mFrame->StyleContext(),
                                             aRowGroupBGData.StyleBorder(mZeroBorder));
   }
 
   //Paint row background
   if (aRowBGData.IsVisible()) {
     nsCSSRendering::PaintBGParams params =
-      nsCSSRendering::PaintBGParams::ForAllLayers(*mPresContext, mRenderingContext,
+      nsCSSRendering::PaintBGParams::ForAllLayers(*mPresContext,
                                                   mDirtyRect,
                                                   aRowBGData.mRect + mRenderPt,
                                                   aRowBGData.mFrame, mBGPaintFlags);
     params.bgClipRect = &aRowBGRect;
     result &=
-      nsCSSRendering::PaintStyleImageLayerWithSC(params,
+      nsCSSRendering::PaintStyleImageLayerWithSC(params, mRenderingContext,
                                             aRowBGData.mFrame->StyleContext(),
                                             aRowBGData.StyleBorder(mZeroBorder));
   }
 
   //Paint cell background in border-collapse unless we're just passing
   if (mIsBorderCollapse && !aPassSelf) {
     result &=
       aCell->PaintCellBackground(mRenderingContext, mDirtyRect,
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -4146,21 +4146,21 @@ DrawResult
 nsTreeBodyFrame::PaintBackgroundLayer(nsStyleContext*      aStyleContext,
                                       nsPresContext*      aPresContext,
                                       nsRenderingContext& aRenderingContext,
                                       const nsRect&        aRect,
                                       const nsRect&        aDirtyRect)
 {
   const nsStyleBorder* myBorder = aStyleContext->StyleBorder();
   nsCSSRendering::PaintBGParams params =
-    nsCSSRendering::PaintBGParams::ForAllLayers(*aPresContext, aRenderingContext,
+    nsCSSRendering::PaintBGParams::ForAllLayers(*aPresContext,
                                                 aDirtyRect, aRect, this,
                                                 nsCSSRendering::PAINTBG_SYNC_DECODE_IMAGES);
   DrawResult result =
-    nsCSSRendering::PaintStyleImageLayerWithSC(params, aStyleContext,
+    nsCSSRendering::PaintStyleImageLayerWithSC(params, aRenderingContext, aStyleContext,
                                                *myBorder);
 
   result &=
     nsCSSRendering::PaintBorderWithStyleBorder(aPresContext, aRenderingContext,
                                                this, aDirtyRect, aRect,
                                                *myBorder, mStyleContext,
                                                PaintBorderFlags::SYNC_DECODE_IMAGES);