Fix special case in SkRRect::setOval where the oval devolves to a rect
Bug:1119593
Change-Id: I6c25c54840f44b5143e40b4ec5da403a737e9d1c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/326441
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/include/core/SkRRect.h b/include/core/SkRRect.h
index 2a4f73c..b0ee03b 100644
--- a/include/core/SkRRect.h
+++ b/include/core/SkRRect.h
@@ -193,10 +193,16 @@
SkScalar xRad = SkScalarHalf(fRect.width());
SkScalar yRad = SkScalarHalf(fRect.height());
- for (int i = 0; i < 4; ++i) {
- fRadii[i].set(xRad, yRad);
+ if (xRad == 0.0f || yRad == 0.0f) {
+ // All the corners will be square
+ memset(fRadii, 0, sizeof(fRadii));
+ fType = kRect_Type;
+ } else {
+ for (int i = 0; i < 4; ++i) {
+ fRadii[i].set(xRad, yRad);
+ }
+ fType = kOval_Type;
}
- fType = kOval_Type;
SkASSERT(this->isValid());
}