26 #ifndef SVGPaintServerGradient_h
27 #define SVGPaintServerGradient_h
34 #include <wtf/RefCounted.h>
35 #include <wtf/RefPtr.h>
47 class SVGGradientElement;
50 enum SVGGradientSpreadMethod {
52 SPREADMETHOD_REFLECT = 2,
53 SPREADMETHOD_REPEAT = 3
56 typedef std::pair<float, QColor> SVGGradientStop;
59 class SVGPaintServerGradient :
public SVGPaintServer {
61 virtual ~SVGPaintServerGradient();
63 const Vector<SVGGradientStop>& gradientStops()
const;
64 void setGradientStops(
const Vector<SVGGradientStop>&);
66 SVGGradientSpreadMethod spreadMethod()
const;
67 void setGradientSpreadMethod(
const SVGGradientSpreadMethod&);
72 bool boundingBoxMode()
const;
73 void setBoundingBoxMode(
bool mode =
true);
75 AffineTransform gradientTransform()
const;
76 void setGradientTransform(
const AffineTransform&);
80 virtual bool setup(QPainter* painter, QPainterPath* path,
const RenderObject*, SVGPaintTargetType,
bool isPaintingText)
const;
82 virtual void teardown(GraphicsContext*&,
const RenderObject*, SVGPaintTargetType,
bool isPaintingText)
const;
83 virtual void renderPath(GraphicsContext*&,
const RenderObject*, SVGPaintTargetType)
const;
85 virtual void invalidate();
88 void updateQuartzGradientStopsCache(
const Vector<SVGGradientStop>&);
89 void updateQuartzGradientCache(
const SVGPaintServerGradient*);
90 void handleBoundingBoxModeAndGradientTransformation(GraphicsContext*,
const FloatRect& targetRect)
const;
95 void fillColorArray(QGradient&,
const Vector<SVGGradientStop>&,
float opacity)
const;
96 virtual QGradient setupGradient(QPainter* painter, QPainterPath* painterPath,
const RenderObject*)
const = 0;
100 SVGPaintServerGradient(
const SVGGradientElement* owner);
103 Vector<SVGGradientStop> m_stops;
104 SVGGradientSpreadMethod m_spreadMethod;
105 bool m_boundingBoxMode;
106 AffineTransform m_gradientTransform;
107 const SVGGradientElement* m_ownerElement;
112 CGFloat colorArray[4];
114 CGFloat previousDeltaInverse;
115 } QuartzGradientStop;
117 struct SharedStopCache :
public RefCounted<SharedStopCache> {
119 static PassRefPtr<SharedStopCache>
create() {
return adoptRef(
new SharedStopCache); }
121 Vector<QuartzGradientStop> m_stops;
124 SharedStopCache() { }
127 RefPtr<SharedStopCache> m_stopsCache;
129 CGShadingRef m_shadingCache;
130 mutable GraphicsContext* m_savedContext;
131 mutable ImageBuffer* m_imageBuffer;
135 inline SVGGradientStop makeGradientStop(
float offset,
const QColor& color)
137 return std::make_pair(offset, color);
144 #endif // SVGPaintServerGradient_h
KAction * create(StandardAction id, const QObject *recvr, const char *slot, QObject *parent)