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

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

Issue 16195004: add asserts to point<-->verb helpers (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/pathops/SkPathOpsTypes.h ('k') | src/utils/SkDumpCanvas.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 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 "SkReduceOrder.h" 7 #include "SkReduceOrder.h"
8 8
9 int SkReduceOrder::reduce(const SkDLine& line) { 9 int SkReduceOrder::reduce(const SkDLine& line) {
10 fLine[0] = line[0]; 10 fLine[0] = line[0];
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 quad.set(a); 430 quad.set(a);
431 SkReduceOrder reducer; 431 SkReduceOrder reducer;
432 int order = reducer.reduce(quad, kFill_Style); 432 int order = reducer.reduce(quad, kFill_Style);
433 if (order == 2) { // quad became line 433 if (order == 2) { // quad became line
434 for (int index = 0; index < order; ++index) { 434 for (int index = 0; index < order; ++index) {
435 SkPoint* pt = reducePts->append(); 435 SkPoint* pt = reducePts->append();
436 pt->fX = SkDoubleToScalar(reducer.fLine[index].fX); 436 pt->fX = SkDoubleToScalar(reducer.fLine[index].fX);
437 pt->fY = SkDoubleToScalar(reducer.fLine[index].fY); 437 pt->fY = SkDoubleToScalar(reducer.fLine[index].fY);
438 } 438 }
439 } 439 }
440 return (SkPath::Verb) (order - 1); 440 return SkPathOpsPointsToVerb(order - 1);
441 } 441 }
442 442
443 SkPath::Verb SkReduceOrder::Cubic(const SkPoint a[4], SkTDArray<SkPoint>* reduce Pts) { 443 SkPath::Verb SkReduceOrder::Cubic(const SkPoint a[4], SkTDArray<SkPoint>* reduce Pts) {
444 SkDCubic cubic; 444 SkDCubic cubic;
445 cubic.set(a); 445 cubic.set(a);
446 SkReduceOrder reducer; 446 SkReduceOrder reducer;
447 int order = reducer.reduce(cubic, kAllow_Quadratics, kFill_Style); 447 int order = reducer.reduce(cubic, kAllow_Quadratics, kFill_Style);
448 if (order == 2 || order == 3) { // cubic became line or quad 448 if (order == 2 || order == 3) { // cubic became line or quad
449 for (int index = 0; index < order; ++index) { 449 for (int index = 0; index < order; ++index) {
450 SkPoint* pt = reducePts->append(); 450 SkPoint* pt = reducePts->append();
451 pt->fX = SkDoubleToScalar(reducer.fQuad[index].fX); 451 pt->fX = SkDoubleToScalar(reducer.fQuad[index].fX);
452 pt->fY = SkDoubleToScalar(reducer.fQuad[index].fY); 452 pt->fY = SkDoubleToScalar(reducer.fQuad[index].fY);
453 } 453 }
454 } 454 }
455 return (SkPath::Verb) (order - 1); 455 return SkPathOpsPointsToVerb(order - 1);
456 } 456 }
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsTypes.h ('k') | src/utils/SkDumpCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698