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.
24 #ifndef RenderSVGResourceFilter_h
25 #define RenderSVGResourceFilter_h
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"
35 WTF_MAKE_FAST_ALLOCATED;
37 enum FilterDataState { PaintingSource, Applying, Built, CycleDetected };
40 : state(PaintingSource)
44 RefPtr<SVGFilter> filter;
45 RefPtr<SVGFilterBuilder> builder;
47 FloatRect drawingRegion;
48 FilterDataState state;
51 class GraphicsContext;
53 class RenderSVGResourceFilter FINAL : public RenderSVGResourceContainer {
55 explicit RenderSVGResourceFilter(SVGFilterElement*);
56 virtual ~RenderSVGResourceFilter();
57 virtual void destroy() OVERRIDE;
59 virtual bool isChildAllowed(RenderObject*, RenderStyle*) const OVERRIDE;
61 virtual const char* renderName() const OVERRIDE { return "RenderSVGResourceFilter"; }
62 virtual bool isSVGResourceFilter() const OVERRIDE { return true; }
64 virtual void removeAllClientsFromCache(bool markForInvalidation = true) OVERRIDE;
65 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true) OVERRIDE;
67 virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode) OVERRIDE;
68 virtual void postApplyResource(RenderObject*, GraphicsContext*&) OVERRIDE;
70 FloatRect resourceBoundingBox(const RenderObject*);
72 PassRefPtr<SVGFilterBuilder> buildPrimitives(SVGFilter*);
74 SVGUnitTypes::SVGUnitType filterUnits() const { return toSVGFilterElement(element())->filterUnits()->currentValue()->enumValue(); }
75 SVGUnitTypes::SVGUnitType primitiveUnits() const { return toSVGFilterElement(element())->primitiveUnits()->currentValue()->enumValue(); }
77 void primitiveAttributeChanged(RenderObject*, const QualifiedName&);
79 virtual RenderSVGResourceType resourceType() const OVERRIDE { return s_resourceType; }
80 static const RenderSVGResourceType s_resourceType;
82 FloatRect drawingRegion(RenderObject*) const;
84 typedef HashMap<RenderObject*, OwnPtr<FilterData> > FilterMap;
88 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderSVGResourceFilter, isSVGResourceFilter());