23 #include "wtf/Platform.h"
34 #include <QPainterPath>
41 void SVGPaintServerGradient::fillColorArray(QGradient& gradient,
const Vector<SVGGradientStop>& stops,
44 kDebug() << stops.size() << endl;
45 for (
unsigned i = 0; i < stops.size(); ++i) {
46 float offset = stops[i].first;
47 QColor color = stops[i].second;
48 kDebug() <<
"offset" << offset <<
"color" << color << endl;
50 QColor c(color.red(), color.green(), color.blue());
51 c.setAlpha(
int(color.alpha() * opacity));
53 gradient.setColorAt(offset, c);
57 bool SVGPaintServerGradient::setup(QPainter* painter, QPainterPath* painterPath,
const RenderObject*
object,
58 SVGPaintTargetType type,
bool isPaintingText)
const
60 Q_UNUSED(isPaintingText);
61 kDebug() <<
"!!!!!!!" << endl;
62 m_ownerElement->buildGradient();
70 RenderStyle* renderStyle =
object->style();
72 QGradient gradient = setupGradient(painter, painterPath,
object);
74 painter->setPen(Qt::NoPen);
75 painter->setBrush(Qt::NoBrush);
77 if (spreadMethod() == SPREADMETHOD_REPEAT)
78 gradient.setSpread(QGradient::RepeatSpread);
79 else if (spreadMethod() == SPREADMETHOD_REFLECT)
80 gradient.setSpread(QGradient::ReflectSpread);
82 gradient.setSpread(QGradient::PadSpread);
85 kDebug() <<
"type: " << type << (type & ApplyToFillTargetType) << endl;
86 if ((type & ApplyToFillTargetType) && renderStyle->svgStyle()->hasFill()) {
87 fillColorArray(gradient, gradientStops(), opacity);
89 QBrush brush(gradient);
90 brush.setMatrix(gradientTransform());
92 painter->setBrush(brush);
96 if ((type & ApplyToStrokeTargetType) && renderStyle->svgStyle()->hasStroke()) {
97 fillColorArray(gradient, gradientStops(), opacity);
100 QBrush brush(gradient);
101 brush.setMatrix(gradientTransform());
103 setPenProperties(
object, renderStyle, pen);
106 painter->setPen(pen);
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)