| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 public: | 103 public: |
| 104 RectsBlurKey(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, | 104 RectsBlurKey(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, |
| 105 const SkRect rects[], int count) | 105 const SkRect rects[], int count) |
| 106 : fSigma(sigma) | 106 : fSigma(sigma) |
| 107 , fStyle(style) | 107 , fStyle(style) |
| 108 , fQuality(quality) | 108 , fQuality(quality) |
| 109 { | 109 { |
| 110 SkASSERT(1 == count || 2 == count); | 110 SkASSERT(1 == count || 2 == count); |
| 111 SkIRect ir; | 111 SkIRect ir; |
| 112 rects[0].roundOut(&ir); | 112 rects[0].roundOut(&ir); |
| 113 fSizes[0] = SkSize::Make(0, 0); | 113 fSizes[0] = SkSize::Make(rects[0].width(), rects[0].height()); |
| 114 fSizes[1] = SkSize::Make(0, 0); | 114 if (2 == count) { |
| 115 fSizes[2] = SkSize::Make(0, 0); | 115 fSizes[1] = SkSize::Make(rects[1].width(), rects[1].height()); |
| 116 fSizes[2] = SkSize::Make(rects[0].x() - rects[1].x(), rects[0].y() -
rects[1].y()); |
| 117 } else { |
| 118 fSizes[1] = SkSize::Make(0, 0); |
| 119 fSizes[2] = SkSize::Make(0, 0); |
| 120 } |
| 116 fSizes[3] = SkSize::Make(rects[0].x() - ir.x(), rects[0].y() - ir.y()); | 121 fSizes[3] = SkSize::Make(rects[0].x() - ir.x(), rects[0].y() - ir.y()); |
| 117 for (int i = 0; i < count; i++) { | |
| 118 fSizes[i] = SkSize::Make(rects[i].width(), rects[i].height()); | |
| 119 } | |
| 120 if (2 == count) { | |
| 121 fSizes[2] = SkSize::Make(rects[0].x() - rects[1].x(), rects[0].y() -
rects[1].y()); | |
| 122 } | |
| 123 | 122 |
| 124 this->init(&gRectsBlurKeyNamespaceLabel, 0, | 123 this->init(&gRectsBlurKeyNamespaceLabel, 0, |
| 125 sizeof(fSigma) + sizeof(fStyle) + sizeof(fQuality) + sizeof(f
Sizes)); | 124 sizeof(fSigma) + sizeof(fStyle) + sizeof(fQuality) + sizeof(f
Sizes)); |
| 126 } | 125 } |
| 127 | 126 |
| 128 SkScalar fSigma; | 127 SkScalar fSigma; |
| 129 int32_t fStyle; | 128 int32_t fStyle; |
| 130 int32_t fQuality; | 129 int32_t fQuality; |
| 131 SkSize fSizes[4]; | 130 SkSize fSizes[4]; |
| 132 }; | 131 }; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 mask->fImage = (uint8_t*)(result.fData->data()); | 181 mask->fImage = (uint8_t*)(result.fData->data()); |
| 183 return result.fData; | 182 return result.fData; |
| 184 } | 183 } |
| 185 | 184 |
| 186 void SkMaskCache::Add(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, | 185 void SkMaskCache::Add(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, |
| 187 const SkRect rects[], int count, const SkMask& mask, SkCac
hedData* data, | 186 const SkRect rects[], int count, const SkMask& mask, SkCac
hedData* data, |
| 188 SkResourceCache* localCache) { | 187 SkResourceCache* localCache) { |
| 189 RectsBlurKey key(sigma, style, quality, rects, count); | 188 RectsBlurKey key(sigma, style, quality, rects, count); |
| 190 return CHECK_LOCAL(localCache, add, Add, new RectsBlurRec(key, mask, data)); | 189 return CHECK_LOCAL(localCache, add, Add, new RectsBlurRec(key, mask, data)); |
| 191 } | 190 } |
| OLD | NEW |