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

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

Issue 806653007: Fix up all the easy virtual ... SK_OVERRIDE cases. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 11 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 struct BitmapRec : public SkResourceCache::Rec { 54 struct BitmapRec : public SkResourceCache::Rec {
55 BitmapRec(uint32_t genID, SkScalar scaleX, SkScalar scaleY, const SkIRect& b ounds, 55 BitmapRec(uint32_t genID, SkScalar scaleX, SkScalar scaleY, const SkIRect& b ounds,
56 const SkBitmap& result) 56 const SkBitmap& result)
57 : fKey(genID, scaleX, scaleY, bounds) 57 : fKey(genID, scaleX, scaleY, bounds)
58 , fBitmap(result) 58 , fBitmap(result)
59 {} 59 {}
60 60
61 BitmapKey fKey; 61 BitmapKey fKey;
62 SkBitmap fBitmap; 62 SkBitmap fBitmap;
63 63
64 virtual const Key& getKey() const SK_OVERRIDE { return fKey; } 64 const Key& getKey() const SK_OVERRIDE { return fKey; }
65 virtual size_t bytesUsed() const SK_OVERRIDE { return sizeof(fKey) + fBitmap .getSize(); } 65 size_t bytesUsed() const SK_OVERRIDE { return sizeof(fKey) + fBitmap.getSize (); }
66 66
67 static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextBitmap ) { 67 static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextBitmap ) {
68 const BitmapRec& rec = static_cast<const BitmapRec&>(baseRec); 68 const BitmapRec& rec = static_cast<const BitmapRec&>(baseRec);
69 SkBitmap* result = (SkBitmap*)contextBitmap; 69 SkBitmap* result = (SkBitmap*)contextBitmap;
70 70
71 *result = rec.fBitmap; 71 *result = rec.fBitmap;
72 result->lockPixels(); 72 result->lockPixels();
73 return SkToBool(result->getPixels()); 73 return SkToBool(result->getPixels());
74 } 74 }
75 }; 75 };
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 : fKey(src.getGenerationID(), 0, 0, get_bounds_from_bitmap(src)) 132 : fKey(src.getGenerationID(), 0, 0, get_bounds_from_bitmap(src))
133 , fMipMap(result) 133 , fMipMap(result)
134 { 134 {
135 fMipMap->attachToCacheAndRef(); 135 fMipMap->attachToCacheAndRef();
136 } 136 }
137 137
138 virtual ~MipMapRec() { 138 virtual ~MipMapRec() {
139 fMipMap->detachFromCacheAndUnref(); 139 fMipMap->detachFromCacheAndUnref();
140 } 140 }
141 141
142 virtual const Key& getKey() const SK_OVERRIDE { return fKey; } 142 const Key& getKey() const SK_OVERRIDE { return fKey; }
143 virtual size_t bytesUsed() const SK_OVERRIDE { return sizeof(fKey) + fMipMap ->size(); } 143 size_t bytesUsed() const SK_OVERRIDE { return sizeof(fKey) + fMipMap->size() ; }
144 144
145 static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextMip) { 145 static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextMip) {
146 const MipMapRec& rec = static_cast<const MipMapRec&>(baseRec); 146 const MipMapRec& rec = static_cast<const MipMapRec&>(baseRec);
147 const SkMipMap* mm = SkRef(rec.fMipMap); 147 const SkMipMap* mm = SkRef(rec.fMipMap);
148 // the call to ref() above triggers a "lock" in the case of discardable memory, 148 // the call to ref() above triggers a "lock" in the case of discardable memory,
149 // which means we can now check for null (in case the lock failed). 149 // which means we can now check for null (in case the lock failed).
150 if (NULL == mm->data()) { 150 if (NULL == mm->data()) {
151 mm->unref(); // balance our call to ref() 151 mm->unref(); // balance our call to ref()
152 return false; 152 return false;
153 } 153 }
(...skipping 24 matching lines...) Expand all
178 178
179 const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkResourceCache* l ocalCache) { 179 const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkResourceCache* l ocalCache) {
180 SkMipMap* mipmap = SkMipMap::Build(src, get_fact(localCache)); 180 SkMipMap* mipmap = SkMipMap::Build(src, get_fact(localCache));
181 if (mipmap) { 181 if (mipmap) {
182 MipMapRec* rec = SkNEW_ARGS(MipMapRec, (src, mipmap)); 182 MipMapRec* rec = SkNEW_ARGS(MipMapRec, (src, mipmap));
183 CHECK_LOCAL(localCache, add, Add, rec); 183 CHECK_LOCAL(localCache, add, Add, rec);
184 } 184 }
185 return mipmap; 185 return mipmap;
186 } 186 }
187 187
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