blob: 9b298a467f9a98b786594c6fe56baf022824b877 [file] [log] [blame]
Brian Salomond7065e72018-10-12 11:42:02 -04001/*
2 * Copyright 2018 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"
Ben Wagner7fde8e12019-05-01 17:28:53 -04009#include "include/core/SkBlendMode.h"
10#include "include/core/SkCanvas.h"
11#include "include/core/SkColor.h"
Brian Salomondb151e02019-09-17 12:11:16 -040012#include "include/core/SkColorFilter.h"
Kevin Lubick5e8f45f2022-03-31 15:07:44 -040013#include "include/core/SkColorSpace.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040014#include "include/core/SkImage.h"
15#include "include/core/SkImageInfo.h"
16#include "include/core/SkMatrix.h"
17#include "include/core/SkPaint.h"
18#include "include/core/SkPoint.h"
19#include "include/core/SkRect.h"
20#include "include/core/SkRefCnt.h"
21#include "include/core/SkScalar.h"
22#include "include/core/SkShader.h"
23#include "include/core/SkSize.h"
24#include "include/core/SkString.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050025#include "include/core/SkSurface.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040026#include "include/core/SkTileMode.h"
27#include "include/core/SkTypes.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050028#include "include/effects/SkGradientShader.h"
Jim Van Vertha8624432023-02-13 16:48:09 -050029#include "include/gpu/GrDirectContext.h"
Kevin Lubick9b028372023-10-05 15:04:54 -040030#include "tools/GpuToolUtils.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050031#include "tools/ToolUtils.h"
Brian Salomond7065e72018-10-12 11:42:02 -040032
Ben Wagner7fde8e12019-05-01 17:28:53 -040033#include <algorithm>
34#include <initializer_list>
35#include <utility>
36
Brian Salomon1da5cad2018-11-21 09:21:18 -050037// Makes a set of m x n tiled images to be drawn with SkCanvas::experimental_drawImageSetV1().
Brian Salomon0087c832018-10-15 14:48:20 -040038static void make_image_tiles(int tileW, int tileH, int m, int n, const SkColor colors[4],
Michael Ludwig1c66ad92020-07-10 08:59:44 -040039 SkCanvas::ImageSetEntry set[], const SkColor bgColor=SK_ColorLTGRAY) {
Brian Salomon0087c832018-10-15 14:48:20 -040040 const int w = tileW * m;
41 const int h = tileH * n;
Kevin Lubick5c93acf2023-05-09 12:11:43 -040042 auto surf = SkSurfaces::Raster(
Brian Salomon0087c832018-10-15 14:48:20 -040043 SkImageInfo::Make(w, h, kRGBA_8888_SkColorType, kPremul_SkAlphaType));
Michael Ludwig1c66ad92020-07-10 08:59:44 -040044 surf->getCanvas()->clear(bgColor);
Brian Salomon0087c832018-10-15 14:48:20 -040045
46 static constexpr SkScalar kStripeW = 10;
47 static constexpr SkScalar kStripeSpacing = 30;
48 SkPaint paint;
49
50 SkPoint pts1[] = {{0.f, 0.f}, {(SkScalar)w, (SkScalar)h}};
Mike Reedfae8fce2019-04-03 10:27:45 -040051 auto grad = SkGradientShader::MakeLinear(pts1, colors, nullptr, 2, SkTileMode::kClamp);
Brian Salomon0087c832018-10-15 14:48:20 -040052 paint.setShader(std::move(grad));
53 paint.setAntiAlias(true);
54 paint.setStyle(SkPaint::kStroke_Style);
55 paint.setStrokeWidth(kStripeW);
56 SkPoint stripePts[] = {{-w - kStripeW, -kStripeW}, {kStripeW, h + kStripeW}};
57 while (stripePts[0].fX <= w) {
58 surf->getCanvas()->drawPoints(SkCanvas::kLines_PointMode, 2, stripePts, paint);
59 stripePts[0].fX += kStripeSpacing;
60 stripePts[1].fX += kStripeSpacing;
61 }
62
63 SkPoint pts2[] = {{0.f, (SkScalar)h}, {(SkScalar)w, 0.f}};
Mike Reedfae8fce2019-04-03 10:27:45 -040064 grad = SkGradientShader::MakeLinear(pts2, colors + 2, nullptr, 2, SkTileMode::kClamp);
Brian Salomon0087c832018-10-15 14:48:20 -040065 paint.setShader(std::move(grad));
66 paint.setBlendMode(SkBlendMode::kMultiply);
67 stripePts[0] = {-w - kStripeW, h + kStripeW};
68 stripePts[1] = {kStripeW, -kStripeW};
69 while (stripePts[0].fX <= w) {
70 surf->getCanvas()->drawPoints(SkCanvas::kLines_PointMode, 2, stripePts, paint);
71 stripePts[0].fX += kStripeSpacing;
72 stripePts[1].fX += kStripeSpacing;
73 }
74 auto fullImage = surf->makeImageSnapshot();
75 for (int y = 0; y < n; ++y) {
76 for (int x = 0; x < m; ++x) {
77 // Images will have 1 pixel of overlap at interior seams for filtering continuity.
78 SkIRect subset = SkIRect::MakeXYWH(x * tileW - 1, y * tileH - 1, tileW + 2, tileH + 2);
79 set[y * m + x].fAAFlags = SkCanvas::kNone_QuadAAFlags;
80 if (x == 0) {
81 subset.fLeft = 0;
82 set[y * m + x].fAAFlags |= SkCanvas::kLeft_QuadAAFlag;
83 }
84 if (x == m - 1) {
85 subset.fRight = w;
86 set[y * m + x].fAAFlags |= SkCanvas::kRight_QuadAAFlag;
87 }
88 if (y == 0) {
89 subset.fTop = 0;
90 set[y * m + x].fAAFlags |= SkCanvas::kTop_QuadAAFlag;
91 }
92 if (y == n - 1) {
93 subset.fBottom = h;
94 set[y * m + x].fAAFlags |= SkCanvas::kBottom_QuadAAFlag;
95 }
Kevin Lubick14d319b2023-04-27 15:43:07 -040096 set[y * m + x].fImage = fullImage->makeSubset(nullptr, subset);
Brian Salomon0087c832018-10-15 14:48:20 -040097 set[y * m + x].fSrcRect =
98 SkRect::MakeXYWH(x == 0 ? 0 : 1, y == 0 ? 0 : 1, tileW, tileH);
99 set[y * m + x].fDstRect = SkRect::MakeXYWH(x * tileW, y * tileH, tileW, tileH);
Brian Salomon1da5cad2018-11-21 09:21:18 -0500100 set[y * m + x].fAlpha = 1.f;
Brian Salomon0087c832018-10-15 14:48:20 -0400101 SkASSERT(set[y * m + x].fImage);
102 }
103 }
104}
105
Brian Salomond7065e72018-10-12 11:42:02 -0400106namespace skiagm {
107
108class DrawImageSetGM : public GM {
109private:
Leandro Lovisolo24fa2112023-08-15 19:05:17 +0000110 SkString getName() const override { return SkString("draw_image_set"); }
Leandro Lovisolo8f023882023-08-15 21:13:52 +0000111 SkISize getISize() override { return {1000, 725}; }
Brian Salomond7065e72018-10-12 11:42:02 -0400112 void onOnceBeforeDraw() override {
Brian Salomon0087c832018-10-15 14:48:20 -0400113 static constexpr SkColor kColors[] = {SK_ColorCYAN, SK_ColorBLACK,
114 SK_ColorMAGENTA, SK_ColorBLACK};
115 make_image_tiles(kTileW, kTileH, kM, kN, kColors, fSet);
Brian Salomond7065e72018-10-12 11:42:02 -0400116 }
117
118 void onDraw(SkCanvas* canvas) override {
119 SkScalar d = SkVector{kM * kTileW, kN * kTileH}.length();
120 SkMatrix matrices[4];
121 // rotation
122 matrices[0].setRotate(30);
123 matrices[0].postTranslate(d / 3, 0);
124 // perespective
125 SkPoint src[4];
126 SkRect::MakeWH(kM * kTileW, kN * kTileH).toQuad(src);
127 SkPoint dst[4] = {{0, 0},
128 {kM * kTileW + 10.f, -5.f},
129 {kM * kTileW - 28.f, kN * kTileH + 40.f},
130 {45.f, kN * kTileH - 25.f}};
131 SkAssertResult(matrices[1].setPolyToPoly(src, dst, 4));
132 matrices[1].postTranslate(d, 50.f);
133 // skew
134 matrices[2].setRotate(-60.f);
135 matrices[2].postSkew(0.5f, -1.15f);
136 matrices[2].postScale(0.6f, 1.05f);
137 matrices[2].postTranslate(d, 2.6f * d);
138 // perspective + mirror in x.
139 dst[1] = {-.25 * kM * kTileW, 0};
140 dst[0] = {5.f / 4.f * kM * kTileW, 0};
141 dst[3] = {2.f / 3.f * kM * kTileW, 1 / 2.f * kN * kTileH};
142 dst[2] = {1.f / 3.f * kM * kTileW, 1 / 2.f * kN * kTileH - 0.1f * kTileH};
143 SkAssertResult(matrices[3].setPolyToPoly(src, dst, 4));
144 matrices[3].postTranslate(100.f, d);
Mike Reed99116302021-01-25 11:37:10 -0500145 for (auto fm : {SkFilterMode::kNearest, SkFilterMode::kLinear}) {
Michael Ludwigcf677782019-03-26 16:41:49 -0400146 SkPaint setPaint;
Michael Ludwigcf677782019-03-26 16:41:49 -0400147 setPaint.setBlendMode(SkBlendMode::kSrcOver);
Mike Reed99116302021-01-25 11:37:10 -0500148 SkSamplingOptions sampling(fm);
Michael Ludwig926fb892019-03-22 16:37:53 -0400149
Herb Derbyc37b3862022-06-21 09:49:17 -0400150 for (size_t m = 0; m < std::size(matrices); ++m) {
Brian Salomond7065e72018-10-12 11:42:02 -0400151 // Draw grid of red lines at interior tile boundaries.
152 static constexpr SkScalar kLineOutset = 10.f;
153 SkPaint paint;
154 paint.setAntiAlias(true);
155 paint.setColor(SK_ColorRED);
156 paint.setStyle(SkPaint::kStroke_Style);
157 paint.setStrokeWidth(0.f);
158 for (int x = 1; x < kM; ++x) {
159 SkPoint pts[] = {{x * kTileW, 0}, {x * kTileW, kN * kTileH}};
160 matrices[m].mapPoints(pts, 2);
161 SkVector v = pts[1] - pts[0];
162 v.setLength(v.length() + kLineOutset);
163 canvas->drawLine(pts[1] - v, pts[0] + v, paint);
164 }
165 for (int y = 1; y < kN; ++y) {
166 SkPoint pts[] = {{0, y * kTileH}, {kTileW * kM, y * kTileH}};
167 matrices[m].mapPoints(pts, 2);
168 SkVector v = pts[1] - pts[0];
169 v.setLength(v.length() + kLineOutset);
170 canvas->drawLine(pts[1] - v, pts[0] + v, paint);
171 }
172 canvas->save();
173 canvas->concat(matrices[m]);
Mike Reed99116302021-01-25 11:37:10 -0500174 canvas->experimental_DrawEdgeAAImageSet(fSet, kM * kN, nullptr, nullptr, sampling,
175 &setPaint,
Michael Ludwig926fb892019-03-22 16:37:53 -0400176 SkCanvas::kFast_SrcRectConstraint);
Brian Salomond7065e72018-10-12 11:42:02 -0400177 canvas->restore();
178 }
Michael Ludwiga3c45c72019-01-17 17:26:48 -0500179 // A more exotic case with an unusual blend mode, mixed aa flags set, and alpha,
Brian Salomondb151e02019-09-17 12:11:16 -0400180 // subsets the image. And another with all the above plus a color filter.
Brian Salomond7065e72018-10-12 11:42:02 -0400181 SkCanvas::ImageSetEntry entry;
182 entry.fSrcRect = SkRect::MakeWH(kTileW, kTileH).makeInset(kTileW / 4.f, kTileH / 4.f);
Brian Salomondb151e02019-09-17 12:11:16 -0400183 entry.fDstRect = SkRect::MakeWH(1.5 * kTileW, 1.5 * kTileH).makeOffset(d / 4, 2 * d);
Brian Salomon0087c832018-10-15 14:48:20 -0400184 entry.fImage = fSet[0].fImage;
Brian Salomon1da5cad2018-11-21 09:21:18 -0500185 entry.fAlpha = 0.7f;
Michael Ludwiga3c45c72019-01-17 17:26:48 -0500186 entry.fAAFlags = SkCanvas::kLeft_QuadAAFlag | SkCanvas::kTop_QuadAAFlag;
Brian Salomond7065e72018-10-12 11:42:02 -0400187 canvas->save();
188 canvas->rotate(3.f);
Michael Ludwig926fb892019-03-22 16:37:53 -0400189
Michael Ludwigcf677782019-03-26 16:41:49 -0400190 setPaint.setBlendMode(SkBlendMode::kExclusion);
Mike Reed99116302021-01-25 11:37:10 -0500191 canvas->experimental_DrawEdgeAAImageSet(&entry, 1, nullptr, nullptr, sampling,
192 &setPaint, SkCanvas::kFast_SrcRectConstraint);
Brian Salomondb151e02019-09-17 12:11:16 -0400193 canvas->translate(entry.fDstRect.width() + 8.f, 0);
194 SkPaint cfPaint = setPaint;
195 cfPaint.setColorFilter(SkColorFilters::LinearToSRGBGamma());
Mike Reed99116302021-01-25 11:37:10 -0500196 canvas->experimental_DrawEdgeAAImageSet(&entry, 1, nullptr, nullptr, sampling,
197 &cfPaint, SkCanvas::kFast_SrcRectConstraint);
Brian Salomond7065e72018-10-12 11:42:02 -0400198 canvas->restore();
199 canvas->translate(2 * d, 0);
200 }
201 }
Brian Salomon9fa47cc2021-10-08 18:48:26 -0400202 inline static constexpr int kM = 4;
203 inline static constexpr int kN = 3;
204 inline static constexpr SkScalar kTileW = 30;
205 inline static constexpr SkScalar kTileH = 60;
Brian Salomon0087c832018-10-15 14:48:20 -0400206 SkCanvas::ImageSetEntry fSet[kM * kN];
207};
208
209// This GM exercises rect-stays-rect type matrices to test that filtering and antialiasing are not
210// incorrectly disabled.
211class DrawImageSetRectToRectGM : public GM {
212private:
Leandro Lovisolo24fa2112023-08-15 19:05:17 +0000213 SkString getName() const override { return SkString("draw_image_set_rect_to_rect"); }
Leandro Lovisolo8f023882023-08-15 21:13:52 +0000214 SkISize getISize() override { return {1250, 850}; }
Brian Salomon0087c832018-10-15 14:48:20 -0400215 void onOnceBeforeDraw() override {
216 static constexpr SkColor kColors[] = {SK_ColorBLUE, SK_ColorWHITE,
217 SK_ColorRED, SK_ColorWHITE};
218 make_image_tiles(kTileW, kTileH, kM, kN, kColors, fSet);
219 }
220
221 void onDraw(SkCanvas* canvas) override {
Mike Kleinea3f0142019-03-20 11:12:10 -0500222 ToolUtils::draw_checkerboard(canvas, SK_ColorBLACK, SK_ColorWHITE, 50);
Brian Salomon0087c832018-10-15 14:48:20 -0400223 static constexpr SkScalar kW = kM * kTileW;
224 static constexpr SkScalar kH = kN * kTileH;
225 SkMatrix matrices[5];
226 // Identity
227 matrices[0].reset();
228 // 90 degree rotation
229 matrices[1].setRotate(90, kW / 2.f, kH / 2.f);
230 // Scaling
231 matrices[2].setScale(2.f, 0.5f);
232 // Mirror in x and y
233 matrices[3].setScale(-1.f, -1.f);
234 matrices[3].postTranslate(kW, kH);
235 // Mirror in y, rotate, and scale.
236 matrices[4].setScale(1.f, -1.f);
237 matrices[4].postTranslate(0, kH);
238 matrices[4].postRotate(90, kW / 2.f, kH / 2.f);
239 matrices[4].postScale(2.f, 0.5f);
240
Michael Ludwig926fb892019-03-22 16:37:53 -0400241 SkPaint paint;
Michael Ludwig926fb892019-03-22 16:37:53 -0400242 paint.setBlendMode(SkBlendMode::kSrcOver);
243
Brian Osman788b9162020-02-07 10:36:46 -0500244 static constexpr SkScalar kTranslate = std::max(kW, kH) * 2.f + 10.f;
Brian Salomon0087c832018-10-15 14:48:20 -0400245 canvas->translate(5.f, 5.f);
246 canvas->save();
247 for (SkScalar frac : {0.f, 0.5f}) {
248 canvas->save();
249 canvas->translate(frac, frac);
Herb Derbyc37b3862022-06-21 09:49:17 -0400250 for (size_t m = 0; m < std::size(matrices); ++m) {
Brian Salomon0087c832018-10-15 14:48:20 -0400251 canvas->save();
252 canvas->concat(matrices[m]);
Mike Reed99116302021-01-25 11:37:10 -0500253 canvas->experimental_DrawEdgeAAImageSet(fSet, kM * kN, nullptr, nullptr,
254 SkSamplingOptions(SkFilterMode::kLinear),
255 &paint, SkCanvas::kFast_SrcRectConstraint);
Brian Salomon0087c832018-10-15 14:48:20 -0400256 canvas->restore();
257 canvas->translate(kTranslate, 0);
258 }
259 canvas->restore();
260 canvas->restore();
261 canvas->translate(0, kTranslate);
262 canvas->save();
263 }
264 for (SkVector scale : {SkVector{2.f, 0.5f}, SkVector{0.5, 2.f}}) {
265 SkCanvas::ImageSetEntry scaledSet[kM * kN];
266 std::copy_n(fSet, kM * kN, scaledSet);
267 for (int i = 0; i < kM * kN; ++i) {
268 scaledSet[i].fDstRect.fLeft *= scale.fX;
269 scaledSet[i].fDstRect.fTop *= scale.fY;
270 scaledSet[i].fDstRect.fRight *= scale.fX;
271 scaledSet[i].fDstRect.fBottom *= scale.fY;
Brian Salomon1da5cad2018-11-21 09:21:18 -0500272 scaledSet[i].fAlpha = 0 == (i % 3) ? 0.4f : 1.f;
Brian Salomon0087c832018-10-15 14:48:20 -0400273 }
Herb Derbyc37b3862022-06-21 09:49:17 -0400274 for (size_t m = 0; m < std::size(matrices); ++m) {
Brian Salomon0087c832018-10-15 14:48:20 -0400275 canvas->save();
276 canvas->concat(matrices[m]);
Michael Ludwig926fb892019-03-22 16:37:53 -0400277 canvas->experimental_DrawEdgeAAImageSet(scaledSet, kM * kN, nullptr, nullptr,
Mike Reed99116302021-01-25 11:37:10 -0500278 SkSamplingOptions(SkFilterMode::kLinear),
Michael Ludwig926fb892019-03-22 16:37:53 -0400279 &paint, SkCanvas::kFast_SrcRectConstraint);
Brian Salomon0087c832018-10-15 14:48:20 -0400280 canvas->restore();
281 canvas->translate(kTranslate, 0);
282 }
283 canvas->restore();
284 canvas->translate(0, kTranslate);
285 canvas->save();
286 }
287 }
Brian Salomon9fa47cc2021-10-08 18:48:26 -0400288 inline static constexpr int kM = 2;
289 inline static constexpr int kN = 2;
290 inline static constexpr int kTileW = 40;
291 inline static constexpr int kTileH = 50;
Brian Salomon0087c832018-10-15 14:48:20 -0400292 SkCanvas::ImageSetEntry fSet[kM * kN];
Brian Salomond7065e72018-10-12 11:42:02 -0400293};
294
Michael Ludwig1c66ad92020-07-10 08:59:44 -0400295// This GM exercises alpha-only and color textures being combined correctly with the paint's color.
296class DrawImageSetAlphaOnlyGM : public GM {
297private:
Leandro Lovisolo24fa2112023-08-15 19:05:17 +0000298 SkString getName() const override { return SkString("draw_image_set_alpha_only"); }
Leandro Lovisolo8f023882023-08-15 21:13:52 +0000299 SkISize getISize() override { return {kM * kTileW, 2 * kN * kTileH}; }
Adlai Holler3a220172020-07-15 10:37:50 -0400300
Brian Salomonc759bbf2023-12-05 11:11:27 -0500301 DrawResult onGpuSetup(SkCanvas* canvas, SkString*, GraphiteTestContext*) override {
Jim Van Vertha8624432023-02-13 16:48:09 -0500302 auto direct = GrAsDirectContext(canvas->recordingContext());
Robert Phillips3d518872023-03-22 10:50:00 -0400303#if defined(SK_GRAPHITE)
304 auto recorder = canvas->recorder();
305#endif
Michael Ludwig1c66ad92020-07-10 08:59:44 -0400306 static constexpr SkColor kColors[] = {SK_ColorBLUE, SK_ColorTRANSPARENT,
307 SK_ColorRED, SK_ColorTRANSPARENT};
308 static constexpr SkColor kBGColor = SkColorSetARGB(128, 128, 128, 128);
309 make_image_tiles(kTileW, kTileH, kM, kN, kColors, fSet, kBGColor);
310
311 // Modify the alpha of the entries, decreasing by column, and convert even rows to
312 // alpha-only textures.
313 sk_sp<SkColorSpace> alphaSpace = SkColorSpace::MakeSRGB();
314 for (int y = 0; y < kN; ++y) {
315 for (int x = 0; x < kM; ++x) {
316 int i = y * kM + x;
317 fSet[i].fAlpha = (kM - x) / (float) kM;
318 if (y % 2 == 0) {
Robert Phillips3d518872023-03-22 10:50:00 -0400319#if defined(SK_GRAPHITE)
320 if (recorder) {
321 fSet[i].fImage = fSet[i].fImage->makeColorTypeAndColorSpace(
Kevin Lubickf95da882023-05-12 11:16:12 -0400322 recorder, kAlpha_8_SkColorType, alphaSpace, {});
Robert Phillips3d518872023-03-22 10:50:00 -0400323 } else
324#endif
325 {
326 fSet[i].fImage = fSet[i].fImage->makeColorTypeAndColorSpace(
Kevin Lubickf95da882023-05-12 11:16:12 -0400327 direct, kAlpha_8_SkColorType, alphaSpace);
Robert Phillips3d518872023-03-22 10:50:00 -0400328 }
Michael Ludwig1c66ad92020-07-10 08:59:44 -0400329 }
330 }
331 }
Adlai Holler3a220172020-07-15 10:37:50 -0400332 return skiagm::DrawResult::kOk;
Michael Ludwig1c66ad92020-07-10 08:59:44 -0400333 }
334
335 void onDraw(SkCanvas* canvas) override {
336 ToolUtils::draw_checkerboard(canvas, SK_ColorGRAY, SK_ColorDKGRAY, 25);
337
338 SkPaint paint;
Michael Ludwig1c66ad92020-07-10 08:59:44 -0400339 paint.setBlendMode(SkBlendMode::kSrcOver);
340 paint.setColor4f({0.2f, 0.8f, 0.4f, 1.f}); // colorizes even rows, no effect on odd rows
341
342 // Top rows use experimental edge set API
Mike Reed99116302021-01-25 11:37:10 -0500343 canvas->experimental_DrawEdgeAAImageSet(fSet, kM * kN, nullptr, nullptr,
344 SkSamplingOptions(SkFilterMode::kLinear), &paint,
Michael Ludwig1c66ad92020-07-10 08:59:44 -0400345 SkCanvas::kFast_SrcRectConstraint);
346
347 canvas->translate(0.f, kN * kTileH);
348
349 // Bottom rows draw each image from the set using the regular API
350 for (int y = 0; y < kN; ++y) {
351 for (int x = 0; x < kM; ++x) {
352 int i = y * kM + x;
353 SkPaint entryPaint = paint;
354 entryPaint.setAlphaf(fSet[i].fAlpha * paint.getAlphaf());
Robert Phillips0fb10ab2022-04-20 14:57:03 -0400355 sk_sp<SkImage> orig = sk_ref_sp(const_cast<SkImage*>(fSet[i].fImage.get()));
356 canvas->drawImageRect(ToolUtils::MakeTextureImage(canvas, std::move(orig)),
357 fSet[i].fSrcRect, fSet[i].fDstRect,
Mike Reed07c5f522021-01-23 12:23:23 -0500358 SkSamplingOptions(), &entryPaint,
359 SkCanvas::kFast_SrcRectConstraint);
Michael Ludwig1c66ad92020-07-10 08:59:44 -0400360 }
361 }
362 }
363
Brian Salomon9fa47cc2021-10-08 18:48:26 -0400364 inline static constexpr int kM = 4;
365 inline static constexpr int kN = 4;
366 inline static constexpr int kTileW = 50;
367 inline static constexpr int kTileH = 50;
Michael Ludwig1c66ad92020-07-10 08:59:44 -0400368 SkCanvas::ImageSetEntry fSet[kM * kN];
369};
370
Brian Salomond7065e72018-10-12 11:42:02 -0400371DEF_GM(return new DrawImageSetGM();)
Brian Salomon0087c832018-10-15 14:48:20 -0400372DEF_GM(return new DrawImageSetRectToRectGM();)
Michael Ludwig1c66ad92020-07-10 08:59:44 -0400373DEF_GM(return new DrawImageSetAlphaOnlyGM();)
Brian Salomond7065e72018-10-12 11:42:02 -0400374
375} // namespace skiagm