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#include "core/rendering/svg/RenderSVGResourceContainer.h" 28#include "core/svg/SVGFilterElement.h" 29#include "core/svg/graphics/filters/SVGFilter.h" 30#include "core/svg/graphics/filters/SVGFilterBuilder.h" 31 32namespace blink { 33 34struct FilterData { 35 WTF_MAKE_FAST_ALLOCATED; 36public: 37 enum FilterDataState { PaintingSource, Applying, Built, CycleDetected }; 38 39 FilterData() 40 : state(PaintingSource) 41 { 42 } 43 44 RefPtr<SVGFilter> filter; 45 RefPtr<SVGFilterBuilder> builder; 46 FloatRect boundaries; 47 FloatRect drawingRegion; 48 FilterDataState state; 49}; 50 51class GraphicsContext; 52 53class RenderSVGResourceFilter FINAL : public RenderSVGResourceContainer { 54public: 55 explicit RenderSVGResourceFilter(SVGFilterElement*); 56 virtual ~RenderSVGResourceFilter(); 57 virtual void destroy() OVERRIDE; 58 59 virtual bool isChildAllowed(RenderObject*, RenderStyle*) const OVERRIDE; 60 61 virtual const char* renderName() const OVERRIDE { return "RenderSVGResourceFilter"; } 62 virtual bool isSVGResourceFilter() const OVERRIDE { return true; } 63 64 virtual void removeAllClientsFromCache(bool markForInvalidation = true) OVERRIDE; 65 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true) OVERRIDE; 66 67 virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode) OVERRIDE; 68 virtual void postApplyResource(RenderObject*, GraphicsContext*&) OVERRIDE; 69 70 FloatRect resourceBoundingBox(const RenderObject*); 71 72 PassRefPtr<SVGFilterBuilder> buildPrimitives(SVGFilter*); 73 74 SVGUnitTypes::SVGUnitType filterUnits() const { return toSVGFilterElement(element())->filterUnits()->currentValue()->enumValue(); } 75 SVGUnitTypes::SVGUnitType primitiveUnits() const { return toSVGFilterElement(element())->primitiveUnits()->currentValue()->enumValue(); } 76 77 void primitiveAttributeChanged(RenderObject*, const QualifiedName&); 78 79 virtual RenderSVGResourceType resourceType() const OVERRIDE { return s_resourceType; } 80 static const RenderSVGResourceType s_resourceType; 81 82 FloatRect drawingRegion(RenderObject*) const; 83private: 84 typedef HashMap<RenderObject*, OwnPtr<FilterData> > FilterMap; 85 FilterMap m_filter; 86}; 87 88DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderSVGResourceFilter, isSVGResourceFilter()); 89 90} 91 92#endif 93