| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 140 } |
| 141 | 141 |
| 142 RectsBlurKey fKey; | 142 RectsBlurKey fKey; |
| 143 MaskValue fValue; | 143 MaskValue fValue; |
| 144 | 144 |
| 145 const Key& getKey() const SK_OVERRIDE { return fKey; } | 145 const Key& getKey() const SK_OVERRIDE { return fKey; } |
| 146 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 = static_cast<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; |
| 157 } | 157 } |
| 158 *result = rec.fValue; | 158 *result = rec.fValue; |
| 159 return true; | 159 return true; |
| 160 } | 160 } |
| (...skipping 13 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 |