| OLD | NEW |
| 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 "SkRandom.h" | 9 #include "SkRandom.h" |
| 10 #include "SkRegion.h" | 10 #include "SkRegion.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 RegionBench(int count, Proc proc, const char name[]) { | 91 RegionBench(int count, Proc proc, const char name[]) { |
| 92 fProc = proc; | 92 fProc = proc; |
| 93 fName.printf("region_%s_%d", name, count); | 93 fName.printf("region_%s_%d", name, count); |
| 94 | 94 |
| 95 SkRandom rand; | 95 SkRandom rand; |
| 96 for (int i = 0; i < count; i++) { | 96 for (int i = 0; i < count; i++) { |
| 97 fA.op(randrect(rand), SkRegion::kXOR_Op); | 97 fA.op(randrect(rand), SkRegion::kXOR_Op); |
| 98 fB.op(randrect(rand), SkRegion::kXOR_Op); | 98 fB.op(randrect(rand), SkRegion::kXOR_Op); |
| 99 } | 99 } |
| 100 fIsRendering = false; | 100 } |
| 101 |
| 102 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
| 103 return backend == kNonRendering_Backend; |
| 101 } | 104 } |
| 102 | 105 |
| 103 protected: | 106 protected: |
| 104 virtual const char* onGetName() { return fName.c_str(); } | 107 virtual const char* onGetName() { return fName.c_str(); } |
| 105 | 108 |
| 106 virtual void onDraw(SkCanvas* canvas) { | 109 virtual void onDraw(SkCanvas* canvas) { |
| 107 Proc proc = fProc; | 110 Proc proc = fProc; |
| 108 for (int i = 0; i < this->getLoops(); ++i) { | 111 for (int i = 0; i < this->getLoops(); ++i) { |
| 109 proc(fA, fB); | 112 proc(fA, fB); |
| 110 } | 113 } |
| 111 } | 114 } |
| 112 | 115 |
| 113 private: | 116 private: |
| 114 typedef SkBenchmark INHERITED; | 117 typedef SkBenchmark INHERITED; |
| 115 }; | 118 }; |
| 116 | 119 |
| 117 #define SMALL 16 | 120 #define SMALL 16 |
| 118 | 121 |
| 119 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, union_proc, "union")); ) | 122 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, union_proc, "union")); ) |
| 120 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, sect_proc, "intersect")); ) | 123 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, sect_proc, "intersect")); ) |
| 121 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, diff_proc, "difference")); ) | 124 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, diff_proc, "difference")); ) |
| 122 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, diffrect_proc, "differencerect
")); ) | 125 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, diffrect_proc, "differencerect
")); ) |
| 123 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, diffrectbig_proc, "differencer
ectbig")); ) | 126 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, diffrectbig_proc, "differencer
ectbig")); ) |
| 124 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, containsrect_proc, "containsre
ct")); ) | 127 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, containsrect_proc, "containsre
ct")); ) |
| 125 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, sectsrgn_proc, "intersectsrgn"
)); ) | 128 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, sectsrgn_proc, "intersectsrgn"
)); ) |
| 126 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, sectsrect_proc, "intersectsrec
t")); ) | 129 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, sectsrect_proc, "intersectsrec
t")); ) |
| 127 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, containsxy_proc, "containsxy")
); ) | 130 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, containsxy_proc, "containsxy")
); ) |
| OLD | NEW |