blob: 43e8167596f2b599c64ae1e57319d6a26e49bef2 [file] [log] [blame]
Brian Salomon201700f2019-05-17 12:05:44 -04001/*
2 * Copyright 2019 Google LLC
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
8#include "gm/gm.h"
9#include "include/core/SkCanvas.h"
10#include "include/core/SkColor.h"
11#include "include/core/SkPaint.h"
12#include "include/core/SkRect.h"
13#include "include/core/SkSurface.h"
Brian Salomon024bd002019-06-11 11:38:16 -040014#include "include/core/SkYUVAIndex.h"
Brian Salomon201700f2019-05-17 12:05:44 -040015#include "include/gpu/GrContext.h"
Robert Phillipsb7bfbc22020-07-01 12:55:01 -040016#include "include/gpu/GrRecordingContext.h"
Brian Salomon201700f2019-05-17 12:05:44 -040017#include "src/core/SkAutoPixmapStorage.h"
18#include "src/core/SkConvertPixels.h"
Brian Salomon024bd002019-06-11 11:38:16 -040019#include "src/core/SkScopeExit.h"
Brian Salomon201700f2019-05-17 12:05:44 -040020#include "tools/Resources.h"
21#include "tools/ToolUtils.h"
22
Brian Salomon9241a6d2019-10-03 13:26:54 -040023namespace {
24struct AsyncContext {
25 bool fCalled = false;
Brian Salomon63a0a752020-06-26 13:32:09 -040026 std::unique_ptr<const SkImage::AsyncReadResult> fResult;
Brian Salomon9241a6d2019-10-03 13:26:54 -040027};
28} // anonymous namespace
29
30// Making this a lambda in the test functions caused:
31// "error: cannot compile this forwarded non-trivially copyable parameter yet"
32// on x86/Win/Clang bot, referring to 'result'.
Brian Salomon63a0a752020-06-26 13:32:09 -040033static void async_callback(void* c, std::unique_ptr<const SkImage::AsyncReadResult> result) {
Brian Salomon9241a6d2019-10-03 13:26:54 -040034 auto context = static_cast<AsyncContext*>(c);
35 context->fResult = std::move(result);
36 context->fCalled = true;
37};
38
Brian Salomon201700f2019-05-17 12:05:44 -040039// Draws the image to a surface, does a asyncRescaleAndReadPixels of the image, and then sticks
40// the result in a raster image.
Brian Salomon63a0a752020-06-26 13:32:09 -040041template <typename Src>
42static sk_sp<SkImage> do_read_and_scale(Src* src,
43 GrContext* context,
44 const SkIRect& srcRect,
45 const SkImageInfo& ii,
46 SkImage::RescaleGamma rescaleGamma,
Brian Salomon286b5572019-05-20 10:25:50 -040047 SkFilterQuality quality) {
Brian Salomon63a0a752020-06-26 13:32:09 -040048 auto* asyncContext = new AsyncContext();
49 src->asyncRescaleAndReadPixels(ii, srcRect, rescaleGamma, quality, async_callback,
50 asyncContext);
51 if (context) {
52 context->submit();
Brian Salomon39278022020-06-02 11:47:26 -040053 }
Brian Salomon63a0a752020-06-26 13:32:09 -040054 while (!asyncContext->fCalled) {
Brian Salomon9c219782019-10-02 22:51:08 +000055 // Only GPU should actually be asynchronous.
Brian Salomon63a0a752020-06-26 13:32:09 -040056 SkASSERT(context);
57 context->checkAsyncWorkCompletion();
Brian Salomon9c219782019-10-02 22:51:08 +000058 }
Brian Salomon63a0a752020-06-26 13:32:09 -040059 if (!asyncContext->fResult) {
Brian Salomon9241a6d2019-10-03 13:26:54 -040060 return nullptr;
61 }
Brian Salomon63a0a752020-06-26 13:32:09 -040062 SkPixmap pixmap(ii, asyncContext->fResult->data(0), asyncContext->fResult->rowBytes(0));
Brian Salomon9241a6d2019-10-03 13:26:54 -040063 auto releasePixels = [](const void*, void* c) { delete static_cast<AsyncContext*>(c); };
Brian Salomon63a0a752020-06-26 13:32:09 -040064 return SkImage::MakeFromRaster(pixmap, releasePixels, asyncContext);
Ravi Mistrycb550102019-10-03 09:06:25 +000065}
66
Brian Salomon63a0a752020-06-26 13:32:09 -040067template <typename Src>
68static sk_sp<SkImage> do_read_and_scale_yuv(Src* src,
69 GrContext* context,
70 SkYUVColorSpace yuvCS,
71 const SkIRect& srcRect,
72 SkISize size,
73 SkImage::RescaleGamma rescaleGamma,
74 SkFilterQuality quality,
75 SkScopeExit* cleanup) {
Brian Salomon9241a6d2019-10-03 13:26:54 -040076 SkASSERT(!(size.width() & 0b1) && !(size.height() & 0b1));
Ravi Mistrycb550102019-10-03 09:06:25 +000077
Brian Salomon9241a6d2019-10-03 13:26:54 -040078 SkISize uvSize = {size.width()/2, size.height()/2};
79 SkImageInfo yII = SkImageInfo::Make(size, kGray_8_SkColorType, kPremul_SkAlphaType);
80 SkImageInfo uvII = SkImageInfo::Make(uvSize, kGray_8_SkColorType, kPremul_SkAlphaType);
Ravi Mistrycb550102019-10-03 09:06:25 +000081
Brian Salomon63a0a752020-06-26 13:32:09 -040082 AsyncContext asyncContext;
83 src->asyncRescaleAndReadPixelsYUV420(yuvCS, SkColorSpace::MakeSRGB(), srcRect, size,
84 rescaleGamma, quality, async_callback, &asyncContext);
85 if (context) {
86 context->submit();
Brian Salomon39278022020-06-02 11:47:26 -040087 }
Brian Salomon63a0a752020-06-26 13:32:09 -040088 while (!asyncContext.fCalled) {
Ravi Mistrycb550102019-10-03 09:06:25 +000089 // Only GPU should actually be asynchronous.
Brian Salomon63a0a752020-06-26 13:32:09 -040090 SkASSERT(context);
91 context->checkAsyncWorkCompletion();
Ravi Mistrycb550102019-10-03 09:06:25 +000092 }
Brian Salomon63a0a752020-06-26 13:32:09 -040093 if (!asyncContext.fResult) {
Brian Salomoncd5caa32019-06-11 17:02:19 -040094 return nullptr;
95 }
Brian Salomon024bd002019-06-11 11:38:16 -040096 GrBackendTexture backendTextures[3];
Robert Phillips0a15cc62019-07-30 12:49:10 -040097
Brian Salomon63a0a752020-06-26 13:32:09 -040098 SkPixmap yPM(yII, asyncContext.fResult->data(0), asyncContext.fResult->rowBytes(0));
99 SkPixmap uPM(uvII, asyncContext.fResult->data(1), asyncContext.fResult->rowBytes(1));
100 SkPixmap vPM(uvII, asyncContext.fResult->data(2), asyncContext.fResult->rowBytes(2));
Brian Salomon9241a6d2019-10-03 13:26:54 -0400101
Brian Salomon63a0a752020-06-26 13:32:09 -0400102 backendTextures[0] = context->createBackendTexture(yPM, GrRenderable::kNo, GrProtected::kNo);
103 backendTextures[1] = context->createBackendTexture(uPM, GrRenderable::kNo, GrProtected::kNo);
104 backendTextures[2] = context->createBackendTexture(vPM, GrRenderable::kNo, GrProtected::kNo);
Brian Salomon9241a6d2019-10-03 13:26:54 -0400105
Robert Phillips2e1142c2019-08-14 12:33:29 -0400106 SkYUVAIndex indices[4] = {
107 { 0, SkColorChannel::kR},
108 { 1, SkColorChannel::kR},
109 { 2, SkColorChannel::kR},
110 {-1, SkColorChannel::kR}
111 };
112
Brian Salomon63a0a752020-06-26 13:32:09 -0400113 *cleanup = {[context, backendTextures] {
Greg Danielce9f0162020-06-30 13:42:46 -0400114 context->flush();
Brian Salomon63a0a752020-06-26 13:32:09 -0400115 context->submit(true);
116 context->deleteBackendTexture(backendTextures[0]);
117 context->deleteBackendTexture(backendTextures[1]);
118 context->deleteBackendTexture(backendTextures[2]);
Brian Salomon024bd002019-06-11 11:38:16 -0400119 }};
120
Brian Salomon63a0a752020-06-26 13:32:09 -0400121 return SkImage::MakeFromYUVATextures(context, yuvCS, backendTextures, indices, size,
Brian Salomon024bd002019-06-11 11:38:16 -0400122 kTopLeft_GrSurfaceOrigin, SkColorSpace::MakeSRGB());
123}
124
Brian Salomon201700f2019-05-17 12:05:44 -0400125// Draws a grid of rescales. The columns are none, low, and high filter quality. The rows are
126// rescale in src gamma and rescale in linear gamma.
Brian Salomon63a0a752020-06-26 13:32:09 -0400127template <typename Src>
128static skiagm::DrawResult do_rescale_grid(SkCanvas* canvas,
129 Src* src,
130 GrContext* context,
131 const SkIRect& srcRect,
132 SkISize newSize,
133 bool doYUV420,
134 SkString* errorMsg,
135 int pad = 0) {
Brian Salomon024bd002019-06-11 11:38:16 -0400136 if (doYUV420) {
Robert Phillipsf8f45d92020-07-01 11:11:18 -0400137 if (!canvas->recordingContext() || !canvas->recordingContext()->asDirectContext()) {
Brian Salomoncd5caa32019-06-11 17:02:19 -0400138 errorMsg->printf("YUV420 only supported on direct GPU for now.");
Brian Salomon024bd002019-06-11 11:38:16 -0400139 return skiagm::DrawResult::kSkip;
140 }
141 }
Brian Salomon201700f2019-05-17 12:05:44 -0400142 if (canvas->imageInfo().colorType() == kUnknown_SkColorType) {
143 *errorMsg = "Not supported on recording/vector backends.";
144 return skiagm::DrawResult::kSkip;
145 }
Brian Salomon9241a6d2019-10-03 13:26:54 -0400146 const auto ii = canvas->imageInfo().makeDimensions(newSize);
Brian Salomona34e0fc2019-05-17 19:56:59 +0000147
Brian Salomon024bd002019-06-11 11:38:16 -0400148 SkYUVColorSpace yuvColorSpace = kRec601_SkYUVColorSpace;
Brian Salomona34e0fc2019-05-17 19:56:59 +0000149 canvas->save();
Brian Salomon63a0a752020-06-26 13:32:09 -0400150 for (auto gamma : {SkImage::RescaleGamma::kSrc, SkImage::RescaleGamma::kLinear}) {
Brian Salomona34e0fc2019-05-17 19:56:59 +0000151 canvas->save();
152 for (auto quality : {kNone_SkFilterQuality, kLow_SkFilterQuality, kHigh_SkFilterQuality}) {
Brian Salomon024bd002019-06-11 11:38:16 -0400153 SkScopeExit cleanup;
154 sk_sp<SkImage> result;
155 if (doYUV420) {
Brian Salomon63a0a752020-06-26 13:32:09 -0400156 result = do_read_and_scale_yuv(src, context, yuvColorSpace, srcRect, newSize, gamma,
Brian Salomon024bd002019-06-11 11:38:16 -0400157 quality, &cleanup);
Brian Salomoncd5caa32019-06-11 17:02:19 -0400158 if (!result) {
159 errorMsg->printf("YUV420 async call failed. Allowed for now.");
160 return skiagm::DrawResult::kSkip;
161 }
Brian Salomon024bd002019-06-11 11:38:16 -0400162 int nextCS = static_cast<int>(yuvColorSpace + 1) % (kLastEnum_SkYUVColorSpace + 1);
163 yuvColorSpace = static_cast<SkYUVColorSpace>(nextCS);
164 } else {
Brian Salomon63a0a752020-06-26 13:32:09 -0400165 result = do_read_and_scale(src, context, srcRect, ii, gamma, quality);
Brian Salomoncd5caa32019-06-11 17:02:19 -0400166 if (!result) {
167 errorMsg->printf("async read call failed.");
168 return skiagm::DrawResult::kFail;
169 }
Brian Salomon024bd002019-06-11 11:38:16 -0400170 }
171 canvas->drawImage(result, 0, 0);
Brian Salomon9241a6d2019-10-03 13:26:54 -0400172 canvas->translate(newSize.width() + pad, 0);
Brian Salomona34e0fc2019-05-17 19:56:59 +0000173 }
174 canvas->restore();
Brian Salomon9241a6d2019-10-03 13:26:54 -0400175 canvas->translate(0, newSize.height() + pad);
Brian Salomon451b01f2019-05-17 12:39:17 -0400176 }
Brian Salomona34e0fc2019-05-17 19:56:59 +0000177 canvas->restore();
178 return skiagm::DrawResult::kOk;
Brian Salomon451b01f2019-05-17 12:39:17 -0400179}
180
Brian Salomon63a0a752020-06-26 13:32:09 -0400181static skiagm::DrawResult do_rescale_image_grid(SkCanvas* canvas,
182 const char* imageFile,
183 const SkIRect& srcRect,
184 SkISize newSize,
185 bool doSurface,
186 bool doYUV420,
187 SkString* errorMsg) {
Brian Salomon286b5572019-05-20 10:25:50 -0400188 auto image = GetResourceAsImage(imageFile);
189 if (!image) {
190 errorMsg->printf("Could not load image file %s.", imageFile);
191 return skiagm::DrawResult::kFail;
192 }
193 if (canvas->imageInfo().colorType() == kUnknown_SkColorType) {
194 *errorMsg = "Not supported on recording/vector backends.";
195 return skiagm::DrawResult::kSkip;
196 }
Brian Salomon63a0a752020-06-26 13:32:09 -0400197 if (doSurface) {
198 // Turn the image into a surface in order to call the read and rescale API
199 auto surfInfo = image->imageInfo().makeDimensions(image->dimensions());
200 auto surface = canvas->makeSurface(surfInfo);
201 if (!surface && surfInfo.colorType() == kBGRA_8888_SkColorType) {
202 surfInfo = surfInfo.makeColorType(kRGBA_8888_SkColorType);
203 surface = canvas->makeSurface(surfInfo);
Brian Salomon1caf3782020-06-26 17:06:31 +0000204 }
Brian Salomon63a0a752020-06-26 13:32:09 -0400205 if (!surface) {
206 *errorMsg = "Could not create surface for image.";
207 // When testing abandoned GrContext we expect surface creation to fail.
Robert Phillips9eb00022020-06-30 15:30:12 -0400208 if (canvas->recordingContext() && canvas->recordingContext()->abandoned()) {
Brian Salomon63a0a752020-06-26 13:32:09 -0400209 return skiagm::DrawResult::kSkip;
210 }
211 return skiagm::DrawResult::kFail;
212 }
213 SkPaint paint;
214 paint.setBlendMode(SkBlendMode::kSrc);
215 surface->getCanvas()->drawImage(image, 0, 0, &paint);
216 return do_rescale_grid(canvas, surface.get(), canvas->getGrContext(), srcRect, newSize,
217 doYUV420, errorMsg);
218 } else if (auto ctx = canvas->getGrContext()) {
219 image = image->makeTextureImage(ctx);
220 if (!image) {
221 *errorMsg = "Could not create image.";
222 // When testing abandoned GrContext we expect surface creation to fail.
Robert Phillips9eb00022020-06-30 15:30:12 -0400223 if (canvas->recordingContext() && canvas->recordingContext()->abandoned()) {
Brian Salomon63a0a752020-06-26 13:32:09 -0400224 return skiagm::DrawResult::kSkip;
225 }
226 return skiagm::DrawResult::kFail;
227 }
Brian Salomon1caf3782020-06-26 17:06:31 +0000228 }
Brian Salomon63a0a752020-06-26 13:32:09 -0400229 return do_rescale_grid(canvas, image.get(), canvas->getGrContext(), srcRect, newSize, doYUV420,
230 errorMsg);
Brian Salomon286b5572019-05-20 10:25:50 -0400231}
232
Brian Salomon63a0a752020-06-26 13:32:09 -0400233#define DEF_RESCALE_AND_READ_SURF_GM(IMAGE_FILE, TAG, SRC_RECT, W, H) \
234 DEF_SIMPLE_GM_CAN_FAIL(async_rescale_and_read_##TAG, canvas, errorMsg, 3 * W, 2 * H) { \
235 ToolUtils::draw_checkerboard(canvas, SK_ColorDKGRAY, SK_ColorLTGRAY, 25); \
236 return do_rescale_image_grid(canvas, #IMAGE_FILE, SRC_RECT, {W, H}, true, false, \
237 errorMsg); \
Brian Salomon201700f2019-05-17 12:05:44 -0400238 }
239
Brian Salomon63a0a752020-06-26 13:32:09 -0400240#define DEF_RESCALE_AND_READ_YUV_SURF_GM(IMAGE_FILE, TAG, SRC_RECT, W, H) \
241 DEF_SIMPLE_GM_CAN_FAIL(async_rescale_and_read_yuv420_##TAG, canvas, errorMsg, 3 * W, 2 * H) { \
242 ToolUtils::draw_checkerboard(canvas, SK_ColorDKGRAY, SK_ColorLTGRAY, 25); \
243 return do_rescale_image_grid(canvas, #IMAGE_FILE, SRC_RECT, {W, H}, true, true, errorMsg); \
Brian Salomon024bd002019-06-11 11:38:16 -0400244 }
245
Brian Salomon63a0a752020-06-26 13:32:09 -0400246#define DEF_RESCALE_AND_READ_IMG_GM(IMAGE_FILE, TAG, SRC_RECT, W, H) \
247 DEF_SIMPLE_GM_CAN_FAIL(async_rescale_and_read_##TAG, canvas, errorMsg, 3 * W, 2 * H) { \
248 ToolUtils::draw_checkerboard(canvas, SK_ColorDKGRAY, SK_ColorLTGRAY, 25); \
249 return do_rescale_image_grid(canvas, #IMAGE_FILE, SRC_RECT, {W, H}, false, false, \
250 errorMsg); \
251 }
Brian Salomon024bd002019-06-11 11:38:16 -0400252
Brian Salomon63a0a752020-06-26 13:32:09 -0400253#define DEF_RESCALE_AND_READ_YUV_IMG_GM(IMAGE_FILE, TAG, SRC_RECT, W, H) \
254 DEF_SIMPLE_GM_CAN_FAIL(async_rescale_and_read_yuv420_##TAG, canvas, errorMsg, 3 * W, 2 * H) { \
255 ToolUtils::draw_checkerboard(canvas, SK_ColorDKGRAY, SK_ColorLTGRAY, 25); \
256 return do_rescale_image_grid(canvas, #IMAGE_FILE, SRC_RECT, {W, H}, true, true, errorMsg); \
257 }
Brian Salomon201700f2019-05-17 12:05:44 -0400258
Brian Salomon63a0a752020-06-26 13:32:09 -0400259DEF_RESCALE_AND_READ_YUV_SURF_GM(
260 images/yellow_rose.webp, rose, SkIRect::MakeXYWH(50, 5, 200, 150), 410, 376)
Brian Salomon201700f2019-05-17 12:05:44 -0400261
Brian Salomon63a0a752020-06-26 13:32:09 -0400262DEF_RESCALE_AND_READ_YUV_IMG_GM(
263 images/yellow_rose.webp, rose_down, SkIRect::MakeXYWH(50, 5, 200, 150), 106, 60)
264
265DEF_RESCALE_AND_READ_SURF_GM(
266 images/yellow_rose.webp, rose, SkIRect::MakeXYWH(100, 20, 100, 100), 410, 410)
267
268DEF_RESCALE_AND_READ_SURF_GM(images/dog.jpg, dog_down, SkIRect::MakeXYWH(0, 10, 180, 150), 45, 45)
269DEF_RESCALE_AND_READ_IMG_GM(images/dog.jpg, dog_up, SkIRect::MakeWH(180, 180), 800, 400)
270
271DEF_RESCALE_AND_READ_IMG_GM(
272 images/text.png, text_down, SkIRect::MakeWH(637, 105), (int)(0.7 * 637), (int)(0.7 * 105))
273DEF_RESCALE_AND_READ_SURF_GM(
274 images/text.png, text_up, SkIRect::MakeWH(637, 105), (int)(1.2 * 637), (int)(1.2 * 105))
275DEF_RESCALE_AND_READ_IMG_GM(images/text.png,
276 text_up_large,
277 SkIRect::MakeXYWH(300, 0, 300, 105),
278 (int)(2.4 * 300),
279 (int)(2.4 * 105))
Brian Salomon286b5572019-05-20 10:25:50 -0400280
Brian Salomona7e5c7c2020-01-27 15:41:40 -0500281// Exercises non-scaling YUV420. Reads from the original canvas's surface in order to
282// exercise case where source surface is not a texture (in glbert config).
283DEF_SIMPLE_GM_CAN_FAIL(async_yuv_no_scale, canvas, errorMsg, 400, 300) {
284 auto surface = canvas->getSurface();
285 if (!surface) {
286 *errorMsg = "Not supported on recording/vector backends.";
287 return skiagm::DrawResult::kSkip;
288 }
289
290 auto image = GetResourceAsImage("images/yellow_rose.webp");
291 if (!image) {
292 return skiagm::DrawResult::kFail;
293 }
294 SkPaint paint;
295 canvas->drawImage(image.get(), 0, 0);
296
297 SkScopeExit scopeExit;
298 auto yuvImage = do_read_and_scale_yuv(
Brian Salomon63a0a752020-06-26 13:32:09 -0400299 surface, surface->getContext(), kRec601_SkYUVColorSpace, SkIRect::MakeWH(400, 300),
300 {400, 300}, SkImage::RescaleGamma::kSrc, kNone_SkFilterQuality, &scopeExit);
Brian Salomona7e5c7c2020-01-27 15:41:40 -0500301
302 canvas->clear(SK_ColorWHITE);
303 canvas->drawImage(yuvImage.get(), 0, 0);
304
305 return skiagm::DrawResult::kOk;
306}
307
Brian Salomon286b5572019-05-20 10:25:50 -0400308DEF_SIMPLE_GM_CAN_FAIL(async_rescale_and_read_no_bleed, canvas, errorMsg, 60, 60) {
309 if (canvas->imageInfo().colorType() == kUnknown_SkColorType) {
310 *errorMsg = "Not supported on recording/vector backends.";
311 return skiagm::DrawResult::kSkip;
312 }
313
314 static constexpr int kBorder = 5;
315 static constexpr int kInner = 5;
316 const auto srcRect = SkIRect::MakeXYWH(kBorder, kBorder, kInner, kInner);
317 auto surfaceII =
318 SkImageInfo::Make(kInner + 2 * kBorder, kInner + 2 * kBorder, kRGBA_8888_SkColorType,
319 kPremul_SkAlphaType, SkColorSpace::MakeSRGB());
320 auto surface = canvas->makeSurface(surfaceII);
Brian Salomonaf9b7b92019-05-20 12:19:37 -0400321 if (!surface) {
322 *errorMsg = "Could not create surface for image.";
Brian Salomon9be911c2019-05-20 14:01:21 -0400323 // When testing abandoned GrContext we expect surface creation to fail.
324 if (canvas->getGrContext() && canvas->getGrContext()->abandoned()) {
325 return skiagm::DrawResult::kSkip;
326 }
Brian Salomonaf9b7b92019-05-20 12:19:37 -0400327 return skiagm::DrawResult::kFail;
328 }
Brian Salomon286b5572019-05-20 10:25:50 -0400329 surface->getCanvas()->clear(SK_ColorRED);
330 surface->getCanvas()->save();
331 surface->getCanvas()->clipRect(SkRect::Make(srcRect), SkClipOp::kIntersect, false);
332 surface->getCanvas()->clear(SK_ColorBLUE);
333 surface->getCanvas()->restore();
334 static constexpr int kPad = 2;
335 canvas->translate(kPad, kPad);
336 skiagm::DrawResult result;
Brian Salomon9241a6d2019-10-03 13:26:54 -0400337 SkISize downSize = {static_cast<int>(kInner/2), static_cast<int>(kInner / 2)};
Brian Salomon63a0a752020-06-26 13:32:09 -0400338 GrContext* context = canvas->getGrContext();
339 result = do_rescale_grid(canvas, surface.get(), context, srcRect, downSize, false, errorMsg,
340 kPad);
341
Brian Salomon286b5572019-05-20 10:25:50 -0400342 if (result != skiagm::DrawResult::kOk) {
343 return result;
344 }
Mike Kleinf68213f2020-01-27 12:16:22 -0600345 canvas->translate(0, 4 * downSize.height());
Brian Salomon9241a6d2019-10-03 13:26:54 -0400346 SkISize upSize = {static_cast<int>(kInner * 3.5), static_cast<int>(kInner * 4.6)};
Brian Salomon63a0a752020-06-26 13:32:09 -0400347 result =
348 do_rescale_grid(canvas, surface.get(), context, srcRect, upSize, false, errorMsg, kPad);
Brian Salomon286b5572019-05-20 10:25:50 -0400349 if (result != skiagm::DrawResult::kOk) {
350 return result;
351 }
352 return skiagm::DrawResult::kOk;
353}