File indexing completed on 2024-05-12 15:39:16

0001 /*
0002  * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
0003  *
0004  * Redistribution and use in source and binary forms, with or without
0005  * modification, are permitted provided that the following conditions
0006  * are met:
0007  * 1. Redistributions of source code must retain the above copyright
0008  *    notice, this list of conditions and the following disclaimer.
0009  * 2. Redistributions in binary form must reproduce the above copyright
0010  *    notice, this list of conditions and the following disclaimer in the
0011  *    documentation and/or other materials provided with the distribution.
0012  *
0013  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
0014  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0015  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
0016  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
0017  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
0018  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
0019  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
0020  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
0021  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0022  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0023  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0024  */
0025 
0026 #ifndef SVGResourceClipper_h
0027 #define SVGResourceClipper_h
0028 
0029 #if ENABLE(SVG)
0030 
0031 #include "SVGResource.h"
0032 #include "Path.h"
0033 
0034 // khtml
0035 #include "wtf/PassRefPtr.h"
0036 
0037 namespace WebCore
0038 {
0039 
0040 struct ClipData {
0041     Path path;
0042     WindRule windRule;
0043     bool bboxUnits : 1;
0044 };
0045 
0046 class ClipDataList
0047 {
0048 public:
0049     void addPath(const Path &pathData, WindRule windRule, bool bboxUnits)
0050     {
0051         ClipData clipData;
0052 
0053         clipData.path = pathData;
0054         clipData.windRule = windRule;
0055         clipData.bboxUnits = bboxUnits;
0056 
0057         m_clipData.append(clipData);
0058     }
0059 
0060     void clear()
0061     {
0062         m_clipData.clear();
0063     }
0064     const Vector<ClipData> &clipData() const
0065     {
0066         return m_clipData;
0067     }
0068     bool isEmpty() const
0069     {
0070         return m_clipData.isEmpty();
0071     }
0072 private:
0073     Vector<ClipData> m_clipData;
0074 };
0075 
0076 /*class GraphicsContext;*/
0077 
0078 class SVGResourceClipper : public SVGResource
0079 {
0080 public:
0081     static PassRefPtr<SVGResourceClipper> create()
0082     {
0083         return adoptRef(new SVGResourceClipper);
0084     }
0085     virtual ~SVGResourceClipper();
0086 
0087     void resetClipData();
0088     void addClipData(const Path &, WindRule, bool bboxUnits);
0089 
0090     const ClipDataList &clipData() const;
0091 
0092     SVGResourceType resourceType() const override
0093     {
0094         return ClipperResourceType;
0095     }
0096     /*virtual TextStream& externalRepresentation(TextStream&) const;*/
0097 
0098     // To be implemented by the specific rendering devices
0099     void applyClip(/*GraphicsContext**/QPainter *painter, const FloatRect &boundingBox) const;
0100 private:
0101     SVGResourceClipper();
0102     ClipDataList m_clipData;
0103 };
0104 
0105 /*TextStream& operator<<(TextStream&, WindRule);
0106 TextStream& operator<<(TextStream&, const ClipData&);*/
0107 
0108 SVGResourceClipper *getClipperById(Document *, const AtomicString &);
0109 
0110 } // namespace WebCore
0111 
0112 #endif
0113 
0114 #endif // SVGResourceClipper_h