Go to the documentation of this file.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 #ifndef GNASH_MATRIX_H
00026 #define GNASH_MATRIX_H
00027
00028 #include "dsodefs.h"
00029
00030 #include <iosfwd>
00031 #include <boost/cstdint.hpp>
00032
00033
00034 namespace gnash {
00035 class SWFRect;
00036 namespace geometry {
00037 class Point2d;
00038 template<typename T> class Range2d;
00039 }
00040 }
00041
00042
00043 namespace gnash {
00044
00053 class DSOEXPORT SWFMatrix
00054 {
00055 public:
00056
00058 SWFMatrix()
00059 :
00060 _a(65536),
00061 _b(0),
00062 _c(0),
00063 _d(65536),
00064 _tx(0),
00065 _ty(0)
00066 {}
00067
00069 SWFMatrix(int a, int b, int c, int d, int x, int y)
00070 :
00071 _a(a),
00072 _b(b),
00073 _c(c),
00074 _d(d),
00075 _tx(x),
00076 _ty(y)
00077 {}
00078
00079 boost::int32_t a() const {
00080 return _a;
00081 }
00082
00083 boost::int32_t b() const {
00084 return _b;
00085 }
00086
00087 boost::int32_t c() const {
00088 return _c;
00089 }
00090
00091 boost::int32_t d() const {
00092 return _d;
00093 }
00094
00095 boost::int32_t tx() const {
00096 return _tx;
00097 }
00098
00099 boost::int32_t ty() const {
00100 return _ty;
00101 }
00102
00104 void set_identity();
00105
00107
00110 void concatenate(const SWFMatrix& m);
00111
00113
00116 void concatenate_translation(int _tx, int _ty);
00117
00119
00122 void concatenate_scale(double x, double y);
00123
00125 void set_lerp(const SWFMatrix& m1, const SWFMatrix& m2, float t);
00126
00128 void set_scale_rotation(double x_scale, double y_scale, double rotation);
00129
00131 void set_scale(double x_scale, double y_scale);
00132
00134 void set_x_scale(double scale);
00135
00137 void set_y_scale(double scale);
00138
00140 void set_rotation(double rotation);
00141
00143 void set_x_translation(int x) {
00144 _tx = x;
00145 }
00146
00148 void set_y_translation(int y) {
00149 _ty = y;
00150 }
00151
00153 void set_translation(int x, int y) {
00154 _tx = x;
00155 _ty = y;
00156 }
00157
00159 void transform(geometry::Point2d& p) const;
00160
00162 void transform(boost::int32_t& x, boost::int32_t& y) const;
00163
00165
00168 void transform(geometry::Point2d* result, const geometry::Point2d& p) const;
00169
00171
00174 void transform(geometry::Range2d<boost::int32_t>& r) const;
00175
00176 void transform(SWFRect& r) const;
00177
00179 SWFMatrix& invert();
00180
00182 double get_x_scale() const;
00183
00185 double get_y_scale() const;
00186
00188 double get_rotation() const;
00189
00191 int get_x_translation() const {
00192 return _tx;
00193 }
00194
00196 int get_y_translation() const {
00197 return _ty;
00198 }
00199
00201 friend bool operator==(const SWFMatrix& a, const SWFMatrix& b);
00202
00203 private:
00204
00206 boost::int64_t determinant() const;
00207
00209 boost::int32_t _a;
00210
00212 boost::int32_t _b;
00213
00215 boost::int32_t _c;
00216
00218 boost::int32_t _d;
00219
00221 boost::int32_t _tx;
00222
00224 boost::int32_t _ty;
00225
00226
00227 };
00228
00229 inline bool
00230 operator==(const SWFMatrix& a, const SWFMatrix& b)
00231 {
00232 return
00233 a.a() == b._a &&
00234 a._b == b._b &&
00235 a._tx == b._tx &&
00236 a._d == b._d &&
00237 a._c == b._c &&
00238 a._ty == b._ty;
00239 }
00240
00241 std::ostream& operator<<(std::ostream& o, const SWFMatrix& m);
00242
00243 }
00244
00245 #endif
00246
00247
00248
00249
00250
00251
00252