Bug 1520877 - Part 1: Add an API for filling rounded rects. r=mattwoodrow
authorBas Schouten <bschouten@mozilla.com>
Thu, 17 Jan 2019 20:16:34 +0100
changeset 511624 5ab4532b7850be80c87121325321774c7bcb1d3e
parent 511623 5f4630838d46dd81dadb13220a4af0da9e23a619
child 511625 1d614d0ffdc104414c18c108c6c75c93dbd459c4
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1520877
milestone66.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 1520877 - Part 1: Add an API for filling rounded rects. r=mattwoodrow Differential Revision: https://phabricator.services.mozilla.com/D16892
gfx/2d/2D.h
gfx/2d/DrawTarget.cpp
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -1054,16 +1054,28 @@ class DrawTarget : public external::Atom
    * @param aRect Rectangle that forms the mask of this filling operation
    * @param aPattern Pattern that forms the source of this filling operation
    * @param aOptions Options that are applied to this operation
    */
   virtual void FillRect(const Rect &aRect, const Pattern &aPattern,
                         const DrawOptions &aOptions = DrawOptions()) = 0;
 
   /**
+   * Fill a rounded rectangle on the DrawTarget with a certain source pattern.
+   *
+   * @param aRect Rounded rectangle that forms the mask of this filling
+   * operation
+   * @param aPattern Pattern that forms the source of this filling operation
+   * @param aOptions Options that are applied to this operation
+   */
+  virtual void FillRoundedRect(const RoundedRect &aRect,
+                               const Pattern &aPattern,
+                               const DrawOptions &aOptions = DrawOptions());
+
+  /**
    * Stroke a rectangle on the DrawTarget with a certain source pattern.
    *
    * @param aRect Rectangle that forms the mask of this stroking operation
    * @param aPattern Pattern that forms the source of this stroking operation
    * @param aOptions Options that are applied to this operation
    */
   virtual void StrokeRect(const Rect &aRect, const Pattern &aPattern,
                           const StrokeOptions &aStrokeOptions = StrokeOptions(),
--- a/gfx/2d/DrawTarget.cpp
+++ b/gfx/2d/DrawTarget.cpp
@@ -178,16 +178,23 @@ void DrawTarget::PushDeviceSpaceClipRect
     AppendRectToPath(pathBuilder, Rect(aRects[i]));
   }
   RefPtr<Path> path = pathBuilder->Finish();
   PushClip(path);
 
   SetTransform(oldTransform);
 }
 
+void DrawTarget::FillRoundedRect(const RoundedRect& aRect,
+                                 const Pattern& aPattern,
+                                 const DrawOptions& aOptions) {
+  RefPtr<Path> path = MakePathForRoundedRect(*this, aRect.rect, aRect.corners);
+  Fill(path, aPattern, aOptions);
+}
+
 void DrawTarget::StrokeGlyphs(ScaledFont* aFont, const GlyphBuffer& aBuffer,
                               const Pattern& aPattern,
                               const StrokeOptions& aStrokeOptions,
                               const DrawOptions& aOptions) {
   RefPtr<Path> path = aFont->GetPathForGlyphs(aBuffer, this);
   Stroke(path, aPattern, aStrokeOptions, aOptions);
 }