1 /* 2 Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> 3 2009 Dirk Schulze <krit@webkit.org> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Library General Public 7 License as published by the Free Software Foundation; either 8 version 2 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Library General Public License for more details. 14 15 You should have received a copy of the GNU Library General Public License 16 aint with this library; see the file COPYING.LIB. If not, write to 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef FilterEffect_h 22 #define FilterEffect_h 23 24 #if ENABLE(FILTERS) 25 #include "Filter.h" 26 #include "FloatRect.h" 27 #include "GraphicsContext.h" 28 #include "ImageBuffer.h" 29 #include "TextStream.h" 30 31 #include <wtf/PassOwnPtr.h> 32 #include <wtf/RefCounted.h> 33 #include <wtf/RefPtr.h> 34 35 namespace WebCore { 36 37 class FilterEffect : public RefCounted<FilterEffect> { 38 public: 39 virtual ~FilterEffect(); 40 xBoundingBoxMode()41 bool xBoundingBoxMode() const { return m_xBBoxMode; } setXBoundingBoxMode(bool bboxMode)42 void setXBoundingBoxMode(bool bboxMode) { m_xBBoxMode = bboxMode; } 43 yBoundingBoxMode()44 bool yBoundingBoxMode() const { return m_yBBoxMode; } setYBoundingBoxMode(bool bboxMode)45 void setYBoundingBoxMode(bool bboxMode) { m_yBBoxMode = bboxMode; } 46 widthBoundingBoxMode()47 bool widthBoundingBoxMode() const { return m_widthBBoxMode; } setWidthBoundingBoxMode(bool bboxMode)48 void setWidthBoundingBoxMode(bool bboxMode) { m_widthBBoxMode = bboxMode; } 49 heightBoundingBoxMode()50 bool heightBoundingBoxMode() const { return m_heightBBoxMode; } setHeightBoundingBoxMode(bool bboxMode)51 void setHeightBoundingBoxMode(bool bboxMode) { m_heightBBoxMode = bboxMode; } 52 setUnionOfChildEffectSubregions(const FloatRect & uniteRect)53 void setUnionOfChildEffectSubregions(const FloatRect& uniteRect) { m_unionOfChildEffectSubregions = uniteRect; } unionOfChildEffectSubregions()54 FloatRect unionOfChildEffectSubregions() const { return m_unionOfChildEffectSubregions; } 55 subRegion()56 FloatRect subRegion() const { return m_subRegion; } setSubRegion(const FloatRect & subRegion)57 void setSubRegion(const FloatRect& subRegion) { m_subRegion = subRegion; } 58 hasX()59 bool hasX() { return m_hasX; } setHasX(bool value)60 void setHasX(bool value) { m_hasX = value; } 61 hasY()62 bool hasY() { return m_hasY; } setHasY(bool value)63 void setHasY(bool value) { m_hasY = value; } 64 hasWidth()65 bool hasWidth() { return m_hasWidth; } setHasWidth(bool value)66 void setHasWidth(bool value) { m_hasWidth = value; } 67 hasHeight()68 bool hasHeight() { return m_hasHeight; } setHasHeight(bool value)69 void setHasHeight(bool value) { m_hasHeight = value; } 70 71 // The result is bounded by the size of the filter primitive to save resources resultImage()72 ImageBuffer* resultImage() { return m_effectBuffer.get(); } setEffectBuffer(PassOwnPtr<ImageBuffer> effectBuffer)73 void setEffectBuffer(PassOwnPtr<ImageBuffer> effectBuffer) { m_effectBuffer = effectBuffer; } 74 75 FloatRect calculateUnionOfChildEffectSubregions(Filter*, FilterEffect*, FilterEffect*); 76 FloatRect calculateUnionOfChildEffectSubregions(Filter*, FilterEffect*); 77 78 GraphicsContext* getEffectContext(); 79 FloatRect calculateDrawingRect(const FloatRect&); 80 uniteChildEffectSubregions(Filter * filter)81 virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return filter->filterRegion(); } 82 virtual FloatRect calculateEffectRect(Filter*); 83 virtual void apply(Filter*) = 0; 84 virtual void dump() = 0; 85 isSourceInput()86 virtual bool isSourceInput() { return false; } 87 88 virtual TextStream& externalRepresentation(TextStream&) const; 89 protected: 90 FilterEffect(); 91 92 private: 93 94 bool m_xBBoxMode : 1; 95 bool m_yBBoxMode : 1; 96 bool m_widthBBoxMode : 1; 97 bool m_heightBBoxMode : 1; 98 99 bool m_hasX : 1; 100 bool m_hasY : 1; 101 bool m_hasWidth : 1; 102 bool m_hasHeight : 1; 103 104 FloatRect m_subRegion; 105 FloatRect m_unionOfChildEffectSubregions; 106 107 mutable OwnPtr<ImageBuffer> m_effectBuffer; 108 }; 109 110 } // namespace WebCore 111 112 #endif // ENABLE(FILTERS) 113 114 #endif // FilterEffect_h 115