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

Side by Side Diff: tests/MallocPixelRefTest.cpp

Issue 137993012: use some helper Make functions to initialize SkImageInfo (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkScaledImageCache.cpp ('k') | tests/PixelRefTest.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 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"
11 #include "TestClassDef.h" 11 #include "TestClassDef.h"
12 12
13 static void delete_uint8_proc(void* ptr, void*) { 13 static void delete_uint8_proc(void* ptr, void*) {
14 delete[] static_cast<uint8_t*>(ptr); 14 delete[] static_cast<uint8_t*>(ptr);
15 } 15 }
16 16
17 static void set_to_one_proc(void*, void* context) { 17 static void set_to_one_proc(void*, void* context) {
18 *(static_cast<int*>(context)) = 1; 18 *(static_cast<int*>(context)) = 1;
19 } 19 }
20 20
21 /** 21 /**
22 * This test contains basic sanity checks concerning SkMallocPixelRef. 22 * This test contains basic sanity checks concerning SkMallocPixelRef.
23 */ 23 */
24 DEF_TEST(MallocPixelRef, reporter) { 24 DEF_TEST(MallocPixelRef, reporter) {
25 REPORTER_ASSERT(reporter, true); 25 REPORTER_ASSERT(reporter, true);
26 SkImageInfo info = {10, 13, kPMColor_SkColorType, kPremul_SkAlphaType}; 26 SkImageInfo info = SkImageInfo::MakeN32Premul(10, 13);
27 { 27 {
28 SkAutoTUnref<SkMallocPixelRef> pr( 28 SkAutoTUnref<SkMallocPixelRef> pr(
29 SkMallocPixelRef::NewAllocate(info, info.minRowBytes() - 1, NULL)); 29 SkMallocPixelRef::NewAllocate(info, info.minRowBytes() - 1, NULL));
30 // rowbytes too small. 30 // rowbytes too small.
31 REPORTER_ASSERT(reporter, NULL == pr.get()); 31 REPORTER_ASSERT(reporter, NULL == pr.get());
32 } 32 }
33 { 33 {
34 size_t rowBytes = info.minRowBytes() - 1; 34 size_t rowBytes = info.minRowBytes() - 1;
35 size_t size = info.getSafeSize(rowBytes); 35 size_t size = info.getSafeSize(rowBytes);
36 void* addr = sk_malloc_throw(size); 36 void* addr = sk_malloc_throw(size);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 REPORTER_ASSERT(reporter, dataPtr->unique()); 106 REPORTER_ASSERT(reporter, dataPtr->unique());
107 SkAutoTUnref<SkMallocPixelRef> pr( 107 SkAutoTUnref<SkMallocPixelRef> pr(
108 SkMallocPixelRef::NewWithData(info, rowBytes, NULL, data.get(), 4)); 108 SkMallocPixelRef::NewWithData(info, rowBytes, NULL, data.get(), 4));
109 REPORTER_ASSERT(reporter, !(dataPtr->unique())); 109 REPORTER_ASSERT(reporter, !(dataPtr->unique()));
110 data.reset(NULL); 110 data.reset(NULL);
111 REPORTER_ASSERT(reporter, dataPtr->unique()); 111 REPORTER_ASSERT(reporter, dataPtr->unique());
112 REPORTER_ASSERT(reporter, 112 REPORTER_ASSERT(reporter,
113 static_cast<const void*>(dataPtr->bytes() + 4) == pr->pixels()); 113 static_cast<const void*>(dataPtr->bytes() + 4) == pr->pixels());
114 } 114 }
115 } 115 }
OLDNEW
« no previous file with comments | « src/core/SkScaledImageCache.cpp ('k') | tests/PixelRefTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698