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

Side by Side Diff: src/core/SkCachedData.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/SkBlitter.cpp ('k') | src/core/SkCanvas.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 2014 Google Inc. 2 * Copyright 2014 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 "SkCachedData.h" 8 #include "SkCachedData.h"
9 #include "SkDiscardableMemory.h" 9 #include "SkDiscardableMemory.h"
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 fStorage.fDM = dm; 50 fStorage.fDM = dm;
51 inc(); 51 inc();
52 } 52 }
53 53
54 SkCachedData::~SkCachedData() { 54 SkCachedData::~SkCachedData() {
55 switch (fStorageType) { 55 switch (fStorageType) {
56 case kMalloc_StorageType: 56 case kMalloc_StorageType:
57 sk_free(fStorage.fMalloc); 57 sk_free(fStorage.fMalloc);
58 break; 58 break;
59 case kDiscardableMemory_StorageType: 59 case kDiscardableMemory_StorageType:
60 SkDELETE(fStorage.fDM); 60 delete fStorage.fDM;
61 break; 61 break;
62 } 62 }
63 dec(); 63 dec();
64 } 64 }
65 65
66 class SkCachedData::AutoMutexWritable { 66 class SkCachedData::AutoMutexWritable {
67 public: 67 public:
68 AutoMutexWritable(const SkCachedData* cd) : fCD(const_cast<SkCachedData*>(cd )) { 68 AutoMutexWritable(const SkCachedData* cd) : fCD(const_cast<SkCachedData*>(cd )) {
69 fCD->fMutex.acquire(); 69 fCD->fMutex.acquire();
70 fCD->validate(); 70 fCD->validate();
(...skipping 10 matching lines...) Expand all
81 SkCachedData* fCD; 81 SkCachedData* fCD;
82 }; 82 };
83 83
84 void SkCachedData::internalRef(bool fromCache) const { 84 void SkCachedData::internalRef(bool fromCache) const {
85 AutoMutexWritable(this)->inMutexRef(fromCache); 85 AutoMutexWritable(this)->inMutexRef(fromCache);
86 } 86 }
87 87
88 void SkCachedData::internalUnref(bool fromCache) const { 88 void SkCachedData::internalUnref(bool fromCache) const {
89 if (AutoMutexWritable(this)->inMutexUnref(fromCache)) { 89 if (AutoMutexWritable(this)->inMutexUnref(fromCache)) {
90 // can't delete inside doInternalUnref, since it is locking a mutex (whi ch we own) 90 // can't delete inside doInternalUnref, since it is locking a mutex (whi ch we own)
91 SkDELETE(this); 91 delete this;
92 } 92 }
93 } 93 }
94 94
95 //////////////////////////////////////////////////////////////////////////////// /////////////////// 95 //////////////////////////////////////////////////////////////////////////////// ///////////////////
96 96
97 void SkCachedData::inMutexRef(bool fromCache) { 97 void SkCachedData::inMutexRef(bool fromCache) {
98 if ((1 == fRefCnt) && fInCache) { 98 if ((1 == fRefCnt) && fInCache) {
99 this->inMutexLock(); 99 this->inMutexLock();
100 } 100 }
101 101
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 case kDiscardableMemory_StorageType: 189 case kDiscardableMemory_StorageType:
190 // fData can be null or the actual value, depending if DM's lock succeeded 190 // fData can be null or the actual value, depending if DM's lock succeeded
191 break; 191 break;
192 } 192 }
193 } else { 193 } else {
194 SkASSERT((fInCache && 1 == fRefCnt) || (0 == fRefCnt)); 194 SkASSERT((fInCache && 1 == fRefCnt) || (0 == fRefCnt));
195 SkASSERT(NULL == fData); 195 SkASSERT(NULL == fData);
196 } 196 }
197 } 197 }
198 #endif 198 #endif
OLDNEW
« no previous file with comments | « src/core/SkBlitter.cpp ('k') | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698