1 /*
2 Copyright (C) Alex Mathews <possessedpenguinbob@gmail.com>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 aint with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18 */
19
20 #include "config.h"
21
22 #if ENABLE(FILTERS)
23 #include "FilterEffect.h"
24
25 namespace WebCore {
26
FilterEffect()27 FilterEffect::FilterEffect()
28 : m_xBBoxMode(false)
29 , m_yBBoxMode(false)
30 , m_widthBBoxMode(false)
31 , m_heightBBoxMode(false)
32 , m_hasX(false)
33 , m_hasY(false)
34 , m_hasWidth(false)
35 , m_hasHeight(false)
36 {
37 }
38
~FilterEffect()39 FilterEffect::~FilterEffect()
40 {
41 }
42
calculateUnionOfChildEffectSubregions(Filter * filter,FilterEffect * in)43 FloatRect FilterEffect::calculateUnionOfChildEffectSubregions(Filter* filter, FilterEffect* in)
44 {
45 return in->calculateEffectRect(filter);
46 }
47
calculateUnionOfChildEffectSubregions(Filter * filter,FilterEffect * in,FilterEffect * in2)48 FloatRect FilterEffect::calculateUnionOfChildEffectSubregions(Filter* filter, FilterEffect* in, FilterEffect* in2)
49 {
50 FloatRect uniteEffectRect = in->calculateEffectRect(filter);
51 uniteEffectRect.unite(in2->calculateEffectRect(filter));
52 return uniteEffectRect;
53 }
54
calculateEffectRect(Filter * filter)55 FloatRect FilterEffect::calculateEffectRect(Filter* filter)
56 {
57 setUnionOfChildEffectSubregions(uniteChildEffectSubregions(filter));
58 filter->calculateEffectSubRegion(this);
59 return subRegion();
60 }
61
calculateDrawingRect(const FloatRect & srcRect)62 FloatRect FilterEffect::calculateDrawingRect(const FloatRect& srcRect)
63 {
64 FloatPoint startPoint = FloatPoint(srcRect.x() - subRegion().x(), srcRect.y() - subRegion().y());
65 FloatRect drawingRect = FloatRect(startPoint, srcRect.size());
66 return drawingRect;
67 }
68
getEffectContext()69 GraphicsContext* FilterEffect::getEffectContext()
70 {
71 IntRect bufferRect = enclosingIntRect(subRegion());
72 m_effectBuffer = ImageBuffer::create(bufferRect.size(), LinearRGB);
73 return m_effectBuffer->context();
74 }
75
externalRepresentation(TextStream & ts) const76 TextStream& FilterEffect::externalRepresentation(TextStream& ts) const
77 {
78 return ts;
79 }
80
81 } // namespace WebCore
82
83 #endif // ENABLE(FILTERS)
84