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

Side by Side Diff: bench/PathBench.cpp

Issue 73643005: Implement a benchmark for GrResourceCache (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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
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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 } 210 }
211 } 211 }
212 virtual int complexity() SK_OVERRIDE { return 2; } 212 virtual int complexity() SK_OVERRIDE { return 2; }
213 private: 213 private:
214 typedef PathBench INHERITED; 214 typedef PathBench INHERITED;
215 }; 215 };
216 216
217 class RandomPathBench : public SkBenchmark { 217 class RandomPathBench : public SkBenchmark {
218 public: 218 public:
219 RandomPathBench() { 219 RandomPathBench() {
220 fIsRendering = false; 220 }
221
222 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
223 return backend == kNonRendering_Backend;
221 } 224 }
222 225
223 protected: 226 protected:
224 void createData(int minVerbs, 227 void createData(int minVerbs,
225 int maxVerbs, 228 int maxVerbs,
226 bool allowMoves = true, 229 bool allowMoves = true,
227 SkRect* bounds = NULL) { 230 SkRect* bounds = NULL) {
228 SkRect tempBounds; 231 SkRect tempBounds;
229 if (NULL == bounds) { 232 if (NULL == bounds) {
230 tempBounds.setXYWH(0, 0, SK_Scalar1, SK_Scalar1); 233 tempBounds.setXYWH(0, 0, SK_Scalar1, SK_Scalar1);
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 757
755 class ConservativelyContainsBench : public SkBenchmark { 758 class ConservativelyContainsBench : public SkBenchmark {
756 public: 759 public:
757 enum Type { 760 enum Type {
758 kRect_Type, 761 kRect_Type,
759 kRoundRect_Type, 762 kRoundRect_Type,
760 kOval_Type, 763 kOval_Type,
761 }; 764 };
762 765
763 ConservativelyContainsBench(Type type) { 766 ConservativelyContainsBench(Type type) {
764 fIsRendering = false;
765 fParity = false; 767 fParity = false;
766 fName = "conservatively_contains_"; 768 fName = "conservatively_contains_";
767 switch (type) { 769 switch (type) {
768 case kRect_Type: 770 case kRect_Type:
769 fName.append("rect"); 771 fName.append("rect");
770 fPath.addRect(kBaseRect); 772 fPath.addRect(kBaseRect);
771 break; 773 break;
772 case kRoundRect_Type: 774 case kRoundRect_Type:
773 fName.append("round_rect"); 775 fName.append("round_rect");
774 fPath.addRoundRect(kBaseRect, kRRRadii[0], kRRRadii[1]); 776 fPath.addRoundRect(kBaseRect, kRRRadii[0], kRRRadii[1]);
775 break; 777 break;
776 case kOval_Type: 778 case kOval_Type:
777 fName.append("oval"); 779 fName.append("oval");
778 fPath.addOval(kBaseRect); 780 fPath.addOval(kBaseRect);
779 break; 781 break;
780 } 782 }
781 } 783 }
782 784
785 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
786 return backend == kNonRendering_Backend;
787 }
788
783 private: 789 private:
784 virtual const char* onGetName() SK_OVERRIDE { 790 virtual const char* onGetName() SK_OVERRIDE {
785 return fName.c_str(); 791 return fName.c_str();
786 } 792 }
787 793
788 virtual void onDraw(SkCanvas*) SK_OVERRIDE { 794 virtual void onDraw(SkCanvas*) SK_OVERRIDE {
789 for (int i = 0; i < this->getLoops(); ++i) { 795 for (int i = 0; i < this->getLoops(); ++i) {
790 const SkRect& rect = fQueryRects[i % kQueryRectCnt]; 796 const SkRect& rect = fQueryRects[i % kQueryRectCnt];
791 fParity = fParity != fPath.conservativelyContainsRect(rect); 797 fParity = fParity != fPath.conservativelyContainsRect(rect);
792 } 798 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 } 902 }
897 } 903 }
898 904
899 class ConicBench : public SkBenchmark { 905 class ConicBench : public SkBenchmark {
900 public: 906 public:
901 ConicBench() { 907 ConicBench() {
902 SkRandom rand; 908 SkRandom rand;
903 for (int i = 0; i < CONICS; ++i) { 909 for (int i = 0; i < CONICS; ++i) {
904 rand_conic(&fConics[i], rand); 910 rand_conic(&fConics[i], rand);
905 } 911 }
906 fIsRendering = false; 912 }
913
914 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
915 return backend == kNonRendering_Backend;
907 } 916 }
908 917
909 protected: 918 protected:
910 enum { 919 enum {
911 CONICS = 100 920 CONICS = 100
912 }; 921 };
913 SkConic fConics[CONICS]; 922 SkConic fConics[CONICS];
914 923
915 private: 924 private:
916 typedef SkBenchmark INHERITED; 925 typedef SkBenchmark INHERITED;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 DEF_BENCH( return new ArbRoundRectBench(true); ) 1043 DEF_BENCH( return new ArbRoundRectBench(true); )
1035 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k Rect_Type); ) 1044 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k Rect_Type); )
1036 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k RoundRect_Type); ) 1045 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k RoundRect_Type); )
1037 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k Oval_Type); ) 1046 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k Oval_Type); )
1038 1047
1039 DEF_BENCH( return new ConicBench_Chop5() ) 1048 DEF_BENCH( return new ConicBench_Chop5() )
1040 DEF_BENCH( return new ConicBench_ChopHalf() ) 1049 DEF_BENCH( return new ConicBench_ChopHalf() )
1041 DEF_BENCH( return new ConicBench_ComputeError() ) 1050 DEF_BENCH( return new ConicBench_ComputeError() )
1042 DEF_BENCH( return new ConicBench_asQuadTol() ) 1051 DEF_BENCH( return new ConicBench_asQuadTol() )
1043 DEF_BENCH( return new ConicBench_quadPow2() ) 1052 DEF_BENCH( return new ConicBench_quadPow2() )
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698