oliver | 7cf2d68 | 2006-10-31 04:17:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #ifndef SVGResourceClipper_H |
| 27 | #define SVGResourceClipper_H |
| 28 | |
darin | 6de7ece | 2006-11-06 06:05:51 +0000 | [diff] [blame] | 29 | #ifdef SVG_SUPPORT |
| 30 | |
oliver | 7cf2d68 | 2006-10-31 04:17:43 +0000 | [diff] [blame] | 31 | #include "SVGResource.h" |
| 32 | #include "Path.h" |
| 33 | |
| 34 | namespace WebCore { |
| 35 | |
| 36 | struct ClipData { |
| 37 | Path path; |
| 38 | WindRule windRule; |
| 39 | bool bboxUnits : 1; |
| 40 | }; |
| 41 | |
andersca | 02b2f19 | 2006-11-16 21:22:48 +0000 | [diff] [blame] | 42 | class ClipDataList { |
oliver | 7cf2d68 | 2006-10-31 04:17:43 +0000 | [diff] [blame] | 43 | public: |
andersca | 02b2f19 | 2006-11-16 21:22:48 +0000 | [diff] [blame] | 44 | void addPath(const Path& pathData, WindRule windRule, bool bboxUnits) |
oliver | 7cf2d68 | 2006-10-31 04:17:43 +0000 | [diff] [blame] | 45 | { |
| 46 | ClipData clipData; |
andersca | 02b2f19 | 2006-11-16 21:22:48 +0000 | [diff] [blame] | 47 | |
oliver | 7cf2d68 | 2006-10-31 04:17:43 +0000 | [diff] [blame] | 48 | clipData.path = pathData; |
| 49 | clipData.windRule = windRule; |
| 50 | clipData.bboxUnits = bboxUnits; |
andersca | 02b2f19 | 2006-11-16 21:22:48 +0000 | [diff] [blame] | 51 | |
| 52 | m_clipData.append(clipData); |
oliver | 7cf2d68 | 2006-10-31 04:17:43 +0000 | [diff] [blame] | 53 | } |
andersca | 02b2f19 | 2006-11-16 21:22:48 +0000 | [diff] [blame] | 54 | |
| 55 | void clear() { m_clipData.clear(); } |
| 56 | const Vector<ClipData>& clipData() const { return m_clipData; } |
| 57 | private: |
| 58 | Vector<ClipData> m_clipData; |
| 59 | }; |
oliver | 7cf2d68 | 2006-10-31 04:17:43 +0000 | [diff] [blame] | 60 | |
zimmermann | b67995f | 2006-11-30 21:47:57 +0000 | [diff] [blame] | 61 | class GraphicsContext; |
| 62 | |
oliver | 7cf2d68 | 2006-10-31 04:17:43 +0000 | [diff] [blame] | 63 | class SVGResourceClipper : public SVGResource { |
| 64 | public: |
| 65 | SVGResourceClipper(); |
| 66 | virtual ~SVGResourceClipper(); |
| 67 | |
| 68 | void resetClipData(); |
| 69 | void addClipData(const Path&, WindRule, bool bboxUnits); |
| 70 | |
| 71 | const ClipDataList& clipData() const; |
| 72 | |
| 73 | virtual bool isClipper() const { return true; } |
| 74 | virtual TextStream& externalRepresentation(TextStream&) const; |
| 75 | |
| 76 | // To be implemented by the specific rendering devices |
zimmermann | b67995f | 2006-11-30 21:47:57 +0000 | [diff] [blame] | 77 | void applyClip(GraphicsContext*, const FloatRect& boundingBox) const; |
oliver | 7cf2d68 | 2006-10-31 04:17:43 +0000 | [diff] [blame] | 78 | |
| 79 | private: |
| 80 | ClipDataList m_clipData; |
| 81 | }; |
| 82 | |
| 83 | TextStream& operator<<(TextStream&, WindRule); |
| 84 | TextStream& operator<<(TextStream&, const ClipData&); |
| 85 | |
| 86 | SVGResourceClipper* getClipperById(Document*, const AtomicString&); |
| 87 | |
| 88 | } // namespace WebCore |
| 89 | |
darin | 6de7ece | 2006-11-06 06:05:51 +0000 | [diff] [blame] | 90 | #endif |
| 91 | |
oliver | 7cf2d68 | 2006-10-31 04:17:43 +0000 | [diff] [blame] | 92 | #endif // SVGResourceClipper_H |