diff options
Diffstat (limited to 'WebCore/svg/graphics/qt')
-rw-r--r-- | WebCore/svg/graphics/qt/RenderPathQt.cpp | 89 | ||||
-rw-r--r-- | WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp | 110 | ||||
-rw-r--r-- | WebCore/svg/graphics/qt/SVGPaintServerLinearGradientQt.cpp | 65 | ||||
-rw-r--r-- | WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp | 90 | ||||
-rw-r--r-- | WebCore/svg/graphics/qt/SVGPaintServerQt.cpp | 72 | ||||
-rw-r--r-- | WebCore/svg/graphics/qt/SVGPaintServerRadialGradientQt.cpp | 98 | ||||
-rw-r--r-- | WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp | 78 | ||||
-rw-r--r-- | WebCore/svg/graphics/qt/SVGResourceClipperQt.cpp | 127 |
8 files changed, 0 insertions, 729 deletions
diff --git a/WebCore/svg/graphics/qt/RenderPathQt.cpp b/WebCore/svg/graphics/qt/RenderPathQt.cpp deleted file mode 100644 index 8bee8b8..0000000 --- a/WebCore/svg/graphics/qt/RenderPathQt.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org> - 2004, 2005, 2006 Rob Buis <buis@kde.org> - 2005 Eric Seidel <eric.seidel@kdemail.net> - - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" -#include "RenderPath.h" -#include "SVGRenderStyle.h" -#include "SVGPaintServer.h" - -#include <QDebug> -#include <QPainterPathStroker> - -namespace WebCore { - -bool RenderPath::strokeContains(const FloatPoint& point, bool requiresStroke) const -{ - if (path().isEmpty()) - return false; - - if (requiresStroke && !SVGPaintServer::strokePaintServer(style(), this)) - return false; - - return false; -} - -static QPainterPath getPathStroke(const QPainterPath &path, const RenderObject* object, const RenderStyle* style) -{ - QPainterPathStroker s; - s.setWidth(SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0)); - - if (style->svgStyle()->capStyle() == ButtCap) - s.setCapStyle(Qt::FlatCap); - else if (style->svgStyle()->capStyle() == RoundCap) - s.setCapStyle(Qt::RoundCap); - - if (style->svgStyle()->joinStyle() == MiterJoin) { - s.setJoinStyle(Qt::MiterJoin); - s.setMiterLimit((qreal) style->svgStyle()->strokeMiterLimit()); - } else if(style->svgStyle()->joinStyle() == RoundJoin) - s.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)s.width()); - - s.setDashPattern(pattern); - - Q_UNUSED(dashOffset); - // TODO: dash-offset, does/will qt4 API allow it? (Rob) - } - - return s.createStroke(path); -} - -FloatRect RenderPath::strokeBBox() const -{ - QPainterPath outline = getPathStroke(*(path().platformPath()), this, style()); - return outline.boundingRect(); -} - -} - -// vim:ts=4:noet diff --git a/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp deleted file mode 100644 index 113f9a7..0000000 --- a/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org> - - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPaintServerGradient.h" - -#include "GraphicsContext.h" -#include "RenderObject.h" -#include "RenderStyle.h" -#include "SVGGradientElement.h" - -#include <QPainter> -#include <QPainterPath> -#include <QColor> -#include <QGradient> - -namespace WebCore { - -// Helper function used by linear & radial gradient -void SVGPaintServerGradient::fillColorArray(QGradient& gradient, const Vector<SVGGradientStop>& stops, - float opacity) const -{ - for (unsigned i = 0; i < stops.size(); ++i) { - float offset = stops[i].first; - Color color = stops[i].second; - - QColor c(color.red(), color.green(), color.blue()); - c.setAlpha(int(color.alpha() * opacity)); - - gradient.setColorAt(offset, c); - } -} - -bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object, - SVGPaintTargetType type, bool isPaintingText) const -{ - m_ownerElement->buildGradient(); - - QPainter* painter(context ? context->platformContext() : 0); - Q_ASSERT(painter); - - QPainterPath* path(context ? context->currentPath() : 0); - Q_ASSERT(path); - - 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() == SpreadMethodRepeat) - gradient.setSpread(QGradient::RepeatSpread); - else if (spreadMethod() == SpreadMethodReflect) - gradient.setSpread(QGradient::ReflectSpread); - else - gradient.setSpread(QGradient::PadSpread); - double opacity = 1.0; - - if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) { - fillColorArray(gradient, gradientStops(), opacity); - - QBrush brush(gradient); - brush.setMatrix(gradientTransform()); - - painter->setBrush(brush); - context->setFillRule(svgStyle->fillRule()); - } - - if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) { - fillColorArray(gradient, gradientStops(), opacity); - - QPen pen; - QBrush brush(gradient); - brush.setMatrix(gradientTransform()); - pen.setBrush(brush); - painter->setPen(pen); - - applyStrokeStyleToContext(context, style, object); - } - - return true; -} - -} // namespace WebCore - -#endif - -// vim:ts=4:noet diff --git a/WebCore/svg/graphics/qt/SVGPaintServerLinearGradientQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerLinearGradientQt.cpp deleted file mode 100644 index 69934ab..0000000 --- a/WebCore/svg/graphics/qt/SVGPaintServerLinearGradientQt.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org> - - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPaintServerLinearGradient.h" -#include "SVGGradientElement.h" - -#include "GraphicsContext.h" -#include "RenderPath.h" - -#include <QLinearGradient> -#include <QPainter> -#include <QPainterPath> - -namespace WebCore { - -QGradient SVGPaintServerLinearGradient::setupGradient(GraphicsContext*& context, const RenderObject* object) const -{ - QPainterPath* path(context ? context->currentPath() : 0); - Q_ASSERT(path); - - double x1, x2, y1, y2; - if (boundingBoxMode()) { - QRectF bbox = path->boundingRect(); - x1 = bbox.x(); - y1 = bbox.y(); - x2 = bbox.x() + bbox.width(); - y2 = bbox.y() + bbox.height(); - } else { - x1 = gradientStart().x(); - y1 = gradientStart().y(); - x2 = gradientEnd().x(); - y2 = gradientEnd().y(); - } - - QLinearGradient gradient(QPointF(x1, y1), QPointF(x2, y2)); - - return gradient; -} - -} // namespace WebCore - -#endif - -// vim:ts=4:noet diff --git a/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp deleted file mode 100644 index 70ec14c..0000000 --- a/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org> - 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 - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" - -#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 -{ - Q_ASSERT(context); - Q_ASSERT(object); - - FloatRect targetRect = object->relativeBBox(false); - m_ownerElement->buildPattern(targetRect); - - if (!tile()) - return false; - - 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); - - 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 & ApplyToStrokeTargetType) && svgStyle->hasStroke()) { - QPen pen; - pen.setBrush(brush); - painter->setPen(pen); - applyStrokeStyleToContext(context, style, object); - } - - return true; -} - -void SVGPaintServerPattern::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const -{ - context->restore(); -} - -} // namespace WebCore - -#endif - -// vim:ts=4:noet diff --git a/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp deleted file mode 100644 index 801201b..0000000 --- a/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org> - Copyright (C) 2008 Holger Hans Peter Freyther - - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPaintServer.h" - -#include "GraphicsContext.h" -#include "SVGRenderStyle.h" -#include "RenderObject.h" - -#include <QPainter> -#include <QVector> - -namespace WebCore { - -void SVGPaintServer::draw(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const -{ - if (!setup(context, path, type)) - return; - - renderPath(context, path, type); - teardown(context, path, type); -} - -void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const -{ - // no-op -} - -void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const -{ - RenderStyle* renderStyle = path ? path->style(): 0; - - QPainter* painter(context ? context->platformContext() : 0); - Q_ASSERT(painter); - - QPainterPath* painterPath(context ? context->currentPath() : 0); - Q_ASSERT(painterPath); - - if ((type & ApplyToFillTargetType) && (!renderStyle || renderStyle->svgStyle()->hasFill())) - painter->fillPath(*painterPath, painter->brush()); - - if ((type & ApplyToStrokeTargetType) && (!renderStyle || renderStyle->svgStyle()->hasStroke())) - painter->strokePath(*painterPath, painter->pen()); -} - -} // namespace WebCore - -#endif - -// vim:ts=4:noet diff --git a/WebCore/svg/graphics/qt/SVGPaintServerRadialGradientQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerRadialGradientQt.cpp deleted file mode 100644 index 95d71a3..0000000 --- a/WebCore/svg/graphics/qt/SVGPaintServerRadialGradientQt.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org> - - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPaintServerRadialGradient.h" - -#include "GraphicsContext.h" -#include "RenderPath.h" - -#include <math.h> -#include <QPainter> -#include <QPainterPath> -#include <QRadialGradient> - -namespace WebCore { - -QGradient SVGPaintServerRadialGradient::setupGradient(GraphicsContext*& context, const RenderObject* object) const -{ - QPainter* painter(context ? context->platformContext() : 0); - Q_ASSERT(painter); - - QPainterPath* path(context ? context->currentPath() : 0); - Q_ASSERT(path); - - RenderStyle* renderStyle = object->style(); - - QMatrix mat = painter->matrix(); - - double cx, fx, cy, fy, r; - if (boundingBoxMode()) { - QRectF bbox = path->boundingRect(); - cx = double(bbox.left()) + (double(gradientCenter().x() / 100.0) * double(bbox.width())); - cy = double(bbox.top()) + (double(gradientCenter().y() / 100.0) * double(bbox.height())); - fx = double(bbox.left()) + (double(gradientFocal().x() / 100.0) * double(bbox.width())) - cx; - fy = double(bbox.top()) + (double(gradientFocal().y() / 100.0) * double(bbox.height())) - cy; - r = double(gradientRadius() / 100.0) * (sqrt(pow(bbox.width(), 2) + pow(bbox.height(), 2))); - - float width = bbox.width(); - float height = bbox.height(); - - int diff = int(width - height); // allow slight tolerance - if (!(diff > -2 && diff < 2)) { - // make elliptical or circular depending on bbox aspect ratio - float ratioX = (width / height); - float ratioY = (height / width); - mat.scale((width > height) ? 1 : ratioX, (width > height) ? ratioY : 1); - } - } else { - cx = gradientCenter().x(); - cy = gradientCenter().y(); - - fx = gradientFocal().x(); - fy = gradientFocal().y(); - - fx -= cx; - fy -= cy; - - r = gradientRadius(); - } - - if (sqrt(fx * fx + fy * fy) > r) { - // Spec: If (fx, fy) lies outside the circle defined by (cx, cy) and r, set (fx, fy) - // to the point of intersection of the line through (fx, fy) and the circle. - double angle = atan2(fy, fx); - fx = int(cos(angle) * r) - 1; - fy = int(sin(angle) * r) - 1; - } - - QRadialGradient gradient(QPointF(cx, cy), gradientRadius(), QPointF(fx + cx, fy + cy)); - - return gradient; -} - -} // namespace WebCore - -#endif - -// vim:ts=4:noet diff --git a/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp deleted file mode 100644 index e088df2..0000000 --- a/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org> - Copyright (C) 2008 Holger Hans Peter Freyther - - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPaintServerSolid.h" - -#include "GraphicsContext.h" -#include "RenderPath.h" - -#include <QPainter> - -namespace WebCore { - -bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const -{ - QPainter* painter(context ? context->platformContext() : 0); - Q_ASSERT(painter); - - const SVGRenderStyle* svgStyle = object->style()->svgStyle(); - RenderStyle* style = object ? object->style() : 0; - // TODO? painter->setOpacity(renderStyle->opacity()); - - QColor c = color(); - - if ((type & ApplyToFillTargetType) && (!style || svgStyle->hasFill())) { - if (style) - c.setAlphaF(svgStyle->fillOpacity()); - - QBrush brush(c); - painter->setBrush(brush); - - if (style) - context->setFillRule(svgStyle->fillRule()); - - /* if(isPaintingText()) ... */ - } - - if ((type & ApplyToStrokeTargetType) && (!style || svgStyle->hasStroke())) { - if (style) - c.setAlphaF(svgStyle->strokeOpacity()); - - QPen pen(c); - painter->setPen(pen); - if (style) - applyStrokeStyleToContext(context, style, object); - - /* if(isPaintingText()) ... */ - } - - return true; -} - -} // namespace WebCore - -#endif - -// vim:ts=4:noet diff --git a/WebCore/svg/graphics/qt/SVGResourceClipperQt.cpp b/WebCore/svg/graphics/qt/SVGResourceClipperQt.cpp deleted file mode 100644 index 42d3855..0000000 --- a/WebCore/svg/graphics/qt/SVGResourceClipperQt.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org> - 2004, 2005, 2006 Rob Buis <buis@kde.org> - 2005 Apple Computer, Inc. - - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGResourceClipper.h" - -#include "GraphicsContext.h" - -#include <QPainter> -#include <QPainterPath> - -namespace WebCore { - -void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const -{ - if (m_clipData.clipData().size() < 1) - return; - - context->beginPath(); - - QPainterPath newPath; - - bool heterogenousClipRules = false; - WindRule clipRule = m_clipData.clipData()[0].windRule; - - unsigned int clipDataCount = m_clipData.clipData().size(); - for (unsigned int x = 0; x < clipDataCount; x++) { - ClipData clipData = m_clipData.clipData()[x]; - if (clipData.windRule != clipRule) - heterogenousClipRules = true; - - QPainterPath path = *(clipData.path.platformPath()); - if (path.isEmpty()) - continue; - - if (!newPath.isEmpty()) - newPath.closeSubpath(); - - // Respect clipping units... - QMatrix transform; - - if (clipData.bboxUnits) { - transform.translate(boundingBox.x(), boundingBox.y()); - transform.scale(boundingBox.width(), boundingBox.height()); - } - - // TODO: support heterogenous clip rules! - //clipRule = (clipData.windRule() == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill); - - for (int i = 0; i < path.elementCount(); ++i) { - const QPainterPath::Element &cur = path.elementAt(i); - - switch (cur.type) { - case QPainterPath::MoveToElement: - newPath.moveTo(QPointF(cur.x, cur.y) * transform); - break; - case QPainterPath::LineToElement: - newPath.lineTo(QPointF(cur.x, cur.y) * transform); - break; - case QPainterPath::CurveToElement: - { - const QPainterPath::Element &c1 = path.elementAt(i + 1); - const QPainterPath::Element &c2 = path.elementAt(i + 2); - - Q_ASSERT(c1.type == QPainterPath::CurveToDataElement); - Q_ASSERT(c2.type == QPainterPath::CurveToDataElement); - - newPath.cubicTo(QPointF(cur.x, cur.y) * transform, - QPointF(c1.x, c1.y) * transform, - QPointF(c2.x, c2.y) * transform); - - i += 2; - break; - } - case QPainterPath::CurveToDataElement: - Q_ASSERT(false); - break; - } - } - } - - if (m_clipData.clipData().size()) { - // FIXME! - // We don't currently allow for heterogenous clip rules. - // we would have to detect such, draw to a mask, and then clip - // to that mask - // if (!CGContextIsPathEmpty(cgContext)) { - if (clipRule == RULE_EVENODD) - newPath.setFillRule(Qt::OddEvenFill); - else - newPath.setFillRule(Qt::WindingFill); - // } - } - - QPainter* painter(context ? context->platformContext() : 0); - Q_ASSERT(painter); - - painter->setClipPath(newPath); -} - -} // namespace WebCore - -#endif - -// vim:ts=4:noet |