aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/effects/SkRectShaderImageFilter.h
blob: c4311db43ee6fd81accd695fc4d4d14f2f550c6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * Copyright 2013 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkRectShaderImageFilter_DEFINED
#define SkRectShaderImageFilter_DEFINED

#include "SkImageFilter.h"
#include "SkRect.h"

class SkShader;

class SK_API SkRectShaderImageFilter : public SkImageFilter {
public:
    /** Create a new image filter which fills the given rectangle with pixels
     *  produced by the given SkShader. If no rectangle is specified, an output
     *  is produced with the same bounds as the input primitive (even though
     *  the input primitive's pixels are not used for processing).
     *  @param s     Shader to call for processing. Cannot be NULL. Will be
     *               ref'ed by the new image filter.
     *  @param rect  Rectangle of output pixels in which to apply the shader.
     *               If NULL or a given crop edge is not specified, the source
     *               primitive's bounds are used instead.
     */
    SK_ATTR_DEPRECATED("use Create(SkShader*, const CropRect*)")
    static SkRectShaderImageFilter* Create(SkShader* s, const SkRect& rect);

    static SkRectShaderImageFilter* Create(SkShader* s, const CropRect* rect = NULL, uint32_t uniqueID = 0);
    virtual ~SkRectShaderImageFilter();

    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRectShaderImageFilter)

protected:
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
    SkRectShaderImageFilter(SkReadBuffer& buffer);
#endif
    virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;

    virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
                               SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;

private:
    SkRectShaderImageFilter(SkShader* s, const CropRect* rect, uint32_t uniqueID = 0);
    SkShader*  fShader;

    typedef SkImageFilter INHERITED;
};

#endif