Bug 1085533, part 1 - Add MakePathForRoundedRect and MakePathForEllipse helpers to Moz2D. r=mattwoodrow
authorJonathan Watt <jwatt@jwatt.org>
Fri, 24 Oct 2014 08:26:28 +0100
changeset 212081 6decbde116bc7f899ae63c0dbf503895da1b88f6
parent 212080 6ec7bc95ee48da3531fc3a65b55bf4c7fd65fb04
child 212082 15f6514447d6369b5b8f6818491e93e50f9d2c43
push id27697
push usercbook@mozilla.com
push dateFri, 24 Oct 2014 13:48:53 +0000
treeherdermozilla-central@de805196bbc4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1085533
milestone36.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 1085533, part 1 - Add MakePathForRoundedRect and MakePathForEllipse helpers to Moz2D. r=mattwoodrow
gfx/2d/PathHelpers.h
--- a/gfx/2d/PathHelpers.h
+++ b/gfx/2d/PathHelpers.h
@@ -141,27 +141,46 @@ void EllipseToBezier(T* aSink, const Poi
  *                 start at the right of the top left edge and draw counter-
  *                 clockwise.
  */
 GFX2D_API void AppendRoundedRectToPath(PathBuilder* aPathBuilder,
                                        const Rect& aRect,
                                        const Size(& aCornerRadii)[4],
                                        bool aDrawClockwise = true);
 
+inline TemporaryRef<Path> MakePathForRoundedRect(const DrawTarget& aDrawTarget,
+                                                 const Rect& aRect,
+                                                 const Size(& aCornerRadii)[4],
+                                                 bool aDrawClockwise = true)
+{
+  RefPtr<PathBuilder> builder = aDrawTarget.CreatePathBuilder();
+  AppendRoundedRectToPath(builder, aRect, aCornerRadii, aDrawClockwise);
+  return builder->Finish();
+}
+
 /**
  * Appends a path represending an ellipse to the path being built by
  * aPathBuilder.
  *
  * The ellipse extends aDimensions.width / 2.0 in the horizontal direction
  * from aCenter, and aDimensions.height / 2.0 in the vertical direction.
  */
 GFX2D_API void AppendEllipseToPath(PathBuilder* aPathBuilder,
                                    const Point& aCenter,
                                    const Size& aDimensions);
 
+inline TemporaryRef<Path> MakePathForEllipse(const DrawTarget& aDrawTarget,
+                                             const Point& aCenter,
+                                             const Size& aDimensions)
+{
+  RefPtr<PathBuilder> builder = aDrawTarget.CreatePathBuilder();
+  AppendEllipseToPath(builder, aCenter, aDimensions);
+  return builder->Finish();
+}
+
 /**
  * If aDrawTarget's transform only contains a translation, and if this line is
  * a horizontal or vertical line, this function will snap the line's vertices
  * to align with the device pixel grid so that stroking the line with a one
  * pixel wide stroke will result in a crisp line that is not antialiased over
  * two pixels across its width.
  *
  * @return Returns true if this function snaps aRect's vertices, else returns