• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2     Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3                   2004, 2005 Rob Buis <buis@kde.org>
4                   2005 Eric Seidel <eric@webkit.org>
5 
6     This library is free software; you can redistribute it and/or
7     modify it under the terms of the GNU Library General Public
8     License as published by the Free Software Foundation; either
9     version 2 of the License, or (at your option) any later version.
10 
11     This library is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14     Library General Public License for more details.
15 
16     You should have received a copy of the GNU Library General Public License
17     aint with this library; see the file COPYING.LIB.  If not, write to
18     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19     Boston, MA 02110-1301, USA.
20 */
21 
22 #ifndef SVGFEComponentTransfer_h
23 #define SVGFEComponentTransfer_h
24 
25 #if ENABLE(FILTERS)
26 #include "FilterEffect.h"
27 
28 #include "Filter.h"
29 #include <wtf/Vector.h>
30 
31 namespace WebCore {
32 
33     enum ComponentTransferType {
34         FECOMPONENTTRANSFER_TYPE_UNKNOWN  = 0,
35         FECOMPONENTTRANSFER_TYPE_IDENTITY = 1,
36         FECOMPONENTTRANSFER_TYPE_TABLE    = 2,
37         FECOMPONENTTRANSFER_TYPE_DISCRETE = 3,
38         FECOMPONENTTRANSFER_TYPE_LINEAR   = 4,
39         FECOMPONENTTRANSFER_TYPE_GAMMA    = 5
40     };
41 
42     struct ComponentTransferFunction {
ComponentTransferFunctionComponentTransferFunction43         ComponentTransferFunction()
44             : type(FECOMPONENTTRANSFER_TYPE_UNKNOWN)
45             , slope(0.0f)
46             , intercept(0.0f)
47             , amplitude(0.0f)
48             , exponent(0.0f)
49             , offset(0.0f)
50         {
51         }
52 
53         ComponentTransferType type;
54 
55         float slope;
56         float intercept;
57         float amplitude;
58         float exponent;
59         float offset;
60 
61         Vector<float> tableValues;
62     };
63 
64     class FEComponentTransfer : public FilterEffect {
65     public:
66         static PassRefPtr<FEComponentTransfer> create(FilterEffect*, const ComponentTransferFunction&,
67                 const ComponentTransferFunction&, const ComponentTransferFunction&, const ComponentTransferFunction&);
68 
69         ComponentTransferFunction redFunction() const;
70         void setRedFunction(const ComponentTransferFunction&);
71 
72         ComponentTransferFunction greenFunction() const;
73         void setGreenFunction(const ComponentTransferFunction&);
74 
75         ComponentTransferFunction blueFunction() const;
76         void setBlueFunction(const ComponentTransferFunction&);
77 
78         ComponentTransferFunction alphaFunction() const;
79         void setAlphaFunction(const ComponentTransferFunction&);
80 
uniteChildEffectSubregions(Filter * filter)81         virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get()); }
82         void apply(Filter*);
83         void dump();
84 
85     private:
86         FEComponentTransfer(FilterEffect*,const ComponentTransferFunction&, const ComponentTransferFunction&,
87                 const ComponentTransferFunction&, const ComponentTransferFunction&);
88 
89         RefPtr<FilterEffect> m_in;
90         ComponentTransferFunction m_redFunc;
91         ComponentTransferFunction m_greenFunc;
92         ComponentTransferFunction m_blueFunc;
93         ComponentTransferFunction m_alphaFunc;
94     };
95 
96 } // namespace WebCore
97 
98 #endif // ENABLE(FILTERS)
99 
100 #endif // SVGFEComponentTransfer_h
101