OLD | NEW |
---|---|
(Empty) | |
1 | |
2 /* | |
3 * Copyright 2013 Google Inc. | |
4 * | |
5 * Use of this source code is governed by a BSD-style license that can be | |
6 * found in the LICENSE file. | |
7 */ | |
8 | |
9 #include "SkBenchmark.h" | |
10 #include "SkCanvas.h" | |
11 #include "SkPaint.h" | |
12 #include "SkRandom.h" | |
13 | |
robertphillips
2013/08/01 17:50:14
comment r.e. what it is supposed to hit?
bsalomon
2013/08/02 19:35:10
Done.
| |
14 class FSRectBench : public SkBenchmark { | |
15 public: | |
16 FSRectBench(void* param) | |
17 : INHERITED(param) { | |
robertphillips
2013/08/01 17:50:14
MWC?
bsalomon
2013/08/02 19:35:10
Done.
| |
18 SkRandom rand; | |
19 static const SkScalar kMinOffset = 0; | |
robertphillips
2013/08/01 17:50:14
Move this setup out of the ctor and into onPreDraw
bsalomon
2013/08/02 19:35:10
Done.
| |
20 static const SkScalar kMaxOffset = 100 * SK_Scalar1; | |
21 static const SkScalar kOffsetRange = kMaxOffset - kMinOffset; | |
robertphillips
2013/08/01 17:50:14
pre++?
bsalomon
2013/08/02 19:35:10
Done.
| |
22 for (int i = 0; i < N; i++) { | |
23 fRects[i].fLeft = -kMinOffset - SkScalarMul(rand.nextUScalar1(), kOf fsetRange); | |
24 fRects[i].fTop = -kMinOffset - SkScalarMul(rand.nextUScalar1(), kOff setRange); | |
25 fRects[i].fRight = W + kMinOffset + SkScalarMul(rand.nextUScalar1(), kOffsetRange); | |
26 fRects[i].fBottom = H + kMinOffset + SkScalarMul(rand.nextUScalar1() , kOffsetRange); | |
27 fColors[i] = rand.nextU() | 0xFF000000; | |
28 } | |
29 } | |
30 | |
31 protected: | |
32 virtual const char* onGetName() SK_OVERRIDE { return "fullscreen_rects"; } | |
33 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | |
34 SkPaint paint; | |
robertphillips
2013/08/01 17:50:14
pre++?
bsalomon
2013/08/02 19:35:10
Done.
| |
35 for (int i = 0; i < N; i++) { | |
36 paint.setColor(fColors[i]); | |
37 canvas->drawRect(fRects[i], paint); | |
38 } | |
39 } | |
40 | |
41 private: | |
42 enum { | |
43 W = 640, | |
44 H = 480, | |
45 N = SkBENCHLOOP(300) | |
46 }; | |
47 SkRect fRects[N]; | |
48 SkColor fColors[N]; | |
49 | |
50 typedef SkBenchmark INHERITED; | |
51 }; | |
52 | |
53 DEF_BENCH( return SkNEW_ARGS(FSRectBench, (p)); ) | |
OLD | NEW |