Bug 1476512 - Part 1: Add RoundedRect clipping API to Moz2D. r=mattwoodrow
MozReview-Commit-ID: DxEgcbqIsCN
--- 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]));