~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
3
 
    Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de>
4
 
 
5
 
    This library is free software; you can redistribute it and/or
6
 
    modify it under the terms of the GNU Library General Public
7
 
    License as published by the Free Software Foundation; either
8
 
    version 2 of the License, or (at your option) any later version.
9
 
 
10
 
    This library is distributed in the hope that it will be useful,
11
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 
    Library General Public License for more details.
14
 
 
15
 
    You should have received a copy of the GNU Library General Public License
16
 
    aint with this library; see the file COPYING.LIB.  If not, write to
17
 
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
 
    Boston, MA 02110-1301, USA.
19
 
*/
20
 
 
21
 
#include "config.h"
22
 
 
23
 
#if ENABLE(SVG)
24
 
#include "SVGPaintServerPattern.h"
25
 
 
26
 
#include "TransformationMatrix.h"
27
 
#include "GraphicsContext.h"
28
 
#include "ImageBuffer.h"
29
 
#include "Pattern.h"
30
 
#include "RenderObject.h"
31
 
#include "SVGPatternElement.h"
32
 
 
33
 
#include <QPainter>
34
 
#include <QPainterPath>
35
 
 
36
 
namespace WebCore {
37
 
 
38
 
bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
39
 
{
40
 
    Q_ASSERT(context);
41
 
    Q_ASSERT(object);
42
 
 
43
 
    FloatRect targetRect = object->relativeBBox(false);
44
 
    m_ownerElement->buildPattern(targetRect);
45
 
 
46
 
    if (!tile())
47
 
        return false;
48
 
 
49
 
    QPainter* painter = context->platformContext();
50
 
    QPainterPath* path = context->currentPath();
51
 
 
52
 
    RenderStyle* style = object->style();
53
 
    const SVGRenderStyle* svgStyle = object->style()->svgStyle();
54
 
 
55
 
    RefPtr<Pattern> pattern = Pattern::create(tile()->image(), true, true);
56
 
 
57
 
    context->save();
58
 
    painter->setPen(Qt::NoPen);
59
 
    painter->setBrush(Qt::NoBrush);
60
 
 
61
 
    TransformationMatrix affine;
62
 
    affine.translate(patternBoundaries().x(), patternBoundaries().y());
63
 
    affine.multiply(patternTransform());
64
 
 
65
 
    QBrush brush(pattern->createPlatformPattern(affine));
66
 
    if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) {
67
 
        painter->setBrush(brush);
68
 
        context->setFillRule(svgStyle->fillRule());
69
 
    }
70
 
 
71
 
    if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) {
72
 
        QPen pen;
73
 
        pen.setBrush(brush);
74
 
        painter->setPen(pen);
75
 
        applyStrokeStyleToContext(context, style, object);
76
 
    }
77
 
 
78
 
    return true;
79
 
}
80
 
 
81
 
void SVGPaintServerPattern::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const
82
 
{
83
 
    context->restore();
84
 
}
85
 
 
86
 
} // namespace WebCore
87
 
 
88
 
#endif
89
 
 
90
 
// vim:ts=4:noet