Brian Salomon | 201700f | 2019-05-17 12:05:44 -0400 | [diff] [blame] | 1 | /* |
| 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 Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 14 | #include "include/core/SkYUVAIndex.h" |
Brian Salomon | 201700f | 2019-05-17 12:05:44 -0400 | [diff] [blame] | 15 | #include "include/gpu/GrContext.h" |
| 16 | #include "src/core/SkAutoPixmapStorage.h" |
| 17 | #include "src/core/SkConvertPixels.h" |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 18 | #include "src/core/SkScopeExit.h" |
| 19 | #include "src/gpu/GrContextPriv.h" |
| 20 | #include "src/gpu/GrGpu.h" |
Brian Salomon | 201700f | 2019-05-17 12:05:44 -0400 | [diff] [blame] | 21 | #include "tools/Resources.h" |
| 22 | #include "tools/ToolUtils.h" |
| 23 | |
| 24 | // Draws the image to a surface, does a asyncRescaleAndReadPixels of the image, and then sticks |
| 25 | // the result in a raster image. |
Brian Salomon | 286b557 | 2019-05-20 10:25:50 -0400 | [diff] [blame] | 26 | static sk_sp<SkImage> do_read_and_scale(SkSurface* surface, const SkIRect& srcRect, |
| 27 | const SkImageInfo& ii, SkSurface::RescaleGamma rescaleGamma, |
| 28 | SkFilterQuality quality) { |
Brian Salomon | 201700f | 2019-05-17 12:05:44 -0400 | [diff] [blame] | 29 | SkBitmap bmp; |
| 30 | bmp.allocPixels(ii); |
Brian Salomon | 201700f | 2019-05-17 12:05:44 -0400 | [diff] [blame] | 31 | SkPaint paint; |
| 32 | paint.setBlendMode(SkBlendMode::kSrc); |
Brian Salomon | 201700f | 2019-05-17 12:05:44 -0400 | [diff] [blame] | 33 | struct Context { |
| 34 | SkPixmap fPixmap; |
| 35 | bool fCalled = false; |
Brian Salomon | cd5caa3 | 2019-06-11 17:02:19 -0400 | [diff] [blame] | 36 | bool fSucceeded = false; |
Brian Salomon | 201700f | 2019-05-17 12:05:44 -0400 | [diff] [blame] | 37 | } context; |
| 38 | SkAssertResult(bmp.peekPixels(&context.fPixmap)); |
| 39 | auto callback = [](void* c, const void* data, size_t rowBytes) { |
| 40 | auto context = reinterpret_cast<Context*>(c); |
| 41 | context->fCalled = true; |
| 42 | if (!data) { |
| 43 | context->fPixmap.reset(); |
| 44 | return; |
| 45 | } |
Brian Salomon | cd5caa3 | 2019-06-11 17:02:19 -0400 | [diff] [blame] | 46 | context->fSucceeded = true; |
Brian Salomon | 201700f | 2019-05-17 12:05:44 -0400 | [diff] [blame] | 47 | SkRectMemcpy(context->fPixmap.writable_addr(), context->fPixmap.rowBytes(), data, rowBytes, |
| 48 | context->fPixmap.info().minRowBytes(), context->fPixmap.height()); |
| 49 | }; |
Brian Salomon | 286b557 | 2019-05-20 10:25:50 -0400 | [diff] [blame] | 50 | surface->asyncRescaleAndReadPixels(ii, srcRect, rescaleGamma, quality, callback, &context); |
Brian Salomon | 201700f | 2019-05-17 12:05:44 -0400 | [diff] [blame] | 51 | while (!context.fCalled) { |
| 52 | // Only GPU should actually be asynchronous. |
Brian Salomon | 286b557 | 2019-05-20 10:25:50 -0400 | [diff] [blame] | 53 | SkASSERT(surface->getCanvas()->getGrContext()); |
| 54 | surface->getCanvas()->getGrContext()->checkAsyncWorkCompletion(); |
Brian Salomon | 201700f | 2019-05-17 12:05:44 -0400 | [diff] [blame] | 55 | } |
Brian Salomon | cd5caa3 | 2019-06-11 17:02:19 -0400 | [diff] [blame] | 56 | return context.fSucceeded ? SkImage::MakeFromBitmap(bmp) : nullptr; |
Brian Salomon | 201700f | 2019-05-17 12:05:44 -0400 | [diff] [blame] | 57 | } |
| 58 | |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 59 | static sk_sp<SkImage> do_read_and_scale_yuv(SkSurface* surface, SkYUVColorSpace yuvCS, |
| 60 | const SkIRect& srcRect, int dstW, int dstH, |
| 61 | SkSurface::RescaleGamma rescaleGamma, |
| 62 | SkFilterQuality quality, SkScopeExit* cleanup) { |
| 63 | SkASSERT(!(dstW & 0b1) && !(dstH & 0b1)); |
Robert Phillips | 2e1142c | 2019-08-14 12:33:29 -0400 | [diff] [blame] | 64 | |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 65 | struct Context { |
Robert Phillips | 2e1142c | 2019-08-14 12:33:29 -0400 | [diff] [blame] | 66 | Context(int w, int h) { |
| 67 | SkImageInfo yII = SkImageInfo::Make(w, h, kGray_8_SkColorType, kPremul_SkAlphaType); |
| 68 | SkImageInfo uvII = SkImageInfo::Make(w / 2, h / 2, kGray_8_SkColorType, |
| 69 | kPremul_SkAlphaType); |
| 70 | |
| 71 | fYData.alloc(yII); |
| 72 | fUData.alloc(uvII); |
| 73 | fVData.alloc(uvII); |
| 74 | } |
| 75 | |
| 76 | SkAutoPixmapStorage fYData; |
| 77 | SkAutoPixmapStorage fUData; |
| 78 | SkAutoPixmapStorage fVData; |
| 79 | bool fCalled = false; |
| 80 | bool fSucceeded = false; |
| 81 | } context(dstW, dstH); |
| 82 | |
| 83 | auto callback = [](void* c, const void* data[3], size_t rowBytes[3]) { |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 84 | auto context = reinterpret_cast<Context*>(c); |
| 85 | context->fCalled = true; |
| 86 | if (!data) { |
| 87 | return; |
| 88 | } |
Brian Salomon | cd5caa3 | 2019-06-11 17:02:19 -0400 | [diff] [blame] | 89 | context->fSucceeded = true; |
Robert Phillips | 2e1142c | 2019-08-14 12:33:29 -0400 | [diff] [blame] | 90 | SkRectMemcpy(context->fYData.writable_addr(), context->fYData.rowBytes(), data[0], |
| 91 | rowBytes[0], context->fYData.width(), context->fYData.height()); |
| 92 | SkRectMemcpy(context->fUData.writable_addr(), context->fUData.rowBytes(), data[1], |
| 93 | rowBytes[1], context->fUData.width(), context->fUData.height()); |
| 94 | SkRectMemcpy(context->fVData.writable_addr(), context->fVData.rowBytes(), data[2], |
| 95 | rowBytes[2], context->fVData.width(), context->fVData.height()); |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 96 | }; |
| 97 | surface->asyncRescaleAndReadPixelsYUV420(yuvCS, SkColorSpace::MakeSRGB(), srcRect, dstW, dstH, |
| 98 | rescaleGamma, quality, callback, &context); |
| 99 | while (!context.fCalled) { |
| 100 | // Only GPU should actually be asynchronous. |
| 101 | SkASSERT(surface->getCanvas()->getGrContext()); |
| 102 | surface->getCanvas()->getGrContext()->checkAsyncWorkCompletion(); |
| 103 | } |
Brian Salomon | cd5caa3 | 2019-06-11 17:02:19 -0400 | [diff] [blame] | 104 | if (!context.fSucceeded) { |
| 105 | return nullptr; |
| 106 | } |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 107 | auto* gr = surface->getCanvas()->getGrContext(); |
| 108 | GrBackendTexture backendTextures[3]; |
Robert Phillips | 0a15cc6 | 2019-07-30 12:49:10 -0400 | [diff] [blame] | 109 | |
Robert Phillips | 2e1142c | 2019-08-14 12:33:29 -0400 | [diff] [blame] | 110 | backendTextures[0] = gr->priv().createBackendTexture(&context.fYData, 1, |
| 111 | GrRenderable::kNo, GrProtected::kNo); |
| 112 | backendTextures[1] = gr->priv().createBackendTexture(&context.fUData, 1, |
| 113 | GrRenderable::kNo, GrProtected::kNo); |
| 114 | backendTextures[2] = gr->priv().createBackendTexture(&context.fVData, 1, |
| 115 | GrRenderable::kNo, GrProtected::kNo); |
| 116 | SkYUVAIndex indices[4] = { |
| 117 | { 0, SkColorChannel::kR}, |
| 118 | { 1, SkColorChannel::kR}, |
| 119 | { 2, SkColorChannel::kR}, |
| 120 | {-1, SkColorChannel::kR} |
| 121 | }; |
| 122 | |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 123 | *cleanup = {[gr, backendTextures] { |
| 124 | GrFlushInfo flushInfo; |
| 125 | flushInfo.fFlags = kSyncCpu_GrFlushFlag; |
| 126 | gr->flush(flushInfo); |
| 127 | gr->deleteBackendTexture(backendTextures[0]); |
| 128 | gr->deleteBackendTexture(backendTextures[1]); |
| 129 | gr->deleteBackendTexture(backendTextures[2]); |
| 130 | }}; |
| 131 | |
| 132 | return SkImage::MakeFromYUVATextures(gr, yuvCS, backendTextures, indices, {dstW, dstH}, |
| 133 | kTopLeft_GrSurfaceOrigin, SkColorSpace::MakeSRGB()); |
| 134 | } |
| 135 | |
Brian Salomon | 201700f | 2019-05-17 12:05:44 -0400 | [diff] [blame] | 136 | // Draws a grid of rescales. The columns are none, low, and high filter quality. The rows are |
| 137 | // rescale in src gamma and rescale in linear gamma. |
Brian Salomon | 286b557 | 2019-05-20 10:25:50 -0400 | [diff] [blame] | 138 | static skiagm::DrawResult do_rescale_grid(SkCanvas* canvas, SkSurface* surface, |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 139 | const SkIRect& srcRect, int newW, int newH, bool doYUV420, |
Brian Salomon | 286b557 | 2019-05-20 10:25:50 -0400 | [diff] [blame] | 140 | SkString* errorMsg, int pad = 0) { |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 141 | if (doYUV420) { |
Brian Salomon | cd5caa3 | 2019-06-11 17:02:19 -0400 | [diff] [blame] | 142 | if (!canvas->getGrContext() || !canvas->getGrContext()->priv().asDirectContext()) { |
| 143 | errorMsg->printf("YUV420 only supported on direct GPU for now."); |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 144 | return skiagm::DrawResult::kSkip; |
| 145 | } |
| 146 | } |
Brian Salomon | 201700f | 2019-05-17 12:05:44 -0400 | [diff] [blame] | 147 | if (canvas->imageInfo().colorType() == kUnknown_SkColorType) { |
| 148 | *errorMsg = "Not supported on recording/vector backends."; |
| 149 | return skiagm::DrawResult::kSkip; |
| 150 | } |
Brian Salomon | a34e0fc | 2019-05-17 19:56:59 +0000 | [diff] [blame] | 151 | const auto ii = canvas->imageInfo().makeWH(newW, newH); |
Brian Salomon | a34e0fc | 2019-05-17 19:56:59 +0000 | [diff] [blame] | 152 | |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 153 | SkYUVColorSpace yuvColorSpace = kRec601_SkYUVColorSpace; |
Brian Salomon | a34e0fc | 2019-05-17 19:56:59 +0000 | [diff] [blame] | 154 | canvas->save(); |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 155 | for (auto gamma : {SkSurface::RescaleGamma::kSrc, SkSurface::RescaleGamma::kLinear}) { |
Brian Salomon | a34e0fc | 2019-05-17 19:56:59 +0000 | [diff] [blame] | 156 | canvas->save(); |
| 157 | for (auto quality : {kNone_SkFilterQuality, kLow_SkFilterQuality, kHigh_SkFilterQuality}) { |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 158 | SkScopeExit cleanup; |
| 159 | sk_sp<SkImage> result; |
| 160 | if (doYUV420) { |
| 161 | result = do_read_and_scale_yuv(surface, yuvColorSpace, srcRect, newW, newH, gamma, |
| 162 | quality, &cleanup); |
Brian Salomon | cd5caa3 | 2019-06-11 17:02:19 -0400 | [diff] [blame] | 163 | if (!result) { |
| 164 | errorMsg->printf("YUV420 async call failed. Allowed for now."); |
| 165 | return skiagm::DrawResult::kSkip; |
| 166 | } |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 167 | int nextCS = static_cast<int>(yuvColorSpace + 1) % (kLastEnum_SkYUVColorSpace + 1); |
| 168 | yuvColorSpace = static_cast<SkYUVColorSpace>(nextCS); |
| 169 | } else { |
| 170 | result = do_read_and_scale(surface, srcRect, ii, gamma, quality); |
Brian Salomon | cd5caa3 | 2019-06-11 17:02:19 -0400 | [diff] [blame] | 171 | if (!result) { |
| 172 | errorMsg->printf("async read call failed."); |
| 173 | return skiagm::DrawResult::kFail; |
| 174 | } |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 175 | } |
| 176 | canvas->drawImage(result, 0, 0); |
Brian Salomon | 286b557 | 2019-05-20 10:25:50 -0400 | [diff] [blame] | 177 | canvas->translate(newW + pad, 0); |
Brian Salomon | a34e0fc | 2019-05-17 19:56:59 +0000 | [diff] [blame] | 178 | } |
| 179 | canvas->restore(); |
Brian Salomon | 286b557 | 2019-05-20 10:25:50 -0400 | [diff] [blame] | 180 | canvas->translate(0, newH + pad); |
Brian Salomon | 451b01f | 2019-05-17 12:39:17 -0400 | [diff] [blame] | 181 | } |
Brian Salomon | a34e0fc | 2019-05-17 19:56:59 +0000 | [diff] [blame] | 182 | canvas->restore(); |
| 183 | return skiagm::DrawResult::kOk; |
Brian Salomon | 451b01f | 2019-05-17 12:39:17 -0400 | [diff] [blame] | 184 | } |
| 185 | |
Brian Salomon | 286b557 | 2019-05-20 10:25:50 -0400 | [diff] [blame] | 186 | static skiagm::DrawResult do_rescale_image_grid(SkCanvas* canvas, const char* imageFile, |
| 187 | const SkIRect& srcRect, int newW, int newH, |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 188 | bool doYUV420, SkString* errorMsg) { |
Brian Salomon | 286b557 | 2019-05-20 10:25:50 -0400 | [diff] [blame] | 189 | 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 | } |
| 198 | // Turn the image into a surface in order to call the read and rescale API |
| 199 | auto surfInfo = image->imageInfo().makeWH(image->width(), image->height()); |
| 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); |
| 204 | } |
| 205 | if (!surface) { |
| 206 | *errorMsg = "Could not create surface for image."; |
Brian Salomon | 9be911c | 2019-05-20 14:01:21 -0400 | [diff] [blame] | 207 | // When testing abandoned GrContext we expect surface creation to fail. |
| 208 | if (canvas->getGrContext() && canvas->getGrContext()->abandoned()) { |
| 209 | return skiagm::DrawResult::kSkip; |
| 210 | } |
Brian Salomon | 286b557 | 2019-05-20 10:25:50 -0400 | [diff] [blame] | 211 | return skiagm::DrawResult::kFail; |
| 212 | } |
| 213 | SkPaint paint; |
| 214 | paint.setBlendMode(SkBlendMode::kSrc); |
| 215 | surface->getCanvas()->drawImage(image, 0, 0, &paint); |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 216 | return do_rescale_grid(canvas, surface.get(), srcRect, newW, newH, doYUV420, errorMsg); |
Brian Salomon | 286b557 | 2019-05-20 10:25:50 -0400 | [diff] [blame] | 217 | } |
| 218 | |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 219 | #define DEF_RESCALE_AND_READ_GM(IMAGE_FILE, TAG, SRC_RECT, W, H) \ |
| 220 | DEF_SIMPLE_GM_CAN_FAIL(async_rescale_and_read_##TAG, canvas, errorMsg, 3 * W, 2 * H) { \ |
| 221 | ToolUtils::draw_checkerboard(canvas, SK_ColorDKGRAY, SK_ColorLTGRAY, 25); \ |
| 222 | return do_rescale_image_grid(canvas, #IMAGE_FILE, SRC_RECT, W, H, false, errorMsg); \ |
Brian Salomon | 201700f | 2019-05-17 12:05:44 -0400 | [diff] [blame] | 223 | } |
| 224 | |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 225 | #define DEF_RESCALE_AND_READ_YUV_GM(IMAGE_FILE, TAG, SRC_RECT, W, H) \ |
| 226 | DEF_SIMPLE_GM_CAN_FAIL(async_rescale_and_read_yuv420_##TAG, canvas, errorMsg, 3 * W, 2 * H) { \ |
| 227 | ToolUtils::draw_checkerboard(canvas, SK_ColorDKGRAY, SK_ColorLTGRAY, 25); \ |
| 228 | return do_rescale_image_grid(canvas, #IMAGE_FILE, SRC_RECT, W, H, true, errorMsg); \ |
| 229 | } |
| 230 | |
| 231 | DEF_RESCALE_AND_READ_YUV_GM(images/yellow_rose.webp, rose, SkIRect::MakeXYWH(50, 5, 200, 150), |
| 232 | 410, 376) |
| 233 | |
Brian Salomon | 201700f | 2019-05-17 12:05:44 -0400 | [diff] [blame] | 234 | DEF_RESCALE_AND_READ_GM(images/yellow_rose.webp, rose, SkIRect::MakeXYWH(100, 20, 100, 100), |
| 235 | 410, 410) |
| 236 | |
| 237 | DEF_RESCALE_AND_READ_GM(images/dog.jpg, dog_down, SkIRect::MakeXYWH(0, 10, 180, 150), 45, 45) |
Brian Salomon | c7e9f78 | 2019-05-28 20:39:53 -0400 | [diff] [blame] | 238 | DEF_RESCALE_AND_READ_GM(images/dog.jpg, dog_up, SkIRect::MakeWH(180, 180), 800, 400) |
Brian Salomon | 201700f | 2019-05-17 12:05:44 -0400 | [diff] [blame] | 239 | |
| 240 | DEF_RESCALE_AND_READ_GM(images/text.png, text_down, SkIRect::MakeWH(637, 105), (int)(0.7 * 637), |
| 241 | (int)(0.7 * 105)) |
| 242 | DEF_RESCALE_AND_READ_GM(images/text.png, text_up, SkIRect::MakeWH(637, 105), (int)(1.2 * 637), |
| 243 | (int)(1.2 * 105)) |
| 244 | DEF_RESCALE_AND_READ_GM(images/text.png, text_up_large, SkIRect::MakeXYWH(300, 0, 300, 105), |
| 245 | (int)(2.4 * 300), (int)(2.4 * 105)) |
Brian Salomon | 286b557 | 2019-05-20 10:25:50 -0400 | [diff] [blame] | 246 | |
| 247 | DEF_SIMPLE_GM_CAN_FAIL(async_rescale_and_read_no_bleed, canvas, errorMsg, 60, 60) { |
| 248 | if (canvas->imageInfo().colorType() == kUnknown_SkColorType) { |
| 249 | *errorMsg = "Not supported on recording/vector backends."; |
| 250 | return skiagm::DrawResult::kSkip; |
| 251 | } |
| 252 | |
| 253 | static constexpr int kBorder = 5; |
| 254 | static constexpr int kInner = 5; |
| 255 | const auto srcRect = SkIRect::MakeXYWH(kBorder, kBorder, kInner, kInner); |
| 256 | auto surfaceII = |
| 257 | SkImageInfo::Make(kInner + 2 * kBorder, kInner + 2 * kBorder, kRGBA_8888_SkColorType, |
| 258 | kPremul_SkAlphaType, SkColorSpace::MakeSRGB()); |
| 259 | auto surface = canvas->makeSurface(surfaceII); |
Brian Salomon | af9b7b9 | 2019-05-20 12:19:37 -0400 | [diff] [blame] | 260 | if (!surface) { |
| 261 | *errorMsg = "Could not create surface for image."; |
Brian Salomon | 9be911c | 2019-05-20 14:01:21 -0400 | [diff] [blame] | 262 | // When testing abandoned GrContext we expect surface creation to fail. |
| 263 | if (canvas->getGrContext() && canvas->getGrContext()->abandoned()) { |
| 264 | return skiagm::DrawResult::kSkip; |
| 265 | } |
Brian Salomon | af9b7b9 | 2019-05-20 12:19:37 -0400 | [diff] [blame] | 266 | return skiagm::DrawResult::kFail; |
| 267 | } |
Brian Salomon | 286b557 | 2019-05-20 10:25:50 -0400 | [diff] [blame] | 268 | surface->getCanvas()->clear(SK_ColorRED); |
| 269 | surface->getCanvas()->save(); |
| 270 | surface->getCanvas()->clipRect(SkRect::Make(srcRect), SkClipOp::kIntersect, false); |
| 271 | surface->getCanvas()->clear(SK_ColorBLUE); |
| 272 | surface->getCanvas()->restore(); |
| 273 | static constexpr int kPad = 2; |
| 274 | canvas->translate(kPad, kPad); |
| 275 | skiagm::DrawResult result; |
| 276 | auto downW = static_cast<int>(kInner / 2); |
| 277 | auto downH = static_cast<int>(kInner / 2); |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 278 | result = do_rescale_grid(canvas, surface.get(), srcRect, downW, downH, false, errorMsg, kPad); |
Brian Salomon | 286b557 | 2019-05-20 10:25:50 -0400 | [diff] [blame] | 279 | if (result != skiagm::DrawResult::kOk) { |
| 280 | return result; |
| 281 | } |
| 282 | canvas->translate(0, 2 * downH); |
| 283 | auto upW = static_cast<int>(kInner * 3.5); |
| 284 | auto upH = static_cast<int>(kInner * 4.6); |
Brian Salomon | 024bd00 | 2019-06-11 11:38:16 -0400 | [diff] [blame] | 285 | result = do_rescale_grid(canvas, surface.get(), srcRect, upW, upH, false, errorMsg, kPad); |
Brian Salomon | 286b557 | 2019-05-20 10:25:50 -0400 | [diff] [blame] | 286 | if (result != skiagm::DrawResult::kOk) { |
| 287 | return result; |
| 288 | } |
| 289 | return skiagm::DrawResult::kOk; |
| 290 | } |