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

Side by Side Diff: bench/PathBench.cpp

Issue 65493004: increase coverage of SkPath.cpp, remove unused code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: increase coverage above 95%; add missing conic case Created 7 years, 1 month 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 | « no previous file | include/core/SkPath.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkBenchmark.h" 8 #include "SkBenchmark.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 SkAutoTArray<SkPath> fCopies; 488 SkAutoTArray<SkPath> fCopies;
489 typedef RandomPathBench INHERITED; 489 typedef RandomPathBench INHERITED;
490 }; 490 };
491 491
492 class SkBench_AddPathTest : public RandomPathBench { 492 class SkBench_AddPathTest : public RandomPathBench {
493 public: 493 public:
494 enum AddType { 494 enum AddType {
495 kAdd_AddType, 495 kAdd_AddType,
496 kAddTrans_AddType, 496 kAddTrans_AddType,
497 kAddMatrix_AddType, 497 kAddMatrix_AddType,
498 kPathTo_AddType,
499 kReverseAdd_AddType, 498 kReverseAdd_AddType,
500 kReversePathTo_AddType, 499 kReversePathTo_AddType,
501 }; 500 };
502 501
503 SkBench_AddPathTest(AddType type) : fType(type) { 502 SkBench_AddPathTest(AddType type) : fType(type) {
504 fMatrix.setRotate(60 * SK_Scalar1); 503 fMatrix.setRotate(60 * SK_Scalar1);
505 } 504 }
506 505
507 protected: 506 protected:
508 virtual const char* onGetName() SK_OVERRIDE { 507 virtual const char* onGetName() SK_OVERRIDE {
509 switch (fType) { 508 switch (fType) {
510 case kAdd_AddType: 509 case kAdd_AddType:
511 return "path_add_path"; 510 return "path_add_path";
512 case kAddTrans_AddType: 511 case kAddTrans_AddType:
513 return "path_add_path_trans"; 512 return "path_add_path_trans";
514 case kAddMatrix_AddType: 513 case kAddMatrix_AddType:
515 return "path_add_path_matrix"; 514 return "path_add_path_matrix";
516 case kPathTo_AddType:
517 return "path_path_to";
518 case kReverseAdd_AddType: 515 case kReverseAdd_AddType:
519 return "path_reverse_add_path"; 516 return "path_reverse_add_path";
520 case kReversePathTo_AddType: 517 case kReversePathTo_AddType:
521 return "path_reverse_path_to"; 518 return "path_reverse_path_to";
522 default: 519 default:
523 SkDEBUGFAIL("Bad add type"); 520 SkDEBUGFAIL("Bad add type");
524 return ""; 521 return "";
525 } 522 }
526 } 523 }
527 524
528 virtual void onPreDraw() SK_OVERRIDE { 525 virtual void onPreDraw() SK_OVERRIDE {
529 // pathTo and reversePathTo assume a single contour path. 526 // reversePathTo assumes a single contour path.
530 bool allowMoves = kPathTo_AddType != fType && 527 bool allowMoves = kReversePathTo_AddType != fType;
531 kReversePathTo_AddType != fType;
532 this->createData(10, 100, allowMoves); 528 this->createData(10, 100, allowMoves);
533 fPaths0.reset(kPathCnt); 529 fPaths0.reset(kPathCnt);
534 fPaths1.reset(kPathCnt); 530 fPaths1.reset(kPathCnt);
535 for (int i = 0; i < kPathCnt; ++i) { 531 for (int i = 0; i < kPathCnt; ++i) {
536 this->makePath(&fPaths0[i]); 532 this->makePath(&fPaths0[i]);
537 this->makePath(&fPaths1[i]); 533 this->makePath(&fPaths1[i]);
538 } 534 }
539 this->finishedMakingPaths(); 535 this->finishedMakingPaths();
540 } 536 }
541 537
(...skipping 13 matching lines...) Expand all
555 result.addPath(fPaths1[idx], 2 * SK_Scalar1, 5 * SK_Scalar1) ; 551 result.addPath(fPaths1[idx], 2 * SK_Scalar1, 5 * SK_Scalar1) ;
556 } 552 }
557 break; 553 break;
558 case kAddMatrix_AddType: 554 case kAddMatrix_AddType:
559 for (int i = 0; i < this->getLoops(); ++i) { 555 for (int i = 0; i < this->getLoops(); ++i) {
560 int idx = i & (kPathCnt - 1); 556 int idx = i & (kPathCnt - 1);
561 SkPath result = fPaths0[idx]; 557 SkPath result = fPaths0[idx];
562 result.addPath(fPaths1[idx], fMatrix); 558 result.addPath(fPaths1[idx], fMatrix);
563 } 559 }
564 break; 560 break;
565 case kPathTo_AddType:
566 for (int i = 0; i < this->getLoops(); ++i) {
567 int idx = i & (kPathCnt - 1);
568 SkPath result = fPaths0[idx];
569 result.pathTo(fPaths1[idx]);
570 }
571 break;
572 case kReverseAdd_AddType: 561 case kReverseAdd_AddType:
573 for (int i = 0; i < this->getLoops(); ++i) { 562 for (int i = 0; i < this->getLoops(); ++i) {
574 int idx = i & (kPathCnt - 1); 563 int idx = i & (kPathCnt - 1);
575 SkPath result = fPaths0[idx]; 564 SkPath result = fPaths0[idx];
576 result.reverseAddPath(fPaths1[idx]); 565 result.reverseAddPath(fPaths1[idx]);
577 } 566 }
578 break; 567 break;
579 case kReversePathTo_AddType: 568 case kReversePathTo_AddType:
580 for (int i = 0; i < this->getLoops(); ++i) { 569 for (int i = 0; i < this->getLoops(); ++i) {
581 int idx = i & (kPathCnt - 1); 570 int idx = i & (kPathCnt - 1);
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 1018
1030 DEF_BENCH( return new PathCreateBench(); ) 1019 DEF_BENCH( return new PathCreateBench(); )
1031 DEF_BENCH( return new PathCopyBench(); ) 1020 DEF_BENCH( return new PathCopyBench(); )
1032 DEF_BENCH( return new PathTransformBench(true); ) 1021 DEF_BENCH( return new PathTransformBench(true); )
1033 DEF_BENCH( return new PathTransformBench(false); ) 1022 DEF_BENCH( return new PathTransformBench(false); )
1034 DEF_BENCH( return new PathEqualityBench(); ) 1023 DEF_BENCH( return new PathEqualityBench(); )
1035 1024
1036 DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kAdd_AddType); ) 1025 DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kAdd_AddType); )
1037 DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kAddTrans_AddType ); ) 1026 DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kAddTrans_AddType ); )
1038 DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kAddMatrix_AddTyp e); ) 1027 DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kAddMatrix_AddTyp e); )
1039 DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kPathTo_AddType); )
1040 DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kReverseAdd_AddTy pe); ) 1028 DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kReverseAdd_AddTy pe); )
1041 DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kReversePathTo_Ad dType); ) 1029 DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kReversePathTo_Ad dType); )
1042 1030
1043 DEF_BENCH( return new CirclesBench(FLAGS00); ) 1031 DEF_BENCH( return new CirclesBench(FLAGS00); )
1044 DEF_BENCH( return new CirclesBench(FLAGS01); ) 1032 DEF_BENCH( return new CirclesBench(FLAGS01); )
1045 DEF_BENCH( return new ArbRoundRectBench(false); ) 1033 DEF_BENCH( return new ArbRoundRectBench(false); )
1046 DEF_BENCH( return new ArbRoundRectBench(true); ) 1034 DEF_BENCH( return new ArbRoundRectBench(true); )
1047 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k Rect_Type); ) 1035 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k Rect_Type); )
1048 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k RoundRect_Type); ) 1036 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k RoundRect_Type); )
1049 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k Oval_Type); ) 1037 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k Oval_Type); )
1050 1038
1051 DEF_BENCH( return new ConicBench_Chop5() ) 1039 DEF_BENCH( return new ConicBench_Chop5() )
1052 DEF_BENCH( return new ConicBench_ChopHalf() ) 1040 DEF_BENCH( return new ConicBench_ChopHalf() )
1053 DEF_BENCH( return new ConicBench_ComputeError() ) 1041 DEF_BENCH( return new ConicBench_ComputeError() )
1054 DEF_BENCH( return new ConicBench_asQuadTol() ) 1042 DEF_BENCH( return new ConicBench_asQuadTol() )
1055 DEF_BENCH( return new ConicBench_quadPow2() ) 1043 DEF_BENCH( return new ConicBench_quadPow2() )
OLDNEW
« no previous file with comments | « no previous file | include/core/SkPath.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698