summaryrefslogtreecommitdiffstats
path: root/WebCore/svg/graphics/qt
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
commit1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 (patch)
tree4457a7306ea5acb43fe05bfe0973b1f7faf97ba2 /WebCore/svg/graphics/qt
parent9364f22aed35e1a1e9d07c121510f80be3ab0502 (diff)
downloadexternal_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.zip
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.gz
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.bz2
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'WebCore/svg/graphics/qt')
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp18
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp69
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerQt.cpp40
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp21
-rw-r--r--WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp8
5 files changed, 72 insertions, 84 deletions
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp
index 7240c49..113f9a7 100644
--- a/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp
+++ b/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp
@@ -62,42 +62,42 @@ bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject
QPainterPath* path(context ? context->currentPath() : 0);
Q_ASSERT(path);
- RenderStyle* renderStyle = object->style();
+ const SVGRenderStyle* svgStyle = object->style()->svgStyle();
+ RenderStyle* style = object->style();
QGradient gradient = setupGradient(context, object);
painter->setPen(Qt::NoPen);
painter->setBrush(Qt::NoBrush);
- if (spreadMethod() == SPREADMETHOD_REPEAT)
+ if (spreadMethod() == SpreadMethodRepeat)
gradient.setSpread(QGradient::RepeatSpread);
- else if (spreadMethod() == SPREADMETHOD_REFLECT)
+ else if (spreadMethod() == SpreadMethodReflect)
gradient.setSpread(QGradient::ReflectSpread);
else
gradient.setSpread(QGradient::PadSpread);
double opacity = 1.0;
- if ((type & ApplyToFillTargetType) && renderStyle->svgStyle()->hasFill()) {
+ if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) {
fillColorArray(gradient, gradientStops(), opacity);
QBrush brush(gradient);
brush.setMatrix(gradientTransform());
painter->setBrush(brush);
- context->setFillRule(renderStyle->svgStyle()->fillRule());
+ context->setFillRule(svgStyle->fillRule());
}
- if ((type & ApplyToStrokeTargetType) && renderStyle->svgStyle()->hasStroke()) {
+ if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) {
fillColorArray(gradient, gradientStops(), opacity);
QPen pen;
QBrush brush(gradient);
brush.setMatrix(gradientTransform());
-
- setPenProperties(object, renderStyle, pen);
pen.setBrush(brush);
-
painter->setPen(pen);
+
+ applyStrokeStyleToContext(context, style, object);
}
return true;
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp
index 119e0b0..70ec14c 100644
--- a/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp
+++ b/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp
@@ -1,7 +1,6 @@
/*
Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
-
- This file is part of the KDE project
+ Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -24,54 +23,66 @@
#if ENABLE(SVG)
#include "SVGPaintServerPattern.h"
+#include "AffineTransform.h"
+#include "GraphicsContext.h"
+#include "ImageBuffer.h"
+#include "Pattern.h"
+#include "RenderObject.h"
+#include "SVGPatternElement.h"
+
+#include <QPainter>
+#include <QPainterPath>
+
namespace WebCore {
bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
{
- // FIXME: Reactivate old pattern code
+ Q_ASSERT(context);
+ Q_ASSERT(object);
-/*
- QPainter* painter(context ? context->platformContext() : 0);
- Q_ASSERT(painter);
+ FloatRect targetRect = object->relativeBBox(false);
+ m_ownerElement->buildPattern(targetRect);
- QPainterPath* _path = static_cast<QPainterPath*>(qtContext->path());
- Q_ASSERT(_path != 0);
+ if (!tile())
+ return false;
- RenderStyle* renderStyle = object->style();
+ QPainter* painter = context->platformContext();
+ QPainterPath* path = context->currentPath();
+ RenderStyle* style = object->style();
+ const SVGRenderStyle* svgStyle = object->style()->svgStyle();
+
+ RefPtr<Pattern> pattern = Pattern::create(tile()->image(), true, true);
+
+ context->save();
painter->setPen(Qt::NoPen);
painter->setBrush(Qt::NoBrush);
- QImage* patternimage = new QImage(tile()->bits(), tile()->width(), tile()->height(), QImage::Format_ARGB32_Premultiplied);
- patternimage->setAlphaBuffer(true);
- if (type & APPLY_TO_FILL) {
- //QColor c = color();
- //c.setAlphaF(style->fillPainter()->opacity() * style->opacity() * opacity());
- KRenderingFillPainter fillPainter = KSVGPainterFactory::fillPainter(renderStyle, object);
- QBrush brush(QPixmap::fromImage(*patternimage));
- _path->setFillRule(fillPainter.fillRule() == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
+
+ AffineTransform affine;
+ affine.translate(patternBoundaries().x(), patternBoundaries().y());
+ affine.multiply(patternTransform());
+
+ QBrush brush(pattern->createPlatformPattern(affine));
+ if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) {
painter->setBrush(brush);
+ context->setFillRule(svgStyle->fillRule());
}
- if (type & APPLY_TO_STROKE) {
- //QColor c = color();
- //c.setAlphaF(style->strokePainter()->opacity() * style->opacity() * opacity());
- KRenderingStrokePainter strokePainter = KSVGPainterFactory::strokePainter(renderStyle, object);
+ if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) {
QPen pen;
- QBrush brush(QPixmap::fromImage(*patternimage));
-
- setPenProperties(strokePainter, pen);
pen.setBrush(brush);
painter->setPen(pen);
+ applyStrokeStyleToContext(context, style, object);
}
- painter->drawPath(*_path);
-
- delete patternimage;
-*/
-
return true;
}
+void SVGPaintServerPattern::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const
+{
+ context->restore();
+}
+
} // namespace WebCore
#endif
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp
index db20347..801201b 100644
--- a/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp
+++ b/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp
@@ -1,5 +1,6 @@
/*
Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2008 Holger Hans Peter Freyther
This file is part of the KDE project
@@ -33,39 +34,6 @@
namespace WebCore {
-void SVGPaintServer::setPenProperties(const RenderObject* object, const RenderStyle* style, QPen& pen) const
-{
- pen.setWidthF(SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0));
-
- if (style->svgStyle()->capStyle() == ButtCap)
- pen.setCapStyle(Qt::FlatCap);
- else if (style->svgStyle()->capStyle() == RoundCap)
- pen.setCapStyle(Qt::RoundCap);
-
- if (style->svgStyle()->joinStyle() == MiterJoin) {
- pen.setJoinStyle(Qt::MiterJoin);
- pen.setMiterLimit((qreal) style->svgStyle()->strokeMiterLimit());
- } else if(style->svgStyle()->joinStyle() == RoundJoin)
- pen.setJoinStyle(Qt::RoundJoin);
-
- const DashArray& dashes = WebCore::dashArrayFromRenderingStyle(style);
- double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0);
-
- unsigned int dashLength = !dashes.isEmpty() ? dashes.size() : 0;
- if(dashLength) {
- QVector<qreal> pattern;
- unsigned int count = (dashLength % 2) == 0 ? dashLength : dashLength * 2;
-
- for(unsigned int i = 0; i < count; i++)
- pattern.append(dashes[i % dashLength] / (float)pen.widthF());
-
- pen.setDashPattern(pattern);
-
- Q_UNUSED(dashOffset);
- // TODO: dash-offset, does/will qt4 API allow it? (Rob)
- }
-}
-
void SVGPaintServer::draw(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
{
if (!setup(context, path, type))
@@ -82,7 +50,7 @@ void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTa
void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
{
- RenderStyle* renderStyle = path->style();
+ RenderStyle* renderStyle = path ? path->style(): 0;
QPainter* painter(context ? context->platformContext() : 0);
Q_ASSERT(painter);
@@ -90,10 +58,10 @@ void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* p
QPainterPath* painterPath(context ? context->currentPath() : 0);
Q_ASSERT(painterPath);
- if ((type & ApplyToFillTargetType) && renderStyle->svgStyle()->hasFill())
+ if ((type & ApplyToFillTargetType) && (!renderStyle || renderStyle->svgStyle()->hasFill()))
painter->fillPath(*painterPath, painter->brush());
- if ((type & ApplyToStrokeTargetType) && renderStyle->svgStyle()->hasStroke())
+ if ((type & ApplyToStrokeTargetType) && (!renderStyle || renderStyle->svgStyle()->hasStroke()))
painter->strokePath(*painterPath, painter->pen());
}
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp
index 7b06a03..e088df2 100644
--- a/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp
+++ b/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp
@@ -1,5 +1,6 @@
/*
Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2008 Holger Hans Peter Freyther
This file is part of the KDE project
@@ -36,27 +37,33 @@ bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* o
QPainter* painter(context ? context->platformContext() : 0);
Q_ASSERT(painter);
- RenderStyle* renderStyle = object->style();
+ const SVGRenderStyle* svgStyle = object->style()->svgStyle();
+ RenderStyle* style = object ? object->style() : 0;
// TODO? painter->setOpacity(renderStyle->opacity());
QColor c = color();
- if ((type & ApplyToFillTargetType) && renderStyle->svgStyle()->hasFill()) {
- c.setAlphaF(renderStyle->svgStyle()->fillOpacity());
+ if ((type & ApplyToFillTargetType) && (!style || svgStyle->hasFill())) {
+ if (style)
+ c.setAlphaF(svgStyle->fillOpacity());
QBrush brush(c);
painter->setBrush(brush);
- context->setFillRule(renderStyle->svgStyle()->fillRule());
+
+ if (style)
+ context->setFillRule(svgStyle->fillRule());
/* if(isPaintingText()) ... */
}
- if ((type & ApplyToStrokeTargetType) && renderStyle->svgStyle()->hasStroke()) {
- c.setAlphaF(renderStyle->svgStyle()->strokeOpacity());
+ if ((type & ApplyToStrokeTargetType) && (!style || svgStyle->hasStroke())) {
+ if (style)
+ c.setAlphaF(svgStyle->strokeOpacity());
QPen pen(c);
- setPenProperties(object, renderStyle, pen);
painter->setPen(pen);
+ if (style)
+ applyStrokeStyleToContext(context, style, object);
/* if(isPaintingText()) ... */
}
diff --git a/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp b/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp
index 557f3dd..cbf90cd 100644
--- a/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp
+++ b/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp
@@ -21,24 +21,26 @@
#include "config.h"
-#if ENABLE(SVG) && ENABLE(SVG_EXPERIMENTAL_FEATURES)
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
#include "SVGResourceFilter.h"
+#include "NotImplemented.h"
namespace WebCore {
SVGResourceFilterPlatformData* SVGResourceFilter::createPlatformData()
{
+ notImplemented();
return 0;
}
void SVGResourceFilter::prepareFilter(GraphicsContext*&, const FloatRect&)
{
- // FIXME: implement me :-)
+ notImplemented();
}
void SVGResourceFilter::applyFilter(GraphicsContext*&, const FloatRect&)
{
- // FIXME: implement me :-)
+ notImplemented();
}
} // namespace WebCore