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

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

Issue 1271033002: private iterator to visit all resource cache entries (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add iter for fontcache Created 5 years, 4 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
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 "SkMaskCache.h" 8 #include "SkMaskCache.h"
9 9
10 #define CHECK_LOCAL(localCache, localName, globalName, ...) \ 10 #define CHECK_LOCAL(localCache, localName, globalName, ...) \
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 ~RRectBlurRec() { 47 ~RRectBlurRec() {
48 fValue.fData->detachFromCacheAndUnref(); 48 fValue.fData->detachFromCacheAndUnref();
49 } 49 }
50 50
51 RRectBlurKey fKey; 51 RRectBlurKey fKey;
52 MaskValue fValue; 52 MaskValue fValue;
53 53
54 const Key& getKey() const override { return fKey; } 54 const Key& getKey() const override { return fKey; }
55 size_t bytesUsed() const override { return sizeof(*this) + fValue.fData->siz e(); } 55 size_t bytesUsed() const override { return sizeof(*this) + fValue.fData->siz e(); }
56 const char* getCategory() const override { return "rrect-blur"; }
57 SkDiscardableMemory* diagnostic_only_getDiscardable() const override {
58 return fValue.fData->diagnostic_only_getDiscardable();
59 }
56 60
57 static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextData) { 61 static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextData) {
58 const RRectBlurRec& rec = static_cast<const RRectBlurRec&>(baseRec); 62 const RRectBlurRec& rec = static_cast<const RRectBlurRec&>(baseRec);
59 MaskValue* result = (MaskValue*)contextData; 63 MaskValue* result = (MaskValue*)contextData;
60 64
61 SkCachedData* tmpData = rec.fValue.fData; 65 SkCachedData* tmpData = rec.fValue.fData;
62 tmpData->ref(); 66 tmpData->ref();
63 if (NULL == tmpData->data()) { 67 if (NULL == tmpData->data()) {
64 tmpData->unref(); 68 tmpData->unref();
65 return false; 69 return false;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 141 }
138 ~RectsBlurRec() { 142 ~RectsBlurRec() {
139 fValue.fData->detachFromCacheAndUnref(); 143 fValue.fData->detachFromCacheAndUnref();
140 } 144 }
141 145
142 RectsBlurKey fKey; 146 RectsBlurKey fKey;
143 MaskValue fValue; 147 MaskValue fValue;
144 148
145 const Key& getKey() const override { return fKey; } 149 const Key& getKey() const override { return fKey; }
146 size_t bytesUsed() const override { return sizeof(*this) + fValue.fData->siz e(); } 150 size_t bytesUsed() const override { return sizeof(*this) + fValue.fData->siz e(); }
151 const char* getCategory() const override { return "rects-blur"; }
152 SkDiscardableMemory* diagnostic_only_getDiscardable() const override {
153 return fValue.fData->diagnostic_only_getDiscardable();
154 }
147 155
148 static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextData) { 156 static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextData) {
149 const RectsBlurRec& rec = static_cast<const RectsBlurRec&>(baseRec); 157 const RectsBlurRec& rec = static_cast<const RectsBlurRec&>(baseRec);
150 MaskValue* result = static_cast<MaskValue*>(contextData); 158 MaskValue* result = static_cast<MaskValue*>(contextData);
151 159
152 SkCachedData* tmpData = rec.fValue.fData; 160 SkCachedData* tmpData = rec.fValue.fData;
153 tmpData->ref(); 161 tmpData->ref();
154 if (NULL == tmpData->data()) { 162 if (NULL == tmpData->data()) {
155 tmpData->unref(); 163 tmpData->unref();
156 return false; 164 return false;
(...skipping 17 matching lines...) Expand all
174 mask->fImage = (uint8_t*)(result.fData->data()); 182 mask->fImage = (uint8_t*)(result.fData->data());
175 return result.fData; 183 return result.fData;
176 } 184 }
177 185
178 void SkMaskCache::Add(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, 186 void SkMaskCache::Add(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality,
179 const SkRect rects[], int count, const SkMask& mask, SkCac hedData* data, 187 const SkRect rects[], int count, const SkMask& mask, SkCac hedData* data,
180 SkResourceCache* localCache) { 188 SkResourceCache* localCache) {
181 RectsBlurKey key(sigma, style, quality, rects, count); 189 RectsBlurKey key(sigma, style, quality, rects, count);
182 return CHECK_LOCAL(localCache, add, Add, SkNEW_ARGS(RectsBlurRec, (key, mask , data))); 190 return CHECK_LOCAL(localCache, add, Add, SkNEW_ARGS(RectsBlurRec, (key, mask , data)));
183 } 191 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698