OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkRTree.h" | 10 #include "SkRTree.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 fName.printf("rtree_%s_query", name); | 60 fName.printf("rtree_%s_query", name); |
61 } | 61 } |
62 | 62 |
63 bool isSuitableFor(Backend backend) override { | 63 bool isSuitableFor(Backend backend) override { |
64 return backend == kNonRendering_Backend; | 64 return backend == kNonRendering_Backend; |
65 } | 65 } |
66 protected: | 66 protected: |
67 const char* onGetName() override { | 67 const char* onGetName() override { |
68 return fName.c_str(); | 68 return fName.c_str(); |
69 } | 69 } |
70 void onPreDraw() override { | 70 void onDelayedSetup() override { |
71 SkRandom rand; | 71 SkRandom rand; |
72 SkAutoTMalloc<SkRect> rects(NUM_QUERY_RECTS); | 72 SkAutoTMalloc<SkRect> rects(NUM_QUERY_RECTS); |
73 for (int i = 0; i < NUM_QUERY_RECTS; ++i) { | 73 for (int i = 0; i < NUM_QUERY_RECTS; ++i) { |
74 rects[i] = fProc(rand, i, NUM_QUERY_RECTS); | 74 rects[i] = fProc(rand, i, NUM_QUERY_RECTS); |
75 } | 75 } |
76 fTree.insert(rects.get(), NUM_QUERY_RECTS); | 76 fTree.insert(rects.get(), NUM_QUERY_RECTS); |
77 } | 77 } |
78 | 78 |
79 void onDraw(const int loops, SkCanvas* canvas) override { | 79 void onDraw(const int loops, SkCanvas* canvas) override { |
80 SkRandom rand; | 80 SkRandom rand; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 129 |
130 DEF_BENCH(return new RTreeBuildBench("XY", &make_XYordered_rects)); | 130 DEF_BENCH(return new RTreeBuildBench("XY", &make_XYordered_rects)); |
131 DEF_BENCH(return new RTreeBuildBench("YX", &make_YXordered_rects)); | 131 DEF_BENCH(return new RTreeBuildBench("YX", &make_YXordered_rects)); |
132 DEF_BENCH(return new RTreeBuildBench("random", &make_random_rects)); | 132 DEF_BENCH(return new RTreeBuildBench("random", &make_random_rects)); |
133 DEF_BENCH(return new RTreeBuildBench("concentric", &make_concentric_rects)); | 133 DEF_BENCH(return new RTreeBuildBench("concentric", &make_concentric_rects)); |
134 | 134 |
135 DEF_BENCH(return new RTreeQueryBench("XY", &make_XYordered_rects)); | 135 DEF_BENCH(return new RTreeQueryBench("XY", &make_XYordered_rects)); |
136 DEF_BENCH(return new RTreeQueryBench("YX", &make_YXordered_rects)); | 136 DEF_BENCH(return new RTreeQueryBench("YX", &make_YXordered_rects)); |
137 DEF_BENCH(return new RTreeQueryBench("random", &make_random_rects)); | 137 DEF_BENCH(return new RTreeQueryBench("random", &make_random_rects)); |
138 DEF_BENCH(return new RTreeQueryBench("concentric", &make_concentric_rects)); | 138 DEF_BENCH(return new RTreeQueryBench("concentric", &make_concentric_rects)); |
OLD | NEW |