Chromium Code Reviews| Index: third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp |
| diff --git a/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp b/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp |
| index 9f2c660ff300aca73abfdf6e331845256eefefc4..373a1321724345b2a34c9b1a86ce54058a103add 100644 |
| --- a/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp |
| +++ b/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp |
| @@ -80,15 +80,17 @@ void readYUV(size_t maxDecodedBytes, unsigned* outputYWidth, unsigned* outputYHe |
| OwnPtr<ImageDecoder> decoder = createDecoder(maxDecodedBytes); |
| decoder->setData(data.get(), true); |
| - OwnPtr<ImagePlanes> imagePlanes = adoptPtr(new ImagePlanes()); |
| - decoder->setImagePlanes(imagePlanes.release()); |
| + // Setting a dummy ImagePlanes object signals to the decoder that we want to do YUV decoding. |
| + OwnPtr<ImagePlanes> dummyImagePlanes = adoptPtr(new ImagePlanes()); |
| + decoder->setImagePlanes(dummyImagePlanes.release()); |
| + |
| bool sizeIsAvailable = decoder->isSizeAvailable(); |
| ASSERT_TRUE(sizeIsAvailable); |
| IntSize size = decoder->decodedSize(); |
| - IntSize ySize = decoder->decodedYUVSize(0, ImageDecoder::ActualSize); |
| - IntSize uSize = decoder->decodedYUVSize(1, ImageDecoder::ActualSize); |
| - IntSize vSize = decoder->decodedYUVSize(2, ImageDecoder::ActualSize); |
| + IntSize ySize = decoder->decodedYUVSize(0); |
| + IntSize uSize = decoder->decodedYUVSize(1); |
| + IntSize vSize = decoder->decodedYUVSize(2); |
| ASSERT_TRUE(size.width() == ySize.width()); |
| ASSERT_TRUE(size.height() == ySize.height()); |
| @@ -99,6 +101,21 @@ void readYUV(size_t maxDecodedBytes, unsigned* outputYWidth, unsigned* outputYHe |
| *outputYHeight = ySize.height(); |
| *outputUVWidth = uSize.width(); |
| *outputUVHeight = uSize.height(); |
| + |
| + size_t rowBytes[3]; |
| + rowBytes[0] = decoder->decodedYUVWidthBytes(0); |
| + rowBytes[1] = decoder->decodedYUVWidthBytes(1); |
| + rowBytes[2] = decoder->decodedYUVWidthBytes(2); |
| + |
| + SkAutoMalloc buffer(rowBytes[0] * ySize.height() + rowBytes[1] * uSize.height() + rowBytes[2] * vSize.height()); |
| + void* planes[3]; |
| + planes[0] = buffer.get(); |
| + planes[1] = ((char*) planes[0]) + rowBytes[0] * ySize.height(); |
| + planes[2] = ((char*) planes[1]) + rowBytes[1] * uSize.height(); |
| + OwnPtr<ImagePlanes> imagePlanes = adoptPtr(new ImagePlanes(planes, rowBytes)); |
| + decoder->setImagePlanes(imagePlanes.release()); |
| + |
| + ASSERT_TRUE(decoder->decodeToYUV()); |
| } |
| // Tests failure on a too big image. |
| @@ -216,6 +233,13 @@ TEST(JPEGImageDecoderTest, yuv) |
| EXPECT_EQ(128u, outputUVWidth); |
| EXPECT_EQ(128u, outputUVHeight); |
| + const char* jpegFileNon8 = "/LayoutTests/fast/images/resources/non8dims.jpg"; // 227x149 |
|
msarett
2016/02/22 20:56:31
Does this need to be a public image? I might need
scroggo_chromium
2016/02/22 21:10:32
Yes.
msarett
2016/02/22 21:42:44
Done.
|
| + readYUV(LargeEnoughSize, &outputYWidth, &outputYHeight, &outputUVWidth, &outputUVHeight, jpegFileNon8); |
| + EXPECT_EQ(227u, outputYWidth); |
| + EXPECT_EQ(149u, outputYHeight); |
| + EXPECT_EQ(114u, outputUVWidth); |
| + EXPECT_EQ(75u, outputUVHeight); |
| + |
| // Make sure we revert to RGBA decoding when we're about to downscale, |
| // which can occur on memory-constrained android devices. |
| RefPtr<SharedBuffer> data = readFile(jpegFile); |