• 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                   2009 Dirk Schulze <krit@webkit.org>
6 
7     This library is free software; you can redistribute it and/or
8     modify it under the terms of the GNU Library General Public
9     License as published by the Free Software Foundation; either
10     version 2 of the License, or (at your option) any later version.
11 
12     This library is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15     Library General Public License for more details.
16 
17     You should have received a copy of the GNU Library General Public License
18     aint with this library; see the file COPYING.LIB.  If not, write to
19     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20     Boston, MA 02110-1301, USA.
21 */
22 
23 #include "config.h"
24 
25 #if ENABLE(SVG) && ENABLE(FILTERS)
26 #include "SVGFEFlood.h"
27 
28 #include "Filter.h"
29 #include "GraphicsContext.h"
30 #include "SVGRenderTreeAsText.h"
31 
32 namespace WebCore {
33 
FEFlood(FilterEffect * in,const Color & floodColor,const float & floodOpacity)34 FEFlood::FEFlood(FilterEffect* in, const Color& floodColor, const float& floodOpacity)
35     : FilterEffect()
36     , m_in(in)
37     , m_floodColor(floodColor)
38     , m_floodOpacity(floodOpacity)
39 {
40 }
41 
create(FilterEffect * in,const Color & floodColor,const float & floodOpacity)42 PassRefPtr<FEFlood> FEFlood::create(FilterEffect* in, const Color& floodColor, const float& floodOpacity)
43 {
44     return adoptRef(new FEFlood(in, floodColor, floodOpacity));
45 }
46 
floodColor() const47 Color FEFlood::floodColor() const
48 {
49     return m_floodColor;
50 }
51 
setFloodColor(const Color & color)52 void FEFlood::setFloodColor(const Color& color)
53 {
54     m_floodColor = color;
55 }
56 
floodOpacity() const57 float FEFlood::floodOpacity() const
58 {
59     return m_floodOpacity;
60 }
61 
setFloodOpacity(float floodOpacity)62 void FEFlood::setFloodOpacity(float floodOpacity)
63 {
64     m_floodOpacity = floodOpacity;
65 }
66 
apply(Filter *)67 void FEFlood::apply(Filter*)
68 {
69     GraphicsContext* filterContext = getEffectContext();
70     if (!filterContext)
71         return;
72 
73     Color color = colorWithOverrideAlpha(floodColor().rgb(), floodOpacity());
74     filterContext->fillRect(FloatRect(FloatPoint(), subRegion().size()), color);
75 }
76 
dump()77 void FEFlood::dump()
78 {
79 }
80 
externalRepresentation(TextStream & ts) const81 TextStream& FEFlood::externalRepresentation(TextStream& ts) const
82 {
83     ts << "[type=FLOOD] ";
84     FilterEffect::externalRepresentation(ts);
85     ts << " [color=" << floodColor() << "]"
86         << " [opacity=" << floodOpacity() << "]";
87     return ts;
88 }
89 
90 } // namespace WebCore
91 
92 #endif // ENABLE(SVG) && ENABLE(FILTERS)
93