SkRectShaderImageFilter.h revision 33e88b7b93e3b5282b205359368990d3f8b3fd04
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 SkRectShaderImageFilter_DEFINED
9#define SkRectShaderImageFilter_DEFINED
10
11#include "SkImageFilter.h"
12#include "SkRect.h"
13
14class SkShader;
15
16class SK_API SkRectShaderImageFilter : public SkImageFilter {
17public:
18    /** Create a new image filter which fills the given rectangle with pixels
19     *  produced by the given SkShader. If no rectangle is specified, an output
20     *  is produced with the same bounds as the input primitive (even though
21     *  the input primitive's pixels are not used for processing).
22     *  @param s     Shader to call for processing. Cannot be NULL. Will be
23     *               ref'ed by the new image filter.
24     *  @param rect  Rectangle of output pixels in which to apply the shader.
25     *               If NULL or a given crop edge is not specified, the source
26     *               primitive's bounds are used instead.
27     */
28    /* DEPRECATED */ static SkRectShaderImageFilter* Create(SkShader* s, const SkRect& rect);
29    static SkRectShaderImageFilter* Create(SkShader* s, const CropRect* rect = NULL);
30    virtual ~SkRectShaderImageFilter();
31
32    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRectShaderImageFilter)
33
34protected:
35    SkRectShaderImageFilter(SkFlattenableReadBuffer& buffer);
36    virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
37
38    virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
39                               SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;
40
41private:
42    SkRectShaderImageFilter(SkShader* s, const CropRect* rect);
43    SkShader*  fShader;
44
45    typedef SkImageFilter INHERITED;
46};
47
48#endif
49