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

cxform.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
00003 // 
00004 // This program is free software; you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation; either version 3 of the License, or
00007 // (at your option) any later version.
00008 // 
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 // 
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017 
00018 #ifndef GNASHCXFORM_H
00019 #define GNASHCXFORM_H
00020 
00021 #include "dsodefs.h" // for DSOEXPORT
00022 
00023 #include <string>
00024 #include <iosfwd>
00025 #include <boost/cstdint.hpp> // for boost::?int??_t 
00026 
00027 namespace gnash {
00028         class rgba;
00029         class SWFStream;
00030 }
00031 
00032 namespace gnash {
00033 
00035 class DSOEXPORT cxform
00036 {
00037 public:
00038 
00039     boost::int16_t ra; // RedMultTerm,   8.8 fixed point
00040     boost::int16_t rb; // RedAddTerm,    16 bit integer(no fraction)
00041     boost::int16_t ga; // GreenMultTerm  8.8 fixed point
00042     boost::int16_t gb; // GreenAddTerm   16 bit integer(no fraction)
00043     boost::int16_t ba; // BlueMultTerm   8.8 fixed point
00044     boost::int16_t bb; // BlueAddTerm    16 bit integer(no fraction)
00045     boost::int16_t aa; // AlphaMultTerm  8.8 fixed point
00046     boost::int16_t ab; // AlphaAddTerm   16 bit integer(no fraction)
00047     
00049     cxform();
00050     
00052     //
00056     void concatenate(const cxform& c);
00057     
00059     rgba transform(const rgba& in) const;
00060     
00062     void transform(boost::uint8_t& r, boost::uint8_t& g, boost::uint8_t& b, boost::uint8_t& a) const;    
00063 
00065     void  store_to(boost::int16_t * dst) const
00066     {
00067         *dst++ = ra; *dst++ = rb; 
00068         *dst++ = ga; *dst++ = gb; 
00069         *dst++ = ba; *dst++ = bb; 
00070         *dst++ = aa; *dst++ = ab; 
00071     }
00072 
00074     cxform & load_from(float * src)
00075     {
00076         // enbrace the overflows intentionally.
00077         ra = static_cast<boost::int16_t>((*src++) * 2.56f);
00078         rb = static_cast<boost::int16_t>(*src++);
00079         ga = static_cast<boost::int16_t>((*src++) * 2.56f);
00080         gb = static_cast<boost::int16_t>(*src++);
00081         ba = static_cast<boost::int16_t>((*src++) * 2.56f);
00082         bb = static_cast<boost::int16_t>(*src++);
00083         aa = static_cast<boost::int16_t>((*src++) * 2.56f);
00084         ab = static_cast<boost::int16_t>(*src++);
00085         return *this;
00086     }
00087     
00089     bool is_identity() const;
00090     
00092     //
00096     bool is_invisible() const;
00097     
00099     void read_rgb(SWFStream& in);
00100 
00102     void read_rgba(SWFStream& in);
00103 
00104     friend bool operator== (const cxform&, const cxform&);
00105     friend bool operator!= (const cxform&, const cxform&);
00106         
00107     friend std::ostream& operator<< (std::ostream& os, const cxform& cx);
00108 
00109         std::string toString() const;
00110 
00111 };
00112 
00113 
00114 inline bool
00115 operator== (const cxform& a, const cxform& b)
00116 {
00117         return  a.ra == b.ra &&
00118             a.rb == b.rb &&
00119             a.ga == b.ga &&
00120             a.gb == b.gb &&
00121             a.ba == b.ba &&
00122             a.bb == b.bb &&
00123             a.aa == b.aa &&
00124             a.ab == b.ab;
00125 }
00126 
00127 inline bool
00128 operator!=(const cxform& a, const cxform& b)
00129 {
00130     return !(a == b);
00131 }
00132 
00133 }       // namespace gnash
00134 
00135 #endif // GNASHCXFORM_H
00136 
00137 
00138 // Local Variables:
00139 // mode: C++
00140 // indent-tabs-mode: t
00141 // End:

Generated on Thu Sep 30 2010 14:34:57 for Gnash by  doxygen 1.7.1