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 13class SK_API SkTileImageFilter : public SkImageFilter { 14 typedef SkImageFilter INHERITED; 15 16public: 17 /** Create a tile image filter 18 @param srcRect Defines the pixels to tile 19 @param dstRect Defines the pixels where tiles are drawn 20 @param input Input from which the subregion defined by srcRect will be tiled 21 */ 22 static SkTileImageFilter* Create(const SkRect& srcRect, const SkRect& dstRect, 23 SkImageFilter* input) { 24 return SkNEW_ARGS(SkTileImageFilter, (srcRect, dstRect, input)); 25 } 26 27 virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const Context& ctx, 28 SkBitmap* dst, SkIPoint* offset) const SK_OVERRIDE; 29 virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&, 30 SkIRect* dst) const SK_OVERRIDE; 31 32 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTileImageFilter) 33 34protected: 35 SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input) 36 : INHERITED(input), fSrcRect(srcRect), fDstRect(dstRect) {} 37 explicit SkTileImageFilter(SkReadBuffer& buffer); 38 39 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; 40 41private: 42 SkRect fSrcRect; 43 SkRect fDstRect; 44}; 45 46#endif 47