aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/YUVTest.cpp
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-03-07 08:39:12 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-07 08:39:12 -0800
commit095d31c8a0eeb5d491febf064bc3c8a44e22b94f (patch)
tree415ad73df7c480fcb9329cec90ac2883c4c9b72f /tests/YUVTest.cpp
parenta9101eef5ffc5f329a5edc75fd67441d868b0e9b (diff)
Update Skia's YUV API
We should match the recently designed API in SkCodec. https://codereview.chromium.org/1549473003/ This requires changes in Chromium as well. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1716523002 Review URL: https://codereview.chromium.org/1716523002
Diffstat (limited to 'tests/YUVTest.cpp')
-rw-r--r--tests/YUVTest.cpp34
1 files changed, 22 insertions, 12 deletions
diff --git a/tests/YUVTest.cpp b/tests/YUVTest.cpp
index b8c4e3598e..e1d8961205 100644
--- a/tests/YUVTest.cpp
+++ b/tests/YUVTest.cpp
@@ -9,6 +9,7 @@
#include "Resources.h"
#include "SkStream.h"
#include "SkTemplates.h"
+#include "SkYUVSizeInfo.h"
#include "Test.h"
static SkStreamAsset* resource(const char path[]) {
@@ -31,7 +32,7 @@ static void codec_yuv(skiatest::Reporter* reporter,
}
// Test queryYUV8()
- SkCodec::YUVSizeInfo info;
+ SkYUVSizeInfo info;
bool success = codec->queryYUV8(nullptr, nullptr);
REPORTER_ASSERT(reporter, !success);
success = codec->queryYUV8(&info, nullptr);
@@ -41,27 +42,36 @@ static void codec_yuv(skiatest::Reporter* reporter,
}
REPORTER_ASSERT(reporter,
0 == memcmp((const void*) &info, (const void*) expectedSizes, 3 * sizeof(SkISize)));
- REPORTER_ASSERT(reporter, info.fYWidthBytes == (uint32_t) SkAlign8(info.fYSize.width()));
- REPORTER_ASSERT(reporter, info.fUWidthBytes == (uint32_t) SkAlign8(info.fUSize.width()));
- REPORTER_ASSERT(reporter, info.fVWidthBytes == (uint32_t) SkAlign8(info.fVSize.width()));
+ REPORTER_ASSERT(reporter, info.fWidthBytes[SkYUVSizeInfo::kY] ==
+ (uint32_t) SkAlign8(info.fSizes[SkYUVSizeInfo::kY].width()));
+ REPORTER_ASSERT(reporter, info.fWidthBytes[SkYUVSizeInfo::kU] ==
+ (uint32_t) SkAlign8(info.fSizes[SkYUVSizeInfo::kU].width()));
+ REPORTER_ASSERT(reporter, info.fWidthBytes[SkYUVSizeInfo::kV] ==
+ (uint32_t) SkAlign8(info.fSizes[SkYUVSizeInfo::kV].width()));
SkYUVColorSpace colorSpace;
success = codec->queryYUV8(&info, &colorSpace);
REPORTER_ASSERT(reporter,
0 == memcmp((const void*) &info, (const void*) expectedSizes, 3 * sizeof(SkISize)));
- REPORTER_ASSERT(reporter, info.fYWidthBytes == (uint32_t) SkAlign8(info.fYSize.width()));
- REPORTER_ASSERT(reporter, info.fUWidthBytes == (uint32_t) SkAlign8(info.fUSize.width()));
- REPORTER_ASSERT(reporter, info.fVWidthBytes == (uint32_t) SkAlign8(info.fVSize.width()));
+ REPORTER_ASSERT(reporter, info.fWidthBytes[SkYUVSizeInfo::kY] ==
+ (uint32_t) SkAlign8(info.fSizes[SkYUVSizeInfo::kY].width()));
+ REPORTER_ASSERT(reporter, info.fWidthBytes[SkYUVSizeInfo::kU] ==
+ (uint32_t) SkAlign8(info.fSizes[SkYUVSizeInfo::kU].width()));
+ REPORTER_ASSERT(reporter, info.fWidthBytes[SkYUVSizeInfo::kV] ==
+ (uint32_t) SkAlign8(info.fSizes[SkYUVSizeInfo::kV].width()));
REPORTER_ASSERT(reporter, kJPEG_SkYUVColorSpace == colorSpace);
// Allocate the memory for the YUV decode
- size_t totalBytes = info.fYWidthBytes * info.fYSize.height() +
- info.fUWidthBytes * info.fUSize.height() +
- info.fVWidthBytes * info.fVSize.height();
+ size_t totalBytes =
+ info.fWidthBytes[SkYUVSizeInfo::kY] * info.fSizes[SkYUVSizeInfo::kY].height() +
+ info.fWidthBytes[SkYUVSizeInfo::kU] * info.fSizes[SkYUVSizeInfo::kU].height() +
+ info.fWidthBytes[SkYUVSizeInfo::kV] * info.fSizes[SkYUVSizeInfo::kV].height();
SkAutoMalloc storage(totalBytes);
void* planes[3];
planes[0] = storage.get();
- planes[1] = SkTAddOffset<void>(planes[0], info.fYWidthBytes * info.fYSize.height());
- planes[2] = SkTAddOffset<void>(planes[1], info.fUWidthBytes * info.fUSize.height());
+ planes[1] = SkTAddOffset<void>(planes[0],
+ info.fWidthBytes[SkYUVSizeInfo::kY] * info.fSizes[SkYUVSizeInfo::kY].height());
+ planes[2] = SkTAddOffset<void>(planes[1],
+ info.fWidthBytes[SkYUVSizeInfo::kU] * info.fSizes[SkYUVSizeInfo::kU].height());
// Test getYUV8Planes()
REPORTER_ASSERT(reporter, SkCodec::kInvalidInput ==