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 "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
10 #include "SkColorMatrixFilter.h" | 10 #include "SkColorMatrixFilter.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } else { | 133 } else { |
134 dx = 0; | 134 dx = 0; |
135 dy = offset; | 135 dy = offset; |
136 } | 136 } |
137 } | 137 } |
138 } | 138 } |
139 | 139 |
140 DEF_SIMPLE_GM(savelayer_with_backdrop, canvas, 830, 550) { | 140 DEF_SIMPLE_GM(savelayer_with_backdrop, canvas, 830, 550) { |
141 SkColorMatrix cm; | 141 SkColorMatrix cm; |
142 cm.setSaturation(10); | 142 cm.setSaturation(10); |
143 SkAutoTUnref<SkColorFilter> cf(SkColorMatrixFilter::Create(cm)); | 143 auto cf(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat)); |
144 const SkScalar kernel[] = { 4, 0, 4, 0, -15, 0, 4, 0, 4 }; | 144 const SkScalar kernel[] = { 4, 0, 4, 0, -15, 0, 4, 0, 4 }; |
145 SkImageFilter* filters[] = { | 145 SkImageFilter* filters[] = { |
146 SkBlurImageFilter::Create(10, 10), | 146 SkBlurImageFilter::Create(10, 10), |
147 SkDilateImageFilter::Create(8, 8), | 147 SkDilateImageFilter::Create(8, 8), |
148 SkMatrixConvolutionImageFilter::Create({ 3, 3 }, kernel, 1, 0, { 0, 0 }, | 148 SkMatrixConvolutionImageFilter::Create({ 3, 3 }, kernel, 1, 0, { 0, 0 }, |
149 SkMatrixConvolutionImageFilter::kClam
pToBlack_TileMode, | 149 SkMatrixConvolutionImageFilter::kClam
pToBlack_TileMode, |
150 true), | 150 true), |
151 SkColorFilterImageFilter::Create(cf), | 151 SkColorFilterImageFilter::Create(cf.get()), |
152 }; | 152 }; |
153 | 153 |
154 const struct { | 154 const struct { |
155 SkScalar fSx, fSy, fTx, fTy; | 155 SkScalar fSx, fSy, fTx, fTy; |
156 } xforms[] = { | 156 } xforms[] = { |
157 { 1, 1, 0, 0 }, | 157 { 1, 1, 0, 0 }, |
158 { 0.5f, 0.5f, 530, 0 }, | 158 { 0.5f, 0.5f, 530, 0 }, |
159 { 0.25f, 0.25f, 530, 275 }, | 159 { 0.25f, 0.25f, 530, 275 }, |
160 { 0.125f, 0.125f, 530, 420 }, | 160 { 0.125f, 0.125f, 530, 420 }, |
161 }; | 161 }; |
162 | 162 |
163 SkPaint paint; | 163 SkPaint paint; |
164 paint.setFilterQuality(kMedium_SkFilterQuality); | 164 paint.setFilterQuality(kMedium_SkFilterQuality); |
165 sk_sp<SkImage> image(GetResourceAsImage("mandrill_512.png")); | 165 sk_sp<SkImage> image(GetResourceAsImage("mandrill_512.png")); |
166 | 166 |
167 canvas->translate(20, 20); | 167 canvas->translate(20, 20); |
168 for (const auto& xform : xforms) { | 168 for (const auto& xform : xforms) { |
169 canvas->save(); | 169 canvas->save(); |
170 canvas->translate(xform.fTx, xform.fTy); | 170 canvas->translate(xform.fTx, xform.fTy); |
171 canvas->scale(xform.fSx, xform.fSy); | 171 canvas->scale(xform.fSx, xform.fSy); |
172 canvas->drawImage(image, 0, 0, &paint); | 172 canvas->drawImage(image, 0, 0, &paint); |
173 draw_set(canvas, filters, SK_ARRAY_COUNT(filters)); | 173 draw_set(canvas, filters, SK_ARRAY_COUNT(filters)); |
174 canvas->restore(); | 174 canvas->restore(); |
175 } | 175 } |
176 | 176 |
177 for (auto& filter : filters) { | 177 for (auto& filter : filters) { |
178 filter->unref(); | 178 filter->unref(); |
179 } | 179 } |
180 } | 180 } |
OLD | NEW |