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

Side by Side Diff: src/pathops/SkPathOpsCurve.cpp

Issue 2321973005: Rewriting path writer (Closed)
Patch Set: revert unneeded test changes Created 4 years, 3 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/pathops/SkPathOpsCurve.h ('k') | src/pathops/SkPathOpsDebug.h » ('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 2015 Google Inc. 2 * Copyright 2015 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 #include "SkPathOpsBounds.h" 7 #include "SkPathOpsBounds.h"
8 #include "SkPathOpsRect.h" 8 #include "SkPathOpsRect.h"
9 #include "SkPathOpsCurve.h" 9 #include "SkPathOpsCurve.h"
10 10
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 void SkDCurve::setQuadBounds(const SkPoint curve[3], SkScalar , 82 void SkDCurve::setQuadBounds(const SkPoint curve[3], SkScalar ,
83 double tStart, double tEnd, SkPathOpsBounds* bounds) { 83 double tStart, double tEnd, SkPathOpsBounds* bounds) {
84 SkDQuad dCurve; 84 SkDQuad dCurve;
85 dCurve.set(curve); 85 dCurve.set(curve);
86 SkDRect dRect; 86 SkDRect dRect;
87 dRect.setBounds(dCurve, fQuad, tStart, tEnd); 87 dRect.setBounds(dCurve, fQuad, tStart, tEnd);
88 bounds->set(SkDoubleToScalar(dRect.fLeft), SkDoubleToScalar(dRect.fTop), 88 bounds->set(SkDoubleToScalar(dRect.fLeft), SkDoubleToScalar(dRect.fTop),
89 SkDoubleToScalar(dRect.fRight), SkDoubleToScalar(dRect.fBottom)); 89 SkDoubleToScalar(dRect.fRight), SkDoubleToScalar(dRect.fBottom));
90 } 90 }
91
92 void SkDCurveSweep::setCurveHullSweep(SkPath::Verb verb) {
93 fOrdered = true;
94 fSweep[0] = fCurve[1] - fCurve[0];
95 if (SkPath::kLine_Verb == verb) {
96 fSweep[1] = fSweep[0];
97 fIsCurve = false;
98 return;
99 }
100 fSweep[1] = fCurve[2] - fCurve[0];
101 // OPTIMIZE: I do the following float check a lot -- probably need a
102 // central place for this val-is-small-compared-to-curve check
103 double maxVal = 0;
104 for (int index = 0; index < SkPathOpsVerbToPoints(verb); ++index) {
105 maxVal = SkTMax(maxVal, SkTMax(SkTAbs(fCurve[index].fX),
106 SkTAbs(fCurve[index].fY)));
107 }
108 {
109 if (SkPath::kCubic_Verb != verb) {
110 if (roughly_zero_when_compared_to(fSweep[0].fX, maxVal)
111 && roughly_zero_when_compared_to(fSweep[0].fY, maxVal)) {
112 fSweep[0] = fSweep[1];
113 }
114 goto setIsCurve;
115 }
116 SkDVector thirdSweep = fCurve[3] - fCurve[0];
117 if (fSweep[0].fX == 0 && fSweep[0].fY == 0) {
118 fSweep[0] = fSweep[1];
119 fSweep[1] = thirdSweep;
120 if (roughly_zero_when_compared_to(fSweep[0].fX, maxVal)
121 && roughly_zero_when_compared_to(fSweep[0].fY, maxVal)) {
122 fSweep[0] = fSweep[1];
123 fCurve[1] = fCurve[3];
124 }
125 goto setIsCurve;
126 }
127 double s1x3 = fSweep[0].crossCheck(thirdSweep);
128 double s3x2 = thirdSweep.crossCheck(fSweep[1]);
129 if (s1x3 * s3x2 >= 0) { // if third vector is on or between first two v ectors
130 goto setIsCurve;
131 }
132 double s2x1 = fSweep[1].crossCheck(fSweep[0]);
133 // FIXME: If the sweep of the cubic is greater than 180 degrees, we're i n trouble
134 // probably such wide sweeps should be artificially subdivided earlier s o that never happens
135 SkASSERT(s1x3 * s2x1 < 0 || s1x3 * s3x2 < 0);
136 if (s3x2 * s2x1 < 0) {
137 SkASSERT(s2x1 * s1x3 > 0);
138 fSweep[0] = fSweep[1];
139 fOrdered = false;
140 }
141 fSweep[1] = thirdSweep;
142 }
143 setIsCurve:
144 fIsCurve = fSweep[0].crossCheck(fSweep[1]) != 0;
145 }
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsCurve.h ('k') | src/pathops/SkPathOpsDebug.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698