Bug 1344622 - Part1. Create WR commands in BorderRenderer. r=mattwoodrow
authorEthan Lin <ethlin@mozilla.com>
Thu, 09 Mar 2017 16:58:38 +0800
changeset 347285 4c6b9024e6ec0a0e1f03dd7f3e8e0460dcf45f43
parent 347284 dd3962dfd678fdf3e88f309c56dba976f37a745b
child 347286 5a5fdbdd7892e11ed3a287c174a2f10f70d43998
push id31493
push userkwierso@gmail.com
push dateMon, 13 Mar 2017 20:10:14 +0000
treeherdermozilla-central@7781e4e0a332 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1344622
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 1344622 - Part1. Create WR commands in BorderRenderer. r=mattwoodrow
layout/painting/nsCSSRenderingBorders.cpp
layout/painting/nsCSSRenderingBorders.h
layout/painting/nsDisplayList.cpp
--- a/layout/painting/nsCSSRenderingBorders.cpp
+++ b/layout/painting/nsCSSRenderingBorders.cpp
@@ -23,16 +23,17 @@
 #include "RoundedRect.h"
 #include "nsIScriptError.h"
 #include "nsClassHashtable.h"
 #include "nsPresContext.h"
 #include "nsStyleStruct.h"
 #include "mozilla/gfx/2D.h"
 #include "gfx2DGlue.h"
 #include "gfxGradientCache.h"
+#include "mozilla/layers/WebRenderDisplayItemLayer.h"
 #include <algorithm>
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 
 #define MAX_COMPOSITE_BORDER_WIDTH LayoutDeviceIntCoord(10000)
 
 /**
@@ -3524,8 +3525,28 @@ nsCSSBorderRenderer::DrawBorders()
       DrawBorderSides(1 << side);
 
       mDrawTarget->PopClip();
 
       PrintAsStringNewline("---------------- (*)");
     }
   }
 }
+
+void
+nsCSSBorderRenderer::CreateWebRenderCommands(wr::DisplayListBuilder& aBuilder,
+                                             layers::WebRenderDisplayItemLayer* aLayer)
+{
+  Rect outlineTransformedRect = aLayer->RelativeToParent(mOuterRect);
+  WrBorderSide side[4];
+  NS_FOR_CSS_SIDES(i) {
+    side[i] = wr::ToWrBorderSide(mBorderWidths[i], ToDeviceColor(mBorderColors[i]), mBorderStyles[i]);
+  }
+
+  WrBorderRadius borderRadius = wr::ToWrBorderRadius(LayerSize(mBorderRadii[0].width, mBorderRadii[0].height),
+                                                     LayerSize(mBorderRadii[1].width, mBorderRadii[1].height),
+                                                     LayerSize(mBorderRadii[3].width, mBorderRadii[3].height),
+                                                     LayerSize(mBorderRadii[2].width, mBorderRadii[2].height));
+  aBuilder.PushBorder(wr::ToWrRect(outlineTransformedRect),
+                      wr::ToWrRect(outlineTransformedRect),
+                      side[0], side[1], side[2], side[3],
+                      borderRadius);
+}
--- a/layout/painting/nsCSSRenderingBorders.h
+++ b/layout/painting/nsCSSRenderingBorders.h
@@ -13,24 +13,28 @@
 #include "mozilla/gfx/BezierUtils.h"
 #include "mozilla/gfx/PathHelpers.h"
 #include "mozilla/RefPtr.h"
 #include "nsColor.h"
 #include "nsCOMPtr.h"
 #include "nsStyleConsts.h"
 #include "nsStyleStruct.h"
 #include "nsPresContext.h"
+#include "gfxUtils.h"
 
 struct nsBorderColors;
 class nsDisplayBorder;
 
 namespace mozilla {
 namespace gfx {
 class GradientStops;
 } // namespace gfx
+namespace layers {
+class WebRenderDisplayItemLayer;
+} // namespace layers
 } // namespace mozilla
 
 // define this to enable a bunch of debug dump info
 #undef DEBUG_NEW_BORDERS
 
 /*
  * Helper class that handles border rendering.
  *
@@ -93,16 +97,19 @@ public:
                       RectCornerRadii& aBorderRadii,
                       const nscolor* aBorderColors,
                       nsBorderColors* const* aCompositeColors,
                       nscolor aBackgroundColor);
 
   // draw the entire border
   void DrawBorders();
 
+  void CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
+                               mozilla::layers::WebRenderDisplayItemLayer* aLayer);
+
   // utility function used for background painting as well as borders
   static void ComputeInnerRadii(const RectCornerRadii& aRadii,
                                 const Float* aBorderSizes,
                                 RectCornerRadii* aInnerRadiiRet);
 
   // Given aRadii as the border radii for a rectangle, compute the
   // appropriate radii for another rectangle *outside* that rectangle
   // by increasing the radii, except keeping sharp corners sharp.
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -4151,32 +4151,17 @@ nsDisplayOutline::BuildLayer(nsDisplayLi
 }
 
 void
 nsDisplayOutline::CreateWebRenderCommands(wr::DisplayListBuilder& aBuilder,
                                           nsTArray<WebRenderParentCommand>& aParentCommands,
                                           WebRenderDisplayItemLayer* aLayer)
 {
   MOZ_ASSERT(mBorderRenderer.isSome());
-
-  Rect outlineTransformedRect = aLayer->RelativeToParent(mBorderRenderer->mOuterRect);
-
-  nsCSSBorderRenderer* br = mBorderRenderer.ptr();
-  WrBorderSide side[4];
-  NS_FOR_CSS_SIDES(i) {
-    side[i] = wr::ToWrBorderSide(br->mBorderWidths[i], ToDeviceColor(br->mBorderColors[i]), br->mBorderStyles[i]);
-  }
-  WrBorderRadius borderRadius = wr::ToWrBorderRadius(LayerSize(br->mBorderRadii[0].width, br->mBorderRadii[0].height),
-                                                     LayerSize(br->mBorderRadii[1].width, br->mBorderRadii[1].height),
-                                                     LayerSize(br->mBorderRadii[3].width, br->mBorderRadii[3].height),
-                                                     LayerSize(br->mBorderRadii[2].width, br->mBorderRadii[2].height));
-  aBuilder.PushBorder(wr::ToWrRect(outlineTransformedRect),
-                      wr::ToWrRect(outlineTransformedRect),
-                      side[0], side[1], side[2], side[3],
-                      borderRadius);
+  mBorderRenderer->CreateWebRenderCommands(aBuilder, aLayer);
 }
 
 bool
 nsDisplayOutline::IsInvisibleInRect(const nsRect& aRect)
 {
   const nsStyleOutline* outline = mFrame->StyleOutline();
   nsRect borderBox(ToReferenceFrame(), mFrame->GetSize());
   if (borderBox.Contains(aRect) &&