KHtml

AffineTransform.h
1 /*
2  * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef AffineTransform_h
27 #define AffineTransform_h
28 
29 #if PLATFORM(CG)
30 #include <CoreGraphics/CGAffineTransform.h>
31 #elif PLATFORM(QT)
32 #include <QMatrix>
33 #elif PLATFORM(CAIRO)
34 #include <cairo.h>
35 #elif PLATFORM(WX) && USE(WXGC)
36 #include <wx/defs.h>
37 #include <wx/graphics.h>
38 #endif
39 
40 namespace WebCore
41 {
42 
43 class IntPoint;
44 class IntRect;
45 class FloatPoint;
46 class FloatRect;
47 
48 class AffineTransform
49 {
50 public:
51  AffineTransform();
52  AffineTransform(double a, double b, double c, double d, double e, double f);
53 #if PLATFORM(CG)
54  AffineTransform(CGAffineTransform transform);
55 #elif PLATFORM(QT)
56  AffineTransform(const QMatrix &matrix);
57 #elif PLATFORM(CAIRO)
58  AffineTransform(const cairo_matrix_t &matrix);
59 #elif PLATFORM(WX) && USE(WXGC)
60  AffineTransform(const wxGraphicsMatrix &matrix);
61 #endif
62 
63  void setMatrix(double a, double b, double c, double d, double e, double f);
64  void map(double x, double y, double *x2, double *y2) const;
65  IntPoint mapPoint(const IntPoint &) const;
66  FloatPoint mapPoint(const FloatPoint &) const;
67  IntRect mapRect(const IntRect &) const;
68  FloatRect mapRect(const FloatRect &) const;
69 
70  bool isIdentity() const;
71 
72  double a() const;
73  void setA(double a);
74 
75  double b() const;
76  void setB(double b);
77 
78  double c() const;
79  void setC(double c);
80 
81  double d() const;
82  void setD(double d);
83 
84  double e() const;
85  void setE(double e);
86 
87  double f() const;
88  void setF(double f);
89 
90  void reset();
91 
92  AffineTransform &multiply(const AffineTransform &);
93  AffineTransform &scale(double);
94  AffineTransform &scale(double sx, double sy);
95  AffineTransform &scaleNonUniform(double sx, double sy);
96  AffineTransform &rotate(double d);
97  AffineTransform &rotateFromVector(double x, double y);
98  AffineTransform &translate(double tx, double ty);
99  AffineTransform &shear(double sx, double sy);
100  AffineTransform &flipX();
101  AffineTransform &flipY();
102  AffineTransform &skew(double angleX, double angleY);
103  AffineTransform &skewX(double angle);
104  AffineTransform &skewY(double angle);
105 
106  double det() const;
107  bool isInvertible() const;
108  AffineTransform inverse() const;
109 
110 #if PLATFORM(CG)
111  operator CGAffineTransform() const;
112 #elif PLATFORM(QT)
113  operator QMatrix() const;
114 #elif PLATFORM(CAIRO)
115  operator cairo_matrix_t() const;
116 #elif PLATFORM(WX) && USE(WXGC)
117  operator wxGraphicsMatrix() const;
118 #endif
119 
120  bool operator==(const AffineTransform &) const;
121  bool operator!=(const AffineTransform &other) const
122  {
123  return !(*this == other);
124  }
125  AffineTransform &operator*=(const AffineTransform &);
126  AffineTransform operator*(const AffineTransform &);
127 
128 private:
129 #if PLATFORM(CG)
130  CGAffineTransform m_transform;
131 #elif PLATFORM(QT)
132  QMatrix m_transform;
133 #elif PLATFORM(CAIRO)
134  cairo_matrix_t m_transform;
135 #elif PLATFORM(WX) && USE(WXGC)
136  wxGraphicsMatrix m_transform;
137 #endif
138 };
139 
140 } // namespace WebCore
141 
142 #endif // AffineTransform_h
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
KGuiItem reset()
QFuture< void > map(Sequence &sequence, MapFunctor function)
bool operator!=(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:47:58 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.