• 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     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 }; //end of SWFMatrix
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 }   // namespace gnash
00228 
00229 #endif // GNASH_MATRIX_H
00230 
00231 
00232 // Local Variables:
00233 // mode: C++
00234 // indent-tabs-mode: t
00235 // End:
00236 // 

Generated on Fri Mar 16 2012 15:46:12 for Gnash by  doxygen 1.7.1