diff options
author | msarett <msarett@google.com> | 2016-03-10 05:44:43 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-10 05:44:43 -0800 |
commit | 4984c3c95f18eda44492a2126c9958e447f2cca8 (patch) | |
tree | add5bdca2495968a8acc1affd10e5cfe225ff4d0 /tests | |
parent | d6215cf4a5f416cf0b64a4fbba95c519f03fe467 (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
Committed: https://skia.googlesource.com/skia/+/095d31c8a0eeb5d491febf064bc3c8a44e22b94f
Review URL: https://codereview.chromium.org/1716523002
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ImageGeneratorTest.cpp | 32 | ||||
-rw-r--r-- | tests/YUVCacheTest.cpp | 19 | ||||
-rw-r--r-- | tests/YUVTest.cpp | 34 |
3 files changed, 47 insertions, 38 deletions
diff --git a/tests/ImageGeneratorTest.cpp b/tests/ImageGeneratorTest.cpp index 7288ecf0a9..3d750b2c73 100644 --- a/tests/ImageGeneratorTest.cpp +++ b/tests/ImageGeneratorTest.cpp @@ -46,27 +46,25 @@ public: DEF_TEST(ImageGenerator, reporter) { MyImageGenerator ig; - SkISize sizes[3]; - sizes[0] = SkISize::Make(200, 200); - sizes[1] = SkISize::Make(100, 100); - sizes[2] = SkISize::Make( 50, 50); - void* planes[3] = { nullptr }; - size_t rowBytes[3] = { 0 }; + SkYUVSizeInfo sizeInfo; + sizeInfo.fSizes[SkYUVSizeInfo::kY] = SkISize::Make(200, 200); + sizeInfo.fSizes[SkYUVSizeInfo::kU] = SkISize::Make(100, 100); + sizeInfo.fSizes[SkYUVSizeInfo::kV] = SkISize::Make( 50, 50); + sizeInfo.fWidthBytes[SkYUVSizeInfo::kY] = 0; + sizeInfo.fWidthBytes[SkYUVSizeInfo::kU] = 0; + sizeInfo.fWidthBytes[SkYUVSizeInfo::kV] = 0; + void* planes[3] = { nullptr }; SkYUVColorSpace colorSpace; // Check that the YUV decoding API does not cause any crashes - ig.getYUV8Planes(sizes, nullptr, nullptr, &colorSpace); - ig.getYUV8Planes(sizes, nullptr, nullptr, nullptr); - ig.getYUV8Planes(sizes, planes, nullptr, nullptr); - ig.getYUV8Planes(sizes, nullptr, rowBytes, nullptr); - ig.getYUV8Planes(sizes, planes, rowBytes, nullptr); - ig.getYUV8Planes(sizes, planes, rowBytes, &colorSpace); - + ig.queryYUV8(&sizeInfo, nullptr); + ig.queryYUV8(&sizeInfo, &colorSpace); + sizeInfo.fWidthBytes[SkYUVSizeInfo::kY] = 250; + sizeInfo.fWidthBytes[SkYUVSizeInfo::kU] = 250; + sizeInfo.fWidthBytes[SkYUVSizeInfo::kV] = 250; int dummy; - planes[0] = planes[1] = planes[2] = &dummy; - rowBytes[0] = rowBytes[1] = rowBytes[2] = 250; - - ig.getYUV8Planes(sizes, planes, rowBytes, &colorSpace); + planes[SkYUVSizeInfo::kY] = planes[SkYUVSizeInfo::kU] = planes[SkYUVSizeInfo::kV] = &dummy; + ig.getYUV8Planes(sizeInfo, planes); // Suppressed due to https://code.google.com/p/skia/issues/detail?id=4339 if (false) { diff --git a/tests/YUVCacheTest.cpp b/tests/YUVCacheTest.cpp index f3a09f116b..b34cf060a5 100644 --- a/tests/YUVCacheTest.cpp +++ b/tests/YUVCacheTest.cpp @@ -32,11 +32,10 @@ DEF_TEST(YUVPlanesCache, reporter) { SkResourceCache cache(1024); SkYUVPlanesCache::Info yuvInfo; - for (int i = 0; i < 3; ++i) { - yuvInfo.fSize[i].fWidth = 20 * i; - yuvInfo.fSize[i].fHeight = 10 * i; - yuvInfo.fSizeInMemory[i] = 800 * i; - yuvInfo.fRowBytes[i] = 80 * i; + for (int i = 0; i < 3; i++) { + yuvInfo.fSizeInfo.fSizes[i].fWidth = 20 * i; + yuvInfo.fSizeInfo.fSizes[i].fHeight = 10 * i; + yuvInfo.fSizeInfo.fWidthBytes[i] = 80 * i; } yuvInfo.fColorSpace = kRec601_SkYUVColorSpace; @@ -61,10 +60,12 @@ DEF_TEST(YUVPlanesCache, reporter) { REPORTER_ASSERT(reporter, data); REPORTER_ASSERT(reporter, data->size() == size); for (int i = 0; i < 3; ++i) { - REPORTER_ASSERT(reporter, yuvInfo.fSize[i].fWidth == yuvInfoRead.fSize[i].fWidth); - REPORTER_ASSERT(reporter, yuvInfo.fSize[i].fHeight == yuvInfoRead.fSize[i].fHeight); - REPORTER_ASSERT(reporter, yuvInfo.fSizeInMemory[i] == yuvInfoRead.fSizeInMemory[i]); - REPORTER_ASSERT(reporter, yuvInfo.fRowBytes[i] == yuvInfoRead.fRowBytes[i]); + REPORTER_ASSERT(reporter, yuvInfo.fSizeInfo.fSizes[i].fWidth == + yuvInfoRead.fSizeInfo.fSizes[i].fWidth); + REPORTER_ASSERT(reporter, yuvInfo.fSizeInfo.fSizes[i].fHeight == + yuvInfoRead.fSizeInfo.fSizes[i].fHeight); + REPORTER_ASSERT(reporter, yuvInfo.fSizeInfo.fWidthBytes[i] == + yuvInfoRead.fSizeInfo.fWidthBytes[i]); } REPORTER_ASSERT(reporter, yuvInfo.fColorSpace == yuvInfoRead.fColorSpace); 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 == |