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

Unified Diff: tests/JpegTest.cpp

Issue 374743003: Skia side RGB to YUV gpu conversion (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Ported a minimal set of blink side changes for YUV decoding tests Created 6 years, 5 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
« tests/ImageGeneratorTest.cpp ('K') | « tests/ImageGeneratorTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/JpegTest.cpp
diff --git a/tests/JpegTest.cpp b/tests/JpegTest.cpp
index f8784a2d26cc3d428ea5394165c55aec3807a4a0..46191eaf2b6e36dfa1f2c7fa513460211016a479 100644
--- a/tests/JpegTest.cpp
+++ b/tests/JpegTest.cpp
@@ -7,9 +7,12 @@
#include "SkBitmap.h"
#include "SkData.h"
+#include "SkDecodingImageGenerator.h"
#include "SkForceLinking.h"
+#include "SkFrontBufferedStream.h"
#include "SkImage.h"
#include "SkImageDecoder.h"
+#include "SkPixelRef.h"
#include "SkStream.h"
#include "Test.h"
@@ -452,3 +455,44 @@ DEF_TEST(Jpeg, reporter) {
SkASSERT(writeSuccess);
#endif
}
+
+DEF_TEST(Jpeg_YUV, reporter) {
+ size_t len = sizeof(goodJpegImage);
+ SkMemoryStream memStream(goodJpegImage, len);
+
+ SkAutoTUnref<SkStreamRewindable> stream(SkFrontBufferedStream::Create(&memStream, len));
scroggo 2014/07/18 21:52:41 Why do you need an SkFrontBufferedStream? An SkMem
+ SkBitmap bitmap;
+ SkDecodingImageGenerator::Options opts;
+ bool pixelsInstalled = SkInstallDiscardablePixelRef(
+ SkDecodingImageGenerator::Create(stream.detach(), opts), &bitmap);
+ REPORTER_ASSERT(reporter, pixelsInstalled);
+
+ if (pixelsInstalled) {
scroggo 2014/07/18 21:52:41 nit: It may be a matter of personal opinion, but y
+ SkPixelRef* pixelRef = bitmap.pixelRef();
+ SkISize yuvSizes[3];
+ bool sizesComputed = (NULL != pixelRef) && pixelRef->getYUV8Planes(yuvSizes, NULL, NULL);
+ REPORTER_ASSERT(reporter, sizesComputed);
+
+ if (sizesComputed) {
+ // Allocate the memory for YUV
+ size_t totalSize(0);
+ size_t sizes[3], rowBytes[3];
+ const int32_t expected_sizes[] = {128, 64, 64};
+ for (int i = 0; i < 3; ++i) {
+ rowBytes[i] = yuvSizes[i].fWidth;
+ totalSize += sizes[i] = rowBytes[i] * yuvSizes[i].fHeight;
+ REPORTER_ASSERT(reporter, rowBytes[i] == (size_t)expected_sizes[i]);
+ REPORTER_ASSERT(reporter, yuvSizes[i].fWidth == expected_sizes[i]);
+ REPORTER_ASSERT(reporter, yuvSizes[i].fHeight == expected_sizes[i]);
+ }
+ SkAutoMalloc storage(totalSize);
+ void* planes[3];
+ planes[0] = storage.get();
+ planes[1] = (uint8_t*)planes[0] + sizes[0];
+ planes[2] = (uint8_t*)planes[1] + sizes[1];
+
+ // Get the YUV planes
+ REPORTER_ASSERT(reporter, pixelRef->getYUV8Planes(yuvSizes, planes, rowBytes));
+ }
+ }
+}
« tests/ImageGeneratorTest.cpp ('K') | « tests/ImageGeneratorTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698