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 int sx;
00060
00062 int shx;
00063
00065 int shy;
00066
00068 int sy;
00069
00071 int tx;
00072
00074 int ty;
00075
00076 friend bool operator== (const SWFMatrix&, const SWFMatrix&);
00077 friend std::ostream& operator<< (std::ostream&, const SWFMatrix&);
00078
00080 SWFMatrix()
00081 :
00082 sx(65536),
00083 shx(0),
00084 shy(0),
00085 sy(65536),
00086 tx(0),
00087 ty(0)
00088 {}
00089
00091 SWFMatrix(int a, int b, int c, int d, int x, int y)
00092 :
00093 sx(a),
00094 shx(b),
00095 shy(c),
00096 sy(d),
00097 tx(x),
00098 ty(y)
00099 {}
00100
00102 void set_identity();
00103
00105
00109 void concatenate(const SWFMatrix& m);
00110
00112
00116 void concatenate_translation(int tx, int ty);
00117
00119
00123 void concatenate_scale(double x, double y);
00124
00126 void set_lerp(const SWFMatrix& m1, const SWFMatrix& m2, float t);
00127
00129 void set_scale_rotation(double x_scale, double y_scale, double rotation);
00130
00132 void set_scale(double x_scale, double y_scale);
00133
00135 void set_x_scale(double scale);
00136
00138 void set_y_scale(double scale);
00139
00141 void set_rotation(double rotation);
00142
00144 void set_x_translation(int x)
00145 {
00146 tx = x;
00147 }
00148
00150 void set_y_translation(int y)
00151 {
00152 ty = y;
00153 }
00154
00156 void set_translation(int x, int y)
00157 {
00158 tx = x;
00159 ty = y;
00160 }
00161
00163 void transform(geometry::Point2d& p) const;
00164
00166 void transform(boost::int32_t& x, boost::int32_t& y) const;
00167
00169
00172 void transform(geometry::Point2d* result,
00173 const geometry::Point2d& p) const;
00174
00176
00179 void transform(geometry::Range2d<boost::int32_t>& r) const;
00180
00181 void transform(SWFRect& r) const;
00182
00184 SWFMatrix& invert();
00185
00187 double get_x_scale() const;
00188
00190 double get_y_scale() const;
00191
00193 double get_rotation() const;
00194
00196 int get_x_translation() const
00197 {
00198 return tx;
00199 }
00200
00202 int get_y_translation() const
00203 {
00204 return ty;
00205 }
00206
00207 private:
00209 boost::int64_t determinant() const;
00210
00211 };
00212
00214 SWFMatrix readSWFMatrix(SWFStream& in);
00215
00216 inline bool operator== (const SWFMatrix& a, const SWFMatrix& b)
00217 {
00218 return
00219 a.sx == b.sx &&
00220 a.shx == b.shx &&
00221 a.tx == b.tx &&
00222 a.sy == b.sy &&
00223 a.shy == b.shy &&
00224 a.ty == b.ty;
00225 }
00226
00227 }
00228
00229 #endif // GNASH_MATRIX_H
00230
00231
00232
00233
00234
00235
00236