| 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 "SkBenchmark.h" |
| 9 #include "SkRandom.h" | 9 #include "SkRandom.h" |
| 10 #include "SkRegion.h" | 10 #include "SkRegion.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 W = 200, | 26 W = 200, |
| 27 H = 200, | 27 H = 200, |
| 28 COUNT = 10, | 28 COUNT = 10, |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 SkIRect randrect(SkRandom& rand, int i) { | 31 SkIRect randrect(SkRandom& rand, int i) { |
| 32 int w = rand.nextU() % W; | 32 int w = rand.nextU() % W; |
| 33 return SkIRect::MakeXYWH(0, i*H/COUNT, w, H/COUNT); | 33 return SkIRect::MakeXYWH(0, i*H/COUNT, w, H/COUNT); |
| 34 } | 34 } |
| 35 | 35 |
| 36 RegionContainBench(void* param, Proc proc, const char name[]) : INHERITED(pa
ram) { | 36 RegionContainBench(Proc proc, const char name[]) { |
| 37 fProc = proc; | 37 fProc = proc; |
| 38 fName.printf("region_contains_%s", name); | 38 fName.printf("region_contains_%s", name); |
| 39 | 39 |
| 40 SkRandom rand; | 40 SkRandom rand; |
| 41 for (int i = 0; i < COUNT; i++) { | 41 for (int i = 0; i < COUNT; i++) { |
| 42 fA.op(randrect(rand, i), SkRegion::kXOR_Op); | 42 fA.op(randrect(rand, i), SkRegion::kXOR_Op); |
| 43 } | 43 } |
| 44 | 44 |
| 45 fB.setRect(0, 0, H, W); | 45 fB.setRect(0, 0, H, W); |
| 46 | 46 |
| 47 fIsRendering = false; | 47 fIsRendering = false; |
| 48 } | 48 } |
| 49 | 49 |
| 50 protected: | 50 protected: |
| 51 virtual const char* onGetName() { return fName.c_str(); } | 51 virtual const char* onGetName() { return fName.c_str(); } |
| 52 | 52 |
| 53 virtual void onDraw(SkCanvas*) { | 53 virtual void onDraw(SkCanvas*) { |
| 54 Proc proc = fProc; | 54 Proc proc = fProc; |
| 55 | 55 |
| 56 for (int i = 0; i < this->getLoops(); ++i) { | 56 for (int i = 0; i < this->getLoops(); ++i) { |
| 57 proc(fA, fB); | 57 proc(fA, fB); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 typedef SkBenchmark INHERITED; | 62 typedef SkBenchmark INHERITED; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 static SkBenchmark* gF0(void* p) { return SkNEW_ARGS(RegionContainBench, (p, sec
t_proc, "sect")); } | 65 DEF_BENCH( return SkNEW_ARGS(RegionContainBench, (sect_proc, "sect")); ) |
| 66 | |
| 67 static BenchRegistry gR0(gF0); | |
| OLD | NEW |