• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • khtml
  • svg
  • graphics
SVGPaintServerGradient.h
Go to the documentation of this file.
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 SVGPaintServerGradient_h
27#define SVGPaintServerGradient_h
28
29#if ENABLE(SVG)
30
31#include "AffineTransform.h"
32#include "SVGPaintServer.h"
33
34#include <wtf/RefCounted.h>
35#include <wtf/RefPtr.h>
36
37#if PLATFORM(QT)
38#include <qglobal.h>
39QT_BEGIN_NAMESPACE
40class QGradient;
41QT_END_NAMESPACE
42#endif
43
44namespace WebCore {
45
46 class ImageBuffer;
47 class SVGGradientElement;
48
49 // FIXME: Remove the spread method enum in SVGGradientElement
50 enum SVGGradientSpreadMethod {
51 SPREADMETHOD_PAD = 1,
52 SPREADMETHOD_REFLECT = 2,
53 SPREADMETHOD_REPEAT = 3
54 };
55
56 typedef std::pair<float, QColor> SVGGradientStop;
57
58
59 class SVGPaintServerGradient : public SVGPaintServer {
60 public:
61 virtual ~SVGPaintServerGradient();
62
63 const Vector<SVGGradientStop>& gradientStops() const;
64 void setGradientStops(const Vector<SVGGradientStop>&);
65
66 SVGGradientSpreadMethod spreadMethod() const;
67 void setGradientSpreadMethod(const SVGGradientSpreadMethod&);
68
69 // Gradient start and end points are percentages when used in boundingBox mode.
70 // For instance start point with value (0,0) is top-left and end point with
71 // value (100, 100) is bottom-right. BoundingBox mode is enabled by default.
72 bool boundingBoxMode() const;
73 void setBoundingBoxMode(bool mode = true);
74
75 AffineTransform gradientTransform() const;
76 void setGradientTransform(const AffineTransform&);
77
78 /*virtual TextStream& externalRepresentation(TextStream&) const;*/
79
80 virtual bool setup(QPainter* painter, QPainterPath* path, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
81#if PLATFORM(CG)
82 virtual void teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
83 virtual void renderPath(GraphicsContext*&, const RenderObject*, SVGPaintTargetType) const;
84
85 virtual void invalidate();
86
87 // Helpers
88 void updateQuartzGradientStopsCache(const Vector<SVGGradientStop>&);
89 void updateQuartzGradientCache(const SVGPaintServerGradient*);
90 void handleBoundingBoxModeAndGradientTransformation(GraphicsContext*, const FloatRect& targetRect) const;
91#endif
92
93#if PLATFORM(QT)
94 protected:
95 void fillColorArray(QGradient&, const Vector<SVGGradientStop>&, float opacity) const;
96 virtual QGradient setupGradient(QPainter* painter, QPainterPath* painterPath, const RenderObject*) const = 0;
97#endif
98
99 protected:
100 SVGPaintServerGradient(const SVGGradientElement* owner);
101
102 private:
103 Vector<SVGGradientStop> m_stops;
104 SVGGradientSpreadMethod m_spreadMethod;
105 bool m_boundingBoxMode;
106 AffineTransform m_gradientTransform;
107 const SVGGradientElement* m_ownerElement;
108
109#if PLATFORM(CG)
110 public:
111 typedef struct {
112 CGFloat colorArray[4];
113 CGFloat offset;
114 CGFloat previousDeltaInverse;
115 } QuartzGradientStop;
116
117 struct SharedStopCache : public RefCounted<SharedStopCache> {
118 public:
119 static PassRefPtr<SharedStopCache> create() { return adoptRef(new SharedStopCache); }
120
121 Vector<QuartzGradientStop> m_stops;
122
123 private:
124 SharedStopCache() { }
125 };
126
127 RefPtr<SharedStopCache> m_stopsCache;
128
129 CGShadingRef m_shadingCache;
130 mutable GraphicsContext* m_savedContext;
131 mutable ImageBuffer* m_imageBuffer;
132#endif
133 };
134
135 inline SVGGradientStop makeGradientStop(float offset, const QColor& color)
136 {
137 return std::make_pair(offset, color);
138 }
139
140} // namespace WebCore
141
142#endif
143
144#endif // SVGPaintServerGradient_h
AffineTransform.h
SVGPaintServer.h
create
KAction * create(StandardAction id, const QObject *recvr, const char *slot, QObject *parent)
WebCore
Definition: CSSHelper.h:7
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal