1 /* 2 Copyright (C) Alex Mathews <possessedpenguinbob (at) 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 27 FilterEffect::FilterEffect() 28 : m_hasX(false) 29 , m_hasY(false) 30 , m_hasWidth(false) 31 , m_hasHeight(false) 32 , m_alphaImage(false) 33 { 34 } 35 36 FilterEffect::~FilterEffect() 37 { 38 } 39 40 FloatRect FilterEffect::calculateUnionOfChildEffectSubregions(Filter* filter, FilterEffect* in) 41 { 42 return in->calculateEffectRect(filter); 43 } 44 45 FloatRect FilterEffect::calculateUnionOfChildEffectSubregions(Filter* filter, FilterEffect* in, FilterEffect* in2) 46 { 47 FloatRect uniteEffectRect = in->calculateEffectRect(filter); 48 uniteEffectRect.unite(in2->calculateEffectRect(filter)); 49 return uniteEffectRect; 50 } 51 52 FloatRect FilterEffect::calculateEffectRect(Filter* filter) 53 { 54 setUnionOfChildEffectSubregions(uniteChildEffectSubregions(filter)); 55 filter->calculateEffectSubRegion(this); 56 return subRegion(); 57 } 58 59 IntRect FilterEffect::calculateDrawingIntRect(const FloatRect& effectRect) 60 { 61 IntPoint location = roundedIntPoint(FloatPoint(scaledSubRegion().x() - effectRect.x(), 62 scaledSubRegion().y() - effectRect.y())); 63 return IntRect(location, resultImage()->size()); 64 } 65 66 FloatRect FilterEffect::calculateDrawingRect(const FloatRect& srcRect) 67 { 68 FloatPoint startPoint = FloatPoint(srcRect.x() - scaledSubRegion().x(), srcRect.y() - scaledSubRegion().y()); 69 FloatRect drawingRect = FloatRect(startPoint, srcRect.size()); 70 return drawingRect; 71 } 72 73 GraphicsContext* FilterEffect::getEffectContext() 74 { 75 IntRect bufferRect = enclosingIntRect(scaledSubRegion()); 76 m_effectBuffer = ImageBuffer::create(bufferRect.size(), LinearRGB); 77 return m_effectBuffer->context(); 78 } 79 80 TextStream& FilterEffect::externalRepresentation(TextStream& ts) const 81 { 82 return ts; 83 } 84 85 } // namespace WebCore 86 87 #endif // ENABLE(FILTERS) 88