• 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(const Color & floodColor,const float & floodOpacity)34 FEFlood::FEFlood(const Color& floodColor, const float& floodOpacity)
35     : FilterEffect()
36     , m_floodColor(floodColor)
37     , m_floodOpacity(floodOpacity)
38 {
39 }
40 
create(const Color & floodColor,const float & floodOpacity)41 PassRefPtr<FEFlood> FEFlood::create(const Color& floodColor, const float& floodOpacity)
42 {
43     return adoptRef(new FEFlood(floodColor, floodOpacity));
44 }
45 
floodColor() const46 Color FEFlood::floodColor() const
47 {
48     return m_floodColor;
49 }
50 
setFloodColor(const Color & color)51 void FEFlood::setFloodColor(const Color& color)
52 {
53     m_floodColor = color;
54 }
55 
floodOpacity() const56 float FEFlood::floodOpacity() const
57 {
58     return m_floodOpacity;
59 }
60 
setFloodOpacity(float floodOpacity)61 void FEFlood::setFloodOpacity(float floodOpacity)
62 {
63     m_floodOpacity = floodOpacity;
64 }
65 
apply(Filter *)66 void FEFlood::apply(Filter*)
67 {
68     GraphicsContext* filterContext = getEffectContext();
69     if (!filterContext)
70         return;
71 
72     Color color = colorWithOverrideAlpha(floodColor().rgb(), floodOpacity());
73     filterContext->fillRect(FloatRect(FloatPoint(), scaledSubRegion().size()), color, DeviceColorSpace);
74 }
75 
dump()76 void FEFlood::dump()
77 {
78 }
79 
externalRepresentation(TextStream & ts) const80 TextStream& FEFlood::externalRepresentation(TextStream& ts) const
81 {
82     ts << "[type=FLOOD] ";
83     FilterEffect::externalRepresentation(ts);
84     ts << " [color=" << floodColor() << "]"
85         << " [opacity=" << floodOpacity() << "]";
86     return ts;
87 }
88 
89 } // namespace WebCore
90 
91 #endif // ENABLE(SVG) && ENABLE(FILTERS)
92