Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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 Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "gm/gm.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 9 | #include "include/core/SkBitmap.h" |
| 10 | #include "include/core/SkCanvas.h" |
| 11 | #include "include/core/SkColor.h" |
| 12 | #include "include/core/SkFont.h" |
| 13 | #include "include/core/SkFontTypes.h" |
| 14 | #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/SkSize.h" |
| 22 | #include "include/core/SkString.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 23 | #include "include/core/SkSurface.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 24 | #include "include/core/SkTypeface.h" |
| 25 | #include "include/core/SkTypes.h" |
Robert Phillips | b87b39b | 2020-07-01 14:45:24 -0400 | [diff] [blame] | 26 | #include "include/gpu/GrDirectContext.h" |
Robert Phillips | b7bfbc2 | 2020-07-01 12:55:01 -0400 | [diff] [blame] | 27 | #include "include/gpu/GrRecordingContext.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 28 | #include "include/gpu/GrTypes.h" |
Kevin Lubick | dc6cc02 | 2023-01-13 11:24:27 -0500 | [diff] [blame] | 29 | #include "include/private/base/SkTArray.h" |
Greg Daniel | 719239c | 2022-04-07 11:20:24 -0400 | [diff] [blame] | 30 | #include "src/gpu/ganesh/GrDirectContextPriv.h" |
| 31 | #include "src/gpu/ganesh/GrPixmap.h" |
Kevin Lubick | bf174bc | 2023-03-27 11:24:20 -0400 | [diff] [blame] | 32 | #include "src/gpu/ganesh/image/SkImage_Ganesh.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 33 | #include "src/image/SkImage_Base.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 34 | #include "tools/ToolUtils.h" |
Kevin Lubick | e836c3a | 2023-10-20 06:55:35 -0400 | [diff] [blame] | 35 | #include "tools/fonts/FontToolUtils.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 36 | #include "tools/gpu/ProxyUtils.h" |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 37 | |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 38 | #include <string.h> |
| 39 | #include <utility> |
| 40 | |
Herb Derby | ec96c21 | 2023-03-06 10:31:22 -0500 | [diff] [blame] | 41 | using namespace skia_private; |
| 42 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 43 | static const int kNumMatrices = 6; |
| 44 | static const int kImageSize = 128; |
| 45 | static const int kLabelSize = 32; |
| 46 | static const int kNumLabels = 4; |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 47 | static const int kInset = 16; |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 48 | |
| 49 | static const int kCellSize = kImageSize+2*kLabelSize; |
| 50 | static const int kGMWidth = kNumMatrices*kCellSize; |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 51 | static const int kGMHeight = 4*kCellSize; |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 52 | |
| 53 | static const SkPoint kPoints[kNumLabels] = { |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 54 | { 0, kImageSize }, // LL |
| 55 | { kImageSize, kImageSize }, // LR |
| 56 | { 0, 0 }, // UL |
| 57 | { kImageSize, 0 }, // UR |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | static const SkMatrix kUVMatrices[kNumMatrices] = { |
| 61 | SkMatrix::MakeAll( 0, -1, 1, |
| 62 | -1, 0, 1, |
| 63 | 0, 0, 1), |
| 64 | SkMatrix::MakeAll( 1, 0, 0, |
| 65 | 0, -1, 1, |
| 66 | 0, 0, 1), |
| 67 | // flip x |
| 68 | SkMatrix::MakeAll(-1, 0, 1, |
| 69 | 0, 1, 0, |
| 70 | 0, 0, 1), |
| 71 | SkMatrix::MakeAll( 0, 1, 0, |
| 72 | -1, 0, 1, |
| 73 | 0, 0, 1), |
| 74 | // flip both x & y == rotate 180 |
| 75 | SkMatrix::MakeAll(-1, 0, 1, |
| 76 | 0, -1, 1, |
| 77 | 0, 0, 1), |
| 78 | // identity |
| 79 | SkMatrix::MakeAll(1, 0, 0, |
| 80 | 0, 1, 0, |
| 81 | 0, 0, 1) |
| 82 | }; |
| 83 | |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 84 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 85 | // Create a fixed size text label like "LL" or "LR". |
Robert Phillips | 88d8aba | 2023-02-22 11:04:06 -0500 | [diff] [blame] | 86 | static sk_sp<SkImage> make_text_image(const char* text, SkColor color) { |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 87 | SkPaint paint; |
| 88 | paint.setAntiAlias(true); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 89 | paint.setColor(color); |
| 90 | |
Kevin Lubick | bca43ec | 2023-10-30 10:11:22 -0400 | [diff] [blame] | 91 | SkFont font = ToolUtils::DefaultPortableFont(); |
Mike Reed | 94cca60 | 2018-12-02 16:04:27 -0500 | [diff] [blame] | 92 | font.setEdging(SkFont::Edging::kAntiAlias); |
Mike Reed | 94cca60 | 2018-12-02 16:04:27 -0500 | [diff] [blame] | 93 | font.setSize(32); |
| 94 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 95 | SkRect bounds; |
Ben Wagner | 51e15a6 | 2019-05-07 15:38:46 -0400 | [diff] [blame] | 96 | font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds); |
Mike Reed | 2ac6ce8 | 2021-01-15 12:26:22 -0500 | [diff] [blame] | 97 | const SkMatrix mat = SkMatrix::RectToRect(bounds, SkRect::MakeWH(kLabelSize, kLabelSize)); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 98 | |
| 99 | const SkImageInfo ii = SkImageInfo::MakeN32Premul(kLabelSize, kLabelSize); |
Kevin Lubick | 5c93acf | 2023-05-09 12:11:43 -0400 | [diff] [blame] | 100 | sk_sp<SkSurface> surf = SkSurfaces::Raster(ii); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 101 | |
| 102 | SkCanvas* canvas = surf->getCanvas(); |
| 103 | |
| 104 | canvas->clear(SK_ColorWHITE); |
| 105 | canvas->concat(mat); |
Ben Wagner | 51e15a6 | 2019-05-07 15:38:46 -0400 | [diff] [blame] | 106 | canvas->drawSimpleText(text, strlen(text), SkTextEncoding::kUTF8, 0, 0, font, paint); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 107 | |
Robert Phillips | 88d8aba | 2023-02-22 11:04:06 -0500 | [diff] [blame] | 108 | return surf->makeImageSnapshot(); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 109 | } |
| 110 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 111 | // Create an image with each corner marked w/ "LL", "LR", etc., with the origin either bottom-left |
| 112 | // or top-left. |
Robert Phillips | 88d8aba | 2023-02-22 11:04:06 -0500 | [diff] [blame] | 113 | static sk_sp<SkImage> make_reference_image(SkCanvas* mainCanvas, |
Herb Derby | ec96c21 | 2023-03-06 10:31:22 -0500 | [diff] [blame] | 114 | const TArray<sk_sp<SkImage>>& labels, |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 115 | bool bottomLeftOrigin) { |
Herb Derby | ffacce5 | 2022-11-09 10:51:34 -0500 | [diff] [blame] | 116 | SkASSERT(kNumLabels == labels.size()); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 117 | |
Robert Phillips | 88d8aba | 2023-02-22 11:04:06 -0500 | [diff] [blame] | 118 | SkImageInfo ii = SkImageInfo::Make(kImageSize, kImageSize, |
| 119 | kRGBA_8888_SkColorType, kOpaque_SkAlphaType); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 120 | SkBitmap bm; |
| 121 | bm.allocPixels(ii); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 122 | |
Robert Phillips | 88d8aba | 2023-02-22 11:04:06 -0500 | [diff] [blame] | 123 | { |
| 124 | SkCanvas canvas(bm); |
| 125 | |
| 126 | canvas.clear(SK_ColorWHITE); |
| 127 | for (int i = 0; i < kNumLabels; ++i) { |
| 128 | canvas.drawImage(labels[i], |
| 129 | 0.0 != kPoints[i].fX ? kPoints[i].fX-kLabelSize-kInset : kInset, |
| 130 | 0.0 != kPoints[i].fY ? kPoints[i].fY-kLabelSize-kInset : kInset); |
| 131 | } |
| 132 | |
| 133 | bm.setImmutable(); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 134 | } |
| 135 | |
Robert Phillips | 88d8aba | 2023-02-22 11:04:06 -0500 | [diff] [blame] | 136 | auto dContext = GrAsDirectContext(mainCanvas->recordingContext()); |
| 137 | if (dContext && !dContext->abandoned()) { |
| 138 | auto origin = bottomLeftOrigin ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin; |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 139 | |
Robert Phillips | 88d8aba | 2023-02-22 11:04:06 -0500 | [diff] [blame] | 140 | auto view = sk_gpu_test::MakeTextureProxyViewFromData(dContext, GrRenderable::kNo, origin, |
| 141 | bm.pixmap()); |
| 142 | if (!view) { |
| 143 | return nullptr; |
| 144 | } |
| 145 | |
Kevin Lubick | bf174bc | 2023-03-27 11:24:20 -0400 | [diff] [blame] | 146 | return sk_make_sp<SkImage_Ganesh>( |
| 147 | sk_ref_sp(dContext), kNeedNewImageUniqueID, std::move(view), ii.colorInfo()); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 148 | } |
| 149 | |
Kevin Lubick | 77472bf | 2023-03-24 07:11:17 -0400 | [diff] [blame] | 150 | return SkImages::RasterFromBitmap(bm); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | // Here we're converting from a matrix that is intended for UVs to a matrix that is intended |
| 154 | // for rect geometry used for a drawImage call. They are, in some sense, inverses of each |
| 155 | // other but we also need a scale to map from the [0..1] uv range to the actual size of |
| 156 | // image. |
| 157 | static bool UVMatToGeomMatForImage(SkMatrix* geomMat, const SkMatrix& uvMat) { |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 158 | |
| 159 | const SkMatrix yFlip = SkMatrix::MakeAll(1, 0, 0, 0, -1, 1, 0, 0, 1); |
| 160 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 161 | SkMatrix tmp = uvMat; |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 162 | tmp.preConcat(yFlip); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 163 | tmp.preScale(1.0f/kImageSize, 1.0f/kImageSize); |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 164 | |
| 165 | tmp.postConcat(yFlip); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 166 | tmp.postScale(kImageSize, kImageSize); |
| 167 | |
| 168 | return tmp.invert(geomMat); |
| 169 | } |
| 170 | |
| 171 | // This GM exercises drawImage with a set of matrices that use an unusual amount of flips and |
| 172 | // rotates. |
Robert Phillips | edcd431 | 2021-06-03 10:14:16 -0400 | [diff] [blame] | 173 | class FlippityGM : public skiagm::GM { |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 174 | public: |
| 175 | FlippityGM() { |
Mike Klein | d46dce3 | 2018-08-16 10:17:03 -0400 | [diff] [blame] | 176 | this->setBGColor(0xFFCCCCCC); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 177 | } |
| 178 | |
Ben Wagner | c061d31 | 2019-08-14 15:31:52 -0400 | [diff] [blame] | 179 | private: |
Leandro Lovisolo | 24fa211 | 2023-08-15 19:05:17 +0000 | [diff] [blame] | 180 | SkString getName() const override { return SkString("flippity"); } |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 181 | |
Leandro Lovisolo | 8f02388 | 2023-08-15 21:13:52 +0000 | [diff] [blame] | 182 | SkISize getISize() override { return SkISize::Make(kGMWidth, kGMHeight); } |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 183 | |
| 184 | // Draw the reference image and the four corner labels in the matrix's coordinate space |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 185 | void drawImageWithMatrixAndLabels(SkCanvas* canvas, SkImage* image, int matIndex, |
| 186 | bool drawSubset, bool drawScaled) { |
| 187 | static const SkRect kSubsets[kNumMatrices] = { |
| 188 | SkRect::MakeXYWH(kInset, 0, kImageSize-kInset, kImageSize), |
| 189 | SkRect::MakeXYWH(0, kInset, kImageSize, kImageSize-kInset), |
| 190 | SkRect::MakeXYWH(0, 0, kImageSize-kInset, kImageSize), |
| 191 | SkRect::MakeXYWH(0, 0, kImageSize, kImageSize-kInset), |
| 192 | SkRect::MakeXYWH(kInset/2, kInset/2, kImageSize-kInset, kImageSize-kInset), |
| 193 | SkRect::MakeXYWH(kInset, kInset, kImageSize-2*kInset, kImageSize-2*kInset), |
| 194 | }; |
| 195 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 196 | SkMatrix imageGeomMat; |
| 197 | SkAssertResult(UVMatToGeomMatForImage(&imageGeomMat, kUVMatrices[matIndex])); |
| 198 | |
| 199 | canvas->save(); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 200 | |
| 201 | // draw the reference image |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 202 | canvas->concat(imageGeomMat); |
| 203 | if (drawSubset) { |
| 204 | canvas->drawImageRect(image, kSubsets[matIndex], |
| 205 | drawScaled ? SkRect::MakeWH(kImageSize, kImageSize) |
| 206 | : kSubsets[matIndex], |
Mike Reed | d396cd5 | 2021-01-23 21:14:47 -0500 | [diff] [blame] | 207 | SkSamplingOptions(), nullptr, |
| 208 | SkCanvas::kFast_SrcRectConstraint); |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 209 | } else { |
| 210 | canvas->drawImage(image, 0, 0); |
| 211 | } |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 212 | |
| 213 | // draw the labels |
| 214 | for (int i = 0; i < kNumLabels; ++i) { |
| 215 | canvas->drawImage(fLabels[i], |
| 216 | 0.0f == kPoints[i].fX ? -kLabelSize : kPoints[i].fX, |
| 217 | 0.0f == kPoints[i].fY ? -kLabelSize : kPoints[i].fY); |
| 218 | } |
| 219 | canvas->restore(); |
| 220 | } |
| 221 | |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 222 | void drawRow(SkCanvas* canvas, bool bottomLeftImage, bool drawSubset, bool drawScaled) { |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 223 | |
| 224 | canvas->save(); |
| 225 | canvas->translate(kLabelSize, kLabelSize); |
| 226 | |
| 227 | for (int i = 0; i < kNumMatrices; ++i) { |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 228 | this->drawImageWithMatrixAndLabels(canvas, fReferenceImages[bottomLeftImage].get(), |
| 229 | i, drawSubset, drawScaled); |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 230 | canvas->translate(kCellSize, 0); |
| 231 | } |
| 232 | canvas->restore(); |
| 233 | } |
| 234 | |
Robert Phillips | 88d8aba | 2023-02-22 11:04:06 -0500 | [diff] [blame] | 235 | void makeLabels() { |
Herb Derby | ffacce5 | 2022-11-09 10:51:34 -0500 | [diff] [blame] | 236 | if (fLabels.size()) { |
Ben Wagner | c061d31 | 2019-08-14 15:31:52 -0400 | [diff] [blame] | 237 | return; |
| 238 | } |
| 239 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 240 | static const char* kLabelText[kNumLabels] = { "LL", "LR", "UL", "UR" }; |
| 241 | |
| 242 | static const SkColor kLabelColors[kNumLabels] = { |
| 243 | SK_ColorRED, |
| 244 | SK_ColorGREEN, |
| 245 | SK_ColorBLUE, |
| 246 | SK_ColorCYAN |
| 247 | }; |
| 248 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 249 | for (int i = 0; i < kNumLabels; ++i) { |
Robert Phillips | 88d8aba | 2023-02-22 11:04:06 -0500 | [diff] [blame] | 250 | fLabels.push_back(make_text_image(kLabelText[i], kLabelColors[i])); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 251 | } |
Herb Derby | ffacce5 | 2022-11-09 10:51:34 -0500 | [diff] [blame] | 252 | SkASSERT(kNumLabels == fLabels.size()); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 253 | } |
| 254 | |
Brian Salomon | c759bbf | 2023-12-05 11:11:27 -0500 | [diff] [blame] | 255 | DrawResult onGpuSetup(SkCanvas* canvas, SkString* errorMsg, GraphiteTestContext*) override { |
Robert Phillips | 88d8aba | 2023-02-22 11:04:06 -0500 | [diff] [blame] | 256 | this->makeLabels(); |
| 257 | fReferenceImages[0] = make_reference_image(canvas, fLabels, false); |
| 258 | fReferenceImages[1] = make_reference_image(canvas, fLabels, true); |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 259 | if (!fReferenceImages[0] || !fReferenceImages[1]) { |
| 260 | *errorMsg = "Failed to create reference images."; |
| 261 | return DrawResult::kFail; |
| 262 | } |
| 263 | |
| 264 | return DrawResult::kOk; |
| 265 | } |
| 266 | |
Robert Phillips | b795bea | 2020-06-25 12:38:53 -0400 | [diff] [blame] | 267 | void onGpuTeardown() override { |
Herb Derby | e308b1c | 2022-12-13 09:27:24 -0500 | [diff] [blame] | 268 | fLabels.clear(); |
Robert Phillips | b795bea | 2020-06-25 12:38:53 -0400 | [diff] [blame] | 269 | fReferenceImages[0] = fReferenceImages[1] = nullptr; |
| 270 | } |
| 271 | |
Robert Phillips | edcd431 | 2021-06-03 10:14:16 -0400 | [diff] [blame] | 272 | void onDraw(SkCanvas* canvas) override { |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 273 | SkASSERT(fReferenceImages[0] && fReferenceImages[1]); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 274 | |
Robert Phillips | f0a30d7 | 2017-11-01 14:05:12 -0400 | [diff] [blame] | 275 | canvas->save(); |
| 276 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 277 | // Top row gets TL image |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 278 | this->drawRow(canvas, false, false, false); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 279 | |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 280 | canvas->translate(0, kCellSize); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 281 | |
| 282 | // Bottom row gets BL image |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 283 | this->drawRow(canvas, true, false, false); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 284 | |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 285 | canvas->translate(0, kCellSize); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 286 | |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 287 | // Third row gets subsets of BL images |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 288 | this->drawRow(canvas, true, true, false); |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 289 | |
| 290 | canvas->translate(0, kCellSize); |
| 291 | |
| 292 | // Fourth row gets scaled subsets of BL images |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 293 | this->drawRow(canvas, true, true, true); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 294 | |
Robert Phillips | f0a30d7 | 2017-11-01 14:05:12 -0400 | [diff] [blame] | 295 | canvas->restore(); |
| 296 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 297 | // separator grid |
Robert Phillips | f0a30d7 | 2017-11-01 14:05:12 -0400 | [diff] [blame] | 298 | for (int i = 0; i < 4; ++i) { |
| 299 | canvas->drawLine(0, i * kCellSize, kGMWidth, i * kCellSize, SkPaint()); |
| 300 | } |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 301 | for (int i = 0; i < kNumMatrices; ++i) { |
| 302 | canvas->drawLine(i * kCellSize, 0, i * kCellSize, kGMHeight, SkPaint()); |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | private: |
Herb Derby | ec96c21 | 2023-03-06 10:31:22 -0500 | [diff] [blame] | 307 | TArray<sk_sp<SkImage>> fLabels; |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 308 | sk_sp<SkImage> fReferenceImages[2]; |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 309 | |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 310 | using INHERITED = GM; |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 311 | }; |
| 312 | |
| 313 | DEF_GM(return new FlippityGM;) |