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