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, ...) \ |
11 ((localCache) ? localCache->localName(__VA_ARGS__) : SkResourceCache::global
Name(__VA_ARGS__)) | 11 ((localCache) ? localCache->localName(__VA_ARGS__) : SkResourceCache::global
Name(__VA_ARGS__)) |
12 | 12 |
13 struct MaskValue { | 13 struct MaskValue { |
14 SkMask fMask; | 14 SkMask fMask; |
15 SkCachedData* fData; | 15 SkCachedData* fData; |
16 }; | 16 }; |
17 | 17 |
18 namespace { | 18 namespace { |
19 static unsigned gRRectBlurKeyNamespaceLabel; | 19 static unsigned gRRectBlurKeyNamespaceLabel; |
20 | 20 |
21 struct RRectBlurKey : public SkResourceCache::Key { | 21 struct RRectBlurKey : public SkResourceCache::Key { |
22 public: | 22 public: |
23 RRectBlurKey(SkScalar sigma, const SkRRect& rrect, SkBlurStyle style, SkBlur
Quality quality) | 23 RRectBlurKey(SkScalar sigma, const SkRRect& rrect, SkBlurStyle style, SkBlur
Quality quality) |
24 : fSigma(sigma) | 24 : fSigma(sigma) |
25 , fStyle(style) | 25 , fStyle(style) |
26 , fQuality(quality) | 26 , fQuality(quality) |
27 , fRRect(rrect) | 27 , fRRect(rrect) |
28 { | 28 { |
29 this->init(&gRRectBlurKeyNamespaceLabel, | 29 this->init(&gRRectBlurKeyNamespaceLabel, 0, |
30 sizeof(fSigma) + sizeof(fStyle) + sizeof(fQuality) + sizeof(f
RRect)); | 30 sizeof(fSigma) + sizeof(fStyle) + sizeof(fQuality) + sizeof(f
RRect)); |
31 } | 31 } |
32 | 32 |
33 SkScalar fSigma; | 33 SkScalar fSigma; |
34 int32_t fStyle; | 34 int32_t fStyle; |
35 int32_t fQuality; | 35 int32_t fQuality; |
36 SkRRect fRRect; | 36 SkRRect fRRect; |
37 }; | 37 }; |
38 | 38 |
39 struct RRectBlurRec : public SkResourceCache::Rec { | 39 struct RRectBlurRec : public SkResourceCache::Rec { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 fSizes[1] = SkSize::Make(0, 0); | 110 fSizes[1] = SkSize::Make(0, 0); |
111 fSizes[2] = SkSize::Make(0, 0); | 111 fSizes[2] = SkSize::Make(0, 0); |
112 fSizes[3] = SkSize::Make(rects[0].x() - ir.x(), rects[0].y() - ir.y()); | 112 fSizes[3] = SkSize::Make(rects[0].x() - ir.x(), rects[0].y() - ir.y()); |
113 for (int i = 0; i < count; i++) { | 113 for (int i = 0; i < count; i++) { |
114 fSizes[i] = SkSize::Make(rects[i].width(), rects[i].height()); | 114 fSizes[i] = SkSize::Make(rects[i].width(), rects[i].height()); |
115 } | 115 } |
116 if (2 == count) { | 116 if (2 == count) { |
117 fSizes[2] = SkSize::Make(rects[0].x() - rects[1].x(), rects[0].y() -
rects[1].y()); | 117 fSizes[2] = SkSize::Make(rects[0].x() - rects[1].x(), rects[0].y() -
rects[1].y()); |
118 } | 118 } |
119 | 119 |
120 this->init(&gRectsBlurKeyNamespaceLabel, | 120 this->init(&gRectsBlurKeyNamespaceLabel, 0, |
121 sizeof(fSigma) + sizeof(fStyle) + sizeof(fQuality) + sizeof(f
Sizes)); | 121 sizeof(fSigma) + sizeof(fStyle) + sizeof(fQuality) + sizeof(f
Sizes)); |
122 } | 122 } |
123 | 123 |
124 SkScalar fSigma; | 124 SkScalar fSigma; |
125 int32_t fStyle; | 125 int32_t fStyle; |
126 int32_t fQuality; | 126 int32_t fQuality; |
127 SkSize fSizes[4]; | 127 SkSize fSizes[4]; |
128 }; | 128 }; |
129 | 129 |
130 struct RectsBlurRec : public SkResourceCache::Rec { | 130 struct RectsBlurRec : public SkResourceCache::Rec { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |