OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 26 matching lines...) Expand all Loading... |
37 fRects[i].fRight = W + kMinOffset + SkScalarMul(rand.nextUScalar
1(), kOffsetRange); | 37 fRects[i].fRight = W + kMinOffset + SkScalarMul(rand.nextUScalar
1(), kOffsetRange); |
38 fRects[i].fBottom = H + kMinOffset + SkScalarMul(rand.nextUScala
r1(), kOffsetRange); | 38 fRects[i].fBottom = H + kMinOffset + SkScalarMul(rand.nextUScala
r1(), kOffsetRange); |
39 fColors[i] = rand.nextU() | 0xFF000000; | 39 fColors[i] = rand.nextU() | 0xFF000000; |
40 } | 40 } |
41 fInit = true; | 41 fInit = true; |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 45 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
46 SkPaint paint; | 46 SkPaint paint; |
47 for (int i = 0; i < N; ++i) { | 47 for (int i = 0; i < this->getLoops(); ++i) { |
48 paint.setColor(fColors[i]); | 48 paint.setColor(fColors[i % N]); |
49 canvas->drawRect(fRects[i], paint); | 49 canvas->drawRect(fRects[i % N], paint); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 private: | 53 private: |
54 enum { | 54 enum { |
55 W = 640, | 55 W = 640, |
56 H = 480, | 56 H = 480, |
57 N = SkBENCHLOOP(300) | 57 N = 300, |
58 }; | 58 }; |
59 SkRect fRects[N]; | 59 SkRect fRects[N]; |
60 SkColor fColors[N]; | 60 SkColor fColors[N]; |
61 bool fInit; | 61 bool fInit; |
62 | 62 |
63 typedef SkBenchmark INHERITED; | 63 typedef SkBenchmark INHERITED; |
64 }; | 64 }; |
65 | 65 |
66 DEF_BENCH( return SkNEW_ARGS(FSRectBench, (p)); ) | 66 DEF_BENCH( return SkNEW_ARGS(FSRectBench, (p)); ) |
OLD | NEW |