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

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

Issue 114673002: be sure to unlock the discardablememory before deleting it (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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
« no previous file with comments | « src/lazy/SkDiscardableMemoryPool.cpp ('k') | tests/CachedDecodingPixelRefTest.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 "SkDiscardablePixelRef.h" 8 #include "SkDiscardablePixelRef.h"
9 #include "SkDiscardableMemory.h" 9 #include "SkDiscardableMemory.h"
10 #include "SkImageGenerator.h" 10 #include "SkImageGenerator.h"
(...skipping 12 matching lines...) Expand all
23 SkASSERT(fGenerator != NULL); 23 SkASSERT(fGenerator != NULL);
24 SkASSERT(fSize > 0); 24 SkASSERT(fSize > 0);
25 SkASSERT(fRowBytes > 0); 25 SkASSERT(fRowBytes > 0);
26 // The SkImageGenerator contract requires fGenerator to always 26 // The SkImageGenerator contract requires fGenerator to always
27 // decode the same image on each call to getPixels(). 27 // decode the same image on each call to getPixels().
28 this->setImmutable(); 28 this->setImmutable();
29 SkSafeRef(fDMFactory); 29 SkSafeRef(fDMFactory);
30 } 30 }
31 31
32 SkDiscardablePixelRef::~SkDiscardablePixelRef() { 32 SkDiscardablePixelRef::~SkDiscardablePixelRef() {
33 if (this->isLocked()) {
34 fDiscardableMemory->unlock();
35 }
33 SkDELETE(fDiscardableMemory); 36 SkDELETE(fDiscardableMemory);
34 SkSafeUnref(fDMFactory); 37 SkSafeUnref(fDMFactory);
35 SkDELETE(fGenerator); 38 SkDELETE(fGenerator);
36 } 39 }
37 40
38 void* SkDiscardablePixelRef::onLockPixels(SkColorTable**) { 41 void* SkDiscardablePixelRef::onLockPixels(SkColorTable**) {
39 if (fDiscardableMemory != NULL) { 42 if (fDiscardableMemory != NULL) {
40 if (fDiscardableMemory->lock()) { 43 if (fDiscardableMemory->lock()) {
41 return fDiscardableMemory->data(); 44 return fDiscardableMemory->data();
42 } 45 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 return dst->allocPixels(NULL, NULL); 83 return dst->allocPixels(NULL, NULL);
81 } 84 }
82 SkAutoTUnref<SkDiscardablePixelRef> ref(SkNEW_ARGS(SkDiscardablePixelRef, 85 SkAutoTUnref<SkDiscardablePixelRef> ref(SkNEW_ARGS(SkDiscardablePixelRef,
83 (generator, info, 86 (generator, info,
84 dst->getSize(), 87 dst->getSize(),
85 dst->rowBytes(), 88 dst->rowBytes(),
86 factory))); 89 factory)));
87 dst->setPixelRef(ref); 90 dst->setPixelRef(ref);
88 return true; 91 return true;
89 } 92 }
OLDNEW
« no previous file with comments | « src/lazy/SkDiscardableMemoryPool.cpp ('k') | tests/CachedDecodingPixelRefTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698