OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "gm.h" | 8 #include "gm.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkBlurImageFilter.h" | 10 #include "SkBlurImageFilter.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 protected: | 43 protected: |
44 SkString onShortName() override { | 44 SkString onShortName() override { |
45 return SkString("localmatriximagefilter"); | 45 return SkString("localmatriximagefilter"); |
46 } | 46 } |
47 | 47 |
48 SkISize onISize() override { | 48 SkISize onISize() override { |
49 return SkISize::Make(640, 640); | 49 return SkISize::Make(640, 640); |
50 } | 50 } |
51 | 51 |
52 static void show_image(SkCanvas* canvas, SkImage* image, sk_sp<SkImageFilter
> filter) { | 52 static void show_image(SkCanvas* canvas, SkImage* image, SkImageFilter* filt
er) { |
53 SkPaint paint; | 53 SkPaint paint; |
54 paint.setStyle(SkPaint::kStroke_Style); | 54 paint.setStyle(SkPaint::kStroke_Style); |
55 SkRect r = SkRect::MakeIWH(image->width(), image->height()).makeOutset(S
K_ScalarHalf, | 55 SkRect r = SkRect::MakeIWH(image->width(), image->height()).makeOutset(S
K_ScalarHalf, |
56 S
K_ScalarHalf); | 56 S
K_ScalarHalf); |
57 canvas->drawRect(r, paint); | 57 canvas->drawRect(r, paint); |
58 | 58 |
59 paint.setStyle(SkPaint::kFill_Style); | 59 paint.setStyle(SkPaint::kFill_Style); |
60 paint.setImageFilter(filter); | 60 paint.setImageFilter(filter); |
61 canvas->drawImage(image, 0, 0, &paint); | 61 canvas->drawImage(image, 0, 0, &paint); |
62 } | 62 } |
(...skipping 11 matching lines...) Expand all Loading... |
74 const SkMatrix matrices[] = { | 74 const SkMatrix matrices[] = { |
75 SkMatrix::MakeScale(SK_ScalarHalf, SK_ScalarHalf), | 75 SkMatrix::MakeScale(SK_ScalarHalf, SK_ScalarHalf), |
76 SkMatrix::MakeScale(2, 2), | 76 SkMatrix::MakeScale(2, 2), |
77 SkMatrix::MakeTrans(10, 10) | 77 SkMatrix::MakeTrans(10, 10) |
78 }; | 78 }; |
79 | 79 |
80 const SkScalar spacer = image0->width() * 3.0f / 2; | 80 const SkScalar spacer = image0->width() * 3.0f / 2; |
81 | 81 |
82 canvas->translate(40, 40); | 82 canvas->translate(40, 40); |
83 for (auto&& factory : factories) { | 83 for (auto&& factory : factories) { |
84 sk_sp<SkImageFilter> filter(factory()); | 84 SkAutoTUnref<SkImageFilter> filter(factory()); |
85 | 85 |
86 canvas->save(); | 86 canvas->save(); |
87 show_image(canvas, image0.get(), filter); | 87 show_image(canvas, image0.get(), filter); |
88 for (const auto& matrix : matrices) { | 88 for (const auto& matrix : matrices) { |
89 sk_sp<SkImageFilter> localFilter(filter->makeWithLocalMatrix(mat
rix)); | 89 SkAutoTUnref<SkImageFilter> localFilter(filter->newWithLocalMatr
ix(matrix)); |
90 canvas->translate(spacer, 0); | 90 canvas->translate(spacer, 0); |
91 show_image(canvas, image0.get(), std::move(localFilter)); | 91 show_image(canvas, image0.get(), localFilter); |
92 } | 92 } |
93 canvas->restore(); | 93 canvas->restore(); |
94 canvas->translate(0, spacer); | 94 canvas->translate(0, spacer); |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
98 private: | 98 private: |
99 typedef GM INHERITED; | 99 typedef GM INHERITED; |
100 }; | 100 }; |
101 DEF_GM( return new LocalMatrixImageFilterGM; ) | 101 DEF_GM( return new LocalMatrixImageFilterGM; ) |
OLD | NEW |