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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
81 for (int i = 0; i < loops; ++i) { | 81 for (int i = 0; i < loops; ++i) { |
82 SkTDArray<unsigned> hits; | 82 SkTDArray<int> hits; |
83 SkRect query; | 83 SkRect query; |
84 query.fLeft = rand.nextRangeF(0, GENERATE_EXTENTS); | 84 query.fLeft = rand.nextRangeF(0, GENERATE_EXTENTS); |
85 query.fTop = rand.nextRangeF(0, GENERATE_EXTENTS); | 85 query.fTop = rand.nextRangeF(0, GENERATE_EXTENTS); |
86 query.fRight = query.fLeft + 1 + rand.nextRangeF(0, GENERATE_EXTENT
S/2); | 86 query.fRight = query.fLeft + 1 + rand.nextRangeF(0, GENERATE_EXTENT
S/2); |
87 query.fBottom = query.fTop + 1 + rand.nextRangeF(0, GENERATE_EXTENT
S/2); | 87 query.fBottom = query.fTop + 1 + rand.nextRangeF(0, GENERATE_EXTENT
S/2); |
88 fTree.search(query, &hits); | 88 fTree.search(query, &hits); |
89 } | 89 } |
90 } | 90 } |
91 private: | 91 private: |
92 SkRTree fTree; | 92 SkRTree fTree; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 129 |
130 DEF_BENCH(return SkNEW_ARGS(RTreeBuildBench, ("XY", &make_XYordered_rect
s))); | 130 DEF_BENCH(return SkNEW_ARGS(RTreeBuildBench, ("XY", &make_XYordered_rect
s))); |
131 DEF_BENCH(return SkNEW_ARGS(RTreeBuildBench, ("YX", &make_YXordered_rect
s))); | 131 DEF_BENCH(return SkNEW_ARGS(RTreeBuildBench, ("YX", &make_YXordered_rect
s))); |
132 DEF_BENCH(return SkNEW_ARGS(RTreeBuildBench, ("random", &make_random_rects))
); | 132 DEF_BENCH(return SkNEW_ARGS(RTreeBuildBench, ("random", &make_random_rects))
); |
133 DEF_BENCH(return SkNEW_ARGS(RTreeBuildBench, ("concentric", &make_concentric_rec
ts))); | 133 DEF_BENCH(return SkNEW_ARGS(RTreeBuildBench, ("concentric", &make_concentric_rec
ts))); |
134 | 134 |
135 DEF_BENCH(return SkNEW_ARGS(RTreeQueryBench, ("XY", &make_XYordered_rect
s))); | 135 DEF_BENCH(return SkNEW_ARGS(RTreeQueryBench, ("XY", &make_XYordered_rect
s))); |
136 DEF_BENCH(return SkNEW_ARGS(RTreeQueryBench, ("YX", &make_YXordered_rect
s))); | 136 DEF_BENCH(return SkNEW_ARGS(RTreeQueryBench, ("YX", &make_YXordered_rect
s))); |
137 DEF_BENCH(return SkNEW_ARGS(RTreeQueryBench, ("random", &make_random_rects))
); | 137 DEF_BENCH(return SkNEW_ARGS(RTreeQueryBench, ("random", &make_random_rects))
); |
138 DEF_BENCH(return SkNEW_ARGS(RTreeQueryBench, ("concentric", &make_concentric_rec
ts))); | 138 DEF_BENCH(return SkNEW_ARGS(RTreeQueryBench, ("concentric", &make_concentric_rec
ts))); |
OLD | NEW |