aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2017-04-20 17:25:26 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-21 13:28:45 +0000
commitd952a9929b2dc826955249c755b6fed5627491c2 (patch)
treeef150bfcaea7e1779be3f6b15f13646f8650854a
parent2af746c1e74af30d0fb02d5c35a178e61d152965 (diff)
Fix reflected ovals.
Addresses an issue with ovals transformed by a matrix with a reflection. Also adds a further check for circles to ensure that teeny tiny ovals (sizes < SK_ScalarNearlyZero) aren't treated as circles. Change-Id: Ie50e4a98365eba7c23e53e68886ebac981ed1def Reviewed-on: https://skia-review.googlesource.com/13989 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
-rw-r--r--gm/ovals.cpp20
-rw-r--r--src/gpu/ops/GrOvalOpFactory.cpp7
2 files changed, 24 insertions, 3 deletions
diff --git a/gm/ovals.cpp b/gm/ovals.cpp
index ec9bd75d47..d6afdcbba7 100644
--- a/gm/ovals.cpp
+++ b/gm/ovals.cpp
@@ -268,6 +268,26 @@ protected:
canvas->restore();
}
+
+ // reflected oval
+ for (int i = 0; i < fPaints.count(); ++i) {
+ SkRect oval = SkRect::MakeLTRB(-30, -30, 30, 30);
+ canvas->save();
+ // position the oval, and make it at off-integer coords.
+ canvas->translate(kXStart + SK_Scalar1 * kXStep * 5 + SK_Scalar1 / 4,
+ kYStart + SK_Scalar1 * kYStep * i + 3 * SK_Scalar1 / 4 +
+ SK_ScalarHalf * kYStep);
+ canvas->rotate(90);
+ canvas->scale(1, -1);
+ canvas->scale(1, 0.66f);
+
+ SkColor color = genColor(&rand);
+ fPaints[i].setColor(color);
+
+ canvas->drawRect(oval, rectPaint);
+ canvas->drawOval(oval, fPaints[i]);
+ canvas->restore();
+ }
}
private:
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index e00ee0b24d..71f8bb089f 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -1172,8 +1172,8 @@ public:
SkScalar ellipseXRadius = SkScalarHalf(ellipse.width());
SkScalar ellipseYRadius = SkScalarHalf(ellipse.height());
SkScalar xRadius = SkScalarAbs(viewMatrix[SkMatrix::kMScaleX] * ellipseXRadius +
- viewMatrix[SkMatrix::kMSkewY] * ellipseYRadius);
- SkScalar yRadius = SkScalarAbs(viewMatrix[SkMatrix::kMSkewX] * ellipseXRadius +
+ viewMatrix[SkMatrix::kMSkewX] * ellipseYRadius);
+ SkScalar yRadius = SkScalarAbs(viewMatrix[SkMatrix::kMSkewY] * ellipseXRadius +
viewMatrix[SkMatrix::kMScaleY] * ellipseYRadius);
// do (potentially) anisotropic mapping of stroke
@@ -2385,7 +2385,8 @@ std::unique_ptr<GrLegacyMeshDrawOp> GrOvalOpFactory::MakeOvalOp(GrColor color,
const GrShaderCaps* shaderCaps) {
// we can draw circles
SkScalar width = oval.width();
- if (SkScalarNearlyEqual(width, oval.height()) && circle_stays_circle(viewMatrix)) {
+ if (width > SK_ScalarNearlyZero && SkScalarNearlyEqual(width, oval.height()) &&
+ circle_stays_circle(viewMatrix)) {
SkPoint center = {oval.centerX(), oval.centerY()};
return CircleOp::Make(color, viewMatrix, center, width / 2.f, GrStyle(stroke, nullptr));
}