| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 | 7 |
| 8 #include "SkBenchmark.h" | 8 #include "Benchmark.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
| 11 #include "SkRandom.h" | 11 #include "SkRandom.h" |
| 12 #include "SkShader.h" | 12 #include "SkShader.h" |
| 13 #include "SkString.h" | 13 #include "SkString.h" |
| 14 | 14 |
| 15 #if SK_SUPPORT_GPU | 15 #if SK_SUPPORT_GPU |
| 16 #include "GrDrawTargetCaps.h" |
| 16 #include "GrTest.h" | 17 #include "GrTest.h" |
| 17 #include "GrDrawTargetCaps.h" | |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 enum Flags { | 20 enum Flags { |
| 21 kBig_Flag = 1 << 0, | 21 kBig_Flag = 1 << 0, |
| 22 kAA_Flag = 1 << 1 | 22 kAA_Flag = 1 << 1 |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 #define FLAGS00 Flags(0) | 25 #define FLAGS00 Flags(0) |
| 26 #define FLAGS01 Flags(kBig_Flag) | 26 #define FLAGS01 Flags(kBig_Flag) |
| 27 #define FLAGS10 Flags(kAA_Flag) | 27 #define FLAGS10 Flags(kAA_Flag) |
| 28 #define FLAGS11 Flags(kBig_Flag | kAA_Flag) | 28 #define FLAGS11 Flags(kBig_Flag | kAA_Flag) |
| 29 | 29 |
| 30 static const int points[] = { | 30 static const int points[] = { |
| 31 10, 10, 15, 5, 20, 20, | 31 10, 10, 15, 5, 20, 20, |
| 32 30, 5, 25, 20, 15, 12, | 32 30, 5, 25, 20, 15, 12, |
| 33 21, 21, 30, 30, 12, 4, | 33 21, 21, 30, 30, 12, 4, |
| 34 32, 28, 20, 18, 12, 10 | 34 32, 28, 20, 18, 12, 10 |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 static const int kMaxPathSize = 10; | 37 static const int kMaxPathSize = 10; |
| 38 | 38 |
| 39 class HairlinePathBench : public SkBenchmark { | 39 class HairlinePathBench : public Benchmark { |
| 40 public: | 40 public: |
| 41 HairlinePathBench(Flags flags) : fFlags(flags) { | 41 HairlinePathBench(Flags flags) : fFlags(flags) { |
| 42 fPaint.setStyle(SkPaint::kStroke_Style); | 42 fPaint.setStyle(SkPaint::kStroke_Style); |
| 43 fPaint.setStrokeWidth(SkIntToScalar(0)); | 43 fPaint.setStrokeWidth(SkIntToScalar(0)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 virtual void appendName(SkString*) = 0; | 46 virtual void appendName(SkString*) = 0; |
| 47 virtual void makePath(SkPath*) = 0; | 47 virtual void makePath(SkPath*) = 0; |
| 48 | 48 |
| 49 protected: | 49 protected: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 71 | 71 |
| 72 for (int i = 0; i < loops; i++) { | 72 for (int i = 0; i < loops; i++) { |
| 73 canvas->drawPath(path, paint); | 73 canvas->drawPath(path, paint); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 SkPaint fPaint; | 78 SkPaint fPaint; |
| 79 SkString fName; | 79 SkString fName; |
| 80 Flags fFlags; | 80 Flags fFlags; |
| 81 typedef SkBenchmark INHERITED; | 81 typedef Benchmark INHERITED; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 class LinePathBench : public HairlinePathBench { | 84 class LinePathBench : public HairlinePathBench { |
| 85 public: | 85 public: |
| 86 LinePathBench(Flags flags) : INHERITED(flags) {} | 86 LinePathBench(Flags flags) : INHERITED(flags) {} |
| 87 | 87 |
| 88 virtual void appendName(SkString* name) SK_OVERRIDE { | 88 virtual void appendName(SkString* name) SK_OVERRIDE { |
| 89 name->append("line"); | 89 name->append("line"); |
| 90 } | 90 } |
| 91 virtual void makePath(SkPath* path) SK_OVERRIDE { | 91 virtual void makePath(SkPath* path) SK_OVERRIDE { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 // Don't have default path renderer for conics yet on GPU, so must use AA | 249 // Don't have default path renderer for conics yet on GPU, so must use AA |
| 250 // DEF_BENCH( return new ConicPathBench(FLAGS00); ) | 250 // DEF_BENCH( return new ConicPathBench(FLAGS00); ) |
| 251 // DEF_BENCH( return new ConicPathBench(FLAGS01); ) | 251 // DEF_BENCH( return new ConicPathBench(FLAGS01); ) |
| 252 DEF_BENCH( return new ConicPathBench(FLAGS10); ) | 252 DEF_BENCH( return new ConicPathBench(FLAGS10); ) |
| 253 DEF_BENCH( return new ConicPathBench(FLAGS11); ) | 253 DEF_BENCH( return new ConicPathBench(FLAGS11); ) |
| 254 | 254 |
| 255 DEF_BENCH( return new CubicPathBench(FLAGS00); ) | 255 DEF_BENCH( return new CubicPathBench(FLAGS00); ) |
| 256 DEF_BENCH( return new CubicPathBench(FLAGS01); ) | 256 DEF_BENCH( return new CubicPathBench(FLAGS01); ) |
| 257 DEF_BENCH( return new CubicPathBench(FLAGS10); ) | 257 DEF_BENCH( return new CubicPathBench(FLAGS10); ) |
| 258 DEF_BENCH( return new CubicPathBench(FLAGS11); ) | 258 DEF_BENCH( return new CubicPathBench(FLAGS11); ) |
| OLD | NEW |