• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2013 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 SkTileImageFilter_DEFINED
9 #define SkTileImageFilter_DEFINED
10 
11 #include "SkFlattenable.h"
12 #include "SkImageFilter.h"
13 
14 class SK_API SkTileImageFilter : public SkImageFilter {
15 public:
16     /** Create a tile image filter
17         @param src  Defines the pixels to tile
18         @param dst  Defines the pixels where tiles are drawn
19         @param input    Input from which the subregion defined by srcRect will be tiled
20     */
21     static sk_sp<SkImageFilter> Make(const SkRect& src,
22                                      const SkRect& dst,
23                                      sk_sp<SkImageFilter> input);
24 
25     SkIRect onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
26                            MapDirection, const SkIRect* inputRect) const override;
27     SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm,
28                                MapDirection, const SkIRect* inputRect) const override;
29     SkRect computeFastBounds(const SkRect& src) const override;
30 
31 protected:
32     void flatten(SkWriteBuffer& buffer) const override;
33 
34     sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
35                                         SkIPoint* offset) const override;
36     sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
37 
38 private:
SK_FLATTENABLE_HOOKS(SkTileImageFilter)39     SK_FLATTENABLE_HOOKS(SkTileImageFilter)
40 
41     SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, sk_sp<SkImageFilter> input)
42         : INHERITED(&input, 1, nullptr), fSrcRect(srcRect), fDstRect(dstRect) {}
43 
44     SkRect fSrcRect;
45     SkRect fDstRect;
46 
47     typedef SkImageFilter INHERITED;
48 };
49 
50 #endif
51