SkTileImageFilter.h revision 1a4fb70c8a04db2d92ec821555f91218a989031d
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 SkTileImageFilter : public SkImageFilter {
14    typedef SkImageFilter INHERITED;
15
16public:
17    /** Tile image filter constructor
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    SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input)
23        : INHERITED(input), fSrcRect(srcRect), fDstRect(dstRect) {}
24
25    virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
26                               SkBitmap* dst, SkIPoint* offset) SK_OVERRIDE;
27
28    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTileImageFilter)
29
30protected:
31    explicit SkTileImageFilter(SkFlattenableReadBuffer& buffer);
32
33    virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE;
34
35private:
36    SkRect fSrcRect;
37    SkRect fDstRect;
38};
39
40#endif
41