Adjust start and end points of arcs based on CTM
GPU was effectively ignoring rotation and scale when drawing arcs. Found
this with a new GM I'll be adding. Hoping to land that separately.
Bug: skia:
Change-Id: I14d36ceaa478193c1a75fb2d06704e7d51f46d02
Reviewed-on: https://skia-review.googlesource.com/17218
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index 5110ccf..623ec7a 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -703,6 +703,18 @@
startPoint.fY = SkScalarSinCos(arcParams->fStartAngleRadians, &startPoint.fX);
SkScalar endAngle = arcParams->fStartAngleRadians + arcParams->fSweepAngleRadians;
stopPoint.fY = SkScalarSinCos(endAngle, &stopPoint.fX);
+
+ // Adjust the start and end points based on the view matrix (to handle rotated arcs)
+ startPoint = viewMatrix.mapVector(startPoint.fX, startPoint.fY);
+ stopPoint = viewMatrix.mapVector(stopPoint.fX, stopPoint.fY);
+ startPoint.normalize();
+ stopPoint.normalize();
+
+ // If the matrix included scale (on one axis) we need to swap our start and end points
+ if ((viewMatrix.getScaleX() < 0) != (viewMatrix.getScaleY() < 0)) {
+ SkTSwap(startPoint, stopPoint);
+ }
+
// Like a fill without useCenter, butt-cap stroke can be implemented by clipping against
// radial lines. However, in both cases we have to be careful about the half-circle.
// case. In that case the two radial lines are equal and so that edge gets clipped