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

Side by Side Diff: tests/YUVCacheTest.cpp

Issue 1716523002: Update Skia's YUV API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCachedData.h" 8 #include "SkCachedData.h"
9 #include "SkYUVPlanesCache.h" 9 #include "SkYUVPlanesCache.h"
10 #include "SkResourceCache.h" 10 #include "SkResourceCache.h"
(...skipping 14 matching lines...) Expand all
25 REPORTER_ASSERT(reporter, data->testing_only_getRefCnt() == refcnt); 25 REPORTER_ASSERT(reporter, data->testing_only_getRefCnt() == refcnt);
26 REPORTER_ASSERT(reporter, data->testing_only_isInCache() == (kInCache == cac heState)); 26 REPORTER_ASSERT(reporter, data->testing_only_isInCache() == (kInCache == cac heState));
27 bool isLocked = (data->data() != nullptr); 27 bool isLocked = (data->data() != nullptr);
28 REPORTER_ASSERT(reporter, isLocked == (lockedState == kLocked)); 28 REPORTER_ASSERT(reporter, isLocked == (lockedState == kLocked));
29 } 29 }
30 30
31 DEF_TEST(YUVPlanesCache, reporter) { 31 DEF_TEST(YUVPlanesCache, reporter) {
32 SkResourceCache cache(1024); 32 SkResourceCache cache(1024);
33 33
34 SkYUVPlanesCache::Info yuvInfo; 34 SkYUVPlanesCache::Info yuvInfo;
35 for (int i = 0; i < 3; ++i) { 35 yuvInfo.fSizeInfo.fYSize.fWidth = 20 * 0;
36 yuvInfo.fSize[i].fWidth = 20 * i; 36 yuvInfo.fSizeInfo.fYSize.fHeight = 10 * 0;
37 yuvInfo.fSize[i].fHeight = 10 * i; 37 yuvInfo.fSizeInfo.fYWidthBytes = 80 * 0;
38 yuvInfo.fSizeInMemory[i] = 800 * i; 38 yuvInfo.fSizeInfo.fUSize.fWidth = 20 * 1;
39 yuvInfo.fRowBytes[i] = 80 * i; 39 yuvInfo.fSizeInfo.fUSize.fHeight = 10 * 1;
40 } 40 yuvInfo.fSizeInfo.fUWidthBytes = 80 * 1;
41 yuvInfo.fSizeInfo.fVSize.fWidth = 20 * 2;
42 yuvInfo.fSizeInfo.fVSize.fHeight = 10 * 2;
43 yuvInfo.fSizeInfo.fVWidthBytes = 80 * 2;
41 yuvInfo.fColorSpace = kRec601_SkYUVColorSpace; 44 yuvInfo.fColorSpace = kRec601_SkYUVColorSpace;
42 45
43 const uint32_t genID = 12345678; 46 const uint32_t genID = 12345678;
44 47
45 SkCachedData* data = SkYUVPlanesCache::FindAndRef(genID, &yuvInfo, &cache); 48 SkCachedData* data = SkYUVPlanesCache::FindAndRef(genID, &yuvInfo, &cache);
46 REPORTER_ASSERT(reporter, nullptr == data); 49 REPORTER_ASSERT(reporter, nullptr == data);
47 50
48 size_t size = 256; 51 size_t size = 256;
49 data = cache.newCachedData(size); 52 data = cache.newCachedData(size);
50 memset(data->writable_data(), 0xff, size); 53 memset(data->writable_data(), 0xff, size);
51 54
52 SkYUVPlanesCache::Add(genID, data, &yuvInfo, &cache); 55 SkYUVPlanesCache::Add(genID, data, &yuvInfo, &cache);
53 check_data(reporter, data, 2, kInCache, kLocked); 56 check_data(reporter, data, 2, kInCache, kLocked);
54 57
55 data->unref(); 58 data->unref();
56 check_data(reporter, data, 1, kInCache, kUnlocked); 59 check_data(reporter, data, 1, kInCache, kUnlocked);
57 60
58 SkYUVPlanesCache::Info yuvInfoRead; 61 SkYUVPlanesCache::Info yuvInfoRead;
59 data = SkYUVPlanesCache::FindAndRef(genID, &yuvInfoRead, &cache); 62 data = SkYUVPlanesCache::FindAndRef(genID, &yuvInfoRead, &cache);
60 63
61 REPORTER_ASSERT(reporter, data); 64 REPORTER_ASSERT(reporter, data);
62 REPORTER_ASSERT(reporter, data->size() == size); 65 REPORTER_ASSERT(reporter, data->size() == size);
63 for (int i = 0; i < 3; ++i) { 66 REPORTER_ASSERT(reporter, yuvInfo.fSizeInfo.fYSize.fWidth ==
64 REPORTER_ASSERT(reporter, yuvInfo.fSize[i].fWidth == yuvInfoRead.fSize[i ].fWidth); 67 yuvInfoRead.fSizeInfo.fYSize.fWidth);
65 REPORTER_ASSERT(reporter, yuvInfo.fSize[i].fHeight == yuvInfoRead.fSize[ i].fHeight); 68 REPORTER_ASSERT(reporter, yuvInfo.fSizeInfo.fYSize.fHeight ==
66 REPORTER_ASSERT(reporter, yuvInfo.fSizeInMemory[i] == yuvInfoRead.fSizeI nMemory[i]); 69 yuvInfoRead.fSizeInfo.fYSize.fHeight);
67 REPORTER_ASSERT(reporter, yuvInfo.fRowBytes[i] == yuvInfoRead.fRowBytes[ i]); 70 REPORTER_ASSERT(reporter, yuvInfo.fSizeInfo.fYWidthBytes == yuvInfoRead.fSiz eInfo.fYWidthBytes);
68 } 71 REPORTER_ASSERT(reporter, yuvInfo.fSizeInfo.fUSize.fWidth ==
72 yuvInfoRead.fSizeInfo.fUSize.fWidth);
73 REPORTER_ASSERT(reporter, yuvInfo.fSizeInfo.fUSize.fHeight ==
74 yuvInfoRead.fSizeInfo.fUSize.fHeight);
75 REPORTER_ASSERT(reporter, yuvInfo.fSizeInfo.fUWidthBytes == yuvInfoRead.fSiz eInfo.fUWidthBytes);
76 REPORTER_ASSERT(reporter, yuvInfo.fSizeInfo.fVSize.fWidth ==
77 yuvInfoRead.fSizeInfo.fVSize.fWidth);
78 REPORTER_ASSERT(reporter, yuvInfo.fSizeInfo.fVSize.fHeight ==
79 yuvInfoRead.fSizeInfo.fVSize.fHeight);
80 REPORTER_ASSERT(reporter, yuvInfo.fSizeInfo.fVWidthBytes == yuvInfoRead.fSiz eInfo.fVWidthBytes);
69 REPORTER_ASSERT(reporter, yuvInfo.fColorSpace == yuvInfoRead.fColorSpace); 81 REPORTER_ASSERT(reporter, yuvInfo.fColorSpace == yuvInfoRead.fColorSpace);
70 82
71 check_data(reporter, data, 2, kInCache, kLocked); 83 check_data(reporter, data, 2, kInCache, kLocked);
72 84
73 cache.purgeAll(); 85 cache.purgeAll();
74 check_data(reporter, data, 1, kNotInCache, kLocked); 86 check_data(reporter, data, 1, kNotInCache, kLocked);
75 data->unref(); 87 data->unref();
76 } 88 }
OLDNEW
« src/gpu/GrYUVProvider.cpp ('K') | « tests/ImageGeneratorTest.cpp ('k') | tests/YUVTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698