Changeset 38785 in webkit


Ignore:
Timestamp:
Nov 26, 2008 7:07:30 AM (15 years ago)
Author:
krit@webkit.org
Message:

2008-11-26 Dirk Schulze <krit@webkit.org>

Reviewed by Simon Hausmann.

Transformations to the context shouldn't transform the currentPath.
Fixed this on Qt.

[QT] GraphicsContext's currenPath can be transformed
https://bugs.webkit.org/show_bug.cgi?id=22163

  • platform/graphics/GraphicsContextPrivate.h:
  • platform/graphics/qt/GraphicsContextQt.cpp: (WebCore::GraphicsContext::restorePlatformState): (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::strokePath): (WebCore::GraphicsContext::fillRect): (WebCore::GraphicsContext::translate): (WebCore::GraphicsContext::rotate): (WebCore::GraphicsContext::scale): (WebCore::GraphicsContext::concatCTM):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r38781 r38785  
     12008-11-26  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        Transformations to the context shouldn't transform the currentPath.
     6        Fixed this on Qt.
     7
     8        [QT] GraphicsContext's currenPath can be transformed
     9        https://bugs.webkit.org/show_bug.cgi?id=22163
     10
     11        * platform/graphics/GraphicsContextPrivate.h:
     12        * platform/graphics/qt/GraphicsContextQt.cpp:
     13        (WebCore::GraphicsContext::restorePlatformState):
     14        (WebCore::GraphicsContext::fillPath):
     15        (WebCore::GraphicsContext::strokePath):
     16        (WebCore::GraphicsContext::fillRect):
     17        (WebCore::GraphicsContext::translate):
     18        (WebCore::GraphicsContext::rotate):
     19        (WebCore::GraphicsContext::scale):
     20        (WebCore::GraphicsContext::concatCTM):
     21
    1222008-11-26  Jan Michael Alonzo  <jmalonzo@webkit.org>
    223
  • trunk/WebCore/platform/graphics/GraphicsContextPrivate.h

    r38001 r38785  
    2727#define GraphicsContextPrivate_h
    2828
     29#include "AffineTransform.h"
    2930#include "Font.h"
    3031#include "Gradient.h"
     
    7172#if PLATFORM(CAIRO)
    7273        float globalAlpha;
     74#elif PLATFORM(QT)
     75        AffineTransform pathTransform;
    7376#endif
    7477        ColorSpace strokeColorSpace;
  • trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp

    r38618 r38785  
    294294{
    295295    m_data->p()->restore();
     296
     297    if (!m_data->currentPath.isEmpty() && m_common->state.pathTransform.isInvertible()) {
     298        QMatrix matrix = m_common->state.pathTransform;
     299        m_data->currentPath = m_data->currentPath * matrix;
     300    }
    296301}
    297302
     
    545550        break;
    546551    }
     552    m_data->currentPath = QPainterPath();
    547553}
    548554
     
    577583    }
    578584    }
     585    m_data->currentPath = QPainterPath();
    579586}
    580587
     
    600607        break;
    601608    }
     609    m_data->currentPath = QPainterPath();
    602610}
    603611
     
    921929
    922930    m_data->p()->translate(x, y);
     931
     932    if (!m_data->currentPath.isEmpty()) {
     933        QMatrix matrix;
     934        m_data->currentPath = m_data->currentPath * matrix.translate(-x, -y);
     935        m_common->state.pathTransform.translate(x, y);
     936    }
    923937}
    924938
     
    937951
    938952    m_data->p()->rotate(180/M_PI*radians);
     953
     954    if (!m_data->currentPath.isEmpty()) {
     955        QMatrix matrix;
     956        m_data->currentPath = m_data->currentPath * matrix.rotate(-180/M_PI*radians);
     957        m_common->state.pathTransform.rotate(radians);
     958    }
    939959}
    940960
     
    945965
    946966    m_data->p()->scale(s.width(), s.height());
     967
     968    if (!m_data->currentPath.isEmpty()) {
     969        QMatrix matrix;
     970        m_data->currentPath = m_data->currentPath * matrix.scale(1 / s.width(), 1 / s.height());
     971        m_common->state.pathTransform.scale(s.width(), s.height());
     972    }
    947973}
    948974
     
    10081034
    10091035    m_data->p()->setMatrix(transform, true);
     1036
     1037    // Transformations to the context shouldn't transform the currentPath.
     1038    // We have to undo every change made to the context from the currentPath to avoid wrong drawings.
     1039    if (!m_data->currentPath.isEmpty() && transform.isInvertible()) {
     1040        QMatrix matrix = transform.inverse();
     1041        m_data->currentPath = m_data->currentPath * matrix;
     1042        m_common->state.pathTransform.multiply(transform);
     1043    }
    10101044}
    10111045
Note: See TracChangeset for help on using the changeset viewer.