ac70ef3876639f69a3818ca6519b003ca41f28b5
[WebKit-https.git] / WebCore / platform / graphics / svg / qt / SVGPaintServerPatternQt.cpp
1 /*
2     Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
3
4     This file is part of the KDE project
5
6     This library is free software; you can redistribute it and/or
7     modify it under the terms of the GNU Library General Public
8     License as published by the Free Software Foundation; either
9     version 2 of the License, or (at your option) any later version.
10
11     This library is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14     Library General Public License for more details.
15
16     You should have received a copy of the GNU Library General Public License
17     aint with this library; see the file COPYING.LIB.  If not, write to
18     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19     Boston, MA 02111-1307, USA.
20 */
21
22 #include "config.h"
23
24 #ifdef SVG_SUPPORT
25 #include "SVGPaintServerPattern.h"
26
27 namespace WebCore {
28
29 bool SVGPaintServerPattern::setup(KRenderingDeviceContext* context, const RenderObject* object, SVGPaintTargetType type) const
30 {
31     // FIXME: Reactivate old pattern code
32
33 /*
34     KRenderingDeviceContextQt* qtContext = static_cast<KRenderingDeviceContextQt*>(context);
35     Q_ASSERT(qtContext != 0);
36
37     QPainterPath* _path = static_cast<QPainterPath*>(qtContext->path());
38     Q_ASSERT(_path != 0);
39
40     if (listener()) {
41         listener()->resourceNotification();
42     }
43
44     RenderStyle* renderStyle = object->style();
45
46     qtContext->painter().setPen(Qt::NoPen);
47     qtContext->painter().setBrush(Qt::NoBrush);
48     QImage* patternimage = new QImage(tile()->bits(), tile()->width(), tile()->height(), QImage::Format_ARGB32_Premultiplied);
49     patternimage->setAlphaBuffer(true);
50     if (type & APPLY_TO_FILL) {
51         //QColor c = color();
52         //c.setAlphaF(style->fillPainter()->opacity() * style->opacity() * opacity());
53         KRenderingFillPainter fillPainter = KSVGPainterFactory::fillPainter(renderStyle, object);
54         QBrush brush(QPixmap::fromImage(*patternimage));
55         _path->setFillRule(fillPainter.fillRule() == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
56         qtContext->painter().setBrush(brush);
57     }
58     if (type & APPLY_TO_STROKE) {
59         //QColor c = color();
60         //c.setAlphaF(style->strokePainter()->opacity() * style->opacity() * opacity());
61         KRenderingStrokePainter strokePainter = KSVGPainterFactory::strokePainter(renderStyle, object);
62
63         QPen pen;
64         QBrush brush(QPixmap::fromImage(*patternimage));
65
66         setPenProperties(strokePainter, pen);
67         pen.setBrush(brush);
68         qtContext->painter().setPen(pen);
69     }
70
71     qtContext->painter().drawPath(*_path);
72
73     delete patternimage;
74 */
75
76     return true;
77 }
78
79 } // namespace WebCore
80
81 #endif
82
83 // vim:ts=4:noet