Gnash  0.8.11dev
SWFCxForm.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc.
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef GNASHCXFORM_H
20 #define GNASHCXFORM_H
21 
22 #include "dsodefs.h" // for DSOEXPORT
23 
24 #include <string>
25 #include <iosfwd>
26 #include <boost/cstdint.hpp>
27 
28 namespace gnash {
29  class rgba;
30 }
31 
32 namespace gnash {
33 
36 {
37 public:
38 
41  :
42  ra(256),
43  ga(256),
44  ba(256),
45  aa(256),
46  rb(0),
47  gb(0),
48  bb(0),
49  ab(0)
50  {
51  }
52 
53  boost::int16_t ra; // RedMultTerm, 8.8 fixed point
54  boost::int16_t ga; // GreenMultTerm 8.8 fixed point
55  boost::int16_t ba; // BlueMultTerm 8.8 fixed point
56  boost::int16_t aa; // AlphaMultTerm 8.8 fixed point
57  boost::int16_t rb; // RedAddTerm, 16 bit integer(no fraction)
58  boost::int16_t gb; // GreenAddTerm 16 bit integer(no fraction)
59  boost::int16_t bb; // BlueAddTerm 16 bit integer(no fraction)
60  boost::int16_t ab; // AlphaAddTerm 16 bit integer(no fraction)
61 
63  //
67  void concatenate(const SWFCxForm& c);
68 
70  rgba transform(const rgba& in) const;
71 
73  void transform(boost::uint8_t& r, boost::uint8_t& g, boost::uint8_t& b,
74  boost::uint8_t& a) const;
75 
76 };
77 
78 inline bool
79 operator==(const SWFCxForm& a, const SWFCxForm& b)
80 {
81  return a.ra == b.ra &&
82  a.rb == b.rb &&
83  a.ga == b.ga &&
84  a.gb == b.gb &&
85  a.ba == b.ba &&
86  a.bb == b.bb &&
87  a.aa == b.aa &&
88  a.ab == b.ab;
89 }
90 
91 inline bool
92 operator!=(const SWFCxForm& a, const SWFCxForm& b)
93 {
94  return !(a == b);
95 }
96 
98 //
102 inline bool
104 {
105  return (255 * cx.aa >> 8) + cx.ab == 0;
106 }
107 
108 std::ostream& operator<<(std::ostream& os, const SWFCxForm& cx);
109 
110 } // namespace gnash
111 
112 #endif
113 
114 
115 // Local Variables:
116 // mode: C++
117 // indent-tabs-mode: t
118 // End: