OLD | NEW |
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 fValue.fData = data; | 44 fValue.fData = data; |
45 fValue.fData->attachToCacheAndRef(); | 45 fValue.fData->attachToCacheAndRef(); |
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 virtual const Key& getKey() const SK_OVERRIDE { return fKey; } | 54 const Key& getKey() const SK_OVERRIDE { return fKey; } |
55 virtual size_t bytesUsed() const SK_OVERRIDE { return sizeof(*this) + fValue
.fData->size(); } | 55 size_t bytesUsed() const SK_OVERRIDE { return sizeof(*this) + fValue.fData->
size(); } |
56 | 56 |
57 static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextData)
{ | 57 static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextData)
{ |
58 const RRectBlurRec& rec = static_cast<const RRectBlurRec&>(baseRec); | 58 const RRectBlurRec& rec = static_cast<const RRectBlurRec&>(baseRec); |
59 MaskValue* result = (MaskValue*)contextData; | 59 MaskValue* result = (MaskValue*)contextData; |
60 | 60 |
61 SkCachedData* tmpData = rec.fValue.fData; | 61 SkCachedData* tmpData = rec.fValue.fData; |
62 tmpData->ref(); | 62 tmpData->ref(); |
63 if (NULL == tmpData->data()) { | 63 if (NULL == tmpData->data()) { |
64 tmpData->unref(); | 64 tmpData->unref(); |
65 return false; | 65 return false; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 fValue.fData = data; | 135 fValue.fData = data; |
136 fValue.fData->attachToCacheAndRef(); | 136 fValue.fData->attachToCacheAndRef(); |
137 } | 137 } |
138 ~RectsBlurRec() { | 138 ~RectsBlurRec() { |
139 fValue.fData->detachFromCacheAndUnref(); | 139 fValue.fData->detachFromCacheAndUnref(); |
140 } | 140 } |
141 | 141 |
142 RectsBlurKey fKey; | 142 RectsBlurKey fKey; |
143 MaskValue fValue; | 143 MaskValue fValue; |
144 | 144 |
145 virtual const Key& getKey() const SK_OVERRIDE { return fKey; } | 145 const Key& getKey() const SK_OVERRIDE { return fKey; } |
146 virtual size_t bytesUsed() const SK_OVERRIDE { return sizeof(*this) + fValue
.fData->size(); } | 146 size_t bytesUsed() const SK_OVERRIDE { return sizeof(*this) + fValue.fData->
size(); } |
147 | 147 |
148 static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextData)
{ | 148 static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextData)
{ |
149 const RectsBlurRec& rec = static_cast<const RectsBlurRec&>(baseRec); | 149 const RectsBlurRec& rec = static_cast<const RectsBlurRec&>(baseRec); |
150 MaskValue* result = (MaskValue*)contextData; | 150 MaskValue* result = (MaskValue*)contextData; |
151 | 151 |
152 SkCachedData* tmpData = rec.fValue.fData; | 152 SkCachedData* tmpData = rec.fValue.fData; |
153 tmpData->ref(); | 153 tmpData->ref(); |
154 if (NULL == tmpData->data()) { | 154 if (NULL == tmpData->data()) { |
155 tmpData->unref(); | 155 tmpData->unref(); |
156 return false; | 156 return false; |
(...skipping 17 matching lines...) Expand all Loading... |
174 mask->fImage = (uint8_t*)(result.fData->data()); | 174 mask->fImage = (uint8_t*)(result.fData->data()); |
175 return result.fData; | 175 return result.fData; |
176 } | 176 } |
177 | 177 |
178 void SkMaskCache::Add(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, | 178 void SkMaskCache::Add(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, |
179 const SkRect rects[], int count, const SkMask& mask, SkCac
hedData* data, | 179 const SkRect rects[], int count, const SkMask& mask, SkCac
hedData* data, |
180 SkResourceCache* localCache) { | 180 SkResourceCache* localCache) { |
181 RectsBlurKey key(sigma, style, quality, rects, count); | 181 RectsBlurKey key(sigma, style, quality, rects, count); |
182 return CHECK_LOCAL(localCache, add, Add, SkNEW_ARGS(RectsBlurRec, (key, mask
, data))); | 182 return CHECK_LOCAL(localCache, add, Add, SkNEW_ARGS(RectsBlurRec, (key, mask
, data))); |
183 } | 183 } |
OLD | NEW |