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

Side by Side Diff: tests/PathOpsTestCommon.cpp

Issue 1107353004: align top and bounds computations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up code 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 | « tests/PathOpsOpTest.cpp ('k') | tools/pathops_sorter.htm » ('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 2012 Google Inc. 2 * Copyright 2012 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 "PathOpsTestCommon.h" 7 #include "PathOpsTestCommon.h"
8 #include "SkPathOpsBounds.h" 8 #include "SkPathOpsBounds.h"
9 #include "SkPathOpsConic.h" 9 #include "SkPathOpsConic.h"
10 #include "SkPathOpsCubic.h" 10 #include "SkPathOpsCubic.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 SkTArray<double, true> ts; 134 SkTArray<double, true> ts;
135 toQuadraticTs(&cubic, precision, &ts); 135 toQuadraticTs(&cubic, precision, &ts);
136 if (ts.count() <= 0) { 136 if (ts.count() <= 0) {
137 SkDQuad quad = cubic.toQuad(); 137 SkDQuad quad = cubic.toQuad();
138 quads.push_back(quad); 138 quads.push_back(quad);
139 return; 139 return;
140 } 140 }
141 double tStart = 0; 141 double tStart = 0;
142 for (int i1 = 0; i1 <= ts.count(); ++i1) { 142 for (int i1 = 0; i1 <= ts.count(); ++i1) {
143 const double tEnd = i1 < ts.count() ? ts[i1] : 1; 143 const double tEnd = i1 < ts.count() ? ts[i1] : 1;
144 SkDRect bounds;
145 bounds.setBounds(cubic);
144 SkDCubic part = cubic.subDivide(tStart, tEnd); 146 SkDCubic part = cubic.subDivide(tStart, tEnd);
145 SkDQuad quad = part.toQuad(); 147 SkDQuad quad = part.toQuad();
148 if (quad[1].fX < bounds.fLeft) {
149 quad[1].fX = bounds.fLeft;
150 } else if (quad[1].fX > bounds.fRight) {
151 quad[1].fX = bounds.fRight;
152 }
153 if (quad[1].fY < bounds.fTop) {
154 quad[1].fY = bounds.fTop;
155 } else if (quad[1].fY > bounds.fBottom) {
156 quad[1].fY = bounds.fBottom;
157 }
146 quads.push_back(quad); 158 quads.push_back(quad);
147 tStart = tEnd; 159 tStart = tEnd;
148 } 160 }
149 } 161 }
150 162
151 void CubicPathToQuads(const SkPath& cubicPath, SkPath* quadPath) { 163 void CubicPathToQuads(const SkPath& cubicPath, SkPath* quadPath) {
152 quadPath->reset(); 164 quadPath->reset();
153 SkDCubic cubic; 165 SkDCubic cubic;
154 SkTArray<SkDQuad, true> quads; 166 SkTArray<SkDQuad, true> quads;
155 SkPath::RawIter iter(cubicPath); 167 SkPath::RawIter iter(cubicPath);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 322 }
311 return true; 323 return true;
312 } 324 }
313 325
314 bool ValidVector(const SkDVector& v) { 326 bool ValidVector(const SkDVector& v) {
315 if (SkDoubleIsNaN(v.fX)) { 327 if (SkDoubleIsNaN(v.fX)) {
316 return false; 328 return false;
317 } 329 }
318 return !SkDoubleIsNaN(v.fY); 330 return !SkDoubleIsNaN(v.fY);
319 } 331 }
OLDNEW
« no previous file with comments | « tests/PathOpsOpTest.cpp ('k') | tools/pathops_sorter.htm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698