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

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

Issue 1074983003: add SkPixmap and external locking to bitmaps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 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 "SkBitmapCache.h" 8 #include "SkBitmapCache.h"
9 #include "SkPixelRef.h" 9 #include "SkPixelRef.h"
10 #include "SkThread.h" 10 #include "SkThread.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 if (fRec.fPixels) { 192 if (fRec.fPixels) {
193 this->onUnlockPixels(); 193 this->onUnlockPixels();
194 fRec.zero(); 194 fRec.zero();
195 } else { 195 } else {
196 SkASSERT(fRec.isZero()); 196 SkASSERT(fRec.isZero());
197 } 197 }
198 } 198 }
199 } 199 }
200 } 200 }
201 201
202 bool SkPixelRef::requestLock(const LockRequest& request, LockResult* result) {
203 SkASSERT(result);
204 if (request.fSize.isEmpty()) {
205 return false;
206 }
207
208 if (fPreLocked) {
209 result->fUnlockProc = NULL;
210 result->fUnlockContext = NULL;
211 result->fCTable = fRec.fColorTable;
212 result->fPixels = fRec.fPixels;
213 result->fRowBytes = fRec.fRowBytes;
214 result->fSize.set(fInfo.width(), fInfo.height());
215 return true;
216 } else {
217 SkAutoMutexAcquire ac(*fMutex);
218 return this->onRequestLock(request, result);
219 }
220 }
221
202 bool SkPixelRef::lockPixelsAreWritable() const { 222 bool SkPixelRef::lockPixelsAreWritable() const {
203 return this->onLockPixelsAreWritable(); 223 return this->onLockPixelsAreWritable();
204 } 224 }
205 225
206 bool SkPixelRef::onLockPixelsAreWritable() const { 226 bool SkPixelRef::onLockPixelsAreWritable() const {
207 return true; 227 return true;
208 } 228 }
209 229
210 uint32_t SkPixelRef::getGenerationID() const { 230 uint32_t SkPixelRef::getGenerationID() const {
211 uint32_t id = fTaggedGenID.load(); 231 uint32_t id = fTaggedGenID.load();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 } 284 }
265 285
266 void SkPixelRef::setImmutable() { 286 void SkPixelRef::setImmutable() {
267 fIsImmutable = true; 287 fIsImmutable = true;
268 } 288 }
269 289
270 bool SkPixelRef::readPixels(SkBitmap* dst, const SkIRect* subset) { 290 bool SkPixelRef::readPixels(SkBitmap* dst, const SkIRect* subset) {
271 return this->onReadPixels(dst, subset); 291 return this->onReadPixels(dst, subset);
272 } 292 }
273 293
294 //////////////////////////////////////////////////////////////////////////////// ///////////////////
295
274 bool SkPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) { 296 bool SkPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) {
275 return false; 297 return false;
276 } 298 }
277 299
278 SkData* SkPixelRef::onRefEncodedData() { 300 SkData* SkPixelRef::onRefEncodedData() {
279 return NULL; 301 return NULL;
280 } 302 }
281 303
282 bool SkPixelRef::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], 304 bool SkPixelRef::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3],
283 SkYUVColorSpace* colorSpace) { 305 SkYUVColorSpace* colorSpace) {
284 return false; 306 return false;
285 } 307 }
286 308
287 size_t SkPixelRef::getAllocatedSizeInBytes() const { 309 size_t SkPixelRef::getAllocatedSizeInBytes() const {
288 return 0; 310 return 0;
289 } 311 }
290 312
313 static void unlock_legacy_result(void* ctx) {
314 SkPixelRef* pr = (SkPixelRef*)ctx;
315 pr->unlockPixels();
316 }
317
318 bool SkPixelRef::onRequestLock(const LockRequest& request, LockResult* result) {
319 LockRec rec;
320 if (!this->onNewLockPixels(&rec)) {
321 return false;
322 }
323
324 result->fUnlockProc = unlock_legacy_result;
325 result->fUnlockContext = SkRef(this);
326 result->fCTable = rec.fColorTable;
327 result->fPixels = rec.fPixels;
328 result->fRowBytes = rec.fRowBytes;
329 result->fSize.set(fInfo.width(), fInfo.height());
330 return true;
331 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698