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

Side by Side Diff: tests/YUVCacheTest.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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/XfermodeTest.cpp ('k') | tests/skia_test.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"
11 #include "Test.h" 11 #include "Test.h"
12 12
13 enum LockedState { 13 enum LockedState {
14 kUnlocked, 14 kUnlocked,
15 kLocked, 15 kLocked,
16 }; 16 };
17 17
18 enum CachedState { 18 enum CachedState {
19 kNotInCache, 19 kNotInCache,
20 kInCache, 20 kInCache,
21 }; 21 };
22 22
23 static void check_data(skiatest::Reporter* reporter, SkCachedData* data, 23 static void check_data(skiatest::Reporter* reporter, SkCachedData* data,
24 int refcnt, CachedState cacheState, LockedState lockedSta te) { 24 int refcnt, CachedState cacheState, LockedState lockedSta te) {
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() != NULL); 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.fSize[i].fWidth = 20 * i;
37 yuvInfo.fSize[i].fHeight = 10 * i; 37 yuvInfo.fSize[i].fHeight = 10 * i;
38 yuvInfo.fSizeInMemory[i] = 800 * i; 38 yuvInfo.fSizeInMemory[i] = 800 * i;
39 yuvInfo.fRowBytes[i] = 80 * i; 39 yuvInfo.fRowBytes[i] = 80 * i;
40 } 40 }
41 yuvInfo.fColorSpace = kRec601_SkYUVColorSpace; 41 yuvInfo.fColorSpace = kRec601_SkYUVColorSpace;
42 42
43 const uint32_t genID = 12345678; 43 const uint32_t genID = 12345678;
44 44
45 SkCachedData* data = SkYUVPlanesCache::FindAndRef(genID, &yuvInfo, &cache); 45 SkCachedData* data = SkYUVPlanesCache::FindAndRef(genID, &yuvInfo, &cache);
46 REPORTER_ASSERT(reporter, NULL == data); 46 REPORTER_ASSERT(reporter, nullptr == data);
47 47
48 size_t size = 256; 48 size_t size = 256;
49 data = cache.newCachedData(size); 49 data = cache.newCachedData(size);
50 memset(data->writable_data(), 0xff, size); 50 memset(data->writable_data(), 0xff, size);
51 51
52 SkYUVPlanesCache::Add(genID, data, &yuvInfo, &cache); 52 SkYUVPlanesCache::Add(genID, data, &yuvInfo, &cache);
53 check_data(reporter, data, 2, kInCache, kLocked); 53 check_data(reporter, data, 2, kInCache, kLocked);
54 54
55 data->unref(); 55 data->unref();
56 check_data(reporter, data, 1, kInCache, kUnlocked); 56 check_data(reporter, data, 1, kInCache, kUnlocked);
(...skipping 10 matching lines...) Expand all
67 REPORTER_ASSERT(reporter, yuvInfo.fRowBytes[i] == yuvInfoRead.fRowBytes[ i]); 67 REPORTER_ASSERT(reporter, yuvInfo.fRowBytes[i] == yuvInfoRead.fRowBytes[ i]);
68 } 68 }
69 REPORTER_ASSERT(reporter, yuvInfo.fColorSpace == yuvInfoRead.fColorSpace); 69 REPORTER_ASSERT(reporter, yuvInfo.fColorSpace == yuvInfoRead.fColorSpace);
70 70
71 check_data(reporter, data, 2, kInCache, kLocked); 71 check_data(reporter, data, 2, kInCache, kLocked);
72 72
73 cache.purgeAll(); 73 cache.purgeAll();
74 check_data(reporter, data, 1, kNotInCache, kLocked); 74 check_data(reporter, data, 1, kNotInCache, kLocked);
75 data->unref(); 75 data->unref();
76 } 76 }
OLDNEW
« no previous file with comments | « tests/XfermodeTest.cpp ('k') | tests/skia_test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698