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

Side by Side Diff: src/lazy/SkDiscardablePixelRef.cpp

Issue 83563002: Implement SkAshmemDiscardableMemory (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: bugfix Created 7 years 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
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 "SkDiscardablePixelRef.h" 8 #include "SkDiscardablePixelRef.h"
9 #include "SkDiscardableMemory.h" 9 #include "SkDiscardableMemory.h"
10 10
(...skipping 13 matching lines...) Expand all
24 24
25 SkDiscardablePixelRef::~SkDiscardablePixelRef() { 25 SkDiscardablePixelRef::~SkDiscardablePixelRef() {
26 SkDELETE(fGenerator); 26 SkDELETE(fGenerator);
27 } 27 }
28 28
29 void* SkDiscardablePixelRef::onLockPixels(SkColorTable**) { 29 void* SkDiscardablePixelRef::onLockPixels(SkColorTable**) {
30 if (fDiscardableMemory != NULL) { 30 if (fDiscardableMemory != NULL) {
31 if (fDiscardableMemory->lock()) { 31 if (fDiscardableMemory->lock()) {
32 return fDiscardableMemory->data(); 32 return fDiscardableMemory->data();
33 } 33 }
34 SkDELETE(fDiscardableMemory);
34 fDiscardableMemory = NULL; 35 fDiscardableMemory = NULL;
35 } 36 }
36 fDiscardableMemory = SkDiscardableMemory::Create(fSize); 37 fDiscardableMemory = SkDiscardableMemory::Create(fSize);
37 if (NULL == fDiscardableMemory) { 38 if (NULL == fDiscardableMemory) {
38 return NULL; // Memory allocation failed. 39 return NULL; // Memory allocation failed.
39 } 40 }
40 void* pixels = fDiscardableMemory->data(); 41 void* pixels = fDiscardableMemory->data();
41 if (!fGenerator->getPixels(fInfo, pixels, fRowBytes)) { 42 if (!fGenerator->getPixels(fInfo, pixels, fRowBytes)) {
42 return NULL; // TODO(halcanary) Find out correct thing to do. 43 return NULL; // TODO(halcanary) Find out correct thing to do.
43 } 44 }
(...skipping 15 matching lines...) Expand all
59 SkDELETE(generator); 60 SkDELETE(generator);
60 return false; 61 return false;
61 } 62 }
62 SkAutoTUnref<SkDiscardablePixelRef> ref(SkNEW_ARGS(SkDiscardablePixelRef, 63 SkAutoTUnref<SkDiscardablePixelRef> ref(SkNEW_ARGS(SkDiscardablePixelRef,
63 (generator, info, 64 (generator, info,
64 dst->getSize(), 65 dst->getSize(),
65 dst->rowBytes()))); 66 dst->rowBytes())));
66 dst->setPixelRef(ref); 67 dst->setPixelRef(ref);
67 return true; 68 return true;
68 } 69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698