In SkCanvas::clipRect, sort incoming rects
This makes our behavior more consistent with drawRect (where we always
sort rects). It also makes it more consistent between CPU and GPU. (CPU
used a technique to implement rect clipping that allowed for unsorted
rects, but GPU's clip stack would reject them as empty).
Fixes https://github.com/flutter/flutter/issues/38753
Change-Id: Ib91ebaf13d08dfe34105b9ee59021ac491d67bc7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317110
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 9479278..fee7279 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1578,10 +1578,11 @@
}
this->checkForDeferredSave();
ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle;
- this->onClipRect(rect, op, edgeStyle);
+ this->onClipRect(rect.makeSorted(), op, edgeStyle);
}
void SkCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) {
+ SkASSERT(rect.isSorted());
const bool isAA = kSoft_ClipEdgeStyle == edgeStyle;
FOR_EACH_TOP_DEVICE(device->clipRect(rect, op, isAA));