Changeset 54112 in webkit


Ignore:
Timestamp:
Jan 31, 2010 1:04:58 PM (14 years ago)
Author:
krit@webkit.org
Message:

2010-01-31 Dirk Schulze <krit@webkit.org>

Reviewed by Simon Fraser.

Add back an AffineTransform class for use by SVG
https://bugs.webkit.org/show_bug.cgi?id=33750

These are the first steps on reimplementing AffineTransform. Unlike
the old affine code, this one is platform independent like TransformationMatrix.
AffineTransform has the benefit, that it stores just 6 doubles instead of
16 in TransformationMatrix. The calculations of transformations are not that
complex and can improve the memory usage and speed of SVG.
AffineTransform can be used by HTML Canvas3D or SVG, since they are 2D related (at
least for the moment).
HTML Canvas is the first that makes use of the new AffineTransform. Next patches
will introduce the affine code to SVG.

No new tests. The new AffineTransformation code is tested by fast/canvas.

  • Android.mk:
  • GNUmakefile.am:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • html/canvas/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::scale): (WebCore::CanvasRenderingContext2D::rotate): (WebCore::CanvasRenderingContext2D::translate): (WebCore::CanvasRenderingContext2D::transform): (WebCore::CanvasRenderingContext2D::setTransform): (WebCore::CanvasRenderingContext2D::isPointInPath): (WebCore::CanvasRenderingContext2D::willDraw):
  • html/canvas/CanvasRenderingContext2D.h:
  • platform/graphics/GraphicsContext.h:
  • platform/graphics/Path.h:
  • platform/graphics/cairo/GraphicsContextCairo.cpp: (WebCore::GraphicsContext::getAffineCTM): (WebCore::GraphicsContext::concatCTM):
  • platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h: (WebCore::GraphicsContextPlatformPrivate::concatCTM):
  • platform/graphics/cairo/PathCairo.cpp: (WebCore::Path::transform):
  • platform/graphics/cairo/TransformationMatrixCairo.cpp: (WebCore::AffineTransform::operator cairo_matrix_t):
  • platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::GraphicsContext::concatCTM): (WebCore::GraphicsContext::getAffineCTM):
  • platform/graphics/cg/GraphicsContextPlatformPrivateCG.h: (WebCore::GraphicsContextPlatformPrivate::concatCTM):
  • platform/graphics/cg/PathCG.cpp: (WebCore::Path::transform):
  • platform/graphics/cg/TransformationMatrixCG.cpp: (WebCore::AffineTransform::operator CGAffineTransform):
  • platform/graphics/haiku/GraphicsContextHaiku.cpp: (WebCore::GraphicsContext::getAffineCTM): (WebCore::GraphicsContext::concatCTM):
  • platform/graphics/haiku/PathHaiku.cpp: (WebCore::Path::transform):
  • platform/graphics/qt/GraphicsContextQt.cpp: (WebCore::GraphicsContext::getAffineCTM): (WebCore::GraphicsContext::concatCTM):
  • platform/graphics/qt/PathQt.cpp: (WebCore::Path::transform):
  • platform/graphics/qt/TransformationMatrixQt.cpp: (WebCore::AffineTransform::operator QTransform):
  • platform/graphics/skia/GraphicsContextSkia.cpp: (WebCore::GraphicsContext::getAffineCTM):
  • platform/graphics/skia/PathSkia.cpp: (WebCore::Path::transform):
  • platform/graphics/skia/TransformationMatrixSkia.cpp: (WebCore::AffineTransform::operator SkMatrix):
  • platform/graphics/transforms/AffineTransform.cpp: Added. (WebCore::affineTransformDecompose): (WebCore::affineTransformCompose): (WebCore::AffineTransform::AffineTransform): (WebCore::AffineTransform::reset): (WebCore::AffineTransform::setMatrix): (WebCore::AffineTransform::isIdentity): (WebCore::AffineTransform::det): (WebCore::AffineTransform::isInvertible): (WebCore::AffineTransform::inverse): (WebCore::AffineTransform::multiply): (WebCore::AffineTransform::multLeft): (WebCore::AffineTransform::rotate): (WebCore::AffineTransform::scale): (WebCore::AffineTransform::translate): (WebCore::AffineTransform::scaleNonUniform): (WebCore::AffineTransform::rotateFromVector): (WebCore::AffineTransform::flipX): (WebCore::AffineTransform::flipY): (WebCore::AffineTransform::shear): (WebCore::AffineTransform::skew): (WebCore::AffineTransform::skewX): (WebCore::AffineTransform::skewY): (WebCore::makeMapBetweenRects): (WebCore::AffineTransform::map): (WebCore::AffineTransform::mapPoint): (WebCore::AffineTransform::mapRect): (WebCore::AffineTransform::blend):
  • platform/graphics/transforms/AffineTransform.h: Added. (WebCore::AffineTransform::a): (WebCore::AffineTransform::setA): (WebCore::AffineTransform::b): (WebCore::AffineTransform::setB): (WebCore::AffineTransform::c): (WebCore::AffineTransform::setC): (WebCore::AffineTransform::d): (WebCore::AffineTransform::setD): (WebCore::AffineTransform::e): (WebCore::AffineTransform::setE): (WebCore::AffineTransform::f): (WebCore::AffineTransform::setF): (WebCore::AffineTransform::operator== ): (WebCore::AffineTransform::operator!=): (WebCore::AffineTransform::operator*=): (WebCore::AffineTransform::operator*): (WebCore::AffineTransform::setMatrix):
  • platform/graphics/wince/GraphicsContextWince.cpp: (WebCore::GraphicsContext::concatCTM): (WebCore::GraphicsContext::getAffineCTM):
  • platform/graphics/wx/GraphicsContextWx.cpp: (WebCore::GraphicsContext::getAffineCTM): (WebCore::GraphicsContext::concatCTM):
  • platform/graphics/wx/PathWx.cpp: (WebCore::Path::transform):
  • platform/graphics/wx/TransformationMatrixWx.cpp: (WebCore::AffineTransform::operator wxGraphicsMatrix):
Location:
trunk/WebCore
Files:
2 added
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/Android.mk

    r53695 r54112  
    467467        platform/graphics/skia/TransformationMatrixSkia.cpp \
    468468        \
     469        platform/graphics/transforms/AffineTransform.cpp \
    469470        platform/graphics/transforms/Matrix3DTransformOperation.cpp \
    470471        platform/graphics/transforms/MatrixTransformOperation.cpp \
  • trunk/WebCore/ChangeLog

    r54111 r54112  
     12010-01-31  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Add back an AffineTransform class for use by SVG
     6        https://bugs.webkit.org/show_bug.cgi?id=33750
     7
     8        These are the first steps on reimplementing AffineTransform. Unlike
     9        the old affine code, this one is platform independent like TransformationMatrix.
     10        AffineTransform has the benefit, that it stores just 6 doubles instead of
     11        16 in TransformationMatrix. The calculations of transformations are not that
     12        complex and can improve the memory usage and speed of SVG.
     13        AffineTransform can be used by HTML Canvas3D or SVG, since they are 2D related (at
     14        least for the moment).
     15        HTML Canvas is the first that makes use of the new AffineTransform. Next patches
     16        will introduce the affine code to SVG.
     17
     18        No new tests. The new AffineTransformation code is tested by fast/canvas.
     19
     20        * Android.mk:
     21        * GNUmakefile.am:
     22        * WebCore.gypi:
     23        * WebCore.pro:
     24        * WebCore.vcproj/WebCore.vcproj:
     25        * WebCore.xcodeproj/project.pbxproj:
     26        * html/canvas/CanvasRenderingContext2D.cpp:
     27        (WebCore::CanvasRenderingContext2D::scale):
     28        (WebCore::CanvasRenderingContext2D::rotate):
     29        (WebCore::CanvasRenderingContext2D::translate):
     30        (WebCore::CanvasRenderingContext2D::transform):
     31        (WebCore::CanvasRenderingContext2D::setTransform):
     32        (WebCore::CanvasRenderingContext2D::isPointInPath):
     33        (WebCore::CanvasRenderingContext2D::willDraw):
     34        * html/canvas/CanvasRenderingContext2D.h:
     35        * platform/graphics/GraphicsContext.h:
     36        * platform/graphics/Path.h:
     37        * platform/graphics/cairo/GraphicsContextCairo.cpp:
     38        (WebCore::GraphicsContext::getAffineCTM):
     39        (WebCore::GraphicsContext::concatCTM):
     40        * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h:
     41        (WebCore::GraphicsContextPlatformPrivate::concatCTM):
     42        * platform/graphics/cairo/PathCairo.cpp:
     43        (WebCore::Path::transform):
     44        * platform/graphics/cairo/TransformationMatrixCairo.cpp:
     45        (WebCore::AffineTransform::operator cairo_matrix_t):
     46        * platform/graphics/cg/GraphicsContextCG.cpp:
     47        (WebCore::GraphicsContext::concatCTM):
     48        (WebCore::GraphicsContext::getAffineCTM):
     49        * platform/graphics/cg/GraphicsContextPlatformPrivateCG.h:
     50        (WebCore::GraphicsContextPlatformPrivate::concatCTM):
     51        * platform/graphics/cg/PathCG.cpp:
     52        (WebCore::Path::transform):
     53        * platform/graphics/cg/TransformationMatrixCG.cpp:
     54        (WebCore::AffineTransform::operator CGAffineTransform):
     55        * platform/graphics/haiku/GraphicsContextHaiku.cpp:
     56        (WebCore::GraphicsContext::getAffineCTM):
     57        (WebCore::GraphicsContext::concatCTM):
     58        * platform/graphics/haiku/PathHaiku.cpp:
     59        (WebCore::Path::transform):
     60        * platform/graphics/qt/GraphicsContextQt.cpp:
     61        (WebCore::GraphicsContext::getAffineCTM):
     62        (WebCore::GraphicsContext::concatCTM):
     63        * platform/graphics/qt/PathQt.cpp:
     64        (WebCore::Path::transform):
     65        * platform/graphics/qt/TransformationMatrixQt.cpp:
     66        (WebCore::AffineTransform::operator QTransform):
     67        * platform/graphics/skia/GraphicsContextSkia.cpp:
     68        (WebCore::GraphicsContext::getAffineCTM):
     69        * platform/graphics/skia/PathSkia.cpp:
     70        (WebCore::Path::transform):
     71        * platform/graphics/skia/TransformationMatrixSkia.cpp:
     72        (WebCore::AffineTransform::operator SkMatrix):
     73        * platform/graphics/transforms/AffineTransform.cpp: Added.
     74        (WebCore::affineTransformDecompose):
     75        (WebCore::affineTransformCompose):
     76        (WebCore::AffineTransform::AffineTransform):
     77        (WebCore::AffineTransform::reset):
     78        (WebCore::AffineTransform::setMatrix):
     79        (WebCore::AffineTransform::isIdentity):
     80        (WebCore::AffineTransform::det):
     81        (WebCore::AffineTransform::isInvertible):
     82        (WebCore::AffineTransform::inverse):
     83        (WebCore::AffineTransform::multiply):
     84        (WebCore::AffineTransform::multLeft):
     85        (WebCore::AffineTransform::rotate):
     86        (WebCore::AffineTransform::scale):
     87        (WebCore::AffineTransform::translate):
     88        (WebCore::AffineTransform::scaleNonUniform):
     89        (WebCore::AffineTransform::rotateFromVector):
     90        (WebCore::AffineTransform::flipX):
     91        (WebCore::AffineTransform::flipY):
     92        (WebCore::AffineTransform::shear):
     93        (WebCore::AffineTransform::skew):
     94        (WebCore::AffineTransform::skewX):
     95        (WebCore::AffineTransform::skewY):
     96        (WebCore::makeMapBetweenRects):
     97        (WebCore::AffineTransform::map):
     98        (WebCore::AffineTransform::mapPoint):
     99        (WebCore::AffineTransform::mapRect):
     100        (WebCore::AffineTransform::blend):
     101        * platform/graphics/transforms/AffineTransform.h: Added.
     102        (WebCore::AffineTransform::a):
     103        (WebCore::AffineTransform::setA):
     104        (WebCore::AffineTransform::b):
     105        (WebCore::AffineTransform::setB):
     106        (WebCore::AffineTransform::c):
     107        (WebCore::AffineTransform::setC):
     108        (WebCore::AffineTransform::d):
     109        (WebCore::AffineTransform::setD):
     110        (WebCore::AffineTransform::e):
     111        (WebCore::AffineTransform::setE):
     112        (WebCore::AffineTransform::f):
     113        (WebCore::AffineTransform::setF):
     114        (WebCore::AffineTransform::operator== ):
     115        (WebCore::AffineTransform::operator!=):
     116        (WebCore::AffineTransform::operator*=):
     117        (WebCore::AffineTransform::operator*):
     118        (WebCore::AffineTransform::setMatrix):
     119        * platform/graphics/wince/GraphicsContextWince.cpp:
     120        (WebCore::GraphicsContext::concatCTM):
     121        (WebCore::GraphicsContext::getAffineCTM):
     122        * platform/graphics/wx/GraphicsContextWx.cpp:
     123        (WebCore::GraphicsContext::getAffineCTM):
     124        (WebCore::GraphicsContext::concatCTM):
     125        * platform/graphics/wx/PathWx.cpp:
     126        (WebCore::Path::transform):
     127        * platform/graphics/wx/TransformationMatrixWx.cpp:
     128        (WebCore::AffineTransform::operator wxGraphicsMatrix):
     129
    11302010-01-31  Pavel Feldman  <pfeldman@chromium.org>
    2131
  • trunk/WebCore/GNUmakefile.am

    r54104 r54112  
    16021602        WebCore/platform/graphics/WidthIterator.cpp \
    16031603        WebCore/platform/graphics/WidthIterator.h \
     1604        WebCore/platform/graphics/transforms/AffineTransform.cpp \
     1605        WebCore/platform/graphics/transforms/AffineTransform.h \
    16041606        WebCore/platform/graphics/transforms/IdentityTransformOperation.h \
    16051607        WebCore/platform/graphics/transforms/MatrixTransformOperation.cpp \
  • trunk/WebCore/WebCore.gypi

    r54110 r54112  
    21372137            'platform/graphics/skia/SkiaUtils.h',
    21382138            'platform/graphics/skia/TransformationMatrixSkia.cpp',
     2139            'platform/graphics/transforms/AffineTransform.cpp',
     2140            'platform/graphics/transforms/AffineTransform.h',
    21392141            'platform/graphics/transforms/IdentityTransformOperation.h',
    21402142            'platform/graphics/transforms/Matrix3DTransformOperation.cpp',
  • trunk/WebCore/WebCore.pro

    r54109 r54112  
    805805    platform/graphics/SegmentedFontData.cpp \
    806806    platform/graphics/SimpleFontData.cpp \
     807    platform/graphics/transforms/AffineTransform.cpp \
    807808    platform/graphics/transforms/TransformationMatrix.cpp \
    808809    platform/graphics/transforms/MatrixTransformOperation.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r54110 r54112  
    2410824108                                        >
    2410924109                                        <File
     24110                                                RelativePath="..\platform\graphics\transforms\AffineTransform.cpp"
     24111                                                >
     24112                                        </File>
     24113                                        <File
     24114                                                RelativePath="..\platform\graphics\transforms\AffineTransform.h"
     24115                                                >
     24116                                        <File
    2411024117                                                RelativePath="..\platform\graphics\transforms\IdentityTransformOperation.h"
    2411124118                                                >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r54103 r54112  
    13141314                84A81F410FC7E02700955300 /* SourceGraphic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84A81F3F0FC7E02700955300 /* SourceGraphic.cpp */; };
    13151315                84A81F420FC7E02700955300 /* SourceGraphic.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A81F400FC7E02700955300 /* SourceGraphic.h */; };
     1316                84D0C4041115F1D40018AA34 /* AffineTransform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84D0C4031115F1D40018AA34 /* AffineTransform.cpp */; };
     1317                84D0C4061115F1EA0018AA34 /* AffineTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D0C4051115F1EA0018AA34 /* AffineTransform.h */; };
    13161318                85004D940ACEEAEF00C438F6 /* DOMSVGDefsElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 85004D880ACEEAEF00C438F6 /* DOMSVGDefsElement.h */; };
    13171319                85004D950ACEEAEF00C438F6 /* DOMSVGDefsElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 85004D890ACEEAEF00C438F6 /* DOMSVGDefsElement.mm */; };
     
    67176719                84B2B1F8056BEF3A00D2B771 /* WebCoreKeyGenerator.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebCoreKeyGenerator.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    67186720                84B2B24F056BF15F00D2B771 /* SSLKeyGeneratorMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SSLKeyGeneratorMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     6721                84D0C4031115F1D40018AA34 /* AffineTransform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AffineTransform.cpp; path = transforms/AffineTransform.cpp; sourceTree = "<group>"; };
     6722                84D0C4051115F1EA0018AA34 /* AffineTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AffineTransform.h; path = transforms/AffineTransform.h; sourceTree = "<group>"; };
    67196723                85004D880ACEEAEF00C438F6 /* DOMSVGDefsElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMSVGDefsElement.h; sourceTree = "<group>"; };
    67206724                85004D890ACEEAEF00C438F6 /* DOMSVGDefsElement.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMSVGDefsElement.mm; sourceTree = "<group>"; };
     
    1090010904                        isa = PBXGroup;
    1090110905                        children = (
     10906                                84D0C4051115F1EA0018AA34 /* AffineTransform.h */,
     10907                                84D0C4031115F1D40018AA34 /* AffineTransform.cpp */,
    1090210908                                49E911B50EF86D47009D0CAF /* IdentityTransformOperation.h */,
    1090310909                                49D5DC270F423A73008F20FD /* Matrix3DTransformOperation.cpp */,
     
    1846618472                                E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
    1846718473                                97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
     18474                                84D0C4061115F1EA0018AA34 /* AffineTransform.h in Headers */,
    1846818475                        );
    1846918476                        runOnlyForDeploymentPostprocessing = 0;
     
    2064020647                                E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
    2064120648                                97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
     20649                                84D0C4041115F1D40018AA34 /* AffineTransform.cpp in Sources */,
    2064220650                        );
    2064320651                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r52682 r54112  
    3131#include "CanvasRenderingContext2D.h"
    3232
    33 #include "TransformationMatrix.h"
     33#include "AffineTransform.h"
    3434#include "CSSParser.h"
    3535#include "CachedImage.h"
     
    358358        return;
    359359
    360     TransformationMatrix newTransform = state().m_transform;
     360    AffineTransform newTransform = state().m_transform;
    361361    newTransform.scaleNonUniform(sx, sy);
    362362    if (!newTransform.isInvertible()) {
     
    367367    state().m_transform = newTransform;
    368368    c->scale(FloatSize(sx, sy));
    369     m_path.transform(TransformationMatrix().scaleNonUniform(1.0/sx, 1.0/sy));
     369    m_path.transform(AffineTransform().scaleNonUniform(1.0 / sx, 1.0 / sy));
    370370}
    371371
     
    381381        return;
    382382
    383     TransformationMatrix newTransform = state().m_transform;
     383    AffineTransform newTransform = state().m_transform;
    384384    newTransform.rotate(angleInRadians / piDouble * 180.0);
    385385    if (!newTransform.isInvertible()) {
     
    390390    state().m_transform = newTransform;
    391391    c->rotate(angleInRadians);
    392     m_path.transform(TransformationMatrix().rotate(-angleInRadians / piDouble * 180.0));
     392    m_path.transform(AffineTransform().rotate(-angleInRadians / piDouble * 180.0));
    393393}
    394394
     
    404404        return;
    405405
    406     TransformationMatrix newTransform = state().m_transform;
     406    AffineTransform newTransform = state().m_transform;
    407407    newTransform.translate(tx, ty);
    408408    if (!newTransform.isInvertible()) {
     
    413413    state().m_transform = newTransform;
    414414    c->translate(tx, ty);
    415     m_path.transform(TransformationMatrix().translate(-tx, -ty));
     415    m_path.transform(AffineTransform().translate(-tx, -ty));
    416416}
    417417
     
    428428        return;
    429429
    430     TransformationMatrix transform(m11, m12, m21, m22, dx, dy);
    431     TransformationMatrix newTransform = transform * state().m_transform;
     430    AffineTransform transform(m11, m12, m21, m22, dx, dy);
     431    AffineTransform newTransform = transform * state().m_transform;
    432432    if (!newTransform.isInvertible()) {
    433433        state().m_invertibleCTM = false;
     
    450450        return;
    451451
    452     TransformationMatrix ctm = state().m_transform;
     452    AffineTransform ctm = state().m_transform;
    453453    if (!ctm.isInvertible())
    454454        return;
     
    709709
    710710    FloatPoint point(x, y);
    711     TransformationMatrix ctm = state().m_transform;
     711    AffineTransform ctm = state().m_transform;
    712712    FloatPoint transformedPoint = ctm.inverse().mapPoint(point);
    713713    return m_path.contains(transformedPoint);
     
    12421242    FloatRect dirtyRect = r;
    12431243    if (options & CanvasWillDrawApplyTransform) {
    1244         TransformationMatrix ctm = state().m_transform;
     1244        AffineTransform ctm = state().m_transform;
    12451245        dirtyRect = ctm.mapRect(r);
    12461246    }
  • trunk/WebCore/html/canvas/CanvasRenderingContext2D.h

    r49734 r54112  
    2727#define CanvasRenderingContext2D_h
    2828
     29#include "AffineTransform.h"
    2930#include "CanvasRenderingContext.h"
    30 #include "TransformationMatrix.h"
    3131#include "FloatSize.h"
    3232#include "Font.h"
     
    219219            float m_globalAlpha;
    220220            CompositeOperator m_globalComposite;
    221             TransformationMatrix m_transform;
     221            AffineTransform m_transform;
    222222            bool m_invertibleCTM;
    223223           
  • trunk/WebCore/platform/graphics/GraphicsContext.h

    r54075 r54112  
    112112    const int cMisspellingLinePatternGapWidth = 1;
    113113
     114    class AffineTransform;
    114115    class Font;
    115116    class Generator;
     
    305306
    306307        void concatCTM(const TransformationMatrix&);
     308        void concatCTM(const AffineTransform&);
    307309        TransformationMatrix getCTM() const;
     310        AffineTransform getAffineCTM() const;
    308311
    309312#if OS(WINCE) && !PLATFORM(QT)
  • trunk/WebCore/platform/graphics/Path.h

    r53131 r54112  
    6868namespace WebCore {
    6969
     70    class AffineTransform;
    7071    class FloatPoint;
    7172    class FloatRect;
     
    146147
    147148        void apply(void* info, PathApplierFunction) const;
     149        void transform(const AffineTransform&);
    148150        void transform(const TransformationMatrix&);
    149151
  • trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r53857 r54112  
    3333#if PLATFORM(CAIRO)
    3434
     35#include "AffineTransform.h"
    3536#include "CairoPath.h"
    3637#include "FEGaussianBlur.h"
     
    215216    cairo_get_matrix(cr, &m);
    216217    return TransformationMatrix(m.xx, m.yx, m.xy, m.yy, m.x0, m.y0);
     218}
     219
     220AffineTransform GraphicsContext::getAffineCTM() const
     221{
     222    cairo_t* cr = platformContext();
     223    cairo_matrix_t m;
     224    cairo_get_matrix(cr, &m);
     225    return AffineTransform(m.xx, m.yx, m.xy, m.yy, m.x0, m.y0);
    217226}
    218227
     
    793802
    794803void GraphicsContext::concatCTM(const TransformationMatrix& transform)
     804{
     805    if (paintingDisabled())
     806        return;
     807
     808    cairo_t* cr = m_data->cr;
     809    const cairo_matrix_t matrix = cairo_matrix_t(transform);
     810    cairo_transform(cr, &matrix);
     811    m_data->concatCTM(transform);
     812}
     813
     814void GraphicsContext::concatCTM(const AffineTransform& transform)
    795815{
    796816    if (paintingDisabled())
  • trunk/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h

    r52421 r54112  
    7272    void rotate(float);
    7373    void translate(float, float);
     74    void concatCTM(const AffineTransform&);
    7475    void concatCTM(const TransformationMatrix&);
    7576    void beginTransparencyLayer() { m_transparencyCount++; }
     
    8687    void rotate(float) {}
    8788    void translate(float, float) {}
     89    void concatCTM(const AffineTransform&) {}
    8890    void concatCTM(const TransformationMatrix&) {}
    8991    void beginTransparencyLayer() {}
  • trunk/WebCore/platform/graphics/cairo/PathCairo.cpp

    r50527 r54112  
    2626#include "Path.h"
    2727
     28#include "AffineTransform.h"
    2829#include "TransformationMatrix.h"
    2930#include "CairoPath.h"
     
    327328}
    328329
     330void Path::transform(const AffineTransform& trans)
     331{
     332    cairo_t* m_cr = platformPath()->m_cr;
     333    cairo_matrix_t c_matrix = cairo_matrix_t(trans);
     334    cairo_matrix_invert(&c_matrix);
     335    cairo_transform(m_cr, &c_matrix);
     336}
     337
    329338void Path::transform(const TransformationMatrix& trans)
    330339{
  • trunk/WebCore/platform/graphics/cairo/TransformationMatrixCairo.cpp

    r40774 r54112  
    2424
    2525#include "config.h"
     26#include "AffineTransform.h"
    2627#include "TransformationMatrix.h"
    2728
     
    4748}
    4849
     50AffineTransform::operator cairo_matrix_t() const
     51{
     52    cairo_matrix_t m;
     53
     54    cairo_matrix_init (&m,
     55                       a(),
     56                       b(),
     57                       c(),
     58                       d(),
     59                       e(),
     60                       f());
     61    return m;
     62}
     63
    4964}
    5065
  • trunk/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r54107 r54112  
    2929#include "GraphicsContext.h"
    3030
     31#include "AffineTransform.h"
    3132#include "FloatConversion.h"
    3233#include "GraphicsContextPlatformPrivateCG.h"
     
    959960}
    960961
    961 void GraphicsContext::concatCTM(const TransformationMatrix& transform)
     962void GraphicsContext::concatCTM(const AffineTransform& transform)
    962963{
    963964    if (paintingDisabled())
     
    966967    m_data->concatCTM(transform);
    967968    m_data->m_userToDeviceTransformKnownToBeIdentity = false;
     969}
     970
     971void GraphicsContext::concatCTM(const TransformationMatrix& transform)
     972{
     973    if (paintingDisabled())
     974        return;
     975    CGContextConcatCTM(platformContext(), transform);
     976    m_data->concatCTM(transform);
     977    m_data->m_userToDeviceTransformKnownToBeIdentity = false;
     978}
     979
     980AffineTransform GraphicsContext::getAffineCTM() const
     981{
     982    CGAffineTransform t = CGContextGetCTM(platformContext());
     983    return AffineTransform(t.a, t.b, t.c, t.d, t.tx, t.ty);
    968984}
    969985
  • trunk/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h

    r51212 r54112  
    7474    void rotate(float) {}
    7575    void translate(float, float) {}
     76    void concatCTM(const AffineTransform&) {}
    7677    void concatCTM(const TransformationMatrix&) {}
    7778    void beginTransparencyLayer() {}
     
    8990    void rotate(float);
    9091    void translate(float, float);
     92    void concatCTM(const AffineTransform&);
    9193    void concatCTM(const TransformationMatrix&);
    9294    void beginTransparencyLayer() { m_transparencyCount++; }
  • trunk/WebCore/platform/graphics/cg/PathCG.cpp

    r47585 r54112  
    3030#if PLATFORM(CG)
    3131
     32#include "AffineTransform.h"
    3233#include "TransformationMatrix.h"
    3334#include <ApplicationServices/ApplicationServices.h>
     
    347348}
    348349
    349 void Path::transform(const TransformationMatrix& transform)
     350void Path::transform(const AffineTransform& transform)
    350351{
    351352    CGMutablePathRef path = CGPathCreateMutable();
     
    356357}
    357358
     359void Path::transform(const TransformationMatrix& transform)
     360{
     361    CGMutablePathRef path = CGPathCreateMutable();
     362    CGAffineTransform transformCG = transform;
     363    CGPathAddPath(path, &transformCG, m_path);
     364    CGPathRelease(m_path);
     365    m_path = path;
     366}
     367
    358368}
    359369
  • trunk/WebCore/platform/graphics/cg/TransformationMatrixCG.cpp

    r40761 r54112  
    2525
    2626#include "config.h"
     27#include "AffineTransform.h"
    2728#include "TransformationMatrix.h"
    2829
     
    4445}
    4546
     47AffineTransform::operator CGAffineTransform() const
     48{
     49    return CGAffineTransformMake(narrowPrecisionToCGFloat(a()),
     50                                 narrowPrecisionToCGFloat(b()),
     51                                 narrowPrecisionToCGFloat(c()),
     52                                 narrowPrecisionToCGFloat(d()),
     53                                 narrowPrecisionToCGFloat(e()),
     54                                 narrowPrecisionToCGFloat(f()));
     55}
     56
    4657}
    4758
  • trunk/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp

    r53857 r54112  
    2929#include "GraphicsContext.h"
    3030
     31#include "AffineTransform.h"
    3132#include "CString.h"
    3233#include "Color.h"
     
    392393}
    393394
     395AffineTransform GraphicsContext::getAffineCTM() const
     396{
     397    notImplemented();
     398    return AffineTransform();
     399}
     400
    394401TransformationMatrix GraphicsContext::getCTM() const
    395402{
     
    445452
    446453void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
     454{
     455    if (paintingDisabled())
     456        return;
     457
     458    notImplemented();
     459}
     460
     461void GraphicsContext::concatCTM(const AffineTransform& transform)
    447462{
    448463    if (paintingDisabled())
  • trunk/WebCore/platform/graphics/haiku/PathHaiku.cpp

    r47142 r54112  
    2929#include "Path.h"
    3030
     31#include "AffineTransform.h"
    3132#include "FloatRect.h"
    3233#include "NotImplemented.h"
     
    147148}
    148149
     150void Path::transform(const AffineTransform& transform)
     151{
     152    notImplemented();
     153}
     154
    149155void Path::transform(const TransformationMatrix& transform)
    150156{
  • trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp

    r53857 r54112  
    4141#endif
    4242
     43#include "AffineTransform.h"
    4344#include "Color.h"
    4445#include "FloatConversion.h"
     
    276277}
    277278
     279AffineTransform GraphicsContext::getAffineCTM() const
     280{
     281    QTransform matrix(platformContext()->combinedTransform());
     282    return AffineTransform(matrix.m11(), matrix.m12(), matrix.m21(),
     283                           matrix.m22(), matrix.dx(), matrix.dy());
     284}
     285
    278286TransformationMatrix GraphicsContext::getCTM() const
    279287{
     
    11891197}
    11901198
     1199void GraphicsContext::concatCTM(const AffineTransform& transform)
     1200{
     1201    if (paintingDisabled())
     1202        return;
     1203
     1204    m_data->p()->setWorldTransform(transform, true);
     1205
     1206    // Transformations to the context shouldn't transform the currentPath.
     1207    // We have to undo every change made to the context from the currentPath
     1208    // to avoid wrong drawings.
     1209    if (!m_data->currentPath.isEmpty() && transform.isInvertible()) {
     1210        QTransform matrix = transform.inverse();
     1211        m_data->currentPath = m_data->currentPath * matrix;
     1212        m_common->state.pathTransform.multiply(transform.toTransformationMatrix());
     1213    }
     1214}
     1215
     1216
    11911217void GraphicsContext::concatCTM(const TransformationMatrix& transform)
    11921218{
  • trunk/WebCore/platform/graphics/qt/PathQt.cpp

    r53131 r54112  
    22 * Copyright (C) 2006 Zack Rusin   <zack@kde.org>
    33 *               2006 Rob Buis     <buis@kde.org>
    4  *               2009 Dirk Schulze <krit@webkit.org>
     4 *               2009, 2010 Dirk Schulze <krit@webkit.org>
    55 *
    66 * All rights reserved.
     
    3131#include "Path.h"
    3232
    33 #include "TransformationMatrix.h"
     33#include "AffineTransform.h"
    3434#include "FloatRect.h"
    3535#include "GraphicsContext.h"
     
    3737#include "PlatformString.h"
    3838#include "StrokeStyleApplier.h"
     39#include "TransformationMatrix.h"
    3940#include <QPainterPath>
    4041#include <QTransform>
     
    380381}
    381382
     383void Path::transform(const AffineTransform& transform)
     384{
     385    m_path = QTransform(transform).map(m_path);
     386}
     387
    382388void Path::transform(const TransformationMatrix& transform)
    383389{
  • trunk/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp

    r46170 r54112  
    2525
    2626#include "config.h"
     27#include "AffineTransform.h"
    2728#include "TransformationMatrix.h"
    2829
     
    3738}
    3839
     40AffineTransform::operator QTransform() const
     41{
     42    return QTransform(a(), b(), c(), d(), e(), f());
     43}
     44
    3945}
    4046
  • trunk/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp

    r53857 r54112  
    3232#include "GraphicsContext.h"
    3333
     34#include "AffineTransform.h"
    3435#include "Color.h"
    3536#include "FloatRect.h"
     
    440441}
    441442
     443void GraphicsContext::concatCTM(const AffineTransform& affine)
     444{
     445    if (paintingDisabled())
     446        return;
     447    platformContext()->canvas()->concat(affine);
     448}
     449
    442450void GraphicsContext::concatCTM(const TransformationMatrix& xform)
    443451{
     
    806814}
    807815
     816AffineTransform GraphicsContext::getAffineCTM() const
     817{
     818    const SkMatrix& m = platformContext()->canvas()->getTotalMatrix();
     819    return AffineTransform(SkScalarToDouble(m.getScaleX()),      // a
     820                           SkScalarToDouble(m.getSkewY()),       // b
     821                           SkScalarToDouble(m.getSkewX()),       // c
     822                           SkScalarToDouble(m.getScaleY()),      // d
     823                           SkScalarToDouble(m.getTranslateX()),  // e
     824                           SkScalarToDouble(m.getTranslateY())); // f
     825}
     826
    808827TransformationMatrix GraphicsContext::getCTM() const
    809828{
  • trunk/WebCore/platform/graphics/skia/PathSkia.cpp

    r49794 r54112  
    3131#include "Path.h"
    3232
     33#include "AffineTransform.h"
    3334#include "FloatRect.h"
    3435#include "ImageBuffer.h"
     
    215216}
    216217
     218void Path::transform(const AffineTransform& xform)
     219{
     220    m_path->transform(xform);
     221}
     222
    217223void Path::transform(const TransformationMatrix& xform)
    218224{
  • trunk/WebCore/platform/graphics/skia/TransformationMatrixSkia.cpp

    r40809 r54112  
    2929
    3030#include "config.h"
     31#include "AffineTransform.h"
    3132#include "TransformationMatrix.h"
    3233
     
    5556}
    5657
     58AffineTransform::operator SkMatrix() const
     59{
     60    SkMatrix result;
     61
     62    result.setScaleX(WebCoreDoubleToSkScalar(a()));
     63    result.setSkewX(WebCoreDoubleToSkScalar(c()));
     64    result.setTranslateX(WebCoreDoubleToSkScalar(e()));
     65
     66    result.setScaleY(WebCoreDoubleToSkScalar(d()));
     67    result.setSkewY(WebCoreDoubleToSkScalar(b()));
     68    result.setTranslateY(WebCoreDoubleToSkScalar(f()));
     69
     70    // FIXME: Set perspective properly.
     71    result.setPerspX(0);
     72    result.setPerspY(0);
     73    result.set(SkMatrix::kMPersp2, SK_Scalar1);
     74
     75    return result;
     76}
     77
    5778} // namespace WebCore
  • trunk/WebCore/platform/graphics/wince/GraphicsContextWince.cpp

    r53857 r54112  
    2222#include "GraphicsContext.h"
    2323
     24#include "AffineTransform.h"
    2425#include "CharacterNames.h"
    2526#include "GlyphBuffer.h"
     
    11441145}
    11451146
     1147void GraphicsContext::concatCTM(const AffineTransform& transform)
     1148{
     1149    m_data->concatCTM(transform);
     1150}
     1151
    11461152void GraphicsContext::concatCTM(const TransformationMatrix& transform)
    11471153{
     
    15301536
    15311537    GradientFill(dc, tv.data(), tv.size(), mesh.data(), mesh.size(), vertical ? GRADIENT_FILL_RECT_V : GRADIENT_FILL_RECT_H);
     1538}
     1539
     1540AffineTransform GraphicsContext::getAffineCTM() const
     1541{
     1542    return m_data->m_transform;
    15321543}
    15331544
  • trunk/WebCore/platform/graphics/wx/GraphicsContextWx.cpp

    r53857 r54112  
    2727#include "GraphicsContext.h"
    2828
     29#include "AffineTransform.h"
    2930#include "TransformationMatrix.h"
    3031#include "FloatRect.h"
     
    360361}
    361362
     363AffineTransform GraphicsContext::getAffineCTM() const
     364{
     365    notImplemented();
     366    return AffineTransform();
     367}
     368
    362369TransformationMatrix GraphicsContext::getCTM() const
    363370{
     
    470477    if (m_data->context)
    471478        m_data->context->SetBrush(wxBrush(color));
     479}
     480
     481void GraphicsContext::concatCTM(const AffineTransform& transform)
     482{
     483    if (paintingDisabled())
     484        return;
     485
     486    notImplemented();
     487    return;
    472488}
    473489
  • trunk/WebCore/platform/graphics/wx/PathWx.cpp

    r45873 r54112  
    2727#include "Path.h"
    2828
     29#include "AffineTransform.h"
    2930#include "TransformationMatrix.h"
    3031#include "FloatPoint.h"
     
    203204}
    204205
     206void Path::transform(const AffineTransform& transform)
     207{
     208#if USE(WXGC)
     209    if (m_path)
     210        m_path->Transform(transform);
     211#endif
     212}
     213
    205214void Path::transform(const TransformationMatrix& transform)
    206215{
  • trunk/WebCore/platform/graphics/wx/TransformationMatrixWx.cpp

    r42610 r54112  
    2525
    2626#include "config.h"
     27#include "AffineTransform.h"
    2728#include "TransformationMatrix.h"
    2829
     
    4647    return matrix;
    4748}
     49
     50AffineTransform::operator wxGraphicsMatrix() const
     51{
     52    wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDefaultRenderer();
     53    ASSERT(renderer);
     54   
     55    wxGraphicsMatrix matrix = renderer->CreateMatrix(a(), b(), c(), d(), e(), f());
     56    return matrix;
     57}
    4858#endif
    4959
Note: See TracChangeset for help on using the changeset viewer.