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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 struct RectsBlurKey : public SkResourceCache::Key { | 98 struct RectsBlurKey : public SkResourceCache::Key { |
99 public: | 99 public: |
100 RectsBlurKey(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, | 100 RectsBlurKey(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, |
101 const SkRect rects[], int count) | 101 const SkRect rects[], int count) |
102 : fSigma(sigma) | 102 : fSigma(sigma) |
103 , fStyle(style) | 103 , fStyle(style) |
104 , fQuality(quality) | 104 , fQuality(quality) |
105 { | 105 { |
106 SkASSERT(1 == count || 2 == count); | 106 SkASSERT(1 == count || 2 == count); |
107 fRects[0] = SkRect::MakeEmpty(); | 107 SkIRect ir; |
108 fRects[1] = SkRect::MakeEmpty(); | 108 rects[0].roundOut(&ir); |
| 109 fSizes[0] = SkSize::Make(0, 0); |
| 110 fSizes[1] = 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()); |
109 for (int i = 0; i < count; i++) { | 113 for (int i = 0; i < count; i++) { |
110 fRects[i] = rects[i]; | 114 fSizes[i] = SkSize::Make(rects[i].width(), rects[i].height()); |
111 } | 115 } |
| 116 if (2 == count) { |
| 117 fSizes[2] = SkSize::Make(rects[0].x() - rects[1].x(), rects[0].y() -
rects[1].y()); |
| 118 } |
| 119 |
112 this->init(&gRectsBlurKeyNamespaceLabel, | 120 this->init(&gRectsBlurKeyNamespaceLabel, |
113 sizeof(fSigma) + sizeof(fStyle) + sizeof(fQuality) + sizeof(f
Rects)); | 121 sizeof(fSigma) + sizeof(fStyle) + sizeof(fQuality) + sizeof(f
Sizes)); |
114 } | 122 } |
115 | 123 |
116 SkScalar fSigma; | 124 SkScalar fSigma; |
117 int32_t fStyle; | 125 int32_t fStyle; |
118 int32_t fQuality; | 126 int32_t fQuality; |
119 SkRect fRects[2]; | 127 SkSize fSizes[4]; |
120 }; | 128 }; |
121 | 129 |
122 struct RectsBlurRec : public SkResourceCache::Rec { | 130 struct RectsBlurRec : public SkResourceCache::Rec { |
123 RectsBlurRec(RectsBlurKey key, const SkMask& mask, SkCachedData* data) | 131 RectsBlurRec(RectsBlurKey key, const SkMask& mask, SkCachedData* data) |
124 : fKey(key) | 132 : fKey(key) |
125 { | 133 { |
126 fValue.fMask = mask; | 134 fValue.fMask = mask; |
127 fValue.fData = data; | 135 fValue.fData = data; |
128 fValue.fData->attachToCacheAndRef(); | 136 fValue.fData->attachToCacheAndRef(); |
129 } | 137 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 mask->fImage = (uint8_t*)(result.fData->data()); | 174 mask->fImage = (uint8_t*)(result.fData->data()); |
167 return result.fData; | 175 return result.fData; |
168 } | 176 } |
169 | 177 |
170 void SkMaskCache::Add(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, | 178 void SkMaskCache::Add(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, |
171 const SkRect rects[], int count, const SkMask& mask, SkCac
hedData* data, | 179 const SkRect rects[], int count, const SkMask& mask, SkCac
hedData* data, |
172 SkResourceCache* localCache) { | 180 SkResourceCache* localCache) { |
173 RectsBlurKey key(sigma, style, quality, rects, count); | 181 RectsBlurKey key(sigma, style, quality, rects, count); |
174 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))); |
175 } | 183 } |
OLD | NEW |