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

Side by Side Diff: src/core/SkMallocPixelRef.cpp

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 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 | « src/core/SkLocalMatrixShader.cpp ('k') | src/core/SkMaskCache.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 2011 Google Inc. 2 * Copyright 2011 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 "SkMallocPixelRef.h" 8 #include "SkMallocPixelRef.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 26 matching lines...) Expand all
37 return true; 37 return true;
38 } 38 }
39 39
40 SkMallocPixelRef* SkMallocPixelRef::NewDirect(const SkImageInfo& info, 40 SkMallocPixelRef* SkMallocPixelRef::NewDirect(const SkImageInfo& info,
41 void* addr, 41 void* addr,
42 size_t rowBytes, 42 size_t rowBytes,
43 SkColorTable* ctable) { 43 SkColorTable* ctable) {
44 if (!is_valid(info, ctable)) { 44 if (!is_valid(info, ctable)) {
45 return NULL; 45 return NULL;
46 } 46 }
47 return SkNEW_ARGS(SkMallocPixelRef, 47 return new SkMallocPixelRef(info, addr, rowBytes, ctable, NULL, NULL);
48 (info, addr, rowBytes, ctable, NULL, NULL));
49 } 48 }
50 49
51 50
52 SkMallocPixelRef* SkMallocPixelRef::NewAllocate(const SkImageInfo& info, 51 SkMallocPixelRef* SkMallocPixelRef::NewAllocate(const SkImageInfo& info,
53 size_t requestedRowBytes, 52 size_t requestedRowBytes,
54 SkColorTable* ctable) { 53 SkColorTable* ctable) {
55 if (!is_valid(info, ctable)) { 54 if (!is_valid(info, ctable)) {
56 return NULL; 55 return NULL;
57 } 56 }
58 57
(...skipping 18 matching lines...) Expand all
77 return NULL; 76 return NULL;
78 } 77 }
79 78
80 size_t size = sk_64_asS32(bigSize); 79 size_t size = sk_64_asS32(bigSize);
81 SkASSERT(size >= info.getSafeSize(rowBytes)); 80 SkASSERT(size >= info.getSafeSize(rowBytes));
82 void* addr = sk_malloc_flags(size, 0); 81 void* addr = sk_malloc_flags(size, 0);
83 if (NULL == addr) { 82 if (NULL == addr) {
84 return NULL; 83 return NULL;
85 } 84 }
86 85
87 return SkNEW_ARGS(SkMallocPixelRef, 86 return new SkMallocPixelRef(info, addr, rowBytes, ctable, sk_free_releasepro c, NULL);
88 (info, addr, rowBytes, ctable,
89 sk_free_releaseproc, NULL));
90 } 87 }
91 88
92 SkMallocPixelRef* SkMallocPixelRef::NewWithProc(const SkImageInfo& info, 89 SkMallocPixelRef* SkMallocPixelRef::NewWithProc(const SkImageInfo& info,
93 size_t rowBytes, 90 size_t rowBytes,
94 SkColorTable* ctable, 91 SkColorTable* ctable,
95 void* addr, 92 void* addr,
96 SkMallocPixelRef::ReleaseProc pr oc, 93 SkMallocPixelRef::ReleaseProc pr oc,
97 void* context) { 94 void* context) {
98 if (!is_valid(info, ctable)) { 95 if (!is_valid(info, ctable)) {
99 return NULL; 96 return NULL;
100 } 97 }
101 return SkNEW_ARGS(SkMallocPixelRef, 98 return new SkMallocPixelRef(info, addr, rowBytes, ctable, proc, context);
102 (info, addr, rowBytes, ctable, proc, context));
103 } 99 }
104 100
105 static void sk_data_releaseproc(void*, void* dataPtr) { 101 static void sk_data_releaseproc(void*, void* dataPtr) {
106 (static_cast<SkData*>(dataPtr))->unref(); 102 (static_cast<SkData*>(dataPtr))->unref();
107 } 103 }
108 104
109 SkMallocPixelRef* SkMallocPixelRef::NewWithData(const SkImageInfo& info, 105 SkMallocPixelRef* SkMallocPixelRef::NewWithData(const SkImageInfo& info,
110 size_t rowBytes, 106 size_t rowBytes,
111 SkColorTable* ctable, 107 SkColorTable* ctable,
112 SkData* data) { 108 SkData* data) {
113 SkASSERT(data != NULL); 109 SkASSERT(data != NULL);
114 if (!is_valid(info, ctable)) { 110 if (!is_valid(info, ctable)) {
115 return NULL; 111 return NULL;
116 } 112 }
117 if ((rowBytes < info.minRowBytes()) 113 if ((rowBytes < info.minRowBytes())
118 || (data->size() < info.getSafeSize(rowBytes))) { 114 || (data->size() < info.getSafeSize(rowBytes))) {
119 return NULL; 115 return NULL;
120 } 116 }
121 data->ref(); 117 data->ref();
122 SkMallocPixelRef* pr 118 SkMallocPixelRef* pr =
123 = SkNEW_ARGS(SkMallocPixelRef, 119 new SkMallocPixelRef(info, const_cast<void*>(data->data()), rowBytes , ctable,
124 (info, const_cast<void*>(data->data()), rowBytes, ctable, 120 sk_data_releaseproc, static_cast<void*>(data));
125 sk_data_releaseproc, static_cast<void*>(data)));
126 SkASSERT(pr != NULL); 121 SkASSERT(pr != NULL);
127 // We rely on the immutability of the pixels to make the 122 // We rely on the immutability of the pixels to make the
128 // const_cast okay. 123 // const_cast okay.
129 pr->setImmutable(); 124 pr->setImmutable();
130 return pr; 125 return pr;
131 } 126 }
132 127
133 /////////////////////////////////////////////////////////////////////////////// 128 ///////////////////////////////////////////////////////////////////////////////
134 129
135 SkMallocPixelRef::SkMallocPixelRef(const SkImageInfo& info, void* storage, 130 SkMallocPixelRef::SkMallocPixelRef(const SkImageInfo& info, void* storage,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 size_t SkMallocPixelRef::getAllocatedSizeInBytes() const { 194 size_t SkMallocPixelRef::getAllocatedSizeInBytes() const {
200 return this->info().getSafeSize(fRB); 195 return this->info().getSafeSize(fRB);
201 } 196 }
202 197
203 /////////////////////////////////////////////////////////////////////////////// 198 ///////////////////////////////////////////////////////////////////////////////
204 199
205 SkPixelRef* SkMallocPixelRef::PRFactory::create(const SkImageInfo& info, size_t rowBytes, 200 SkPixelRef* SkMallocPixelRef::PRFactory::create(const SkImageInfo& info, size_t rowBytes,
206 SkColorTable* ctable) { 201 SkColorTable* ctable) {
207 return SkMallocPixelRef::NewAllocate(info, rowBytes, ctable); 202 return SkMallocPixelRef::NewAllocate(info, rowBytes, ctable);
208 } 203 }
OLDNEW
« no previous file with comments | « src/core/SkLocalMatrixShader.cpp ('k') | src/core/SkMaskCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698