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

Side by Side Diff: tests/MallocPixelRefTest.cpp

Issue 2206633004: Move off SK_SUPPORT_LEGACY_DATA_FACTORIES. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Gotta catch 'em all. Created 4 years, 4 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 2013 Google Inc. 2 * Copyright 2013 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 "SkData.h" 8 #include "SkData.h"
9 #include "SkMallocPixelRef.h" 9 #include "SkMallocPixelRef.h"
10 #include "Test.h" 10 #include "Test.h"
(...skipping 14 matching lines...) Expand all
25 SkImageInfo info = SkImageInfo::MakeN32Premul(10, 13); 25 SkImageInfo info = SkImageInfo::MakeN32Premul(10, 13);
26 { 26 {
27 SkAutoTUnref<SkMallocPixelRef> pr( 27 SkAutoTUnref<SkMallocPixelRef> pr(
28 SkMallocPixelRef::NewAllocate(info, info.minRowBytes() - 1, nullptr) ); 28 SkMallocPixelRef::NewAllocate(info, info.minRowBytes() - 1, nullptr) );
29 // rowbytes too small. 29 // rowbytes too small.
30 REPORTER_ASSERT(reporter, nullptr == pr.get()); 30 REPORTER_ASSERT(reporter, nullptr == pr.get());
31 } 31 }
32 { 32 {
33 size_t rowBytes = info.minRowBytes() - 1; 33 size_t rowBytes = info.minRowBytes() - 1;
34 size_t size = info.getSafeSize(rowBytes); 34 size_t size = info.getSafeSize(rowBytes);
35 SkAutoDataUnref data(SkData::NewUninitialized(size)); 35 sk_sp<SkData> data(SkData::MakeUninitialized(size));
36 SkAutoTUnref<SkMallocPixelRef> pr( 36 SkAutoTUnref<SkMallocPixelRef> pr(
37 SkMallocPixelRef::NewWithData(info, rowBytes, nullptr, data)); 37 SkMallocPixelRef::NewWithData(info, rowBytes, nullptr, data.get()));
38 // rowbytes too small. 38 // rowbytes too small.
39 REPORTER_ASSERT(reporter, nullptr == pr.get()); 39 REPORTER_ASSERT(reporter, nullptr == pr.get());
40 } 40 }
41 { 41 {
42 size_t rowBytes = info.minRowBytes() + 2; 42 size_t rowBytes = info.minRowBytes() + 2;
43 size_t size = info.getSafeSize(rowBytes) - 1; 43 size_t size = info.getSafeSize(rowBytes) - 1;
44 SkAutoDataUnref data(SkData::NewUninitialized(size)); 44 sk_sp<SkData> data(SkData::MakeUninitialized(size));
45 SkAutoTUnref<SkMallocPixelRef> pr( 45 SkAutoTUnref<SkMallocPixelRef> pr(
46 SkMallocPixelRef::NewWithData(info, rowBytes, nullptr, data)); 46 SkMallocPixelRef::NewWithData(info, rowBytes, nullptr, data.get()));
47 // data too small. 47 // data too small.
48 REPORTER_ASSERT(reporter, nullptr == pr.get()); 48 REPORTER_ASSERT(reporter, nullptr == pr.get());
49 } 49 }
50 size_t rowBytes = info.minRowBytes() + 7; 50 size_t rowBytes = info.minRowBytes() + 7;
51 size_t size = info.getSafeSize(rowBytes) + 9; 51 size_t size = info.getSafeSize(rowBytes) + 9;
52 { 52 {
53 SkAutoMalloc memory(size); 53 SkAutoMalloc memory(size);
54 SkAutoTUnref<SkMallocPixelRef> pr( 54 SkAutoTUnref<SkMallocPixelRef> pr(
55 SkMallocPixelRef::NewDirect(info, memory.get(), rowBytes, nullptr)); 55 SkMallocPixelRef::NewDirect(info, memory.get(), rowBytes, nullptr));
56 REPORTER_ASSERT(reporter, pr.get() != nullptr); 56 REPORTER_ASSERT(reporter, pr.get() != nullptr);
(...skipping 29 matching lines...) Expand all
86 } 86 }
87 { 87 {
88 void* addr = static_cast<void*>(new uint8_t[size]); 88 void* addr = static_cast<void*>(new uint8_t[size]);
89 REPORTER_ASSERT(reporter, addr != nullptr); 89 REPORTER_ASSERT(reporter, addr != nullptr);
90 SkAutoTUnref<SkMallocPixelRef> pr( 90 SkAutoTUnref<SkMallocPixelRef> pr(
91 SkMallocPixelRef::NewWithProc(info, rowBytes, nullptr, addr, 91 SkMallocPixelRef::NewWithProc(info, rowBytes, nullptr, addr,
92 delete_uint8_proc, nullptr)); 92 delete_uint8_proc, nullptr));
93 REPORTER_ASSERT(reporter, addr == pr->pixels()); 93 REPORTER_ASSERT(reporter, addr == pr->pixels());
94 } 94 }
95 { 95 {
96 SkAutoDataUnref data(SkData::NewUninitialized(size)); 96 sk_sp<SkData> data(SkData::MakeUninitialized(size));
97 SkData* dataPtr = data.get(); 97 SkData* dataPtr = data.get();
98 REPORTER_ASSERT(reporter, dataPtr->unique()); 98 REPORTER_ASSERT(reporter, dataPtr->unique());
99 SkAutoTUnref<SkMallocPixelRef> pr( 99 SkAutoTUnref<SkMallocPixelRef> pr(
100 SkMallocPixelRef::NewWithData(info, rowBytes, nullptr, data.get())); 100 SkMallocPixelRef::NewWithData(info, rowBytes, nullptr, data.get()));
101 REPORTER_ASSERT(reporter, !(dataPtr->unique())); 101 REPORTER_ASSERT(reporter, !(dataPtr->unique()));
102 data.reset(nullptr); 102 data.reset(nullptr);
103 REPORTER_ASSERT(reporter, dataPtr->unique()); 103 REPORTER_ASSERT(reporter, dataPtr->unique());
104 REPORTER_ASSERT(reporter, dataPtr->data() == pr->pixels()); 104 REPORTER_ASSERT(reporter, dataPtr->data() == pr->pixels());
105 } 105 }
106 } 106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698