Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / platform / graphics / filters / FEConvolveMatrix.h
1 /*
2  * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3  * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
4  * Copyright (C) 2005 Eric Seidel <eric@webkit.org>
5  * Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org>
6  * Copyright (C) 2013 Google Inc. All rights reserved.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB.  If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23
24 #ifndef FEConvolveMatrix_h
25 #define FEConvolveMatrix_h
26
27 #include "platform/geometry/FloatPoint.h"
28 #include "platform/geometry/FloatSize.h"
29 #include "platform/graphics/filters/Filter.h"
30 #include "platform/graphics/filters/FilterEffect.h"
31 #include "wtf/Vector.h"
32
33 namespace blink {
34
35 enum EdgeModeType {
36     EDGEMODE_UNKNOWN   = 0,
37     EDGEMODE_DUPLICATE = 1,
38     EDGEMODE_WRAP      = 2,
39     EDGEMODE_NONE      = 3
40 };
41
42 class PLATFORM_EXPORT FEConvolveMatrix : public FilterEffect {
43 public:
44     static PassRefPtr<FEConvolveMatrix> create(Filter*, const IntSize&,
45             float, float, const IntPoint&, EdgeModeType, const FloatPoint&,
46             bool, const Vector<float>&);
47
48     IntSize kernelSize() const;
49     void setKernelSize(const IntSize&);
50
51     const Vector<float>& kernel() const;
52     void setKernel(const Vector<float>&);
53
54     float divisor() const;
55     bool setDivisor(float);
56
57     float bias() const;
58     bool setBias(float);
59
60     IntPoint targetOffset() const;
61     bool setTargetOffset(const IntPoint&);
62
63     EdgeModeType edgeMode() const;
64     bool setEdgeMode(EdgeModeType);
65
66     FloatPoint kernelUnitLength() const;
67     bool setKernelUnitLength(const FloatPoint&);
68
69     bool preserveAlpha() const;
70     bool setPreserveAlpha(bool);
71
72     virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) override;
73
74     virtual FloatRect mapPaintRect(const FloatRect&, bool forward = true) override final;
75
76     virtual TextStream& externalRepresentation(TextStream&, int indention) const override;
77
78 private:
79
80     FEConvolveMatrix(Filter*, const IntSize&, float, float,
81             const IntPoint&, EdgeModeType, const FloatPoint&, bool, const Vector<float>&);
82
83     IntSize m_kernelSize;
84     float m_divisor;
85     float m_bias;
86     IntPoint m_targetOffset;
87     EdgeModeType m_edgeMode;
88     FloatPoint m_kernelUnitLength;
89     bool m_preserveAlpha;
90     Vector<float> m_kernelMatrix;
91 };
92
93 } // namespace blink
94
95 #endif // FEConvolveMatrix_h