Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1062)

Unified Diff: third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp

Issue 1719533002: Modify YUV codecs to match Skia's API change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update DEPS again Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..305989a7f5d85b376926dd9604a2b114999a7c65 100644
--- a/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp
@@ -36,6 +36,7 @@
#include "public/platform/WebData.h"
#include "public/platform/WebSize.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "wtf/ArrayBuffer.h"
#include "wtf/OwnPtr.h"
#include "wtf/PassOwnPtr.h"
@@ -80,15 +81,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 +102,22 @@ 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);
+
+ RefPtr<ArrayBuffer> buffer(ArrayBuffer::create(rowBytes[0] * ySize.height() + rowBytes[1] * uSize.height() + rowBytes[2] * vSize.height(), 1));
+ void* planes[3];
+ planes[0] = buffer->data();
+ 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 +235,13 @@ TEST(JPEGImageDecoderTest, yuv)
EXPECT_EQ(128u, outputUVWidth);
EXPECT_EQ(128u, outputUVHeight);
+ const char* jpegFileImageSizeNotMultipleOf8 = "/LayoutTests/fast/images/resources/cropped_mandrill.jpg"; // 439x154
+ readYUV(LargeEnoughSize, &outputYWidth, &outputYHeight, &outputUVWidth, &outputUVHeight, jpegFileImageSizeNotMultipleOf8);
+ EXPECT_EQ(439u, outputYWidth);
+ EXPECT_EQ(154u, outputYHeight);
+ EXPECT_EQ(220u, outputUVWidth);
+ EXPECT_EQ(77u, 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);
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698