Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / tests / ReadPixelsTest.cpp
1 /*
2  * Copyright 2011 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
8 #include "include/core/SkBitmap.h"
9 #include "include/core/SkCanvas.h"
10 #include "include/core/SkColorPriv.h"
11 #include "include/core/SkColorSpace.h"
12 #include "include/core/SkImage.h"
13 #include "include/core/SkSurface.h"
14 #include "include/private/SkColorData.h"
15 #include "include/private/SkHalf.h"
16 #include "include/private/SkImageInfoPriv.h"
17 #include "include/utils/SkNWayCanvas.h"
18 #include "src/core/SkMathPriv.h"
19 #include "tests/Test.h"
20
21 static const int DEV_W = 100, DEV_H = 100;
22 static const SkIRect DEV_RECT = SkIRect::MakeWH(DEV_W, DEV_H);
23 static const SkRect DEV_RECT_S = SkRect::MakeWH(DEV_W * SK_Scalar1,
24                                                 DEV_H * SK_Scalar1);
25
26 static SkPMColor get_src_color(int x, int y) {
27     SkASSERT(x >= 0 && x < DEV_W);
28     SkASSERT(y >= 0 && y < DEV_H);
29
30     U8CPU r = x;
31     U8CPU g = y;
32     U8CPU b = 0xc;
33
34     U8CPU a = 0xff;
35     switch ((x+y) % 5) {
36         case 0:
37             a = 0xff;
38             break;
39         case 1:
40             a = 0x80;
41             break;
42         case 2:
43             a = 0xCC;
44             break;
45         case 4:
46             a = 0x01;
47             break;
48         case 3:
49             a = 0x00;
50             break;
51     }
52     return SkPremultiplyARGBInline(a, r, g, b);
53 }
54
55 static SkPMColor get_dst_bmp_init_color(int x, int y, int w) {
56     int n = y * w + x;
57
58     U8CPU b = n & 0xff;
59     U8CPU g = (n >> 8) & 0xff;
60     U8CPU r = (n >> 16) & 0xff;
61     return SkPackARGB32(0xff, r, g , b);
62 }
63
64 // TODO: Make this consider both ATs
65 static SkPMColor convert_to_pmcolor(SkColorType ct, SkAlphaType at, const uint32_t* addr,
66                                     bool* doUnpremul) {
67     *doUnpremul = (kUnpremul_SkAlphaType == at);
68
69     const uint8_t* c = reinterpret_cast<const uint8_t*>(addr);
70     U8CPU a,r,g,b;
71     switch (ct) {
72         case kBGRA_8888_SkColorType:
73             b = static_cast<U8CPU>(c[0]);
74             g = static_cast<U8CPU>(c[1]);
75             r = static_cast<U8CPU>(c[2]);
76             a = static_cast<U8CPU>(c[3]);
77             break;
78         case kRGB_888x_SkColorType:  // fallthrough
79         case kRGBA_8888_SkColorType:
80             r = static_cast<U8CPU>(c[0]);
81             g = static_cast<U8CPU>(c[1]);
82             b = static_cast<U8CPU>(c[2]);
83             // We set this even when for kRGB_888x because our caller will validate that it is 0xff.
84             a = static_cast<U8CPU>(c[3]);
85             break;
86         default:
87             SkDEBUGFAIL("Unexpected colortype");
88             return 0;
89     }
90
91     if (*doUnpremul) {
92         r = SkMulDiv255Ceiling(r, a);
93         g = SkMulDiv255Ceiling(g, a);
94         b = SkMulDiv255Ceiling(b, a);
95     }
96     return SkPackARGB32(a, r, g, b);
97 }
98
99 static sk_sp<SkImage> make_src_image() {
100     static SkBitmap bmp;
101     if (bmp.isNull()) {
102         bmp.allocN32Pixels(DEV_W, DEV_H);
103         intptr_t pixels = reinterpret_cast<intptr_t>(bmp.getPixels());
104         for (int y = 0; y < DEV_H; ++y) {
105             for (int x = 0; x < DEV_W; ++x) {
106                 SkPMColor* pixel = reinterpret_cast<SkPMColor*>(pixels + y * bmp.rowBytes() + x * bmp.bytesPerPixel());
107                 *pixel = get_src_color(x, y);
108             }
109         }
110         bmp.setImmutable();
111     }
112     return bmp.asImage();
113 }
114
115 static void fill_src_canvas(SkCanvas* canvas) {
116     canvas->save();
117     canvas->setMatrix(SkMatrix::I());
118     canvas->clipRect(DEV_RECT_S, SkClipOp::kIntersect);
119     SkPaint paint;
120     paint.setBlendMode(SkBlendMode::kSrc);
121     canvas->drawImage(make_src_image(), 0, 0, SkSamplingOptions(), &paint);
122     canvas->restore();
123 }
124
125 static void fill_dst_bmp_with_init_data(SkBitmap* bitmap) {
126     int w = bitmap->width();
127     int h = bitmap->height();
128     intptr_t pixels = reinterpret_cast<intptr_t>(bitmap->getPixels());
129     for (int y = 0; y < h; ++y) {
130         for (int x = 0; x < w; ++x) {
131             SkPMColor initColor = get_dst_bmp_init_color(x, y, w);
132             if (kAlpha_8_SkColorType == bitmap->colorType()) {
133                 uint8_t* alpha = reinterpret_cast<uint8_t*>(pixels + y * bitmap->rowBytes() + x);
134                 *alpha = SkGetPackedA32(initColor);
135             } else {
136                 SkPMColor* pixel = reinterpret_cast<SkPMColor*>(pixels + y * bitmap->rowBytes() + x * bitmap->bytesPerPixel());
137                 *pixel = initColor;
138             }
139         }
140     }
141 }
142
143 static bool check_read_pixel(SkPMColor a, SkPMColor b, bool didPremulConversion) {
144     if (!didPremulConversion) {
145         return a == b;
146     }
147     int32_t aA = static_cast<int32_t>(SkGetPackedA32(a));
148     int32_t aR = static_cast<int32_t>(SkGetPackedR32(a));
149     int32_t aG = static_cast<int32_t>(SkGetPackedG32(a));
150     int32_t aB = SkGetPackedB32(a);
151
152     int32_t bA = static_cast<int32_t>(SkGetPackedA32(b));
153     int32_t bR = static_cast<int32_t>(SkGetPackedR32(b));
154     int32_t bG = static_cast<int32_t>(SkGetPackedG32(b));
155     int32_t bB = static_cast<int32_t>(SkGetPackedB32(b));
156
157     return aA == bA &&
158            SkAbs32(aR - bR) <= 1 &&
159            SkAbs32(aG - bG) <= 1 &&
160            SkAbs32(aB - bB) <= 1;
161 }
162
163 // checks the bitmap contains correct pixels after the readPixels
164 // if the bitmap was prefilled with pixels it checks that these weren't
165 // overwritten in the area outside the readPixels.
166 static bool check_read(skiatest::Reporter* reporter, const SkBitmap& bitmap, int x, int y,
167                        bool checkSurfacePixels, bool checkBitmapPixels,
168                        SkImageInfo surfaceInfo) {
169     SkAlphaType bmpAT = bitmap.alphaType();
170     SkColorType bmpCT = bitmap.colorType();
171     SkASSERT(!bitmap.isNull());
172     SkASSERT(checkSurfacePixels || checkBitmapPixels);
173
174     int bw = bitmap.width();
175     int bh = bitmap.height();
176
177     SkIRect srcRect = SkIRect::MakeXYWH(x, y, bw, bh);
178     SkIRect clippedSrcRect = DEV_RECT;
179     if (!clippedSrcRect.intersect(srcRect)) {
180         clippedSrcRect.setEmpty();
181     }
182     if (kAlpha_8_SkColorType == bmpCT) {
183         for (int by = 0; by < bh; ++by) {
184             for (int bx = 0; bx < bw; ++bx) {
185                 int devx = bx + srcRect.fLeft;
186                 int devy = by + srcRect.fTop;
187                 const uint8_t* alpha = bitmap.getAddr8(bx, by);
188
189                 if (clippedSrcRect.contains(devx, devy)) {
190                     if (checkSurfacePixels) {
191                         uint8_t surfaceAlpha = (surfaceInfo.alphaType() == kOpaque_SkAlphaType)
192                                                        ? 0xFF
193                                                        : SkGetPackedA32(get_src_color(devx, devy));
194                         if (surfaceAlpha != *alpha) {
195                             ERRORF(reporter,
196                                    "Expected readback alpha (%d, %d) value 0x%02x, got 0x%02x. ",
197                                    bx, by, surfaceAlpha, *alpha);
198                             return false;
199                         }
200                     }
201                 } else if (checkBitmapPixels) {
202                     uint32_t origDstAlpha = SkGetPackedA32(get_dst_bmp_init_color(bx, by, bw));
203                     if (origDstAlpha != *alpha) {
204                         ERRORF(reporter, "Expected clipped out area of readback to be unchanged. "
205                             "Expected 0x%02x, got 0x%02x", origDstAlpha, *alpha);
206                         return false;
207                     }
208                 }
209             }
210         }
211         return true;
212     }
213     for (int by = 0; by < bh; ++by) {
214         for (int bx = 0; bx < bw; ++bx) {
215             int devx = bx + srcRect.fLeft;
216             int devy = by + srcRect.fTop;
217
218             const uint32_t* pixel = bitmap.getAddr32(bx, by);
219
220             if (clippedSrcRect.contains(devx, devy)) {
221                 if (checkSurfacePixels) {
222                     SkPMColor surfacePMColor = get_src_color(devx, devy);
223                     if (SkColorTypeIsAlphaOnly(surfaceInfo.colorType())) {
224                         surfacePMColor &= 0xFF000000;
225                     }
226                     if (kOpaque_SkAlphaType == surfaceInfo.alphaType() || kOpaque_SkAlphaType == bmpAT) {
227                         surfacePMColor |= 0xFF000000;
228                     }
229                     bool didPremul;
230                     SkPMColor pmPixel = convert_to_pmcolor(bmpCT, bmpAT, pixel, &didPremul);
231                     if (!check_read_pixel(pmPixel, surfacePMColor, didPremul)) {
232                         ERRORF(reporter,
233                                "Expected readback pixel (%d, %d) value 0x%08x, got 0x%08x. "
234                                "Readback was unpremul: %d",
235                                bx, by, surfacePMColor, pmPixel, didPremul);
236                         return false;
237                     }
238                 }
239             } else if (checkBitmapPixels) {
240                 uint32_t origDstPixel = get_dst_bmp_init_color(bx, by, bw);
241                 if (origDstPixel != *pixel) {
242                     ERRORF(reporter, "Expected clipped out area of readback to be unchanged. "
243                            "Expected 0x%08x, got 0x%08x", origDstPixel, *pixel);
244                     return false;
245                 }
246             }
247         }
248     }
249     return true;
250 }
251
252 enum class TightRowBytes : bool { kNo, kYes };
253
254 static void init_bitmap(SkBitmap* bitmap, const SkIRect& rect, TightRowBytes tightRB,
255                         SkColorType ct, SkAlphaType at) {
256     SkImageInfo info = SkImageInfo::Make(rect.size(), ct, at);
257     size_t rowBytes = 0;
258     if (tightRB == TightRowBytes::kNo) {
259         rowBytes = SkAlign4((info.width() + 16) * info.bytesPerPixel());
260     }
261     bitmap->allocPixels(info, rowBytes);
262 }
263
264 static const struct {
265     SkColorType fColorType;
266     SkAlphaType fAlphaType;
267 } gReadPixelsConfigs[] = {
268         {kRGBA_8888_SkColorType, kPremul_SkAlphaType},
269         {kRGBA_8888_SkColorType, kUnpremul_SkAlphaType},
270         {kRGB_888x_SkColorType, kOpaque_SkAlphaType},
271         {kBGRA_8888_SkColorType, kPremul_SkAlphaType},
272         {kBGRA_8888_SkColorType, kUnpremul_SkAlphaType},
273         {kAlpha_8_SkColorType, kPremul_SkAlphaType},
274 };
275 const SkIRect gReadPixelsTestRects[] = {
276     // entire thing
277     DEV_RECT,
278     // larger on all sides
279     SkIRect::MakeLTRB(-10, -10, DEV_W + 10, DEV_H + 10),
280     // fully contained
281     SkIRect::MakeLTRB(DEV_W / 4, DEV_H / 4, 3 * DEV_W / 4, 3 * DEV_H / 4),
282     // outside top left
283     SkIRect::MakeLTRB(-10, -10, -1, -1),
284     // touching top left corner
285     SkIRect::MakeLTRB(-10, -10, 0, 0),
286     // overlapping top left corner
287     SkIRect::MakeLTRB(-10, -10, DEV_W / 4, DEV_H / 4),
288     // overlapping top left and top right corners
289     SkIRect::MakeLTRB(-10, -10, DEV_W  + 10, DEV_H / 4),
290     // touching entire top edge
291     SkIRect::MakeLTRB(-10, -10, DEV_W  + 10, 0),
292     // overlapping top right corner
293     SkIRect::MakeLTRB(3 * DEV_W / 4, -10, DEV_W  + 10, DEV_H / 4),
294     // contained in x, overlapping top edge
295     SkIRect::MakeLTRB(DEV_W / 4, -10, 3 * DEV_W  / 4, DEV_H / 4),
296     // outside top right corner
297     SkIRect::MakeLTRB(DEV_W + 1, -10, DEV_W + 10, -1),
298     // touching top right corner
299     SkIRect::MakeLTRB(DEV_W, -10, DEV_W + 10, 0),
300     // overlapping top left and bottom left corners
301     SkIRect::MakeLTRB(-10, -10, DEV_W / 4, DEV_H + 10),
302     // touching entire left edge
303     SkIRect::MakeLTRB(-10, -10, 0, DEV_H + 10),
304     // overlapping bottom left corner
305     SkIRect::MakeLTRB(-10, 3 * DEV_H / 4, DEV_W / 4, DEV_H + 10),
306     // contained in y, overlapping left edge
307     SkIRect::MakeLTRB(-10, DEV_H / 4, DEV_W / 4, 3 * DEV_H / 4),
308     // outside bottom left corner
309     SkIRect::MakeLTRB(-10, DEV_H + 1, -1, DEV_H + 10),
310     // touching bottom left corner
311     SkIRect::MakeLTRB(-10, DEV_H, 0, DEV_H + 10),
312     // overlapping bottom left and bottom right corners
313     SkIRect::MakeLTRB(-10, 3 * DEV_H / 4, DEV_W + 10, DEV_H + 10),
314     // touching entire left edge
315     SkIRect::MakeLTRB(0, DEV_H, DEV_W, DEV_H + 10),
316     // overlapping bottom right corner
317     SkIRect::MakeLTRB(3 * DEV_W / 4, 3 * DEV_H / 4, DEV_W + 10, DEV_H + 10),
318     // overlapping top right and bottom right corners
319     SkIRect::MakeLTRB(3 * DEV_W / 4, -10, DEV_W + 10, DEV_H + 10),
320 };
321
322 bool read_should_succeed(const SkIRect& srcRect, const SkImageInfo& dstInfo,
323                          const SkImageInfo& srcInfo) {
324     return SkIRect::Intersects(srcRect, DEV_RECT) && SkImageInfoValidConversion(dstInfo, srcInfo);
325 }
326
327 static void test_readpixels(skiatest::Reporter* reporter, const sk_sp<SkSurface>& surface,
328                             const SkImageInfo& surfaceInfo) {
329     SkCanvas* canvas = surface->getCanvas();
330     fill_src_canvas(canvas);
331     for (size_t rect = 0; rect < SK_ARRAY_COUNT(gReadPixelsTestRects); ++rect) {
332         const SkIRect& srcRect = gReadPixelsTestRects[rect];
333         for (auto tightRB : {TightRowBytes::kYes, TightRowBytes::kNo}) {
334             for (size_t c = 0; c < SK_ARRAY_COUNT(gReadPixelsConfigs); ++c) {
335                 SkBitmap bmp;
336                 init_bitmap(&bmp, srcRect, tightRB, gReadPixelsConfigs[c].fColorType,
337                             gReadPixelsConfigs[c].fAlphaType);
338
339                 // if the bitmap has pixels allocated before the readPixels,
340                 // note that and fill them with pattern
341                 bool startsWithPixels = !bmp.isNull();
342                 if (startsWithPixels) {
343                     fill_dst_bmp_with_init_data(&bmp);
344                 }
345                 uint32_t idBefore = surface->generationID();
346                 bool success = surface->readPixels(bmp, srcRect.fLeft, srcRect.fTop);
347                 uint32_t idAfter = surface->generationID();
348
349                 // we expect to succeed when the read isn't fully clipped out and the infos are
350                 // compatible.
351                 bool expectSuccess = read_should_succeed(srcRect, bmp.info(), surfaceInfo);
352                 // determine whether we expected the read to succeed.
353                 REPORTER_ASSERT(reporter, expectSuccess == success,
354                                 "Read succeed=%d unexpectedly, src ct/at: %d/%d, dst ct/at: %d/%d",
355                                 success, surfaceInfo.colorType(), surfaceInfo.alphaType(),
356                                 bmp.info().colorType(), bmp.info().alphaType());
357                 // read pixels should never change the gen id
358                 REPORTER_ASSERT(reporter, idBefore == idAfter);
359
360                 if (success || startsWithPixels) {
361                     check_read(reporter, bmp, srcRect.fLeft, srcRect.fTop, success,
362                                startsWithPixels, surfaceInfo);
363                 } else {
364                     // if we had no pixels beforehand and the readPixels
365                     // failed then our bitmap should still not have pixels
366                     REPORTER_ASSERT(reporter, bmp.isNull());
367                 }
368             }
369         }
370     }
371 }
372
373 DEF_TEST(ReadPixels, reporter) {
374     const SkImageInfo info = SkImageInfo::MakeN32Premul(DEV_W, DEV_H);
375     auto surface(SkSurface::MakeRaster(info));
376     test_readpixels(reporter, surface, info);
377 }
378
379 ///////////////////////////////////////////////////////////////////////////////////////////////////
380
381 static const uint32_t kNumPixels = 5;
382
383 // The five reference pixels are: red, green, blue, white, black.
384 // Five is an interesting number to test because we'll exercise a full 4-wide SIMD vector
385 // plus a tail pixel.
386 static const uint32_t rgba[kNumPixels] = {
387         0xFF0000FF, 0xFF00FF00, 0xFFFF0000, 0xFFFFFFFF, 0xFF000000
388 };
389 static const uint32_t bgra[kNumPixels] = {
390         0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000
391 };
392 static const uint16_t rgb565[kNumPixels] = {
393         SK_R16_MASK_IN_PLACE, SK_G16_MASK_IN_PLACE, SK_B16_MASK_IN_PLACE, 0xFFFF, 0x0
394 };
395
396 static const uint16_t rgba4444[kNumPixels] = { 0xF00F, 0x0F0F, 0x00FF, 0xFFFF, 0x000F };
397
398 static const uint64_t kRed      = (uint64_t) SK_Half1 <<  0;
399 static const uint64_t kGreen    = (uint64_t) SK_Half1 << 16;
400 static const uint64_t kBlue     = (uint64_t) SK_Half1 << 32;
401 static const uint64_t kAlpha    = (uint64_t) SK_Half1 << 48;
402 static const uint64_t f16[kNumPixels] = {
403         kAlpha | kRed, kAlpha | kGreen, kAlpha | kBlue, kAlpha | kBlue | kGreen | kRed, kAlpha
404 };
405
406 static const uint8_t alpha8[kNumPixels] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
407 static const uint8_t gray8[kNumPixels] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
408
409 static const void* five_reference_pixels(SkColorType colorType) {
410     switch (colorType) {
411         case kUnknown_SkColorType:
412             return nullptr;
413         case kAlpha_8_SkColorType:
414             return alpha8;
415         case kRGB_565_SkColorType:
416             return rgb565;
417         case kARGB_4444_SkColorType:
418             return rgba4444;
419         case kRGBA_8888_SkColorType:
420             return rgba;
421         case kBGRA_8888_SkColorType:
422             return bgra;
423         case kGray_8_SkColorType:
424             return gray8;
425         case kRGBA_F16_SkColorType:
426             return f16;
427         default:
428             return nullptr;
429     }
430
431     SkASSERT(false);
432     return nullptr;
433 }
434
435 static void test_conversion(skiatest::Reporter* r, const SkImageInfo& dstInfo,
436                             const SkImageInfo& srcInfo) {
437     if (!SkImageInfoIsValid(srcInfo)) {
438         return;
439     }
440
441     const void* srcPixels = five_reference_pixels(srcInfo.colorType());
442     SkPixmap srcPixmap(srcInfo, srcPixels, srcInfo.minRowBytes());
443     sk_sp<SkImage> src = SkImage::MakeFromRaster(srcPixmap, nullptr, nullptr);
444     REPORTER_ASSERT(r, src);
445
446     // Enough space for 5 pixels when color type is F16, more than enough space in other cases.
447     uint64_t dstPixels[kNumPixels];
448     SkPixmap dstPixmap(dstInfo, dstPixels, dstInfo.minRowBytes());
449     bool success = src->readPixels(nullptr, dstPixmap, 0, 0);
450     REPORTER_ASSERT(r, success == SkImageInfoValidConversion(dstInfo, srcInfo));
451
452     if (success) {
453         if (kGray_8_SkColorType == srcInfo.colorType() &&
454             kGray_8_SkColorType != dstInfo.colorType()) {
455             // TODO: test (r,g,b) == (gray,gray,gray)?
456             return;
457         }
458
459         if (kGray_8_SkColorType == dstInfo.colorType() &&
460             kGray_8_SkColorType != srcInfo.colorType()) {
461             // TODO: test gray = luminance?
462             return;
463         }
464
465         if (kAlpha_8_SkColorType == srcInfo.colorType() &&
466             kAlpha_8_SkColorType != dstInfo.colorType()) {
467             // TODO: test output = black with this alpha?
468             return;
469         }
470
471         REPORTER_ASSERT(r, 0 == memcmp(dstPixels, five_reference_pixels(dstInfo.colorType()),
472                                        kNumPixels * SkColorTypeBytesPerPixel(dstInfo.colorType())));
473     }
474 }
475
476 DEF_TEST(ReadPixels_ValidConversion, reporter) {
477     const SkColorType kColorTypes[] = {
478             kUnknown_SkColorType,
479             kAlpha_8_SkColorType,
480             kRGB_565_SkColorType,
481             kARGB_4444_SkColorType,
482             kRGBA_8888_SkColorType,
483             kBGRA_8888_SkColorType,
484             kGray_8_SkColorType,
485             kRGBA_F16_SkColorType,
486     };
487
488     const SkAlphaType kAlphaTypes[] = {
489             kUnknown_SkAlphaType,
490             kOpaque_SkAlphaType,
491             kPremul_SkAlphaType,
492             kUnpremul_SkAlphaType,
493     };
494
495     const sk_sp<SkColorSpace> kColorSpaces[] = {
496             nullptr,
497             SkColorSpace::MakeSRGB(),
498     };
499
500     for (SkColorType dstCT : kColorTypes) {
501         for (SkAlphaType dstAT : kAlphaTypes) {
502             for (const sk_sp<SkColorSpace>& dstCS : kColorSpaces) {
503                 for (SkColorType srcCT : kColorTypes) {
504                     for (SkAlphaType srcAT : kAlphaTypes) {
505                         for (const sk_sp<SkColorSpace>& srcCS : kColorSpaces) {
506                             test_conversion(reporter,
507                                             SkImageInfo::Make(kNumPixels, 1, dstCT, dstAT, dstCS),
508                                             SkImageInfo::Make(kNumPixels, 1, srcCT, srcAT, srcCS));
509                         }
510                     }
511                 }
512             }
513         }
514     }
515 }
516
517 DEF_TEST(ReadPixels_InvalidRowBytes, reporter) {
518     auto srcII = SkImageInfo::Make({10, 10}, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
519     auto surf = SkSurface::MakeRaster(srcII);
520     for (int ct = 0; ct < kLastEnum_SkColorType + 1; ++ct) {
521         auto colorType = static_cast<SkColorType>(ct);
522         size_t bpp = SkColorTypeBytesPerPixel(colorType);
523         if (bpp <= 1) {
524             continue;
525         }
526         auto dstII = srcII.makeColorType(colorType);
527         size_t badRowBytes = (surf->width() + 1)*bpp - 1;
528         auto storage = std::make_unique<char[]>(badRowBytes*surf->height());
529         REPORTER_ASSERT(reporter, !surf->readPixels(dstII, storage.get(), badRowBytes, 0, 0));
530     }
531 }