/* * Original bug was asserting that the matrix-proc had generated a (Y) value * that was out of range. This led (in the release build) to the sampler-proc * reading memory out-of-bounds of the original bitmap. * * We were numerically overflowing our 16bit coordinates that we communicate * between these two procs. The fixes was in two parts: * * 1. Just don't draw bitmaps larger than 64K-1 in width or height, since we * can't represent those coordinates in our transport format (yet). * 2. Perform an unsigned shift during the calculation, so we don't get * sign-extension bleed when packing the two values (X,Y) into our 32bit * slot. * * This tests exercises the original setup, plus 2 more to ensure that we can, * in fact, handle bitmaps at 64K-1 (assuming we don't exceed the total * memory allocation limit). */ static void test_giantrepeat_crbug118018(skiatest::Reporter* reporter) { static const struct { int fWidth; int fHeight; } gTests[] = { { 0x1b294, 0x7f}, // crbug 118018 (width exceeds 64K)... should draw safely now. { 0xFFFF, 0x7f }, // should draw, test max width { 0x7f, 0xFFFF }, // should draw, test max height }; for (size_t i = 0; i < SK_ARRAY_COUNT(gTests); ++i) { test_wacky_bitmapshader(reporter, gTests[i].fWidth, gTests[i].fHeight); } }
/* * Original bug was asserting that the matrix-proc had generated a (Y) value * that was out of range. This led (in the release build) to the sampler-proc * reading memory out-of-bounds of the original bitmap. * * We were numerically overflowing our 16bit coordinates that we communicate * between these two procs. The fixes was in two parts: * * 1. Just don't draw bitmaps larger than 64K-1 in width or height, since we * can't represent those coordinates in our transport format (yet). * 2. Perform an unsigned shift during the calculation, so we don't get * sign-extension bleed when packing the two values (X,Y) into our 32bit * slot. * * This tests exercises the original setup, plus 3 more to ensure that we can, * in fact, handle bitmaps at 64K-1 (assuming we don't exceed the total * memory allocation limit). */ static void test_giantrepeat_crbug118018(skiatest::Reporter* reporter) { static const struct { int fWidth; int fHeight; bool fExpectedToDraw; } gTests[] = { { 0x1b294, 0x7f, false }, // crbug 118018 (width exceeds 64K) { 0xFFFF, 0x7f, true }, // should draw, test max width { 0x7f, 0xFFFF, true }, // should draw, test max height { 0xFFFF, 0xFFFF, false }, // allocation fails (too much RAM) }; for (size_t i = 0; i < SK_ARRAY_COUNT(gTests); ++i) { test_wacky_bitmapshader(reporter, gTests[i].fWidth, gTests[i].fHeight, gTests[i].fExpectedToDraw); } }