| 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" |
| 11 #include "SkPaint.h" | 11 #include "SkPaint.h" |
| 12 #include "SkRandom.h" | 12 #include "SkRandom.h" |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * Draws full screen opaque rectangles. It is designed to test any optimizations
in the GPU backend | 15 * Draws full screen opaque rectangles. It is designed to test any optimizations
in the GPU backend |
| 16 * to turn such draws into clears. | 16 * to turn such draws into clears. |
| 17 */ | 17 */ |
| 18 class FSRectBench : public SkBenchmark { | 18 class FSRectBench : public SkBenchmark { |
| 19 public: | 19 public: |
| 20 FSRectBench(void* param) | 20 FSRectBench(void* param) |
| 21 : INHERITED(param) | 21 : INHERITED(param) |
| 22 , fInit(false) { | 22 , fInit(false) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 protected: | 25 protected: |
| 26 virtual const char* onGetName() SK_OVERRIDE { return "fullscreen_rects"; } | 26 virtual const char* onGetName() SK_OVERRIDE { return "fullscreen_rects"; } |
| 27 | 27 |
| 28 virtual void onPreDraw() SK_OVERRIDE { | 28 virtual void onPreDraw() SK_OVERRIDE { |
| 29 if (!fInit) { | 29 if (!fInit) { |
| 30 SkMWCRandom rand; | 30 SkRandom rand; |
| 31 static const SkScalar kMinOffset = 0; | 31 static const SkScalar kMinOffset = 0; |
| 32 static const SkScalar kMaxOffset = 100 * SK_Scalar1; | 32 static const SkScalar kMaxOffset = 100 * SK_Scalar1; |
| 33 static const SkScalar kOffsetRange = kMaxOffset - kMinOffset; | 33 static const SkScalar kOffsetRange = kMaxOffset - kMinOffset; |
| 34 for (int i = 0; i < N; ++i) { | 34 for (int i = 0; i < N; ++i) { |
| 35 fRects[i].fLeft = -kMinOffset - SkScalarMul(rand.nextUScalar1(),
kOffsetRange); | 35 fRects[i].fLeft = -kMinOffset - SkScalarMul(rand.nextUScalar1(),
kOffsetRange); |
| 36 fRects[i].fTop = -kMinOffset - SkScalarMul(rand.nextUScalar1(),
kOffsetRange); | 36 fRects[i].fTop = -kMinOffset - SkScalarMul(rand.nextUScalar1(),
kOffsetRange); |
| 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 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 57 N = SkBENCHLOOP(300) | 57 N = SkBENCHLOOP(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 |