OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
10 #include "SkDisplacementMapEffect.h" | 10 #include "SkDisplacementMapEffect.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 const char* onGetName() override { | 55 const char* onGetName() override { |
56 return "image_filter_displaced_blur"; | 56 return "image_filter_displaced_blur"; |
57 } | 57 } |
58 | 58 |
59 void onDraw(int loops, SkCanvas* canvas) override { | 59 void onDraw(int loops, SkCanvas* canvas) override { |
60 for (int j = 0; j < loops; j++) { | 60 for (int j = 0; j < loops; j++) { |
61 sk_sp<SkImageFilter> blur(SkBlurImageFilter::Make(4.0f, 4.0f, nullpt
r)); | 61 sk_sp<SkImageFilter> blur(SkBlurImageFilter::Make(4.0f, 4.0f, nullpt
r)); |
62 auto xSelector = SkDisplacementMapEffect::kR_ChannelSelectorType; | 62 auto xSelector = SkDisplacementMapEffect::kR_ChannelSelectorType; |
63 auto ySelector = SkDisplacementMapEffect::kB_ChannelSelectorType; | 63 auto ySelector = SkDisplacementMapEffect::kB_ChannelSelectorType; |
64 SkScalar scale = 2; | 64 SkScalar scale = 2; |
65 sk_sp<SkImageFilter> displ(SkDisplacementMapEffect::Create(xSelector
, ySelector, scale, | 65 |
66 blur.get(
), blur.get())); | |
67 SkPaint paint; | 66 SkPaint paint; |
68 paint.setImageFilter(std::move(displ)); | 67 paint.setImageFilter(SkDisplacementMapEffect::Make(xSelector, ySelec
tor, scale, |
| 68 blur, blur)); |
| 69 |
69 SkRect rect = SkRect::Make(SkIRect::MakeWH(400, 400)); | 70 SkRect rect = SkRect::Make(SkIRect::MakeWH(400, 400)); |
70 canvas->drawRect(rect, paint); | 71 canvas->drawRect(rect, paint); |
71 } | 72 } |
72 } | 73 } |
73 | 74 |
74 private: | 75 private: |
75 typedef Benchmark INHERITED; | 76 typedef Benchmark INHERITED; |
76 }; | 77 }; |
77 | 78 |
78 DEF_BENCH(return new ImageFilterDAGBench;) | 79 DEF_BENCH(return new ImageFilterDAGBench;) |
79 DEF_BENCH(return new ImageFilterDisplacedBlur;) | 80 DEF_BENCH(return new ImageFilterDisplacedBlur;) |
OLD | NEW |