OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2016 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #include "Benchmark.h" |
| 9 #include "SkCanvas.h" |
| 10 #include "SkRandom.h" |
| 11 |
| 12 class QuickRejectBench : public Benchmark { |
| 13 enum { N = 1000000 }; |
| 14 float fFloats[N]; |
| 15 int fInts [N]; |
| 16 |
| 17 const char* onGetName() override { return "quick_reject"; } |
| 18 bool isSuitableFor(Backend backend) override { return backend != kNonRenderi
ng_Backend; } |
| 19 |
| 20 void onDelayedSetup() override { |
| 21 SkRandom rand; |
| 22 for (int i = 0; i < N; ++i) { |
| 23 fFloats[i] = 300.0f * (rand.nextSScalar1() + 0.5f); |
| 24 } |
| 25 } |
| 26 |
| 27 void onDraw(int loops, SkCanvas* canvas) override { |
| 28 while (loops --> 0) { |
| 29 for (int i = 0; i < N - 4; i++) { |
| 30 if (canvas->quickReject(*(SkRect*)(fFloats+i))) { |
| 31 fInts[i] = 11; |
| 32 } else { |
| 33 fInts[i] = 24; |
| 34 } |
| 35 } |
| 36 } |
| 37 } |
| 38 }; |
| 39 DEF_BENCH( return new QuickRejectBench; ) |
OLD | NEW |