blob: c27cb5f66ec570314f878eae579d09a412da5ca5 [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 Phillips95c250c2020-06-29 15:36:12 -040016#include "include/private/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"
Robert Phillips95c250c2020-06-29 15:36:12 -040020#include "src/gpu/GrRecordingContextPriv.h"
Brian Salomon201700f2019-05-17 12:05:44 -040021#include "tools/Resources.h"
22#include "tools/ToolUtils.h"
23
Brian Salomon9241a6d2019-10-03 13:26:54 -040024namespace {
25struct AsyncContext {
26 bool fCalled = false;
Brian Salomon63a0a752020-06-26 13:32:09 -040027 std::unique_ptr<const SkImage::AsyncReadResult> fResult;
Brian Salomon9241a6d2019-10-03 13:26:54 -040028};
29} // anonymous namespace
30
31// Making this a lambda in the test functions caused:
32// "error: cannot compile this forwarded non-trivially copyable parameter yet"
33// on x86/Win/Clang bot, referring to 'result'.
Brian Salomon63a0a752020-06-26 13:32:09 -040034static void async_callback(void* c, std::unique_ptr<const SkImage::AsyncReadResult> result) {
Brian Salomon9241a6d2019-10-03 13:26:54 -040035 auto context = static_cast<AsyncContext*>(c);
36 context->fResult = std::move(result);
37 context->fCalled = true;
38};
39
Brian Salomon201700f2019-05-17 12:05:44 -040040// Draws the image to a surface, does a asyncRescaleAndReadPixels of the image, and then sticks
41// the result in a raster image.
Brian Salomon63a0a752020-06-26 13:32:09 -040042template <typename Src>
43static sk_sp<SkImage> do_read_and_scale(Src* src,
44 GrContext* context,
45 const SkIRect& srcRect,
46 const SkImageInfo& ii,
47 SkImage::RescaleGamma rescaleGamma,
Brian Salomon286b5572019-05-20 10:25:50 -040048 SkFilterQuality quality) {
Brian Salomon63a0a752020-06-26 13:32:09 -040049 auto* asyncContext = new AsyncContext();
50 src->asyncRescaleAndReadPixels(ii, srcRect, rescaleGamma, quality, async_callback,
51 asyncContext);
52 if (context) {
53 context->submit();
Brian Salomon39278022020-06-02 11:47:26 -040054 }
Brian Salomon63a0a752020-06-26 13:32:09 -040055 while (!asyncContext->fCalled) {
Brian Salomon9c219782019-10-02 22:51:08 +000056 // Only GPU should actually be asynchronous.
Brian Salomon63a0a752020-06-26 13:32:09 -040057 SkASSERT(context);
58 context->checkAsyncWorkCompletion();
Brian Salomon9c219782019-10-02 22:51:08 +000059 }
Brian Salomon63a0a752020-06-26 13:32:09 -040060 if (!asyncContext->fResult) {
Brian Salomon9241a6d2019-10-03 13:26:54 -040061 return nullptr;
62 }
Brian Salomon63a0a752020-06-26 13:32:09 -040063 SkPixmap pixmap(ii, asyncContext->fResult->data(0), asyncContext->fResult->rowBytes(0));
Brian Salomon9241a6d2019-10-03 13:26:54 -040064 auto releasePixels = [](const void*, void* c) { delete static_cast<AsyncContext*>(c); };
Brian Salomon63a0a752020-06-26 13:32:09 -040065 return SkImage::MakeFromRaster(pixmap, releasePixels, asyncContext);
Ravi Mistrycb550102019-10-03 09:06:25 +000066}
67
Brian Salomon63a0a752020-06-26 13:32:09 -040068template <typename Src>
69static sk_sp<SkImage> do_read_and_scale_yuv(Src* src,
70 GrContext* context,
71 SkYUVColorSpace yuvCS,
72 const SkIRect& srcRect,
73 SkISize size,
74 SkImage::RescaleGamma rescaleGamma,
75 SkFilterQuality quality,
76 SkScopeExit* cleanup) {
Brian Salomon9241a6d2019-10-03 13:26:54 -040077 SkASSERT(!(size.width() & 0b1) && !(size.height() & 0b1));
Ravi Mistrycb550102019-10-03 09:06:25 +000078
Brian Salomon9241a6d2019-10-03 13:26:54 -040079 SkISize uvSize = {size.width()/2, size.height()/2};
80 SkImageInfo yII = SkImageInfo::Make(size, kGray_8_SkColorType, kPremul_SkAlphaType);
81 SkImageInfo uvII = SkImageInfo::Make(uvSize, kGray_8_SkColorType, kPremul_SkAlphaType);
Ravi Mistrycb550102019-10-03 09:06:25 +000082
Brian Salomon63a0a752020-06-26 13:32:09 -040083 AsyncContext asyncContext;
84 src->asyncRescaleAndReadPixelsYUV420(yuvCS, SkColorSpace::MakeSRGB(), srcRect, size,
85 rescaleGamma, quality, async_callback, &asyncContext);
86 if (context) {
87 context->submit();
Brian Salomon39278022020-06-02 11:47:26 -040088 }
Brian Salomon63a0a752020-06-26 13:32:09 -040089 while (!asyncContext.fCalled) {
Ravi Mistrycb550102019-10-03 09:06:25 +000090 // Only GPU should actually be asynchronous.
Brian Salomon63a0a752020-06-26 13:32:09 -040091 SkASSERT(context);
92 context->checkAsyncWorkCompletion();
Ravi Mistrycb550102019-10-03 09:06:25 +000093 }
Brian Salomon63a0a752020-06-26 13:32:09 -040094 if (!asyncContext.fResult) {
Brian Salomoncd5caa32019-06-11 17:02:19 -040095 return nullptr;
96 }
Brian Salomon024bd002019-06-11 11:38:16 -040097 GrBackendTexture backendTextures[3];
Robert Phillips0a15cc62019-07-30 12:49:10 -040098
Brian Salomon63a0a752020-06-26 13:32:09 -040099 SkPixmap yPM(yII, asyncContext.fResult->data(0), asyncContext.fResult->rowBytes(0));
100 SkPixmap uPM(uvII, asyncContext.fResult->data(1), asyncContext.fResult->rowBytes(1));
101 SkPixmap vPM(uvII, asyncContext.fResult->data(2), asyncContext.fResult->rowBytes(2));
Brian Salomon9241a6d2019-10-03 13:26:54 -0400102
Brian Salomon63a0a752020-06-26 13:32:09 -0400103 backendTextures[0] = context->createBackendTexture(yPM, GrRenderable::kNo, GrProtected::kNo);
104 backendTextures[1] = context->createBackendTexture(uPM, GrRenderable::kNo, GrProtected::kNo);
105 backendTextures[2] = context->createBackendTexture(vPM, GrRenderable::kNo, GrProtected::kNo);
Brian Salomon9241a6d2019-10-03 13:26:54 -0400106
Robert Phillips2e1142c2019-08-14 12:33:29 -0400107 SkYUVAIndex indices[4] = {
108 { 0, SkColorChannel::kR},
109 { 1, SkColorChannel::kR},
110 { 2, SkColorChannel::kR},
111 {-1, SkColorChannel::kR}
112 };
113
Brian Salomon63a0a752020-06-26 13:32:09 -0400114 *cleanup = {[context, backendTextures] {
Greg Danielce9f0162020-06-30 13:42:46 -0400115 context->flush();
Brian Salomon63a0a752020-06-26 13:32:09 -0400116 context->submit(true);
117 context->deleteBackendTexture(backendTextures[0]);
118 context->deleteBackendTexture(backendTextures[1]);
119 context->deleteBackendTexture(backendTextures[2]);
Brian Salomon024bd002019-06-11 11:38:16 -0400120 }};
121
Brian Salomon63a0a752020-06-26 13:32:09 -0400122 return SkImage::MakeFromYUVATextures(context, yuvCS, backendTextures, indices, size,
Brian Salomon024bd002019-06-11 11:38:16 -0400123 kTopLeft_GrSurfaceOrigin, SkColorSpace::MakeSRGB());
124}
125
Brian Salomon201700f2019-05-17 12:05:44 -0400126// Draws a grid of rescales. The columns are none, low, and high filter quality. The rows are
127// rescale in src gamma and rescale in linear gamma.
Brian Salomon63a0a752020-06-26 13:32:09 -0400128template <typename Src>
129static skiagm::DrawResult do_rescale_grid(SkCanvas* canvas,
130 Src* src,
131 GrContext* context,
132 const SkIRect& srcRect,
133 SkISize newSize,
134 bool doYUV420,
135 SkString* errorMsg,
136 int pad = 0) {
Brian Salomon024bd002019-06-11 11:38:16 -0400137 if (doYUV420) {
Robert Phillips95c250c2020-06-29 15:36:12 -0400138 if (!canvas->recordingContext() || !canvas->recordingContext()->priv().asDirectContext()) {
Brian Salomoncd5caa32019-06-11 17:02:19 -0400139 errorMsg->printf("YUV420 only supported on direct GPU for now.");
Brian Salomon024bd002019-06-11 11:38:16 -0400140 return skiagm::DrawResult::kSkip;
141 }
142 }
Brian Salomon201700f2019-05-17 12:05:44 -0400143 if (canvas->imageInfo().colorType() == kUnknown_SkColorType) {
144 *errorMsg = "Not supported on recording/vector backends.";
145 return skiagm::DrawResult::kSkip;
146 }
Brian Salomon9241a6d2019-10-03 13:26:54 -0400147 const auto ii = canvas->imageInfo().makeDimensions(newSize);
Brian Salomona34e0fc2019-05-17 19:56:59 +0000148
Brian Salomon024bd002019-06-11 11:38:16 -0400149 SkYUVColorSpace yuvColorSpace = kRec601_SkYUVColorSpace;
Brian Salomona34e0fc2019-05-17 19:56:59 +0000150 canvas->save();
Brian Salomon63a0a752020-06-26 13:32:09 -0400151 for (auto gamma : {SkImage::RescaleGamma::kSrc, SkImage::RescaleGamma::kLinear}) {
Brian Salomona34e0fc2019-05-17 19:56:59 +0000152 canvas->save();
153 for (auto quality : {kNone_SkFilterQuality, kLow_SkFilterQuality, kHigh_SkFilterQuality}) {
Brian Salomon024bd002019-06-11 11:38:16 -0400154 SkScopeExit cleanup;
155 sk_sp<SkImage> result;
156 if (doYUV420) {
Brian Salomon63a0a752020-06-26 13:32:09 -0400157 result = do_read_and_scale_yuv(src, context, yuvColorSpace, srcRect, newSize, gamma,
Brian Salomon024bd002019-06-11 11:38:16 -0400158 quality, &cleanup);
Brian Salomoncd5caa32019-06-11 17:02:19 -0400159 if (!result) {
160 errorMsg->printf("YUV420 async call failed. Allowed for now.");
161 return skiagm::DrawResult::kSkip;
162 }
Brian Salomon024bd002019-06-11 11:38:16 -0400163 int nextCS = static_cast<int>(yuvColorSpace + 1) % (kLastEnum_SkYUVColorSpace + 1);
164 yuvColorSpace = static_cast<SkYUVColorSpace>(nextCS);
165 } else {
Brian Salomon63a0a752020-06-26 13:32:09 -0400166 result = do_read_and_scale(src, context, srcRect, ii, gamma, quality);
Brian Salomoncd5caa32019-06-11 17:02:19 -0400167 if (!result) {
168 errorMsg->printf("async read call failed.");
169 return skiagm::DrawResult::kFail;
170 }
Brian Salomon024bd002019-06-11 11:38:16 -0400171 }
172 canvas->drawImage(result, 0, 0);
Brian Salomon9241a6d2019-10-03 13:26:54 -0400173 canvas->translate(newSize.width() + pad, 0);
Brian Salomona34e0fc2019-05-17 19:56:59 +0000174 }
175 canvas->restore();
Brian Salomon9241a6d2019-10-03 13:26:54 -0400176 canvas->translate(0, newSize.height() + pad);
Brian Salomon451b01f2019-05-17 12:39:17 -0400177 }
Brian Salomona34e0fc2019-05-17 19:56:59 +0000178 canvas->restore();
179 return skiagm::DrawResult::kOk;
Brian Salomon451b01f2019-05-17 12:39:17 -0400180}
181
Brian Salomon63a0a752020-06-26 13:32:09 -0400182static skiagm::DrawResult do_rescale_image_grid(SkCanvas* canvas,
183 const char* imageFile,
184 const SkIRect& srcRect,
185 SkISize newSize,
186 bool doSurface,
187 bool doYUV420,
188 SkString* errorMsg) {
Brian Salomon286b5572019-05-20 10:25:50 -0400189 auto image = GetResourceAsImage(imageFile);
190 if (!image) {
191 errorMsg->printf("Could not load image file %s.", imageFile);
192 return skiagm::DrawResult::kFail;
193 }
194 if (canvas->imageInfo().colorType() == kUnknown_SkColorType) {
195 *errorMsg = "Not supported on recording/vector backends.";
196 return skiagm::DrawResult::kSkip;
197 }
Brian Salomon63a0a752020-06-26 13:32:09 -0400198 if (doSurface) {
199 // Turn the image into a surface in order to call the read and rescale API
200 auto surfInfo = image->imageInfo().makeDimensions(image->dimensions());
201 auto surface = canvas->makeSurface(surfInfo);
202 if (!surface && surfInfo.colorType() == kBGRA_8888_SkColorType) {
203 surfInfo = surfInfo.makeColorType(kRGBA_8888_SkColorType);
204 surface = canvas->makeSurface(surfInfo);
Brian Salomon1caf3782020-06-26 17:06:31 +0000205 }
Brian Salomon63a0a752020-06-26 13:32:09 -0400206 if (!surface) {
207 *errorMsg = "Could not create surface for image.";
208 // When testing abandoned GrContext we expect surface creation to fail.
Robert Phillips9eb00022020-06-30 15:30:12 -0400209 if (canvas->recordingContext() && canvas->recordingContext()->abandoned()) {
Brian Salomon63a0a752020-06-26 13:32:09 -0400210 return skiagm::DrawResult::kSkip;
211 }
212 return skiagm::DrawResult::kFail;
213 }
214 SkPaint paint;
215 paint.setBlendMode(SkBlendMode::kSrc);
216 surface->getCanvas()->drawImage(image, 0, 0, &paint);
217 return do_rescale_grid(canvas, surface.get(), canvas->getGrContext(), srcRect, newSize,
218 doYUV420, errorMsg);
219 } else if (auto ctx = canvas->getGrContext()) {
220 image = image->makeTextureImage(ctx);
221 if (!image) {
222 *errorMsg = "Could not create image.";
223 // When testing abandoned GrContext we expect surface creation to fail.
Robert Phillips9eb00022020-06-30 15:30:12 -0400224 if (canvas->recordingContext() && canvas->recordingContext()->abandoned()) {
Brian Salomon63a0a752020-06-26 13:32:09 -0400225 return skiagm::DrawResult::kSkip;
226 }
227 return skiagm::DrawResult::kFail;
228 }
Brian Salomon1caf3782020-06-26 17:06:31 +0000229 }
Brian Salomon63a0a752020-06-26 13:32:09 -0400230 return do_rescale_grid(canvas, image.get(), canvas->getGrContext(), srcRect, newSize, doYUV420,
231 errorMsg);
Brian Salomon286b5572019-05-20 10:25:50 -0400232}
233
Brian Salomon63a0a752020-06-26 13:32:09 -0400234#define DEF_RESCALE_AND_READ_SURF_GM(IMAGE_FILE, TAG, SRC_RECT, W, H) \
235 DEF_SIMPLE_GM_CAN_FAIL(async_rescale_and_read_##TAG, canvas, errorMsg, 3 * W, 2 * H) { \
236 ToolUtils::draw_checkerboard(canvas, SK_ColorDKGRAY, SK_ColorLTGRAY, 25); \
237 return do_rescale_image_grid(canvas, #IMAGE_FILE, SRC_RECT, {W, H}, true, false, \
238 errorMsg); \
Brian Salomon201700f2019-05-17 12:05:44 -0400239 }
240
Brian Salomon63a0a752020-06-26 13:32:09 -0400241#define DEF_RESCALE_AND_READ_YUV_SURF_GM(IMAGE_FILE, TAG, SRC_RECT, W, H) \
242 DEF_SIMPLE_GM_CAN_FAIL(async_rescale_and_read_yuv420_##TAG, canvas, errorMsg, 3 * W, 2 * H) { \
243 ToolUtils::draw_checkerboard(canvas, SK_ColorDKGRAY, SK_ColorLTGRAY, 25); \
244 return do_rescale_image_grid(canvas, #IMAGE_FILE, SRC_RECT, {W, H}, true, true, errorMsg); \
Brian Salomon024bd002019-06-11 11:38:16 -0400245 }
246
Brian Salomon63a0a752020-06-26 13:32:09 -0400247#define DEF_RESCALE_AND_READ_IMG_GM(IMAGE_FILE, TAG, SRC_RECT, W, H) \
248 DEF_SIMPLE_GM_CAN_FAIL(async_rescale_and_read_##TAG, canvas, errorMsg, 3 * W, 2 * H) { \
249 ToolUtils::draw_checkerboard(canvas, SK_ColorDKGRAY, SK_ColorLTGRAY, 25); \
250 return do_rescale_image_grid(canvas, #IMAGE_FILE, SRC_RECT, {W, H}, false, false, \
251 errorMsg); \
252 }
Brian Salomon024bd002019-06-11 11:38:16 -0400253
Brian Salomon63a0a752020-06-26 13:32:09 -0400254#define DEF_RESCALE_AND_READ_YUV_IMG_GM(IMAGE_FILE, TAG, SRC_RECT, W, H) \
255 DEF_SIMPLE_GM_CAN_FAIL(async_rescale_and_read_yuv420_##TAG, canvas, errorMsg, 3 * W, 2 * H) { \
256 ToolUtils::draw_checkerboard(canvas, SK_ColorDKGRAY, SK_ColorLTGRAY, 25); \
257 return do_rescale_image_grid(canvas, #IMAGE_FILE, SRC_RECT, {W, H}, true, true, errorMsg); \
258 }
Brian Salomon201700f2019-05-17 12:05:44 -0400259
Brian Salomon63a0a752020-06-26 13:32:09 -0400260DEF_RESCALE_AND_READ_YUV_SURF_GM(
261 images/yellow_rose.webp, rose, SkIRect::MakeXYWH(50, 5, 200, 150), 410, 376)
Brian Salomon201700f2019-05-17 12:05:44 -0400262
Brian Salomon63a0a752020-06-26 13:32:09 -0400263DEF_RESCALE_AND_READ_YUV_IMG_GM(
264 images/yellow_rose.webp, rose_down, SkIRect::MakeXYWH(50, 5, 200, 150), 106, 60)
265
266DEF_RESCALE_AND_READ_SURF_GM(
267 images/yellow_rose.webp, rose, SkIRect::MakeXYWH(100, 20, 100, 100), 410, 410)
268
269DEF_RESCALE_AND_READ_SURF_GM(images/dog.jpg, dog_down, SkIRect::MakeXYWH(0, 10, 180, 150), 45, 45)
270DEF_RESCALE_AND_READ_IMG_GM(images/dog.jpg, dog_up, SkIRect::MakeWH(180, 180), 800, 400)
271
272DEF_RESCALE_AND_READ_IMG_GM(
273 images/text.png, text_down, SkIRect::MakeWH(637, 105), (int)(0.7 * 637), (int)(0.7 * 105))
274DEF_RESCALE_AND_READ_SURF_GM(
275 images/text.png, text_up, SkIRect::MakeWH(637, 105), (int)(1.2 * 637), (int)(1.2 * 105))
276DEF_RESCALE_AND_READ_IMG_GM(images/text.png,
277 text_up_large,
278 SkIRect::MakeXYWH(300, 0, 300, 105),
279 (int)(2.4 * 300),
280 (int)(2.4 * 105))
Brian Salomon286b5572019-05-20 10:25:50 -0400281
Brian Salomona7e5c7c2020-01-27 15:41:40 -0500282// Exercises non-scaling YUV420. Reads from the original canvas's surface in order to
283// exercise case where source surface is not a texture (in glbert config).
284DEF_SIMPLE_GM_CAN_FAIL(async_yuv_no_scale, canvas, errorMsg, 400, 300) {
285 auto surface = canvas->getSurface();
286 if (!surface) {
287 *errorMsg = "Not supported on recording/vector backends.";
288 return skiagm::DrawResult::kSkip;
289 }
290
291 auto image = GetResourceAsImage("images/yellow_rose.webp");
292 if (!image) {
293 return skiagm::DrawResult::kFail;
294 }
295 SkPaint paint;
296 canvas->drawImage(image.get(), 0, 0);
297
298 SkScopeExit scopeExit;
299 auto yuvImage = do_read_and_scale_yuv(
Brian Salomon63a0a752020-06-26 13:32:09 -0400300 surface, surface->getContext(), kRec601_SkYUVColorSpace, SkIRect::MakeWH(400, 300),
301 {400, 300}, SkImage::RescaleGamma::kSrc, kNone_SkFilterQuality, &scopeExit);
Brian Salomona7e5c7c2020-01-27 15:41:40 -0500302
303 canvas->clear(SK_ColorWHITE);
304 canvas->drawImage(yuvImage.get(), 0, 0);
305
306 return skiagm::DrawResult::kOk;
307}
308
Brian Salomon286b5572019-05-20 10:25:50 -0400309DEF_SIMPLE_GM_CAN_FAIL(async_rescale_and_read_no_bleed, canvas, errorMsg, 60, 60) {
310 if (canvas->imageInfo().colorType() == kUnknown_SkColorType) {
311 *errorMsg = "Not supported on recording/vector backends.";
312 return skiagm::DrawResult::kSkip;
313 }
314
315 static constexpr int kBorder = 5;
316 static constexpr int kInner = 5;
317 const auto srcRect = SkIRect::MakeXYWH(kBorder, kBorder, kInner, kInner);
318 auto surfaceII =
319 SkImageInfo::Make(kInner + 2 * kBorder, kInner + 2 * kBorder, kRGBA_8888_SkColorType,
320 kPremul_SkAlphaType, SkColorSpace::MakeSRGB());
321 auto surface = canvas->makeSurface(surfaceII);
Brian Salomonaf9b7b92019-05-20 12:19:37 -0400322 if (!surface) {
323 *errorMsg = "Could not create surface for image.";
Brian Salomon9be911c2019-05-20 14:01:21 -0400324 // When testing abandoned GrContext we expect surface creation to fail.
325 if (canvas->getGrContext() && canvas->getGrContext()->abandoned()) {
326 return skiagm::DrawResult::kSkip;
327 }
Brian Salomonaf9b7b92019-05-20 12:19:37 -0400328 return skiagm::DrawResult::kFail;
329 }
Brian Salomon286b5572019-05-20 10:25:50 -0400330 surface->getCanvas()->clear(SK_ColorRED);
331 surface->getCanvas()->save();
332 surface->getCanvas()->clipRect(SkRect::Make(srcRect), SkClipOp::kIntersect, false);
333 surface->getCanvas()->clear(SK_ColorBLUE);
334 surface->getCanvas()->restore();
335 static constexpr int kPad = 2;
336 canvas->translate(kPad, kPad);
337 skiagm::DrawResult result;
Brian Salomon9241a6d2019-10-03 13:26:54 -0400338 SkISize downSize = {static_cast<int>(kInner/2), static_cast<int>(kInner / 2)};
Brian Salomon63a0a752020-06-26 13:32:09 -0400339 GrContext* context = canvas->getGrContext();
340 result = do_rescale_grid(canvas, surface.get(), context, srcRect, downSize, false, errorMsg,
341 kPad);
342
Brian Salomon286b5572019-05-20 10:25:50 -0400343 if (result != skiagm::DrawResult::kOk) {
344 return result;
345 }
Mike Kleinf68213f2020-01-27 12:16:22 -0600346 canvas->translate(0, 4 * downSize.height());
Brian Salomon9241a6d2019-10-03 13:26:54 -0400347 SkISize upSize = {static_cast<int>(kInner * 3.5), static_cast<int>(kInner * 4.6)};
Brian Salomon63a0a752020-06-26 13:32:09 -0400348 result =
349 do_rescale_grid(canvas, surface.get(), context, srcRect, upSize, false, errorMsg, kPad);
Brian Salomon286b5572019-05-20 10:25:50 -0400350 if (result != skiagm::DrawResult::kOk) {
351 return result;
352 }
353 return skiagm::DrawResult::kOk;
354}