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

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: Rebase 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 unified diff | Download patch
« no previous file with comments | « tests/ImageGeneratorTest.cpp ('k') | tests/YUVTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 for (int i = 0; i < 3; i++) {
36 yuvInfo.fSize[i].fWidth = 20 * i; 36 yuvInfo.fSizeInfo.fSizes[i].fWidth = 20 * i;
37 yuvInfo.fSize[i].fHeight = 10 * i; 37 yuvInfo.fSizeInfo.fSizes[i].fHeight = 10 * i;
38 yuvInfo.fSizeInMemory[i] = 800 * i; 38 yuvInfo.fSizeInfo.fWidthBytes[i] = 80 * i;
39 yuvInfo.fRowBytes[i] = 80 * i;
40 } 39 }
41 yuvInfo.fColorSpace = kRec601_SkYUVColorSpace; 40 yuvInfo.fColorSpace = kRec601_SkYUVColorSpace;
42 41
43 const uint32_t genID = 12345678; 42 const uint32_t genID = 12345678;
44 43
45 SkCachedData* data = SkYUVPlanesCache::FindAndRef(genID, &yuvInfo, &cache); 44 SkCachedData* data = SkYUVPlanesCache::FindAndRef(genID, &yuvInfo, &cache);
46 REPORTER_ASSERT(reporter, nullptr == data); 45 REPORTER_ASSERT(reporter, nullptr == data);
47 46
48 size_t size = 256; 47 size_t size = 256;
49 data = cache.newCachedData(size); 48 data = cache.newCachedData(size);
50 memset(data->writable_data(), 0xff, size); 49 memset(data->writable_data(), 0xff, size);
51 50
52 SkYUVPlanesCache::Add(genID, data, &yuvInfo, &cache); 51 SkYUVPlanesCache::Add(genID, data, &yuvInfo, &cache);
53 check_data(reporter, data, 2, kInCache, kLocked); 52 check_data(reporter, data, 2, kInCache, kLocked);
54 53
55 data->unref(); 54 data->unref();
56 check_data(reporter, data, 1, kInCache, kUnlocked); 55 check_data(reporter, data, 1, kInCache, kUnlocked);
57 56
58 SkYUVPlanesCache::Info yuvInfoRead; 57 SkYUVPlanesCache::Info yuvInfoRead;
59 data = SkYUVPlanesCache::FindAndRef(genID, &yuvInfoRead, &cache); 58 data = SkYUVPlanesCache::FindAndRef(genID, &yuvInfoRead, &cache);
60 59
61 REPORTER_ASSERT(reporter, data); 60 REPORTER_ASSERT(reporter, data);
62 REPORTER_ASSERT(reporter, data->size() == size); 61 REPORTER_ASSERT(reporter, data->size() == size);
63 for (int i = 0; i < 3; ++i) { 62 for (int i = 0; i < 3; ++i) {
64 REPORTER_ASSERT(reporter, yuvInfo.fSize[i].fWidth == yuvInfoRead.fSize[i ].fWidth); 63 REPORTER_ASSERT(reporter, yuvInfo.fSizeInfo.fSizes[i].fWidth ==
65 REPORTER_ASSERT(reporter, yuvInfo.fSize[i].fHeight == yuvInfoRead.fSize[ i].fHeight); 64 yuvInfoRead.fSizeInfo.fSizes[i].fWidth);
66 REPORTER_ASSERT(reporter, yuvInfo.fSizeInMemory[i] == yuvInfoRead.fSizeI nMemory[i]); 65 REPORTER_ASSERT(reporter, yuvInfo.fSizeInfo.fSizes[i].fHeight ==
67 REPORTER_ASSERT(reporter, yuvInfo.fRowBytes[i] == yuvInfoRead.fRowBytes[ i]); 66 yuvInfoRead.fSizeInfo.fSizes[i].fHeight);
67 REPORTER_ASSERT(reporter, yuvInfo.fSizeInfo.fWidthBytes[i] ==
68 yuvInfoRead.fSizeInfo.fWidthBytes[i]);
68 } 69 }
69 REPORTER_ASSERT(reporter, yuvInfo.fColorSpace == yuvInfoRead.fColorSpace); 70 REPORTER_ASSERT(reporter, yuvInfo.fColorSpace == yuvInfoRead.fColorSpace);
70 71
71 check_data(reporter, data, 2, kInCache, kLocked); 72 check_data(reporter, data, 2, kInCache, kLocked);
72 73
73 cache.purgeAll(); 74 cache.purgeAll();
74 check_data(reporter, data, 1, kNotInCache, kLocked); 75 check_data(reporter, data, 1, kNotInCache, kLocked);
75 data->unref(); 76 data->unref();
76 } 77 }
OLDNEW
« no previous file with comments | « tests/ImageGeneratorTest.cpp ('k') | tests/YUVTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698