00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "config.h"
00027 #include "wtf/Platform.h"
00028 #include "AffineTransform.h"
00029
00030 #include "IntRect.h"
00031 #include "FloatRect.h"
00032
00033 namespace WebCore {
00034
00035 AffineTransform::AffineTransform()
00036 : m_transform()
00037 {
00038 }
00039
00040 AffineTransform::AffineTransform(double a, double b, double c, double d, double tx, double ty)
00041 : m_transform(a, b, c, d, tx, ty)
00042 {
00043 }
00044
00045 AffineTransform::AffineTransform(const QMatrix& matrix)
00046 : m_transform(matrix)
00047 {
00048 }
00049
00050 void AffineTransform::setMatrix(double a, double b, double c, double d, double tx, double ty)
00051 {
00052 m_transform.setMatrix(a, b, c, d, tx, ty);
00053 }
00054
00055 void AffineTransform::map(double x, double y, double* x2, double* y2) const
00056 {
00057 qreal tx2, ty2;
00058 m_transform.map(qreal(x), qreal(y), &tx2, &ty2);
00059 *x2 = tx2;
00060 *y2 = ty2;
00061 }
00062
00063 IntRect AffineTransform::mapRect(const IntRect& rect) const
00064 {
00065 return m_transform.mapRect(rect);
00066 }
00067
00068 FloatRect AffineTransform::mapRect(const FloatRect& rect) const
00069 {
00070 return m_transform.mapRect(rect);
00071 }
00072
00073 bool AffineTransform::isIdentity() const
00074 {
00075 return m_transform.isIdentity();
00076 }
00077
00078 double AffineTransform::a() const
00079 {
00080 return m_transform.m11();
00081 }
00082
00083 void AffineTransform::setA(double a)
00084 {
00085 m_transform.setMatrix(a, b(), c(), d(), e(), f());
00086 }
00087
00088 double AffineTransform::b() const
00089 {
00090 return m_transform.m12();
00091 }
00092
00093 void AffineTransform::setB(double b)
00094 {
00095 m_transform.setMatrix(a(), b, c(), d(), e(), f());
00096 }
00097
00098 double AffineTransform::c() const
00099 {
00100 return m_transform.m21();
00101 }
00102
00103 void AffineTransform::setC(double c)
00104 {
00105 m_transform.setMatrix(a(), b(), c, d(), e(), f());
00106 }
00107
00108 double AffineTransform::d() const
00109 {
00110 return m_transform.m22();
00111 }
00112
00113 void AffineTransform::setD(double d)
00114 {
00115 m_transform.setMatrix(a(), b(), c(), d, e(), f());
00116 }
00117
00118 double AffineTransform::e() const
00119 {
00120 return m_transform.dx();
00121 }
00122
00123 void AffineTransform::setE(double e)
00124 {
00125 m_transform.setMatrix(a(), b(), c(), d(), e, f());
00126 }
00127
00128 double AffineTransform::f() const
00129 {
00130 return m_transform.dy();
00131 }
00132
00133 void AffineTransform::setF(double f)
00134 {
00135 m_transform.setMatrix(a(), b(), c(), d(), e(), f);
00136 }
00137
00138 void AffineTransform::reset()
00139 {
00140 m_transform.reset();
00141 }
00142
00143 AffineTransform& AffineTransform::scale(double sx, double sy)
00144 {
00145 m_transform.scale(sx, sy);
00146 return *this;
00147 }
00148
00149 AffineTransform& AffineTransform::rotate(double d)
00150 {
00151 m_transform.rotate(d);
00152 return *this;
00153 }
00154
00155 AffineTransform& AffineTransform::translate(double tx, double ty)
00156 {
00157 m_transform.translate(tx, ty);
00158 return *this;
00159 }
00160
00161 AffineTransform& AffineTransform::shear(double sx, double sy)
00162 {
00163 m_transform.shear(sx, sy);
00164 return *this;
00165 }
00166
00167 double AffineTransform::det() const
00168 {
00169 return m_transform.det();
00170 }
00171
00172 AffineTransform AffineTransform::inverse() const
00173 {
00174 if(!isInvertible())
00175 return AffineTransform();
00176
00177 return m_transform.inverted();
00178 }
00179
00180 AffineTransform::operator QMatrix() const
00181 {
00182 return m_transform;
00183 }
00184
00185 bool AffineTransform::operator==(const AffineTransform& other) const
00186 {
00187 return m_transform == other.m_transform;
00188 }
00189
00190 AffineTransform& AffineTransform::operator*=(const AffineTransform& other)
00191 {
00192 m_transform *= other.m_transform;
00193 return *this;
00194 }
00195
00196 AffineTransform AffineTransform::operator*(const AffineTransform& other)
00197 {
00198 return m_transform * other.m_transform;
00199 }
00200
00201 }
00202
00203