Home | History | Annotate | Download | only in svg
      1 /*
      2  * Copyright (C) Research In Motion Limited 2010. All rights reserved.
      3  *
      4  * This library is free software; you can redistribute it and/or
      5  * modify it under the terms of the GNU Library General Public
      6  * License as published by the Free Software Foundation; either
      7  * version 2 of the License, or (at your option) any later version.
      8  *
      9  * This library is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12  * Library General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU Library General Public License
     15  * along with this library; see the file COPYING.LIB.  If not, write to
     16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     17  * Boston, MA 02110-1301, USA.
     18  */
     19 
     20 #ifndef SVGMarkerLayoutInfo_h
     21 #define SVGMarkerLayoutInfo_h
     22 
     23 #if ENABLE(SVG)
     24 #include "AffineTransform.h"
     25 #include "RenderObject.h"
     26 #include "SVGMarkerData.h"
     27 #include <wtf/Noncopyable.h>
     28 
     29 namespace WebCore {
     30 
     31 class Path;
     32 class RenderSVGResourceMarker;
     33 
     34 struct MarkerLayout {
     35     MarkerLayout(RenderSVGResourceMarker* markerObj = 0, AffineTransform matrixObj = AffineTransform())
     36         : marker(markerObj)
     37         , matrix(matrixObj)
     38     {
     39         ASSERT(marker);
     40     }
     41 
     42     RenderSVGResourceMarker* marker;
     43     AffineTransform matrix;
     44 };
     45 
     46 class SVGMarkerLayoutInfo {
     47     WTF_MAKE_NONCOPYABLE(SVGMarkerLayoutInfo);
     48 public:
     49     SVGMarkerLayoutInfo();
     50     ~SVGMarkerLayoutInfo();
     51 
     52     FloatRect calculateBoundaries(RenderSVGResourceMarker* startMarker, RenderSVGResourceMarker* midMarker, RenderSVGResourceMarker* endMarker, float strokeWidth, const Path&);
     53     void drawMarkers(PaintInfo&);
     54 
     55     // Used by static inline helper functions in SVGMarkerLayoutInfo.cpp
     56     SVGMarkerData& markerData() { return m_markerData; }
     57     RenderSVGResourceMarker* midMarker() const { return m_midMarker; }
     58     int& elementIndex() { return m_elementIndex; }
     59     void addLayoutedMarker(RenderSVGResourceMarker*, const FloatPoint& origin, float angle);
     60     void clear();
     61 
     62 private:
     63     RenderSVGResourceMarker* m_midMarker;
     64 
     65     // Used while layouting markers
     66     int m_elementIndex;
     67     SVGMarkerData m_markerData;
     68     float m_strokeWidth;
     69 
     70     // Holds the final computed result
     71     Vector<MarkerLayout> m_layout;
     72 };
     73 
     74 }
     75 
     76 #endif
     77 #endif
     78