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