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 <ostream>
00031 #include <boost/cstdint.hpp>
00032
00033
00034 namespace gnash {
00035 class SWFStream;
00036 class SWFRect;
00037 namespace geometry {
00038 class Point2d;
00039 template<typename T> class Range2d;
00040 }
00041 }
00042
00043
00044 namespace gnash {
00045
00054 class DSOEXPORT SWFMatrix
00055 {
00056 public:
00057
00059 boost::int32_t sx;
00060
00062 boost::int32_t shx;
00063
00065 boost::int32_t shy;
00066
00068 boost::int32_t sy;
00069
00071 boost::int32_t tx;
00072
00074 boost::int32_t ty;
00075
00077 SWFMatrix()
00078 :
00079 sx(65536),
00080 shx(0),
00081 shy(0),
00082 sy(65536),
00083 tx(0),
00084 ty(0)
00085 {}
00086
00088 SWFMatrix(int a, int b, int c, int d, int x, int y)
00089 :
00090 sx(a),
00091 shx(b),
00092 shy(c),
00093 sy(d),
00094 tx(x),
00095 ty(y)
00096 {}
00097
00099 void set_identity();
00100
00102
00105 void concatenate(const SWFMatrix& m);
00106
00108
00111 void concatenate_translation(int tx, int ty);
00112
00114
00117 void concatenate_scale(double x, double y);
00118
00120 void set_lerp(const SWFMatrix& m1, const SWFMatrix& m2, float t);
00121
00123 void set_scale_rotation(double x_scale, double y_scale, double rotation);
00124
00126 void set_scale(double x_scale, double y_scale);
00127
00129 void set_x_scale(double scale);
00130
00132 void set_y_scale(double scale);
00133
00135 void set_rotation(double rotation);
00136
00138 void set_x_translation(int x) {
00139 tx = x;
00140 }
00141
00143 void set_y_translation(int y) {
00144 ty = y;
00145 }
00146
00148 void set_translation(int x, int y) {
00149 tx = x;
00150 ty = y;
00151 }
00152
00154 void transform(geometry::Point2d& p) const;
00155
00157 void transform(boost::int32_t& x, boost::int32_t& y) const;
00158
00160
00163 void transform(geometry::Point2d* result, const geometry::Point2d& p) const;
00164
00166
00169 void transform(geometry::Range2d<boost::int32_t>& r) const;
00170
00171 void transform(SWFRect& r) const;
00172
00174 SWFMatrix& invert();
00175
00177 double get_x_scale() const;
00178
00180 double get_y_scale() const;
00181
00183 double get_rotation() const;
00184
00186 int get_x_translation() const {
00187 return tx;
00188 }
00189
00191 int get_y_translation() const {
00192 return ty;
00193 }
00194
00195 private:
00196
00198 boost::int64_t determinant() const;
00199
00200 };
00201
00203 SWFMatrix readSWFMatrix(SWFStream& in);
00204
00205 inline bool
00206 operator==(const SWFMatrix& a, const SWFMatrix& b)
00207 {
00208 return
00209 a.sx == b.sx &&
00210 a.shx == b.shx &&
00211 a.tx == b.tx &&
00212 a.sy == b.sy &&
00213 a.shy == b.shy &&
00214 a.ty == b.ty;
00215 }
00216
00217 std::ostream& operator<<(std::ostream& o, const SWFMatrix& m);
00218
00219 }
00220
00221 #endif
00222
00223
00224
00225
00226
00227
00228