Commit 0366708a authored by Mike Klein's avatar Mike Klein Committed by Commit Bot

align extra bitmap padding in unit test to avoid crash

At head this test adds 2 extra bytes of padding to each row of an 8888
(4 byte per pixel) bitmap.  This misaligns all the odd rows.

Through some sort of combination of lack of testing and luck of code
generation, eraseColor() is not crashing on Chromium's tree, but it's
within its rights to do so.  The attached bug shows such a crash on a
32-bit ARM build running on a Nexus5x.

To fix this, I think we can just pad each row by 4 extra bytes.  This
keeps every row aligned, and I think the spirit of the test intact.

Bug: chromium:779715
Change-Id: I58e98e9d7dfe55dbe3512d287158449e21e25d2d
Reviewed-on: https://chromium-review.googlesource.com/883741Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531730}
parent 4dca0796
......@@ -90,7 +90,10 @@ TEST_F(StructTraitsTest, BitmapWithExtraRowBytes) {
SkBitmap input;
// Ensure traits work with bitmaps containing additional bytes between rows.
SkImageInfo info = SkImageInfo::MakeN32(8, 5, kPremul_SkAlphaType);
input.allocPixels(info, info.minRowBytes() + 2);
// Any extra bytes on each row must be a multiple of the row's pixel size to
// keep every row's pixels aligned.
size_t extra = info.bytesPerPixel();
input.allocPixels(info, info.minRowBytes() + extra);
input.eraseColor(SK_ColorRED);
input.erase(SK_ColorTRANSPARENT, SkIRect::MakeXYWH(0, 1, 2, 3));
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment