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 #ifndef GNASHCXFORM_H
00019 #define GNASHCXFORM_H
00020
00021 #include "dsodefs.h"
00022
00023 #include <string>
00024 #include <iosfwd>
00025 #include <boost/cstdint.hpp>
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;
00040 boost::int16_t rb;
00041 boost::int16_t ga;
00042 boost::int16_t gb;
00043 boost::int16_t ba;
00044 boost::int16_t bb;
00045 boost::int16_t aa;
00046 boost::int16_t ab;
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
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 }
00134
00135 #endif // GNASHCXFORM_H
00136
00137
00138
00139
00140
00141