File indexing completed on 2024-05-12 15:39:15
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 SVGPaintServer_h 0027 #define SVGPaintServer_h 0028 0029 #if ENABLE(SVG) 0030 0031 #include "SVGResource.h" 0032 0033 #include "RenderObject.h" 0034 #include "RenderStyle.h" 0035 0036 #if PLATFORM(CG) 0037 #include <ApplicationServices/ApplicationServices.h> 0038 #endif 0039 0040 #if PLATFORM(QT) 0041 #include <qglobal.h> 0042 QT_BEGIN_NAMESPACE 0043 class QPen; 0044 QT_END_NAMESPACE 0045 #endif 0046 0047 #if PLATFORM(CG) 0048 typedef Vector<CGFloat> DashArray; 0049 #else 0050 typedef Vector<float> DashArray; 0051 #endif 0052 0053 namespace WebCore 0054 { 0055 0056 enum SVGPaintServerType { 0057 // Painting mode 0058 SolidPaintServer = 0, 0059 PatternPaintServer = 1, 0060 LinearGradientPaintServer = 2, 0061 RadialGradientPaintServer = 3 0062 }; 0063 0064 enum SVGPaintTargetType { 0065 // Target mode 0066 ApplyToFillTargetType = 1, 0067 ApplyToStrokeTargetType = 2 0068 }; 0069 0070 /*class GraphicsContext; 0071 class RenderObject; 0072 class RenderStyle;*/ 0073 class SVGPaintServerSolid; 0074 0075 class SVGPaintServer : public SVGResource 0076 { 0077 public: 0078 virtual ~SVGPaintServer(); 0079 0080 SVGResourceType resourceType() const override 0081 { 0082 return PaintServerResourceType; 0083 } 0084 0085 virtual SVGPaintServerType type() const = 0; 0086 /* FIXME khtml virtual TextStream& externalRepresentation(TextStream&) const = 0;*/ 0087 0088 // To be implemented in platform specific code. 0089 virtual void draw(QPainter *painter, QPainterPath *painterPath, const RenderObject *, SVGPaintTargetType) const; 0090 virtual void teardown(QPainter *painter, QPainterPath *painterPath, const RenderObject *, SVGPaintTargetType, bool isPaintingText = false) const; 0091 virtual void renderPath(QPainter *painter, QPainterPath *painterPath, const RenderObject *, SVGPaintTargetType) const; 0092 0093 virtual bool setup(QPainter *painter, QPainterPath *painterPath, const RenderObject *, SVGPaintTargetType, bool isPaintingText = false) const = 0; 0094 0095 static SVGPaintServer *strokePaintServer(const RenderStyle *, const RenderObject *); 0096 static SVGPaintServer *fillPaintServer(const RenderStyle *, const RenderObject *); 0097 static SVGPaintServerSolid *sharedSolidPaintServer(); 0098 0099 protected: 0100 #if PLATFORM(CG) 0101 void strokePath(CGContextRef, const RenderObject *) const; 0102 void clipToStrokePath(CGContextRef, const RenderObject *) const; 0103 void fillPath(CGContextRef, const RenderObject *) const; 0104 void clipToFillPath(CGContextRef, const RenderObject *) const; 0105 #endif 0106 0107 #if PLATFORM(QT) 0108 void setPenProperties(const RenderObject *, const RenderStyle *, QPen &) const; 0109 #endif 0110 protected: 0111 SVGPaintServer(); 0112 }; 0113 0114 /*khtml TextStream& operator<<(TextStream&, const SVGPaintServer&);*/ 0115 0116 SVGPaintServer *getPaintServerById(Document *, const AtomicString &); 0117 0118 DashArray dashArrayFromRenderingStyle(const RenderStyle *style); 0119 } // namespace WebCore 0120 0121 #endif 0122 0123 #endif // SVGPaintServer_h