| 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkMaskCache_DEFINED |
| 9 | #define SkMaskCache_DEFINED |
| 10 | |
| 11 | #include "include/core/SkBlurTypes.h" |
| 12 | #include "include/core/SkRRect.h" |
| 13 | #include "include/core/SkRect.h" |
| 14 | #include "src/core/SkCachedData.h" |
| 15 | #include "src/core/SkMask.h" |
| 16 | #include "src/core/SkResourceCache.h" |
| 17 | |
| 18 | class SkMaskCache { |
| 19 | public: |
| 20 | /** |
| 21 | * On success, return a ref to the SkCachedData that holds the pixels, and have mask |
| 22 | * already point to that memory. |
| 23 | * |
| 24 | * On failure, return nullptr. |
| 25 | */ |
| 26 | static SkCachedData* FindAndRef(SkScalar sigma, SkBlurStyle style, |
| 27 | const SkRRect& rrect, SkMask* mask, |
| 28 | SkResourceCache* localCache = nullptr); |
| 29 | static SkCachedData* FindAndRef(SkScalar sigma, SkBlurStyle style, |
| 30 | const SkRect rects[], int count, SkMask* mask, |
| 31 | SkResourceCache* localCache = nullptr); |
| 32 | |
| 33 | /** |
| 34 | * Add a mask and its pixel-data to the cache. |
| 35 | */ |
| 36 | static void Add(SkScalar sigma, SkBlurStyle style, |
| 37 | const SkRRect& rrect, const SkMask& mask, SkCachedData* data, |
| 38 | SkResourceCache* localCache = nullptr); |
| 39 | static void Add(SkScalar sigma, SkBlurStyle style, |
| 40 | const SkRect rects[], int count, const SkMask& mask, SkCachedData* data, |
| 41 | SkResourceCache* localCache = nullptr); |
| 42 | }; |
| 43 | |
| 44 | #endif |
| 45 | |