blob: 7b00af9cf85a3f554359137abc448a540544efea [file] [log] [blame]
senorblanco5878dbd2016-05-19 14:50:29 -07001/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "gm/gm.h"
Michael Ludwigd5fad8c2019-06-18 09:28:47 -04009
Ben Wagner7fde8e12019-05-01 17:28:53 -040010#include "include/core/SkBlendMode.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkCanvas.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040012#include "include/core/SkColor.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "include/core/SkColorFilter.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040014#include "include/core/SkImage.h"
15#include "include/core/SkImageFilter.h"
16#include "include/core/SkImageInfo.h"
17#include "include/core/SkPaint.h"
18#include "include/core/SkPoint.h"
Michael Ludwigfa974632019-06-20 14:21:28 -040019#include "include/core/SkPoint3.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040020#include "include/core/SkRect.h"
21#include "include/core/SkRefCnt.h"
Michael Ludwigfa974632019-06-20 14:21:28 -040022#include "include/core/SkRegion.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040023#include "include/core/SkScalar.h"
24#include "include/core/SkSize.h"
25#include "include/core/SkString.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050026#include "include/core/SkSurface.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040027#include "include/core/SkTypes.h"
Michael Ludwigd5fad8c2019-06-18 09:28:47 -040028
Michael Ludwig898bbfa2019-08-02 15:21:23 -040029#include "include/effects/SkImageFilters.h"
Michael Ludwigd5fad8c2019-06-18 09:28:47 -040030
Michael Ludwig8d3e2792019-06-19 12:46:43 -040031#include "include/gpu/GrContext.h"
32
Michael Ludwigd5fad8c2019-06-18 09:28:47 -040033#include "tools/Resources.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050034#include "tools/ToolUtils.h"
senorblanco5878dbd2016-05-19 14:50:29 -070035
Ben Wagner7fde8e12019-05-01 17:28:53 -040036#include <utility>
37
senorblanco5878dbd2016-05-19 14:50:29 -070038///////////////////////////////////////////////////////////////////////////////
39
Michael Ludwigd5fad8c2019-06-18 09:28:47 -040040static void show_bounds(SkCanvas* canvas, const SkIRect* clip, const SkIRect* inSubset,
41 const SkIRect* outSubset) {
42 const SkIRect* rects[] { clip, inSubset, outSubset };
43 SkColor colors[] { SK_ColorBLUE, SK_ColorYELLOW, SK_ColorRED };
senorblanco5878dbd2016-05-19 14:50:29 -070044
45 SkPaint paint;
46 paint.setStyle(SkPaint::kStroke_Style);
47
48 for (size_t i = 0; i < SK_ARRAY_COUNT(rects); ++i) {
Michael Ludwigd5fad8c2019-06-18 09:28:47 -040049 // Skip null bounds rects, since not all methods have subsets
50 if (rects[i]) {
51 paint.setColor(colors[i]);
52 canvas->drawRect(SkRect::Make(*(rects[i])), paint);
53 }
senorblanco5878dbd2016-05-19 14:50:29 -070054 }
55}
56
Michael Ludwigd5fad8c2019-06-18 09:28:47 -040057// Factories for creating image filters, either with or without a cropRect
58// (this could go away if there was a SkImageFilter::makeWithCropRect() function, but that seems
59// less generally useful).
60typedef sk_sp<SkImageFilter> (*FilterFactory)(sk_sp<SkImage> auxImage, const SkIRect* cropRect);
61
Michael Ludwigfa974632019-06-20 14:21:28 -040062static sk_sp<SkImageFilter> color_filter_factory(sk_sp<SkImage> auxImage, const SkIRect* cropRect) {
Michael Ludwigd5fad8c2019-06-18 09:28:47 -040063 // The color filter uses kSrcIn so that it respects the transparency introduced by clamping;
64 // using kSrc would just turn the entire out rect to green regardless.
65 auto cf = SkColorFilters::Blend(SK_ColorGREEN, SkBlendMode::kSrcIn);
Michael Ludwig898bbfa2019-08-02 15:21:23 -040066 return SkImageFilters::ColorFilter(std::move(cf), nullptr, cropRect);
Michael Ludwigd5fad8c2019-06-18 09:28:47 -040067}
68
Michael Ludwigfa974632019-06-20 14:21:28 -040069static sk_sp<SkImageFilter> blur_filter_factory(sk_sp<SkImage> auxImage, const SkIRect* cropRect) {
Michael Ludwig898bbfa2019-08-02 15:21:23 -040070 return SkImageFilters::Blur(2.0f, 2.0f, nullptr, cropRect);
Michael Ludwigd5fad8c2019-06-18 09:28:47 -040071}
72
Michael Ludwigfa974632019-06-20 14:21:28 -040073static sk_sp<SkImageFilter> drop_shadow_factory(sk_sp<SkImage> auxImage, const SkIRect* cropRect) {
Michael Ludwig898bbfa2019-08-02 15:21:23 -040074 return SkImageFilters::DropShadow(10.0f, 5.0f, 3.0f, 3.0f, SK_ColorBLUE, nullptr, cropRect);
Michael Ludwigd5fad8c2019-06-18 09:28:47 -040075}
76
Michael Ludwigfa974632019-06-20 14:21:28 -040077static sk_sp<SkImageFilter> offset_factory(sk_sp<SkImage> auxImage, const SkIRect* cropRect) {
Michael Ludwig898bbfa2019-08-02 15:21:23 -040078 return SkImageFilters::Offset(10.f, 5.f, nullptr, cropRect);
Michael Ludwigd5fad8c2019-06-18 09:28:47 -040079}
80
Michael Ludwigfa974632019-06-20 14:21:28 -040081static sk_sp<SkImageFilter> dilate_factory(sk_sp<SkImage> auxImage, const SkIRect* cropRect) {
Michael Ludwig898bbfa2019-08-02 15:21:23 -040082 return SkImageFilters::Dilate(10.f, 5.f, nullptr, cropRect);
Michael Ludwigd5fad8c2019-06-18 09:28:47 -040083}
84
Michael Ludwigfa974632019-06-20 14:21:28 -040085static sk_sp<SkImageFilter> erode_factory(sk_sp<SkImage> auxImage, const SkIRect* cropRect) {
Michael Ludwig898bbfa2019-08-02 15:21:23 -040086 return SkImageFilters::Erode(10.f, 5.f, nullptr, cropRect);
Michael Ludwigd5fad8c2019-06-18 09:28:47 -040087}
88
Michael Ludwigfa974632019-06-20 14:21:28 -040089static sk_sp<SkImageFilter> displacement_factory(sk_sp<SkImage> auxImage, const SkIRect* cropRect) {
Michael Ludwig898bbfa2019-08-02 15:21:23 -040090 sk_sp<SkImageFilter> displacement = SkImageFilters::Image(std::move(auxImage));
91 return SkImageFilters::DisplacementMap(SkColorChannel::kR, SkColorChannel::kG, 40.f,
92 std::move(displacement), nullptr, cropRect);
Michael Ludwigd5fad8c2019-06-18 09:28:47 -040093}
94
Michael Ludwigfa974632019-06-20 14:21:28 -040095static sk_sp<SkImageFilter> arithmetic_factory(sk_sp<SkImage> auxImage, const SkIRect* cropRect) {
Michael Ludwig898bbfa2019-08-02 15:21:23 -040096 sk_sp<SkImageFilter> background = SkImageFilters::Image(std::move(auxImage));
97 return SkImageFilters::Arithmetic(0.0f, .6f, 1.f, 0.f, false, std::move(background),
98 nullptr, cropRect);
Michael Ludwigd5fad8c2019-06-18 09:28:47 -040099}
100
Michael Ludwigfa974632019-06-20 14:21:28 -0400101static sk_sp<SkImageFilter> xfermode_factory(sk_sp<SkImage> auxImage, const SkIRect* cropRect) {
Michael Ludwig898bbfa2019-08-02 15:21:23 -0400102 sk_sp<SkImageFilter> background = SkImageFilters::Image(std::move(auxImage));
103 return SkImageFilters::Xfermode(
104 SkBlendMode::kModulate, std::move(background), nullptr, cropRect);
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400105}
106
Michael Ludwigfa974632019-06-20 14:21:28 -0400107static sk_sp<SkImageFilter> convolution_factory(sk_sp<SkImage> auxImage, const SkIRect* cropRect) {
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400108 SkISize kernelSize = SkISize::Make(3, 3);
109 SkIPoint kernelOffset = SkIPoint::Make(1, 1);
110 // A Laplacian edge detector, ee https://en.wikipedia.org/wiki/Kernel_(image_processing)
111 SkScalar kernel[9] = {-1.f, -1.f, -1.f,
112 -1.f, 8.f, -1.f,
113 -1.f, -1.f, -1.f};
Michael Ludwig898bbfa2019-08-02 15:21:23 -0400114 return SkImageFilters::MatrixConvolution(kernelSize, kernel, 1.f, 0.f, kernelOffset,
115 SkTileMode::kClamp, false, nullptr, cropRect);
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400116}
117
Michael Ludwigfa974632019-06-20 14:21:28 -0400118static sk_sp<SkImageFilter> matrix_factory(sk_sp<SkImage> auxImage, const SkIRect* cropRect) {
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400119 SkMatrix matrix = SkMatrix::I();
120 matrix.setRotate(45.f, 50.f, 50.f);
121
122 // This doesn't support a cropRect
Michael Ludwig898bbfa2019-08-02 15:21:23 -0400123 return SkImageFilters::MatrixTransform(matrix, kLow_SkFilterQuality, nullptr);
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400124}
125
Michael Ludwigfa974632019-06-20 14:21:28 -0400126static sk_sp<SkImageFilter> alpha_threshold_factory(sk_sp<SkImage> auxImage,
127 const SkIRect* cropRect) {
Michael Ludwigfa974632019-06-20 14:21:28 -0400128 // Centered cross with higher opacity
129 SkRegion region(SkIRect::MakeLTRB(30, 45, 70, 55));
130 region.op(SkIRect::MakeLTRB(45, 30, 55, 70), SkRegion::kUnion_Op);
131
Michael Ludwig898bbfa2019-08-02 15:21:23 -0400132 return SkImageFilters::AlphaThreshold(region, 1.f, .2f, nullptr, cropRect);
Michael Ludwigfa974632019-06-20 14:21:28 -0400133}
134
135static sk_sp<SkImageFilter> lighting_factory(sk_sp<SkImage> auxImage, const SkIRect* cropRect) {
Michael Ludwigfa974632019-06-20 14:21:28 -0400136 // Must convert the RGB values of the source to alpha, since that is what the lighting filters
137 // use to estimate their normals. This color matrix changes the color to white and the alpha
138 // to be equal to the approx. luminance of the original color.
139 static const float kMatrix[20] = {
140 0.f, 0.f, 0.f, 0.f, 1.f,
141 0.f, 0.f, 0.f, 0.f, 1.f,
142 0.f, 0.f, 0.f, 0.f, 1.f,
143 0.2126f, 0.7152f, 0.0722f, 0.f, 0.f
144 };
Michael Ludwig898bbfa2019-08-02 15:21:23 -0400145 sk_sp<SkImageFilter> srcToAlpha = SkImageFilters::ColorFilter(
Michael Ludwigfa974632019-06-20 14:21:28 -0400146 SkColorFilters::Matrix(kMatrix), nullptr);
147
148 // Combine both specular and diffuse into a single DAG since they use separate internal filter
149 // implementations.
150 SkScalar sinAzimuth = SkScalarSin(SkDegreesToRadians(225.f)),
151 cosAzimuth = SkScalarCos(SkDegreesToRadians(225.f));
152
153 SkPoint3 spotTarget = SkPoint3::Make(SkIntToScalar(40), SkIntToScalar(40), 0);
154 SkPoint3 diffLocation = SkPoint3::Make(spotTarget.fX + 50 * cosAzimuth,
155 spotTarget.fY + 50 * sinAzimuth,
156 SkIntToScalar(10));
157 SkPoint3 specLocation = SkPoint3::Make(spotTarget.fX - 50 * sinAzimuth,
158 spotTarget.fY + 50 * cosAzimuth,
159 SkIntToScalar(10));
Michael Ludwig898bbfa2019-08-02 15:21:23 -0400160 sk_sp<SkImageFilter> diffuse = SkImageFilters::PointLitDiffuse(
161 diffLocation, SK_ColorWHITE, /* scale */ 1.f, /* kd */ 2.f, srcToAlpha, cropRect);
162 sk_sp<SkImageFilter> specular = SkImageFilters::PointLitSpecular(
Michael Ludwigfa974632019-06-20 14:21:28 -0400163 specLocation, SK_ColorRED, /* scale */ 1.f, /* ks */ 1.f, /* shine */ 8.f,
Michael Ludwig898bbfa2019-08-02 15:21:23 -0400164 srcToAlpha, cropRect);
165 return SkImageFilters::Merge(std::move(diffuse), std::move(specular), cropRect);
Michael Ludwigfa974632019-06-20 14:21:28 -0400166}
167
168static sk_sp<SkImageFilter> tile_factory(sk_sp<SkImage> auxImage, const SkIRect* cropRect) {
169 // Tile the subset over a large region
Michael Ludwig898bbfa2019-08-02 15:21:23 -0400170 return SkImageFilters::Tile(SkRect::MakeLTRB(25, 25, 75, 75), SkRect::MakeWH(100, 100),
171 nullptr);
Michael Ludwigfa974632019-06-20 14:21:28 -0400172}
173
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400174namespace {
175 enum class Strategy {
176 // Uses makeWithFilter, passing in subset and clip directly
177 kMakeWithFilter,
178 // Uses saveLayer after clipRect() to filter on the restore (i.e. reference image)
179 kSaveLayer
180 };
181};
182
183// In this GM, we're going to feed the inner portion of a 100x100 mandrill (i.e., strip off a
184// 25-wide border) through the makeWithFilter method. We'll then draw the appropriate subset of the
185// result to the screen at the given offset. Some filters rely on a secondary image, which will be a
186// 100x100 checkerboard. The original image is drawn in the background so that alignment is clear
187// when drawing the result at its reported offset.
senorblanco5878dbd2016-05-19 14:50:29 -0700188class ImageMakeWithFilterGM : public skiagm::GM {
189public:
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400190 ImageMakeWithFilterGM (Strategy strategy, bool filterWithCropRect = false)
191 : fStrategy(strategy)
192 , fFilterWithCropRect(filterWithCropRect)
193 , fMainImage(nullptr)
194 , fAuxImage(nullptr) {}
senorblanco5878dbd2016-05-19 14:50:29 -0700195
196protected:
197 SkString onShortName() override {
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400198 SkString name = SkString("imagemakewithfilter");
199
200 if (fFilterWithCropRect) {
201 name.append("_crop");
202 }
203 if (fStrategy == Strategy::kSaveLayer) {
204 name.append("_ref");
205 }
206 return name;
senorblanco5878dbd2016-05-19 14:50:29 -0700207 }
208
Michael Ludwigfa974632019-06-20 14:21:28 -0400209 SkISize onISize() override { return SkISize::Make(1980, 860); }
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400210
211 void onOnceBeforeDraw() override {
212 SkImageInfo info = SkImageInfo::MakeN32(100, 100, kUnpremul_SkAlphaType);
213 auto surface = SkSurface::MakeRaster(info, nullptr);
214
215 sk_sp<SkImage> colorImage = GetResourceAsImage("images/mandrill_128.png");
216 // Resize to 100x100
217 surface->getCanvas()->drawImageRect(
218 colorImage, SkRect::MakeWH(colorImage->width(), colorImage->height()),
219 SkRect::MakeWH(info.width(), info.height()), nullptr);
220 fMainImage = surface->makeImageSnapshot();
221
222 ToolUtils::draw_checkerboard(surface->getCanvas());
223 fAuxImage = surface->makeImageSnapshot();
224 }
senorblanco5878dbd2016-05-19 14:50:29 -0700225
226 void onDraw(SkCanvas* canvas) override {
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400227 FilterFactory filters[] = {
228 color_filter_factory,
229 blur_filter_factory,
230 drop_shadow_factory,
231 offset_factory,
232 dilate_factory,
233 erode_factory,
234 displacement_factory,
235 arithmetic_factory,
236 xfermode_factory,
237 convolution_factory,
Michael Ludwigfa974632019-06-20 14:21:28 -0400238 matrix_factory,
239 alpha_threshold_factory,
240 lighting_factory,
241 tile_factory
senorblanco5878dbd2016-05-19 14:50:29 -0700242 };
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400243 const char* filterNames[] = {
244 "Color",
245 "Blur",
246 "Drop Shadow",
247 "Offset",
248 "Dilate",
249 "Erode",
250 "Displacement",
251 "Arithmetic",
252 "Xfer Mode",
253 "Convolution",
Michael Ludwigfa974632019-06-20 14:21:28 -0400254 "Matrix Xform",
255 "Alpha Threshold",
256 "Lighting",
257 "Tile"
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400258 };
259 static_assert(SK_ARRAY_COUNT(filters) == SK_ARRAY_COUNT(filterNames), "filter name length");
senorblanco5878dbd2016-05-19 14:50:29 -0700260
261 SkIRect clipBounds[] {
262 { -20, -20, 100, 100 },
263 { 0, 0, 75, 75 },
264 { 20, 20, 100, 100 },
265 { -20, -20, 50, 50 },
266 { 20, 20, 50, 50 },
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400267 { 30, 30, 75, 75 }
senorblanco5878dbd2016-05-19 14:50:29 -0700268 };
269
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400270 // These need to be GPU-backed when on the GPU to ensure that the image filters use the GPU
271 // code paths (otherwise they may choose to do CPU filtering then upload)
272 sk_sp<SkImage> mainImage, auxImage;
273 if (canvas->getGrContext()) {
Michael Ludwig8d3e2792019-06-19 12:46:43 -0400274 if (canvas->getGrContext()->abandoned()) {
275 return;
276 }
Brian Osmand566e2e2019-08-14 13:19:04 -0400277 mainImage = fMainImage->makeTextureImage(canvas->getGrContext());
278 auxImage = fAuxImage->makeTextureImage(canvas->getGrContext());
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400279 } else {
280 mainImage = fMainImage;
281 auxImage = fAuxImage;
282 }
Greg Daniel85da3362020-03-09 15:18:35 -0400283 if (!mainImage || !auxImage) {
284 return;
285 }
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400286 SkASSERT(mainImage && (mainImage->isTextureBacked() || !canvas->getGrContext()));
287 SkASSERT(auxImage && (auxImage->isTextureBacked() || !canvas->getGrContext()));
288
senorblanco5878dbd2016-05-19 14:50:29 -0700289 SkScalar MARGIN = SkIntToScalar(40);
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400290 SkScalar DX = mainImage->width() + MARGIN;
291 SkScalar DY = auxImage->height() + MARGIN;
292
293 // Header hinting at what the filters do
294 SkPaint textPaint;
295 textPaint.setAntiAlias(true);
296 SkFont font(nullptr, 12);
297 for (size_t i = 0; i < SK_ARRAY_COUNT(filterNames); ++i) {
298 canvas->drawString(filterNames[i], DX * i + MARGIN, 15, font, textPaint);
299 }
senorblanco5878dbd2016-05-19 14:50:29 -0700300
301 canvas->translate(MARGIN, MARGIN);
302
senorblanco5878dbd2016-05-19 14:50:29 -0700303 for (auto clipBound : clipBounds) {
304 canvas->save();
305 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
306 SkIRect subset = SkIRect::MakeXYWH(25, 25, 50, 50);
307 SkIRect outSubset;
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400308
309 // Draw the original image faintly so that it aids in checking alignment of the
310 // filtered result.
311 SkPaint alpha;
Michael Ludwigfa974632019-06-20 14:21:28 -0400312 alpha.setAlphaf(0.3f);
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400313 canvas->drawImage(mainImage, 0, 0, &alpha);
314
315 this->drawImageWithFilter(canvas, mainImage, auxImage, filters[i], clipBound,
316 subset, &outSubset);
317
318 // Draw outlines to highlight what was subset, what was cropped, and what was output
319 // (no output subset is displayed for kSaveLayer since that information isn't avail)
320 SkIRect* outSubsetBounds = nullptr;
321 if (fStrategy != Strategy::kSaveLayer) {
322 outSubsetBounds = &outSubset;
323 }
324 show_bounds(canvas, &clipBound, &subset, outSubsetBounds);
325
senorblanco5878dbd2016-05-19 14:50:29 -0700326 canvas->translate(DX, 0);
327 }
328 canvas->restore();
329 canvas->translate(0, DY);
330 }
331 }
332
333private:
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400334 Strategy fStrategy;
335 bool fFilterWithCropRect;
336 sk_sp<SkImage> fMainImage;
337 sk_sp<SkImage> fAuxImage;
338
339 void drawImageWithFilter(SkCanvas* canvas, sk_sp<SkImage> mainImage, sk_sp<SkImage> auxImage,
340 FilterFactory filterFactory, const SkIRect& clip,
341 const SkIRect& subset, SkIRect* dstRect) {
342 // When creating the filter with a crop rect equal to the clip, we should expect to see no
343 // difference from a filter without a crop rect. However, if the CTM isn't managed properly
344 // by makeWithFilter, then the final result will be the incorrect intersection of the clip
345 // and the transformed crop rect.
346 sk_sp<SkImageFilter> filter = filterFactory(auxImage,
347 fFilterWithCropRect ? &clip : nullptr);
348
349 if (fStrategy == Strategy::kSaveLayer) {
350 SkAutoCanvasRestore acr(canvas, true);
351
352 // Clip before the saveLayer with the filter
353 canvas->clipRect(SkRect::Make(clip));
354
355 // Put the image filter on the layer
356 SkPaint paint;
357 paint.setImageFilter(filter);
358 canvas->saveLayer(nullptr, &paint);
359
360 // Draw the original subset of the image
361 canvas->drawImageRect(mainImage, subset, SkRect::Make(subset), nullptr);
362
363 *dstRect = subset;
364 } else {
365 sk_sp<SkImage> result;
366 SkIRect outSubset;
367 SkIPoint offset;
368
369 result = mainImage->makeWithFilter(filter.get(), subset, clip, &outSubset, &offset);
370
371 SkASSERT(result);
372 SkASSERT(mainImage->isTextureBacked() == result->isTextureBacked());
373
374 *dstRect = SkIRect::MakeXYWH(offset.x(), offset.y(),
375 outSubset.width(), outSubset.height());
376 canvas->drawImageRect(result, outSubset, SkRect::Make(*dstRect), nullptr);
377 }
378 }
379
senorblanco5878dbd2016-05-19 14:50:29 -0700380 typedef GM INHERITED;
381};
Michael Ludwigb4580352019-06-21 16:01:42 -0400382// The different strategies should all look the same, with the exception of filters that affect
383// transparent black (i.e. the lighting filter). In the save layer case, the filter affects the
384// transparent pixels outside of the drawn subset, whereas the makeWithFilter is restricted. This
385// works as intended.
Michael Ludwigd5fad8c2019-06-18 09:28:47 -0400386DEF_GM( return new ImageMakeWithFilterGM(Strategy::kMakeWithFilter); )
387DEF_GM( return new ImageMakeWithFilterGM(Strategy::kSaveLayer); )
388// Test with crop rects on the image filters; should look identical to above if working correctly
389DEF_GM( return new ImageMakeWithFilterGM(Strategy::kMakeWithFilter, true); )
390DEF_GM( return new ImageMakeWithFilterGM(Strategy::kSaveLayer, true); )