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>
This commit is contained in:
Brian Osman 2020-09-15 11:56:44 -04:00 committed by Skia Commit-Bot
parent 98c512c89d
commit 560ae27890

View File

@ -1578,10 +1578,11 @@ void SkCanvas::clipRect(const SkRect& rect, SkClipOp op, bool doAA) {
}
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));