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

Side by Side Diff: src/gpu/GrPathUtils.cpp

Issue 1694403003: Modify interface to GrPathUtils::convertCubicToQuads (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: whitespace Created 4 years, 10 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 | « src/gpu/GrPathUtils.h ('k') | src/gpu/batches/GrAAConvexPathRenderer.cpp » ('j') | 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 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 "GrPathUtils.h" 8 #include "GrPathUtils.h"
9 9
10 #include "GrTypes.h" 10 #include "GrTypes.h"
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 toleranceSqd, 538 toleranceSqd,
539 constrainWithinTangents, 539 constrainWithinTangents,
540 dir, 540 dir,
541 quads, 541 quads,
542 sublevel + 1); 542 sublevel + 1);
543 } 543 }
544 } 544 }
545 545
546 void GrPathUtils::convertCubicToQuads(const SkPoint p[4], 546 void GrPathUtils::convertCubicToQuads(const SkPoint p[4],
547 SkScalar tolScale, 547 SkScalar tolScale,
548 bool constrainWithinTangents,
549 SkPathPriv::FirstDirection dir,
550 SkTArray<SkPoint, true>* quads) { 548 SkTArray<SkPoint, true>* quads) {
551 SkPoint chopped[10]; 549 SkPoint chopped[10];
552 int count = SkChopCubicAtInflections(p, chopped); 550 int count = SkChopCubicAtInflections(p, chopped);
553 551
554 // base tolerance is 1 pixel. 552 const SkScalar tolSqd = SkScalarSquare(tolScale);
555 static const SkScalar kTolerance = SK_Scalar1;
556 const SkScalar tolSqd = SkScalarSquare(SkScalarMul(tolScale, kTolerance));
557 553
558 for (int i = 0; i < count; ++i) { 554 for (int i = 0; i < count; ++i) {
559 SkPoint* cubic = chopped + 3*i; 555 SkPoint* cubic = chopped + 3*i;
560 convert_noninflect_cubic_to_quads(cubic, tolSqd, constrainWithinTangents , dir, quads); 556 // The direction param is ignored if the third param is false.
557 convert_noninflect_cubic_to_quads(cubic, tolSqd, false,
558 SkPathPriv::kCCW_FirstDirection, quads );
561 } 559 }
560 }
562 561
562 void GrPathUtils::convertCubicToQuadsConstrainToTangents(const SkPoint p[4],
563 SkScalar tolScale,
564 SkPathPriv::FirstDirect ion dir,
565 SkTArray<SkPoint, true> * quads) {
566 SkPoint chopped[10];
567 int count = SkChopCubicAtInflections(p, chopped);
568
569 const SkScalar tolSqd = SkScalarSquare(tolScale);
570
571 for (int i = 0; i < count; ++i) {
572 SkPoint* cubic = chopped + 3*i;
573 convert_noninflect_cubic_to_quads(cubic, tolSqd, true, dir, quads);
574 }
563 } 575 }
564 576
565 //////////////////////////////////////////////////////////////////////////////// 577 ////////////////////////////////////////////////////////////////////////////////
566 578
567 // Solves linear system to extract klm 579 // Solves linear system to extract klm
568 // P.K = k (similarly for l, m) 580 // P.K = k (similarly for l, m)
569 // Where P is matrix of control points 581 // Where P is matrix of control points
570 // K is coefficients for the line K 582 // K is coefficients for the line K
571 // k is vector of values of K evaluated at the control points 583 // k is vector of values of K evaluated at the control points
572 // Solving for K, thus K = P^(-1) . k 584 // Solving for K, thus K = P^(-1) . k
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 set_loop_klm(d, controlK, controlL, controlM); 819 set_loop_klm(d, controlK, controlL, controlM);
808 } else if (kCusp_SkCubicType == cType) { 820 } else if (kCusp_SkCubicType == cType) {
809 SkASSERT(0.f == d[0]); 821 SkASSERT(0.f == d[0]);
810 set_cusp_klm(d, controlK, controlL, controlM); 822 set_cusp_klm(d, controlK, controlL, controlM);
811 } else if (kQuadratic_SkCubicType == cType) { 823 } else if (kQuadratic_SkCubicType == cType) {
812 set_quadratic_klm(d, controlK, controlL, controlM); 824 set_quadratic_klm(d, controlK, controlL, controlM);
813 } 825 }
814 826
815 calc_cubic_klm(p, controlK, controlL, controlM, klm, &klm[3], &klm[6]); 827 calc_cubic_klm(p, controlK, controlL, controlM, klm, &klm[3], &klm[6]);
816 } 828 }
OLDNEW
« no previous file with comments | « src/gpu/GrPathUtils.h ('k') | src/gpu/batches/GrAAConvexPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698