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

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

Issue 1037793002: C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: git cl web Created 5 years, 9 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/SkAAClip.cpp ('k') | src/core/SkBitmapFilter.h » ('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 "SkBitmapCache.h" 8 #include "SkBitmapCache.h"
9 #include "SkResourceCache.h" 9 #include "SkResourceCache.h"
10 #include "SkMipMap.h" 10 #include "SkMipMap.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 SkIRect fBounds; 64 SkIRect fBounds;
65 }; 65 };
66 66
67 struct BitmapRec : public SkResourceCache::Rec { 67 struct BitmapRec : public SkResourceCache::Rec {
68 BitmapRec(uint32_t genID, SkScalar scaleX, SkScalar scaleY, const SkIRect& b ounds, 68 BitmapRec(uint32_t genID, SkScalar scaleX, SkScalar scaleY, const SkIRect& b ounds,
69 const SkBitmap& result) 69 const SkBitmap& result)
70 : fKey(genID, scaleX, scaleY, bounds) 70 : fKey(genID, scaleX, scaleY, bounds)
71 , fBitmap(result) 71 , fBitmap(result)
72 {} 72 {}
73 73
74 const Key& getKey() const SK_OVERRIDE { return fKey; } 74 const Key& getKey() const override { return fKey; }
75 size_t bytesUsed() const SK_OVERRIDE { return sizeof(fKey) + fBitmap.getSize (); } 75 size_t bytesUsed() const override { return sizeof(fKey) + fBitmap.getSize(); }
76 76
77 static bool Finder(const SkResourceCache::Rec& baseRec, void* contextBitmap) { 77 static bool Finder(const SkResourceCache::Rec& baseRec, void* contextBitmap) {
78 const BitmapRec& rec = static_cast<const BitmapRec&>(baseRec); 78 const BitmapRec& rec = static_cast<const BitmapRec&>(baseRec);
79 SkBitmap* result = (SkBitmap*)contextBitmap; 79 SkBitmap* result = (SkBitmap*)contextBitmap;
80 80
81 *result = rec.fBitmap; 81 *result = rec.fBitmap;
82 result->lockPixels(); 82 result->lockPixels();
83 return SkToBool(result->getPixels()); 83 return SkToBool(result->getPixels());
84 } 84 }
85 85
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 : fKey(src.getGenerationID(), get_bounds_from_bitmap(src)) 164 : fKey(src.getGenerationID(), get_bounds_from_bitmap(src))
165 , fMipMap(result) 165 , fMipMap(result)
166 { 166 {
167 fMipMap->attachToCacheAndRef(); 167 fMipMap->attachToCacheAndRef();
168 } 168 }
169 169
170 virtual ~MipMapRec() { 170 virtual ~MipMapRec() {
171 fMipMap->detachFromCacheAndUnref(); 171 fMipMap->detachFromCacheAndUnref();
172 } 172 }
173 173
174 const Key& getKey() const SK_OVERRIDE { return fKey; } 174 const Key& getKey() const override { return fKey; }
175 size_t bytesUsed() const SK_OVERRIDE { return sizeof(fKey) + fMipMap->size() ; } 175 size_t bytesUsed() const override { return sizeof(fKey) + fMipMap->size(); }
176 176
177 static bool Finder(const SkResourceCache::Rec& baseRec, void* contextMip) { 177 static bool Finder(const SkResourceCache::Rec& baseRec, void* contextMip) {
178 const MipMapRec& rec = static_cast<const MipMapRec&>(baseRec); 178 const MipMapRec& rec = static_cast<const MipMapRec&>(baseRec);
179 const SkMipMap* mm = SkRef(rec.fMipMap); 179 const SkMipMap* mm = SkRef(rec.fMipMap);
180 // the call to ref() above triggers a "lock" in the case of discardable memory, 180 // the call to ref() above triggers a "lock" in the case of discardable memory,
181 // which means we can now check for null (in case the lock failed). 181 // which means we can now check for null (in case the lock failed).
182 if (NULL == mm->data()) { 182 if (NULL == mm->data()) {
183 mm->unref(); // balance our call to ref() 183 mm->unref(); // balance our call to ref()
184 return false; 184 return false;
185 } 185 }
(...skipping 25 matching lines...) Expand all
211 211
212 const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkResourceCache* l ocalCache) { 212 const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkResourceCache* l ocalCache) {
213 SkMipMap* mipmap = SkMipMap::Build(src, get_fact(localCache)); 213 SkMipMap* mipmap = SkMipMap::Build(src, get_fact(localCache));
214 if (mipmap) { 214 if (mipmap) {
215 MipMapRec* rec = SkNEW_ARGS(MipMapRec, (src, mipmap)); 215 MipMapRec* rec = SkNEW_ARGS(MipMapRec, (src, mipmap));
216 CHECK_LOCAL(localCache, add, Add, rec); 216 CHECK_LOCAL(localCache, add, Add, rec);
217 src.pixelRef()->notifyAddedToCache(); 217 src.pixelRef()->notifyAddedToCache();
218 } 218 }
219 return mipmap; 219 return mipmap;
220 } 220 }
OLDNEW
« no previous file with comments | « src/core/SkAAClip.cpp ('k') | src/core/SkBitmapFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698