From a925bb07ad71183a0fb498ef478c9707bceb81af Mon Sep 17 00:00:00 2001 From: Jim Van Verth Date: Tue, 25 Sep 2018 10:49:52 -0400 Subject: [PATCH] Don't draw device-independent ellipses with degenerate matrix Bug: oss-fuzz:9012 Change-Id: I93242447e20d0dda7740a31ad330e0fccdb56fc8 Reviewed-on: https://skia-review.googlesource.com/156800 Reviewed-by: Robert Phillips Commit-Queue: Jim Van Verth --- src/gpu/ops/GrOvalOpFactory.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp index c73937486e..0f36c1b6bd 100644 --- a/src/gpu/ops/GrOvalOpFactory.cpp +++ b/src/gpu/ops/GrOvalOpFactory.cpp @@ -3196,7 +3196,15 @@ std::unique_ptr GrOvalOpFactory::MakeOvalOp(GrContext* context, // Otherwise, if we have shader derivative support, render as device-independent if (shaderCaps->shaderDerivativeSupport()) { - return DIEllipseOp::Make(context, std::move(paint), viewMatrix, oval, style.strokeRec()); + SkScalar a = viewMatrix[SkMatrix::kMScaleX]; + SkScalar b = viewMatrix[SkMatrix::kMSkewX]; + SkScalar c = viewMatrix[SkMatrix::kMSkewY]; + SkScalar d = viewMatrix[SkMatrix::kMScaleY]; + // Check for near-degenerate matrix + if (a*a + c*c > SK_ScalarNearlyZero && b*b + d*d > SK_ScalarNearlyZero) { + return DIEllipseOp::Make(context, std::move(paint), viewMatrix, oval, + style.strokeRec()); + } } return nullptr;