Bug 931996 - Add an AppendEllipseToPath helper to Moz2D. r=Bas
authorJonathan Watt <jwatt@jwatt.org>
Fri, 01 Nov 2013 13:30:00 +0000
changeset 153227 29a30f4e9ad51ce20d91fda17a2bddcbe459da73
parent 153226 f9b22be50b69ed0b73649267283e5be4f07d54bf
child 153228 09abc00886bdb5eb9c9b8ff7166b5c3014735623
push id35722
push userjwatt@jwatt.org
push dateSat, 02 Nov 2013 07:06:17 +0000
treeherdermozilla-inbound@29a30f4e9ad5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs931996
milestone28.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 931996 - Add an AppendEllipseToPath helper to Moz2D. r=Bas
gfx/2d/PathHelpers.cpp
gfx/2d/PathHelpers.h
--- a/gfx/2d/PathHelpers.cpp
+++ b/gfx/2d/PathHelpers.cpp
@@ -145,11 +145,23 @@ AppendRoundedRectToPath(PathBuilder* aPa
     } else {
       aPathBuilder->LineTo(pc);
     }
   }
 
   aPathBuilder->Close();
 }
 
+void
+AppendEllipseToPath(PathBuilder* aPathBuilder,
+                    const Point& aCenter,
+                    const Size& aDimensions)
+{
+  Size halfDim = aDimensions / 2.0;
+  Rect rect(aCenter - Point(halfDim.width, halfDim.height), aDimensions);
+  Size radii[] = { halfDim, halfDim, halfDim, halfDim };
+
+  AppendRoundedRectToPath(aPathBuilder, rect, radii);
+}
+
 } // namespace gfx
 } // namespace mozilla
 
--- a/gfx/2d/PathHelpers.h
+++ b/gfx/2d/PathHelpers.h
@@ -93,12 +93,23 @@ void ArcToBezier(T* aSink, const Point &
  *                 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);
 
+/**
+ * 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);
+
 } // namespace gfx
 } // namespace mozilla
 
 #endif /* MOZILLA_GFX_PATHHELPERS_H_ */