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

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

Issue 16951017: convert pathops to use SkSTArray where possible. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: pathops use SkTArray 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/SkReduceOrder.h ('k') | tests/PathOpsCubicIntersectionTest.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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 return result; 418 return result;
419 } 419 }
420 if (allowQuadratics == SkReduceOrder::kAllow_Quadratics 420 if (allowQuadratics == SkReduceOrder::kAllow_Quadratics
421 && (result = check_quadratic(cubic, fCubic))) { 421 && (result = check_quadratic(cubic, fCubic))) {
422 return result; 422 return result;
423 } 423 }
424 fCubic = cubic; 424 fCubic = cubic;
425 return 4; 425 return 4;
426 } 426 }
427 427
428 SkPath::Verb SkReduceOrder::Quad(const SkPoint a[3], SkTDArray<SkPoint>* reduceP ts) { 428 SkPath::Verb SkReduceOrder::Quad(const SkPoint a[3], SkTArray<SkPoint, true>* re ducePts) {
429 SkDQuad quad; 429 SkDQuad quad;
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->push_back();
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 SkPathOpsPointsToVerb(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], SkTArray<SkPoint, true>* r educePts) {
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->push_back();
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 SkPathOpsPointsToVerb(order - 1); 455 return SkPathOpsPointsToVerb(order - 1);
456 } 456 }
OLDNEW
« no previous file with comments | « src/pathops/SkReduceOrder.h ('k') | tests/PathOpsCubicIntersectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698