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 "SkImageFilter.h" 12 13 class SK_API SkTileImageFilter : public SkImageFilter { 14 public: 15 /** Create a tile image filter 16 @param src Defines the pixels to tile 17 @param dst Defines the pixels where tiles are drawn 18 @param input Input from which the subregion defined by srcRect will be tiled 19 */ 20 static sk_sp<SkImageFilter> Make(const SkRect& src, 21 const SkRect& dst, 22 sk_sp<SkImageFilter> input); 23 24 SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override; 25 SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override; 26 SkRect computeFastBounds(const SkRect& src) const override; 27 28 SK_TO_STRING_OVERRIDE() 29 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTileImageFilter) 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 37 private: SkTileImageFilter(const SkRect & srcRect,const SkRect & dstRect,sk_sp<SkImageFilter> input)38 SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, sk_sp<SkImageFilter> input) 39 : INHERITED(&input, 1, nullptr), fSrcRect(srcRect), fDstRect(dstRect) {} 40 41 SkRect fSrcRect; 42 SkRect fDstRect; 43 44 typedef SkImageFilter INHERITED; 45 }; 46 47 #endif 48