• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

SWFMatrix.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
00003 //   Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 // 
00020 //
00021 // Original author: Thatcher Ulrich <tu@tulrich.com> 2003
00022 //
00023 //
00024 
00025 #ifndef GNASH_MATRIX_H
00026 #define GNASH_MATRIX_H
00027 
00028 #include "dsodefs.h" // for DSOEXPORT
00029 
00030 #include <ostream> 
00031 #include <boost/cstdint.hpp>
00032 
00033 // Forward declarations
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 }; //end of SWFMatrix
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 } // namespace gnash
00220 
00221 #endif 
00222 
00223 
00224 // Local Variables:
00225 // mode: C++
00226 // indent-tabs-mode: t
00227 // End:
00228 // 

Generated on Thu Sep 2 2010 for Gnash by  doxygen 1.7.1