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/SkScalar.h" 12 13 class SkCachedData; 14 class SkRRect; 15 class SkResourceCache; 16 enum SkBlurStyle : int; 17 struct SkMask; 18 struct SkRect; 19 template <typename T> class SkTLazy; 20 21 class SkMaskCache { 22 public: 23 /** 24 * On success, return a ref to the SkCachedData that holds the pixels, and have mask 25 * already point to that memory. 26 * 27 * On failure, return nullptr. 28 */ 29 static SkCachedData* FindAndRef(SkScalar sigma, SkBlurStyle style, 30 const SkRRect& rrect, SkTLazy<SkMask>* mask, 31 SkResourceCache* localCache = nullptr); 32 static SkCachedData* FindAndRef(SkScalar sigma, SkBlurStyle style, 33 const SkRect rects[], int count, SkTLazy<SkMask>* mask, 34 SkResourceCache* localCache = nullptr); 35 36 /** 37 * Add a mask and its pixel-data to the cache. 38 */ 39 static void Add(SkScalar sigma, SkBlurStyle style, 40 const SkRRect& rrect, const SkMask& mask, SkCachedData* data, 41 SkResourceCache* localCache = nullptr); 42 static void Add(SkScalar sigma, SkBlurStyle style, 43 const SkRect rects[], int count, const SkMask& mask, SkCachedData* data, 44 SkResourceCache* localCache = nullptr); 45 }; 46 47 #endif 48