OLD | NEW |
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 "SkFlattenableBuffers.h" | 10 #include "SkFlattenableBuffers.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 if (kIndex_8_SkColorType != info.fColorType) { | 146 if (kIndex_8_SkColorType != info.fColorType) { |
147 ctable = NULL; | 147 ctable = NULL; |
148 } | 148 } |
149 | 149 |
150 fStorage = storage; | 150 fStorage = storage; |
151 fCTable = ctable; | 151 fCTable = ctable; |
152 fRB = rowBytes; | 152 fRB = rowBytes; |
153 SkSafeRef(ctable); | 153 SkSafeRef(ctable); |
154 | 154 |
155 this->setPreLocked(fStorage, fCTable); | 155 this->setPreLocked(fStorage, fRB, fCTable); |
156 } | 156 } |
157 | 157 |
158 SkMallocPixelRef::SkMallocPixelRef(const SkImageInfo& info, void* storage, | 158 SkMallocPixelRef::SkMallocPixelRef(const SkImageInfo& info, void* storage, |
159 size_t rowBytes, SkColorTable* ctable, | 159 size_t rowBytes, SkColorTable* ctable, |
160 SkMallocPixelRef::ReleaseProc proc, | 160 SkMallocPixelRef::ReleaseProc proc, |
161 void* context) | 161 void* context) |
162 : INHERITED(info) | 162 : INHERITED(info) |
163 , fReleaseProc(proc) | 163 , fReleaseProc(proc) |
164 , fReleaseProcContext(context) | 164 , fReleaseProcContext(context) |
165 { | 165 { |
166 SkASSERT(is_valid(info, ctable)); | 166 SkASSERT(is_valid(info, ctable)); |
167 SkASSERT(rowBytes >= info.minRowBytes()); | 167 SkASSERT(rowBytes >= info.minRowBytes()); |
168 | 168 |
169 if (kIndex_8_SkColorType != info.fColorType) { | 169 if (kIndex_8_SkColorType != info.fColorType) { |
170 ctable = NULL; | 170 ctable = NULL; |
171 } | 171 } |
172 | 172 |
173 fStorage = storage; | 173 fStorage = storage; |
174 fCTable = ctable; | 174 fCTable = ctable; |
175 fRB = rowBytes; | 175 fRB = rowBytes; |
176 SkSafeRef(ctable); | 176 SkSafeRef(ctable); |
177 | 177 |
178 this->setPreLocked(fStorage, fCTable); | 178 this->setPreLocked(fStorage, fRB, fCTable); |
179 } | 179 } |
180 | 180 |
181 | 181 |
182 SkMallocPixelRef::~SkMallocPixelRef() { | 182 SkMallocPixelRef::~SkMallocPixelRef() { |
183 SkSafeUnref(fCTable); | 183 SkSafeUnref(fCTable); |
184 if (fReleaseProc != NULL) { | 184 if (fReleaseProc != NULL) { |
185 fReleaseProc(fStorage, fReleaseProcContext); | 185 fReleaseProc(fStorage, fReleaseProcContext); |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
189 void* SkMallocPixelRef::onLockPixels(SkColorTable** ctable) { | 189 bool SkMallocPixelRef::onNewLockPixels(LockRec* rec) { |
190 *ctable = fCTable; | 190 rec->fPixels = fStorage; |
191 return fStorage; | 191 rec->fRowBytes = fRB; |
| 192 rec->fColorTable = fCTable; |
| 193 return true; |
192 } | 194 } |
193 | 195 |
194 void SkMallocPixelRef::onUnlockPixels() { | 196 void SkMallocPixelRef::onUnlockPixels() { |
195 // nothing to do | 197 // nothing to do |
196 } | 198 } |
197 | 199 |
198 size_t SkMallocPixelRef::getAllocatedSizeInBytes() const { | 200 size_t SkMallocPixelRef::getAllocatedSizeInBytes() const { |
199 return this->info().getSafeSize(fRB); | 201 return this->info().getSafeSize(fRB); |
200 } | 202 } |
201 | 203 |
(...skipping 25 matching lines...) Expand all Loading... |
227 } else { | 229 } else { |
228 fStorage = NULL; | 230 fStorage = NULL; |
229 } | 231 } |
230 | 232 |
231 if (buffer.readBool()) { | 233 if (buffer.readBool()) { |
232 fCTable = SkNEW_ARGS(SkColorTable, (buffer)); | 234 fCTable = SkNEW_ARGS(SkColorTable, (buffer)); |
233 } else { | 235 } else { |
234 fCTable = NULL; | 236 fCTable = NULL; |
235 } | 237 } |
236 | 238 |
237 this->setPreLocked(fStorage, fCTable); | 239 this->setPreLocked(fStorage, fRB, fCTable); |
238 } | 240 } |
OLD | NEW |