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" |
| 29 | #include "include/private/SkTArray.h" |
Greg Daniel | 81b9897 | 2019-12-13 11:09:43 -0500 | [diff] [blame] | 30 | #include "src/gpu/GrContextPriv.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 31 | #include "src/image/SkImage_Base.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 32 | #include "src/image/SkImage_Gpu.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 33 | #include "tools/ToolUtils.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 34 | #include "tools/gpu/ProxyUtils.h" |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 35 | |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 36 | #include <string.h> |
| 37 | #include <utility> |
| 38 | |
| 39 | class GrRenderTargetContext; |
| 40 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 41 | static const int kNumMatrices = 6; |
| 42 | static const int kImageSize = 128; |
| 43 | static const int kLabelSize = 32; |
| 44 | static const int kNumLabels = 4; |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 45 | static const int kInset = 16; |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 46 | |
| 47 | static const int kCellSize = kImageSize+2*kLabelSize; |
| 48 | static const int kGMWidth = kNumMatrices*kCellSize; |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 49 | static const int kGMHeight = 4*kCellSize; |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 50 | |
| 51 | static const SkPoint kPoints[kNumLabels] = { |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 52 | { 0, kImageSize }, // LL |
| 53 | { kImageSize, kImageSize }, // LR |
| 54 | { 0, 0 }, // UL |
| 55 | { kImageSize, 0 }, // UR |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | static const SkMatrix kUVMatrices[kNumMatrices] = { |
| 59 | SkMatrix::MakeAll( 0, -1, 1, |
| 60 | -1, 0, 1, |
| 61 | 0, 0, 1), |
| 62 | SkMatrix::MakeAll( 1, 0, 0, |
| 63 | 0, -1, 1, |
| 64 | 0, 0, 1), |
| 65 | // flip x |
| 66 | SkMatrix::MakeAll(-1, 0, 1, |
| 67 | 0, 1, 0, |
| 68 | 0, 0, 1), |
| 69 | SkMatrix::MakeAll( 0, 1, 0, |
| 70 | -1, 0, 1, |
| 71 | 0, 0, 1), |
| 72 | // flip both x & y == rotate 180 |
| 73 | SkMatrix::MakeAll(-1, 0, 1, |
| 74 | 0, -1, 1, |
| 75 | 0, 0, 1), |
| 76 | // identity |
| 77 | SkMatrix::MakeAll(1, 0, 0, |
| 78 | 0, 1, 0, |
| 79 | 0, 0, 1) |
| 80 | }; |
| 81 | |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 82 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 83 | // Create a fixed size text label like "LL" or "LR". |
Adlai Holler | 4caa935 | 2020-07-16 10:58:58 -0400 | [diff] [blame] | 84 | static sk_sp<SkImage> make_text_image(GrDirectContext* direct, const char* text, SkColor color) { |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 85 | SkPaint paint; |
| 86 | paint.setAntiAlias(true); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 87 | paint.setColor(color); |
| 88 | |
Mike Reed | 94cca60 | 2018-12-02 16:04:27 -0500 | [diff] [blame] | 89 | SkFont font; |
| 90 | font.setEdging(SkFont::Edging::kAntiAlias); |
Mike Klein | ea3f014 | 2019-03-20 11:12:10 -0500 | [diff] [blame] | 91 | font.setTypeface(ToolUtils::create_portable_typeface()); |
Mike Reed | 94cca60 | 2018-12-02 16:04:27 -0500 | [diff] [blame] | 92 | font.setSize(32); |
| 93 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 94 | SkRect bounds; |
Ben Wagner | 51e15a6 | 2019-05-07 15:38:46 -0400 | [diff] [blame] | 95 | font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 96 | const SkMatrix mat = SkMatrix::MakeRectToRect(bounds, SkRect::MakeWH(kLabelSize, kLabelSize), |
| 97 | SkMatrix::kFill_ScaleToFit); |
| 98 | |
| 99 | const SkImageInfo ii = SkImageInfo::MakeN32Premul(kLabelSize, kLabelSize); |
| 100 | sk_sp<SkSurface> surf = SkSurface::MakeRaster(ii); |
| 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 | |
| 108 | sk_sp<SkImage> image = surf->makeImageSnapshot(); |
| 109 | |
Adlai Holler | 4caa935 | 2020-07-16 10:58:58 -0400 | [diff] [blame] | 110 | return image->makeTextureImage(direct); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 111 | } |
| 112 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 113 | // Create an image with each corner marked w/ "LL", "LR", etc., with the origin either bottom-left |
| 114 | // or top-left. |
Robert Phillips | b87b39b | 2020-07-01 14:45:24 -0400 | [diff] [blame] | 115 | static sk_sp<SkImage> make_reference_image(GrDirectContext* context, |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 116 | const SkTArray<sk_sp<SkImage>>& labels, |
| 117 | bool bottomLeftOrigin) { |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 118 | SkASSERT(kNumLabels == labels.count()); |
| 119 | |
Brian Salomon | 58389b9 | 2018-03-07 13:01:25 -0500 | [diff] [blame] | 120 | SkImageInfo ii = |
| 121 | SkImageInfo::Make(kImageSize, kImageSize, kRGBA_8888_SkColorType, kOpaque_SkAlphaType); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 122 | SkBitmap bm; |
| 123 | bm.allocPixels(ii); |
| 124 | SkCanvas canvas(bm); |
| 125 | |
| 126 | canvas.clear(SK_ColorWHITE); |
| 127 | for (int i = 0; i < kNumLabels; ++i) { |
| 128 | canvas.drawImage(labels[i], |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 129 | 0.0 != kPoints[i].fX ? kPoints[i].fX-kLabelSize-kInset : kInset, |
| 130 | 0.0 != kPoints[i].fY ? kPoints[i].fY-kLabelSize-kInset : kInset); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 131 | } |
| 132 | |
Brian Salomon | 2a4f983 | 2018-03-03 22:43:43 -0500 | [diff] [blame] | 133 | auto origin = bottomLeftOrigin ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin; |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 134 | |
Greg Daniel | 81b9897 | 2019-12-13 11:09:43 -0500 | [diff] [blame] | 135 | // TODO: make MakeTextureProxyFromData return a GrSurfaceProxyView |
Brian Salomon | 4eda710 | 2019-10-21 15:04:52 -0400 | [diff] [blame] | 136 | auto proxy = sk_gpu_test::MakeTextureProxyFromData(context, GrRenderable::kNo, origin, |
| 137 | bm.info(), bm.getPixels(), bm.rowBytes()); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 138 | if (!proxy) { |
| 139 | return nullptr; |
| 140 | } |
| 141 | |
Greg Daniel | 14b5721 | 2019-12-17 16:18:06 -0500 | [diff] [blame] | 142 | GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(), |
Greg Daniel | 7c165a4 | 2020-01-22 12:22:36 -0500 | [diff] [blame] | 143 | GrColorType::kRGBA_8888); |
Greg Daniel | 81b9897 | 2019-12-13 11:09:43 -0500 | [diff] [blame] | 144 | GrSurfaceProxyView view(std::move(proxy), origin, swizzle); |
Greg Daniel | 7c165a4 | 2020-01-22 12:22:36 -0500 | [diff] [blame] | 145 | return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), kNeedNewImageUniqueID, std::move(view), |
| 146 | ii.colorType(), kOpaque_SkAlphaType, nullptr); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | // Here we're converting from a matrix that is intended for UVs to a matrix that is intended |
| 150 | // for rect geometry used for a drawImage call. They are, in some sense, inverses of each |
| 151 | // other but we also need a scale to map from the [0..1] uv range to the actual size of |
| 152 | // image. |
| 153 | static bool UVMatToGeomMatForImage(SkMatrix* geomMat, const SkMatrix& uvMat) { |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 154 | |
| 155 | const SkMatrix yFlip = SkMatrix::MakeAll(1, 0, 0, 0, -1, 1, 0, 0, 1); |
| 156 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 157 | SkMatrix tmp = uvMat; |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 158 | tmp.preConcat(yFlip); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 159 | tmp.preScale(1.0f/kImageSize, 1.0f/kImageSize); |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 160 | |
| 161 | tmp.postConcat(yFlip); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 162 | tmp.postScale(kImageSize, kImageSize); |
| 163 | |
| 164 | return tmp.invert(geomMat); |
| 165 | } |
| 166 | |
| 167 | // This GM exercises drawImage with a set of matrices that use an unusual amount of flips and |
| 168 | // rotates. |
Chris Dalton | 3a77837 | 2019-02-07 15:23:36 -0700 | [diff] [blame] | 169 | class FlippityGM : public skiagm::GpuGM { |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 170 | public: |
| 171 | FlippityGM() { |
Mike Klein | d46dce3 | 2018-08-16 10:17:03 -0400 | [diff] [blame] | 172 | this->setBGColor(0xFFCCCCCC); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 173 | } |
| 174 | |
Ben Wagner | c061d31 | 2019-08-14 15:31:52 -0400 | [diff] [blame] | 175 | private: |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 176 | SkString onShortName() override { |
| 177 | return SkString("flippity"); |
| 178 | } |
| 179 | |
| 180 | SkISize onISize() override { |
| 181 | return SkISize::Make(kGMWidth, kGMHeight); |
| 182 | } |
| 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], |
| 207 | nullptr, SkCanvas::kFast_SrcRectConstraint); |
| 208 | } else { |
| 209 | canvas->drawImage(image, 0, 0); |
| 210 | } |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 211 | |
| 212 | // draw the labels |
| 213 | for (int i = 0; i < kNumLabels; ++i) { |
| 214 | canvas->drawImage(fLabels[i], |
| 215 | 0.0f == kPoints[i].fX ? -kLabelSize : kPoints[i].fX, |
| 216 | 0.0f == kPoints[i].fY ? -kLabelSize : kPoints[i].fY); |
| 217 | } |
| 218 | canvas->restore(); |
| 219 | } |
| 220 | |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 221 | void drawRow(SkCanvas* canvas, bool bottomLeftImage, bool drawSubset, bool drawScaled) { |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 222 | |
| 223 | canvas->save(); |
| 224 | canvas->translate(kLabelSize, kLabelSize); |
| 225 | |
| 226 | for (int i = 0; i < kNumMatrices; ++i) { |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 227 | this->drawImageWithMatrixAndLabels(canvas, fReferenceImages[bottomLeftImage].get(), |
| 228 | i, drawSubset, drawScaled); |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 229 | canvas->translate(kCellSize, 0); |
| 230 | } |
| 231 | canvas->restore(); |
| 232 | } |
| 233 | |
Adlai Holler | 4caa935 | 2020-07-16 10:58:58 -0400 | [diff] [blame] | 234 | void makeLabels(GrDirectContext* direct) { |
Ben Wagner | c061d31 | 2019-08-14 15:31:52 -0400 | [diff] [blame] | 235 | if (fLabels.count()) { |
| 236 | return; |
| 237 | } |
| 238 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 239 | static const char* kLabelText[kNumLabels] = { "LL", "LR", "UL", "UR" }; |
| 240 | |
| 241 | static const SkColor kLabelColors[kNumLabels] = { |
| 242 | SK_ColorRED, |
| 243 | SK_ColorGREEN, |
| 244 | SK_ColorBLUE, |
| 245 | SK_ColorCYAN |
| 246 | }; |
| 247 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 248 | for (int i = 0; i < kNumLabels; ++i) { |
Adlai Holler | 4caa935 | 2020-07-16 10:58:58 -0400 | [diff] [blame] | 249 | fLabels.push_back(make_text_image(direct, kLabelText[i], kLabelColors[i])); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 250 | } |
| 251 | SkASSERT(kNumLabels == fLabels.count()); |
| 252 | } |
| 253 | |
Robert Phillips | b87b39b | 2020-07-01 14:45:24 -0400 | [diff] [blame] | 254 | DrawResult onGpuSetup(GrDirectContext* context, SkString* errorMsg) override { |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 255 | if (!context || context->abandoned()) { |
| 256 | return DrawResult::kSkip; |
| 257 | } |
| 258 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 259 | this->makeLabels(context); |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 260 | fReferenceImages[0] = make_reference_image(context, fLabels, false); |
| 261 | fReferenceImages[1] = make_reference_image(context, fLabels, true); |
| 262 | if (!fReferenceImages[0] || !fReferenceImages[1]) { |
| 263 | *errorMsg = "Failed to create reference images."; |
| 264 | return DrawResult::kFail; |
| 265 | } |
| 266 | |
| 267 | return DrawResult::kOk; |
| 268 | } |
| 269 | |
Robert Phillips | b795bea | 2020-06-25 12:38:53 -0400 | [diff] [blame] | 270 | void onGpuTeardown() override { |
| 271 | fLabels.reset(); |
| 272 | fReferenceImages[0] = fReferenceImages[1] = nullptr; |
| 273 | } |
| 274 | |
Robert Phillips | 95c250c | 2020-06-29 15:36:12 -0400 | [diff] [blame] | 275 | void onDraw(GrRecordingContext*, GrRenderTargetContext*, SkCanvas* canvas) override { |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 276 | SkASSERT(fReferenceImages[0] && fReferenceImages[1]); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 277 | |
Robert Phillips | f0a30d7 | 2017-11-01 14:05:12 -0400 | [diff] [blame] | 278 | canvas->save(); |
| 279 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 280 | // Top row gets TL image |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 281 | this->drawRow(canvas, false, false, false); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 282 | |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 283 | canvas->translate(0, kCellSize); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 284 | |
| 285 | // Bottom row gets BL image |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 286 | this->drawRow(canvas, true, false, false); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 287 | |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 288 | canvas->translate(0, kCellSize); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 289 | |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 290 | // Third row gets subsets of BL images |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 291 | this->drawRow(canvas, true, true, false); |
Robert Phillips | 206bda5 | 2017-11-01 09:26:06 -0400 | [diff] [blame] | 292 | |
| 293 | canvas->translate(0, kCellSize); |
| 294 | |
| 295 | // Fourth row gets scaled subsets of BL images |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 296 | this->drawRow(canvas, true, true, true); |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 297 | |
Robert Phillips | f0a30d7 | 2017-11-01 14:05:12 -0400 | [diff] [blame] | 298 | canvas->restore(); |
| 299 | |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 300 | // separator grid |
Robert Phillips | f0a30d7 | 2017-11-01 14:05:12 -0400 | [diff] [blame] | 301 | for (int i = 0; i < 4; ++i) { |
| 302 | canvas->drawLine(0, i * kCellSize, kGMWidth, i * kCellSize, SkPaint()); |
| 303 | } |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 304 | for (int i = 0; i < kNumMatrices; ++i) { |
| 305 | canvas->drawLine(i * kCellSize, 0, i * kCellSize, kGMHeight, SkPaint()); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | private: |
| 310 | SkTArray<sk_sp<SkImage>> fLabels; |
Robert Phillips | c869ff7 | 2020-06-19 09:50:33 -0400 | [diff] [blame] | 311 | sk_sp<SkImage> fReferenceImages[2]; |
Robert Phillips | a097173 | 2017-10-31 12:26:35 -0400 | [diff] [blame] | 312 | |
| 313 | typedef GM INHERITED; |
| 314 | }; |
| 315 | |
| 316 | DEF_GM(return new FlippityGM;) |