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 "Benchmark.h" | 9 #include "Benchmark.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 fRects[i].fLeft = -kMinOffset - SkScalarMul(rand.nextUScalar1(),
kOffsetRange); | 32 fRects[i].fLeft = -kMinOffset - SkScalarMul(rand.nextUScalar1(),
kOffsetRange); |
33 fRects[i].fTop = -kMinOffset - SkScalarMul(rand.nextUScalar1(),
kOffsetRange); | 33 fRects[i].fTop = -kMinOffset - SkScalarMul(rand.nextUScalar1(),
kOffsetRange); |
34 fRects[i].fRight = W + kMinOffset + SkScalarMul(rand.nextUScalar
1(), kOffsetRange); | 34 fRects[i].fRight = W + kMinOffset + SkScalarMul(rand.nextUScalar
1(), kOffsetRange); |
35 fRects[i].fBottom = H + kMinOffset + SkScalarMul(rand.nextUScala
r1(), kOffsetRange); | 35 fRects[i].fBottom = H + kMinOffset + SkScalarMul(rand.nextUScala
r1(), kOffsetRange); |
36 fColors[i] = rand.nextU() | 0xFF000000; | 36 fColors[i] = rand.nextU() | 0xFF000000; |
37 } | 37 } |
38 fInit = true; | 38 fInit = true; |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 void onDraw(const int loops, SkCanvas* canvas) override { | 42 void onDraw(int loops, SkCanvas* canvas) override { |
43 SkPaint paint; | 43 SkPaint paint; |
44 for (int i = 0; i < loops; ++i) { | 44 for (int i = 0; i < loops; ++i) { |
45 paint.setColor(fColors[i % N]); | 45 paint.setColor(fColors[i % N]); |
46 canvas->drawRect(fRects[i % N], paint); | 46 canvas->drawRect(fRects[i % N], paint); |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 private: | 50 private: |
51 enum { | 51 enum { |
52 W = 640, | 52 W = 640, |
53 H = 480, | 53 H = 480, |
54 N = 300, | 54 N = 300, |
55 }; | 55 }; |
56 SkRect fRects[N]; | 56 SkRect fRects[N]; |
57 SkColor fColors[N]; | 57 SkColor fColors[N]; |
58 bool fInit; | 58 bool fInit; |
59 | 59 |
60 typedef Benchmark INHERITED; | 60 typedef Benchmark INHERITED; |
61 }; | 61 }; |
62 | 62 |
63 DEF_BENCH(return new FSRectBench();) | 63 DEF_BENCH(return new FSRectBench();) |
OLD | NEW |