Changeset 37006 in webkit


Ignore:
Timestamp:
Sep 27, 2008 2:06:35 PM (16 years ago)
Author:
zecke@webkit.org
Message:

2008-09-22 Dirk Schulze <vbs85@gmx.de>

Reviewed by Eric Seidel.

Added SVG pattern support to Qt.

[Qt] SVG patterns are missing
https://bugs.webkit.org/show_bug.cgi?id=20973

  • svg/graphics/qt/SVGPaintServerPatternQt.cpp: (WebCore::SVGPaintServerPattern::setup):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r37005 r37006  
     12008-09-22  Dirk Schulze  <vbs85@gmx.de>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Added SVG pattern support to Qt.
     6
     7        [Qt] SVG patterns are missing
     8        https://bugs.webkit.org/show_bug.cgi?id=20973
     9
     10        * svg/graphics/qt/SVGPaintServerPatternQt.cpp:
     11        (WebCore::SVGPaintServerPattern::setup):
     12
    1132008-09-27  Keishi Hattori  <casey.hattori@gmail.com>
    214
  • trunk/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp

    r29663 r37006  
    11/*
    22    Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
    3 
    4     This file is part of the KDE project
     3    Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de>
    54
    65    This library is free software; you can redistribute it and/or
     
    2524#include "SVGPaintServerPattern.h"
    2625
     26#include "AffineTransform.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
    2736namespace WebCore {
    2837
    2938bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
    3039{
    31     // FIXME: Reactivate old pattern code
    32 
    33 /*
    3440    QPainter* painter(context ? context->platformContext() : 0);
    3541    Q_ASSERT(painter);
    3642
    37     QPainterPath* _path = static_cast<QPainterPath*>(qtContext->path());
    38     Q_ASSERT(_path != 0);
     43    QPainterPath* path(context ? context->currentPath() : 0);
     44    Q_ASSERT(path);
    3945
    40     RenderStyle* renderStyle = object->style();
     46    RenderStyle* style = object ? object->style() : 0;
     47    const SVGRenderStyle* svgStyle = object ? object->style()->svgStyle() : 0;
     48
     49    FloatRect targetRect = object->relativeBBox(false);
     50    m_ownerElement->buildPattern(targetRect);
     51
     52    if (!tile())
     53        return false;
     54
     55    RefPtr<Pattern> pattern = Pattern::create(tile()->image(), true, true);
    4156
    4257    painter->setPen(Qt::NoPen);
    4358    painter->setBrush(Qt::NoBrush);
    44     QImage* patternimage = new QImage(tile()->bits(), tile()->width(), tile()->height(), QImage::Format_ARGB32_Premultiplied);
    45     patternimage->setAlphaBuffer(true);
    46     if (type & APPLY_TO_FILL) {
    47         //QColor c = color();
    48         //c.setAlphaF(style->fillPainter()->opacity() * style->opacity() * opacity());
    49         KRenderingFillPainter fillPainter = KSVGPainterFactory::fillPainter(renderStyle, object);
    50         QBrush brush(QPixmap::fromImage(*patternimage));
    51         _path->setFillRule(fillPainter.fillRule() == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
     59
     60    AffineTransform affine;
     61    affine.translate(patternBoundaries().x(), patternBoundaries().y());
     62    affine.multiply(patternTransform());
     63
     64    QBrush brush(pattern->createPlatformPattern(affine));
     65    if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) {
    5266        painter->setBrush(brush);
     67        context->setFillRule(svgStyle->fillRule());
    5368    }
    54     if (type & APPLY_TO_STROKE) {
    55         //QColor c = color();
    56         //c.setAlphaF(style->strokePainter()->opacity() * style->opacity() * opacity());
    57         KRenderingStrokePainter strokePainter = KSVGPainterFactory::strokePainter(renderStyle, object);
    5869
     70    if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) {
    5971        QPen pen;
    60         QBrush brush(QPixmap::fromImage(*patternimage));
    61 
    62         setPenProperties(strokePainter, pen);
    6372        pen.setBrush(brush);
    6473        painter->setPen(pen);
     74        applyStrokeStyleToContext(context, style, object);
    6575    }
    66 
    67     painter->drawPath(*_path);
    68 
    69     delete patternimage;
    70 */
    7176
    7277    return true;
Note: See TracChangeset for help on using the changeset viewer.