RenderSVGResourceFilter.h revision 2fc2651226baac27029e38c9d6ef883fa32084db
1/* 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. 7 * 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. 12 * 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. 17 * 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. 22 */ 23 24#ifndef RenderSVGResourceFilter_h 25#define RenderSVGResourceFilter_h 26 27#if ENABLE(SVG) && ENABLE(FILTERS) 28#include "FloatRect.h" 29#include "ImageBuffer.h" 30#include "RenderSVGResourceContainer.h" 31#include "SVGFilter.h" 32#include "SVGFilterBuilder.h" 33#include "SVGFilterElement.h" 34#include "SVGUnitTypes.h" 35 36#include <wtf/OwnPtr.h> 37#include <wtf/PassOwnPtr.h> 38#include <wtf/RefPtr.h> 39 40namespace WebCore { 41 42struct FilterData { 43 FilterData() 44 : savedContext(0) 45 , builded(false) 46 { 47 } 48 49 RefPtr<SVGFilter> filter; 50 RefPtr<SVGFilterBuilder> builder; 51 OwnPtr<ImageBuffer> sourceGraphicBuffer; 52 GraphicsContext* savedContext; 53 AffineTransform shearFreeAbsoluteTransform; 54 FloatRect boundaries; 55 FloatSize scale; 56 bool builded; 57}; 58 59class GraphicsContext; 60 61class RenderSVGResourceFilter : public RenderSVGResourceContainer { 62public: 63 RenderSVGResourceFilter(SVGFilterElement*); 64 virtual ~RenderSVGResourceFilter(); 65 66 virtual const char* renderName() const { return "RenderSVGResourceFilter"; } 67 virtual bool isSVGResourceFilter() const { return true; } 68 69 virtual void removeAllClientsFromCache(bool markForInvalidation = true); 70 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true); 71 72 virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode); 73 virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode, const Path*); 74 75 virtual FloatRect resourceBoundingBox(RenderObject*); 76 77 PassRefPtr<SVGFilterBuilder> buildPrimitives(Filter*); 78 79 SVGUnitTypes::SVGUnitType filterUnits() const { return toUnitType(static_cast<SVGFilterElement*>(node())->filterUnits()); } 80 SVGUnitTypes::SVGUnitType primitiveUnits() const { return toUnitType(static_cast<SVGFilterElement*>(node())->primitiveUnits()); } 81 82 void primitiveAttributeChanged(RenderObject*, const QualifiedName&); 83 84 virtual RenderSVGResourceType resourceType() const { return s_resourceType; } 85 static RenderSVGResourceType s_resourceType; 86 87private: 88 bool fitsInMaximumImageSize(const FloatSize&, FloatSize&); 89 90 HashMap<RenderObject*, FilterData*> m_filter; 91}; 92 93} 94 95#endif 96#endif 97