Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 | 8 |
| 9 #include "SkBenchmark.h" | 9 #include "SkBenchmark.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 , fTree(tree) | 79 , fTree(tree) |
| 80 , fProc(proc) | 80 , fProc(proc) |
| 81 , fBulkLoad(bulkLoad) | 81 , fBulkLoad(bulkLoad) |
| 82 , fQuery(q) { | 82 , fQuery(q) { |
| 83 fName.append("rtree_"); | 83 fName.append("rtree_"); |
| 84 fName.append(name); | 84 fName.append(name); |
| 85 fName.append("_query"); | 85 fName.append("_query"); |
| 86 if (fBulkLoad) { | 86 if (fBulkLoad) { |
| 87 fName.append("_bulk"); | 87 fName.append("_bulk"); |
| 88 } | 88 } |
| 89 SkRandom rand; | |
| 90 for (int j = 0; j < SkBENCHLOOP(NUM_QUERY_RECTS); ++j) { | |
| 91 fTree->insert(reinterpret_cast<void*>(j), fProc(rand, j, | |
| 92 SkBENCHLOOP(NUM_QUERY_RECTS)), fBulkLoad); | |
| 93 } | |
| 94 fTree->flushDeferredInserts(); | |
| 95 fIsRendering = false; | 89 fIsRendering = false; |
| 96 } | 90 } |
| 97 virtual ~BBoxQueryBench() { | 91 virtual ~BBoxQueryBench() { |
| 98 fTree->unref(); | 92 fTree->unref(); |
| 99 } | 93 } |
| 100 protected: | 94 protected: |
|
robertphillips
2013/07/29 11:57:10
SK_OVERRIDE
| |
| 101 virtual const char* onGetName() { | 95 virtual const char* onGetName() { |
| 102 return fName.c_str(); | 96 return fName.c_str(); |
| 103 } | 97 } |
|
robertphillips
2013/07/29 11:57:10
SK_OVERRIDE
| |
| 98 virtual void onPreDraw() { | |
|
robertphillips
2013/07/29 11:57:10
Use SkMWCRandom instead
| |
| 99 SkRandom rand; | |
| 100 for (int j = 0; j < SkBENCHLOOP(NUM_QUERY_RECTS); ++j) { | |
| 101 fTree->insert(reinterpret_cast<void*>(j), fProc(rand, j, | |
| 102 SkBENCHLOOP(NUM_QUERY_RECTS)), fBulkLoad); | |
| 103 } | |
| 104 fTree->flushDeferredInserts(); | |
| 105 } | |
| 106 | |
|
robertphillips
2013/07/29 11:57:10
SK_OVERRIDE
| |
| 104 virtual void onDraw(SkCanvas* canvas) { | 107 virtual void onDraw(SkCanvas* canvas) { |
| 105 SkRandom rand; | 108 SkRandom rand; |
| 106 for (int i = 0; i < SkBENCHLOOP(NUM_QUERIES); ++i) { | 109 for (int i = 0; i < SkBENCHLOOP(NUM_QUERIES); ++i) { |
| 107 SkTDArray<void*> hits; | 110 SkTDArray<void*> hits; |
| 108 SkIRect query; | 111 SkIRect query; |
| 109 switch(fQuery) { | 112 switch(fQuery) { |
| 110 case kSmall_QueryType: | 113 case kSmall_QueryType: |
| 111 query.fLeft = rand.nextU() % GENERATE_EXTENTS; | 114 query.fLeft = rand.nextU() % GENERATE_EXTENTS; |
| 112 query.fTop = rand.nextU() % GENERATE_EXTENTS; | 115 query.fTop = rand.nextU() % GENERATE_EXTENTS; |
| 113 query.fRight = query.fLeft + (GENERATE_EXTENTS / 20); | 116 query.fRight = query.fLeft + (GENERATE_EXTENTS / 20); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 static inline SkBenchmark* Fact4(void* p) { | 211 static inline SkBenchmark* Fact4(void* p) { |
| 209 return SkNEW_ARGS(BBoxQueryBench, (p, "random", &make_random_rects, false, | 212 return SkNEW_ARGS(BBoxQueryBench, (p, "random", &make_random_rects, false, |
| 210 BBoxQueryBench::kRandom_QueryType, SkRTree::Create(5, 16)) ); | 213 BBoxQueryBench::kRandom_QueryType, SkRTree::Create(5, 16)) ); |
| 211 } | 214 } |
| 212 | 215 |
| 213 static BenchRegistry gReg0(Fact0); | 216 static BenchRegistry gReg0(Fact0); |
| 214 static BenchRegistry gReg1(Fact1); | 217 static BenchRegistry gReg1(Fact1); |
| 215 static BenchRegistry gReg2(Fact2); | 218 static BenchRegistry gReg2(Fact2); |
| 216 static BenchRegistry gReg3(Fact3); | 219 static BenchRegistry gReg3(Fact3); |
| 217 static BenchRegistry gReg4(Fact4); | 220 static BenchRegistry gReg4(Fact4); |
| OLD | NEW |