OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkBlurMaskFilter.h" | 9 #include "SkBlurMaskFilter.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkLayerDrawLooper.h" | 11 #include "SkLayerDrawLooper.h" |
12 #include "SkPaint.h" | 12 #include "SkPaint.h" |
13 #include "SkPath.h" | 13 #include "SkPath.h" |
14 #include "SkRandom.h" | 14 #include "SkRandom.h" |
15 | 15 |
16 // This bench replicates a problematic use case of a draw looper used | 16 // This bench replicates a problematic use case of a draw looper used |
17 // to create an inner blurred rect | 17 // to create an inner blurred rect |
18 class RectoriBench : public Benchmark { | 18 class RectoriBench : public Benchmark { |
19 public: | 19 public: |
20 RectoriBench() {} | 20 RectoriBench() {} |
21 | 21 |
22 protected: | 22 protected: |
23 | 23 |
24 const char* onGetName() override { | 24 const char* onGetName() override { |
25 return "rectori"; | 25 return "rectori"; |
26 } | 26 } |
27 | 27 |
28 void onDraw(const int loops, SkCanvas* canvas) override { | 28 void onDraw(int loops, SkCanvas* canvas) override { |
29 SkRandom Random; | 29 SkRandom Random; |
30 | 30 |
31 for (int i = 0; i < loops; i++) { | 31 for (int i = 0; i < loops; i++) { |
32 SkScalar blurSigma = Random.nextRangeScalar(1.5f, 25.0f); | 32 SkScalar blurSigma = Random.nextRangeScalar(1.5f, 25.0f); |
33 SkScalar size = Random.nextRangeScalar(20*blurSigma, 50*blurSigma); | 33 SkScalar size = Random.nextRangeScalar(20*blurSigma, 50*blurSigma); |
34 | 34 |
35 SkScalar x = Random.nextRangeScalar(0.0f, W - size); | 35 SkScalar x = Random.nextRangeScalar(0.0f, W - size); |
36 SkScalar y = Random.nextRangeScalar(0.0f, H - size); | 36 SkScalar y = Random.nextRangeScalar(0.0f, H - size); |
37 | 37 |
38 SkRect inner = { x, y, x + size, y + size }; | 38 SkRect inner = { x, y, x + size, y + size }; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 info.fOffset.set(0, 0); | 96 info.fOffset.set(0, 0); |
97 | 97 |
98 paint = looperBuilder.addLayer(info); | 98 paint = looperBuilder.addLayer(info); |
99 return looperBuilder.detachLooper(); | 99 return looperBuilder.detachLooper(); |
100 } | 100 } |
101 | 101 |
102 typedef Benchmark INHERITED; | 102 typedef Benchmark INHERITED; |
103 }; | 103 }; |
104 | 104 |
105 DEF_BENCH(return new RectoriBench();) | 105 DEF_BENCH(return new RectoriBench();) |
OLD | NEW |