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) 2009 Dirk Schulze <krit@webkit.org>
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
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.
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.
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.
30 #include "GraphicsContext.h"
31 #include "RenderTreeAsText.h"
32 #include "TextStream.h"
36 FEOffset::FEOffset(Filter* filter, float dx, float dy)
37 : FilterEffect(filter)
43 PassRefPtr<FEOffset> FEOffset::create(Filter* filter, float dx, float dy)
45 return adoptRef(new FEOffset(filter, dx, dy));
48 float FEOffset::dx() const
53 void FEOffset::setDx(float dx)
58 float FEOffset::dy() const
63 void FEOffset::setDy(float dy)
68 void FEOffset::determineAbsolutePaintRect()
70 FloatRect paintRect = inputEffect(0)->absolutePaintRect();
71 Filter* filter = this->filter();
72 paintRect.move(filter->applyHorizontalScale(m_dx), filter->applyVerticalScale(m_dy));
73 paintRect.intersect(maxEffectRect());
74 setAbsolutePaintRect(enclosingIntRect(paintRect));
77 void FEOffset::apply()
81 FilterEffect* in = inputEffect(0);
86 ImageBuffer* resultImage = createImageBufferResult();
90 setIsAlphaImage(in->isAlphaImage());
92 FloatRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect());
93 Filter* filter = this->filter();
94 drawingRegion.move(filter->applyHorizontalScale(m_dx), filter->applyVerticalScale(m_dy));
95 resultImage->context()->drawImageBuffer(in->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegion);
102 TextStream& FEOffset::externalRepresentation(TextStream& ts, int indent) const
104 writeIndent(ts, indent);
106 FilterEffect::externalRepresentation(ts);
107 ts << " dx=\"" << dx() << "\" dy=\"" << dy() << "\"]\n";
108 inputEffect(0)->externalRepresentation(ts, indent + 1);
112 } // namespace WebCore
114 #endif // ENABLE(FILTERS)