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, MarkedForRemoval };
41 , state(PaintingSource)
45 RefPtr<SVGFilter> filter;
46 RefPtr<SVGFilterBuilder> builder;
47 OwnPtr<ImageBuffer> sourceGraphicBuffer;
48 GraphicsContext* savedContext;
49 AffineTransform shearFreeAbsoluteTransform;
51 FloatRect drawingRegion;
53 FilterDataState state;
56 class GraphicsContext;
58 class RenderSVGResourceFilter FINAL : public RenderSVGResourceContainer {
60 explicit RenderSVGResourceFilter(SVGFilterElement*);
61 virtual ~RenderSVGResourceFilter();
63 virtual bool isChildAllowed(RenderObject*, RenderStyle*) const OVERRIDE;
65 virtual const char* renderName() const OVERRIDE { return "RenderSVGResourceFilter"; }
66 virtual bool isSVGResourceFilter() const OVERRIDE { return true; }
68 virtual void removeAllClientsFromCache(bool markForInvalidation = true) OVERRIDE;
69 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true) OVERRIDE;
71 virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode) OVERRIDE;
72 virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode, const Path*, const RenderSVGShape*) OVERRIDE;
74 FloatRect resourceBoundingBox(const RenderObject*);
76 PassRefPtr<SVGFilterBuilder> buildPrimitives(SVGFilter*);
78 SVGUnitTypes::SVGUnitType filterUnits() const { return toSVGFilterElement(element())->filterUnits()->currentValue()->enumValue(); }
79 SVGUnitTypes::SVGUnitType primitiveUnits() const { return toSVGFilterElement(element())->primitiveUnits()->currentValue()->enumValue(); }
81 void primitiveAttributeChanged(RenderObject*, const QualifiedName&);
83 virtual RenderSVGResourceType resourceType() const OVERRIDE { return s_resourceType; }
84 static const RenderSVGResourceType s_resourceType;
86 FloatRect drawingRegion(RenderObject*) const;
88 void adjustScaleForMaximumImageSize(const FloatSize&, FloatSize&);
90 typedef HashMap<RenderObject*, OwnPtr<FilterData> > FilterMap;
93 HashSet<RenderObject*> m_objects;
96 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderSVGResourceFilter, isSVGResourceFilter());