Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/core/SkGeometry.cpp

Issue 1133113003: remove near one check for arcs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkGeometry.h" 8 #include "SkGeometry.h"
9 #include "SkMatrix.h" 9 #include "SkMatrix.h"
10 #include "SkNx.h" 10 #include "SkNx.h"
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 for (int i = 0; i < conicCount; ++i) { 1550 for (int i = 0; i < conicCount; ++i) {
1551 dst[i].set(&quadrantPts[i * 2], quadrantWeight); 1551 dst[i].set(&quadrantPts[i * 2], quadrantWeight);
1552 } 1552 }
1553 1553
1554 // Now compute any remaing (sub-90-degree) arc for the last conic 1554 // Now compute any remaing (sub-90-degree) arc for the last conic
1555 const SkPoint finalP = { x, y }; 1555 const SkPoint finalP = { x, y };
1556 const SkPoint& lastQ = quadrantPts[quadrant * 2]; // will already be a unit -vector 1556 const SkPoint& lastQ = quadrantPts[quadrant * 2]; // will already be a unit -vector
1557 const SkScalar dot = SkVector::DotProduct(lastQ, finalP); 1557 const SkScalar dot = SkVector::DotProduct(lastQ, finalP);
1558 SkASSERT(0 <= dot && dot <= SK_Scalar1 + SK_ScalarNearlyZero); 1558 SkASSERT(0 <= dot && dot <= SK_Scalar1 + SK_ScalarNearlyZero);
1559 1559
1560 if (dot < 1 - SK_ScalarNearlyZero) { 1560 if (dot < 1) {
1561 SkVector offCurve = { lastQ.x() + x, lastQ.y() + y }; 1561 SkVector offCurve = { lastQ.x() + x, lastQ.y() + y };
1562 // compute the bisector vector, and then rescale to be the off-curve poi nt. 1562 // compute the bisector vector, and then rescale to be the off-curve poi nt.
1563 // we compute its length from cos(theta/2) = length / 1, using half-angl e identity we get 1563 // we compute its length from cos(theta/2) = length / 1, using half-angl e identity we get
1564 // length = sqrt(2 / (1 + cos(theta)). We already have cos() when to com puted the dot. 1564 // length = sqrt(2 / (1 + cos(theta)). We already have cos() when to com puted the dot.
1565 // This is nice, since our computed weight is cos(theta/2) as well! 1565 // This is nice, since our computed weight is cos(theta/2) as well!
1566 // 1566 //
1567 const SkScalar cosThetaOver2 = SkScalarSqrt((1 + dot) / 2); 1567 const SkScalar cosThetaOver2 = SkScalarSqrt((1 + dot) / 2);
1568 offCurve.setLength(SkScalarInvert(cosThetaOver2)); 1568 offCurve.setLength(SkScalarInvert(cosThetaOver2));
1569 dst[conicCount].set(lastQ, offCurve, finalP, cosThetaOver2); 1569 dst[conicCount].set(lastQ, offCurve, finalP, cosThetaOver2);
1570 conicCount += 1; 1570 conicCount += 1;
1571 } 1571 }
1572 1572
1573 // now handle counter-clockwise and the initial unitStart rotation 1573 // now handle counter-clockwise and the initial unitStart rotation
1574 SkMatrix matrix; 1574 SkMatrix matrix;
1575 matrix.setSinCos(uStart.fY, uStart.fX); 1575 matrix.setSinCos(uStart.fY, uStart.fX);
1576 if (dir == kCCW_SkRotationDirection) { 1576 if (dir == kCCW_SkRotationDirection) {
1577 matrix.preScale(SK_Scalar1, -SK_Scalar1); 1577 matrix.preScale(SK_Scalar1, -SK_Scalar1);
1578 } 1578 }
1579 if (userMatrix) { 1579 if (userMatrix) {
1580 matrix.postConcat(*userMatrix); 1580 matrix.postConcat(*userMatrix);
1581 } 1581 }
1582 for (int i = 0; i < conicCount; ++i) { 1582 for (int i = 0; i < conicCount; ++i) {
1583 matrix.mapPoints(dst[i].fPts, 3); 1583 matrix.mapPoints(dst[i].fPts, 3);
1584 } 1584 }
1585 return conicCount; 1585 return conicCount;
1586 } 1586 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698