aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-05-17 11:43:11 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-17 16:08:06 +0000
commitfd773fb508001bab4bccd580e09e82e3541386db (patch)
treed503243b3fc49f2c510c015307a7a515e4f4716f /src
parente3cd691090cadd09c121d670e535fa7cb3230686 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/ops/GrOvalOpFactory.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index 5110ccfb40..623ec7ab7f 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -703,6 +703,18 @@ public:
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