Bug 1476512 - Part 1: Add RoundedRect clipping API to Moz2D. r=mattwoodrow draft
authorBas Schouten <bschouten@mozilla.com>
Wed, 18 Jul 2018 09:18:29 +0200
changeset 819602 3f3c83ba553bdbb79d850c05ea3cce18aaacfcf9
parent 819601 69cb8f448aab1a188d16164c9390ffcd84d4a890
push id116593
push userbschouten@mozilla.com
push dateWed, 18 Jul 2018 07:19:30 +0000
reviewersmattwoodrow
bugs1476512
milestone63.0a1
Bug 1476512 - Part 1: Add RoundedRect clipping API to Moz2D. r=mattwoodrow MozReview-Commit-ID: DxEgcbqIsCN
gfx/2d/2D.h
gfx/2d/DrawTarget.cpp
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -1225,16 +1225,24 @@ public:
    * Push an axis-aligned rectangular clip to the DrawTarget. This rectangle
    * is specified in user space.
    *
    * @param aRect The rect to clip to
    */
   virtual void PushClipRect(const Rect &aRect) = 0;
 
   /**
+   * Push a rounded rectt clip to the DrawTarget. This rectangle
+   * is specified in user space.
+   *
+   * @param aRect The rounded rect to clip to
+   */
+  virtual void PushClipRoundedRect(const RoundedRect &aRect);
+
+  /**
    * Push a clip region specifed by the union of axis-aligned rectangular
    * clips to the DrawTarget. These rectangles are specified in device space.
    * This must be balanced by a corresponding call to PopClip within a layer.
    *
    * @param aRects The rects to clip to
    * @param aCount The number of rectangles
    */
   virtual void PushDeviceSpaceClipRects(const IntRect* aRects, uint32_t aCount);
--- a/gfx/2d/DrawTarget.cpp
+++ b/gfx/2d/DrawTarget.cpp
@@ -183,16 +183,23 @@ DrawTarget::DrawCapturedDT(DrawTargetCap
   if (aTransform.HasNonIntegerTranslation()) {
     gfxWarning() << "Non integer translations are not supported for DrawCaptureDT at this time!";
     return;
   }
   static_cast<DrawTargetCaptureImpl*>(aCaptureDT)->ReplayToDrawTarget(this, aTransform);
 }
 
 void
+DrawTarget::PushClipRoundedRect(const RoundedRect &aRect)
+{
+  RefPtr<Path> path = MakePathForRoundedRect(*this, aRect);
+  PushClip(path);
+}
+
+void
 DrawTarget::PushDeviceSpaceClipRects(const IntRect* aRects, uint32_t aCount)
 {
   Matrix oldTransform = GetTransform();
   SetTransform(Matrix());
 
   RefPtr<PathBuilder> pathBuilder = CreatePathBuilder();
   for (uint32_t i = 0; i < aCount; i++) {
     AppendRectToPath(pathBuilder, Rect(aRects[i]));