blob: c100f161b840d5eaacbc0ab762b5c177c38eb303 [file] [log] [blame]
oliver7cf2d682006-10-31 04:17:43 +00001/*
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
darin6de7ece2006-11-06 06:05:51 +000029#ifdef SVG_SUPPORT
30
oliver7cf2d682006-10-31 04:17:43 +000031#include "SVGResource.h"
32#include "Path.h"
33
34namespace WebCore {
35
36 struct ClipData {
37 Path path;
38 WindRule windRule;
39 bool bboxUnits : 1;
40 };
41
andersca02b2f192006-11-16 21:22:48 +000042 class ClipDataList {
oliver7cf2d682006-10-31 04:17:43 +000043 public:
andersca02b2f192006-11-16 21:22:48 +000044 void addPath(const Path& pathData, WindRule windRule, bool bboxUnits)
oliver7cf2d682006-10-31 04:17:43 +000045 {
46 ClipData clipData;
andersca02b2f192006-11-16 21:22:48 +000047
oliver7cf2d682006-10-31 04:17:43 +000048 clipData.path = pathData;
49 clipData.windRule = windRule;
50 clipData.bboxUnits = bboxUnits;
andersca02b2f192006-11-16 21:22:48 +000051
52 m_clipData.append(clipData);
oliver7cf2d682006-10-31 04:17:43 +000053 }
andersca02b2f192006-11-16 21:22:48 +000054
55 void clear() { m_clipData.clear(); }
56 const Vector<ClipData>& clipData() const { return m_clipData; }
57 private:
58 Vector<ClipData> m_clipData;
59 };
oliver7cf2d682006-10-31 04:17:43 +000060
zimmermannb67995f2006-11-30 21:47:57 +000061 class GraphicsContext;
62
oliver7cf2d682006-10-31 04:17:43 +000063 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
zimmermannb67995f2006-11-30 21:47:57 +000077 void applyClip(GraphicsContext*, const FloatRect& boundingBox) const;
oliver7cf2d682006-10-31 04:17:43 +000078
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
darin6de7ece2006-11-06 06:05:51 +000090#endif
91
oliver7cf2d682006-10-31 04:17:43 +000092#endif // SVGResourceClipper_H