Home | History | Annotate | Download | only in svg
      1 /*
      2  * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann (at) kde.org>
      3  * Copyright (C) 2004, 2005 Rob Buis <buis (at) kde.org>
      4  * Copyright (C) 2005 Eric Seidel <eric (at) webkit.org>
      5  * Copyright (C) 2009 Dirk Schulze <krit (at) 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 
     40 namespace WebCore {
     41 
     42 struct FilterData {
     43     FilterData()
     44         : savedContext(0)
     45         , builded(false)
     46         , markedForRemoval(false)
     47     {
     48     }
     49 
     50     RefPtr<SVGFilter> filter;
     51     RefPtr<SVGFilterBuilder> builder;
     52     OwnPtr<ImageBuffer> sourceGraphicBuffer;
     53     GraphicsContext* savedContext;
     54     AffineTransform shearFreeAbsoluteTransform;
     55     FloatRect boundaries;
     56     FloatSize scale;
     57     bool builded : 1;
     58     bool markedForRemoval : 1;
     59 };
     60 
     61 class GraphicsContext;
     62 
     63 class RenderSVGResourceFilter : public RenderSVGResourceContainer {
     64 public:
     65     RenderSVGResourceFilter(SVGFilterElement*);
     66     virtual ~RenderSVGResourceFilter();
     67 
     68     virtual const char* renderName() const { return "RenderSVGResourceFilter"; }
     69     virtual bool isSVGResourceFilter() const { return true; }
     70 
     71     virtual void removeAllClientsFromCache(bool markForInvalidation = true);
     72     virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true);
     73 
     74     virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode);
     75     virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode, const Path*);
     76 
     77     virtual FloatRect resourceBoundingBox(RenderObject*);
     78 
     79     PassRefPtr<SVGFilterBuilder> buildPrimitives(Filter*);
     80 
     81     SVGUnitTypes::SVGUnitType filterUnits() const { return toUnitType(static_cast<SVGFilterElement*>(node())->filterUnits()); }
     82     SVGUnitTypes::SVGUnitType primitiveUnits() const { return toUnitType(static_cast<SVGFilterElement*>(node())->primitiveUnits()); }
     83 
     84     void primitiveAttributeChanged(RenderObject*, const QualifiedName&);
     85 
     86     virtual RenderSVGResourceType resourceType() const { return s_resourceType; }
     87     static RenderSVGResourceType s_resourceType;
     88 
     89 private:
     90     bool fitsInMaximumImageSize(const FloatSize&, FloatSize&);
     91 
     92     HashMap<RenderObject*, FilterData*> m_filter;
     93 };
     94 
     95 }
     96 
     97 #endif
     98 #endif
     99