update copyright date
[gnash.git] / libcore / SWFCxForm.h
blob4067443a52d3d543cf8941add0e7cc6dfc58fe47
1 //
2 // Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #ifndef GNASHCXFORM_H
19 #define GNASHCXFORM_H
21 #include "dsodefs.h" // for DSOEXPORT
23 #include <string>
24 #include <iosfwd>
25 #include <boost/cstdint.hpp>
27 namespace gnash {
28 class rgba;
31 namespace gnash {
33 /// Color transformation record
34 class DSOEXPORT SWFCxForm
36 public:
38 /// Construct an identity CxForm
39 SWFCxForm()
41 ra(256),
42 ga(256),
43 ba(256),
44 aa(256),
45 rb(0),
46 gb(0),
47 bb(0),
48 ab(0)
52 boost::int16_t ra; // RedMultTerm, 8.8 fixed point
53 boost::int16_t ga; // GreenMultTerm 8.8 fixed point
54 boost::int16_t ba; // BlueMultTerm 8.8 fixed point
55 boost::int16_t aa; // AlphaMultTerm 8.8 fixed point
56 boost::int16_t rb; // RedAddTerm, 16 bit integer(no fraction)
57 boost::int16_t gb; // GreenAddTerm 16 bit integer(no fraction)
58 boost::int16_t bb; // BlueAddTerm 16 bit integer(no fraction)
59 boost::int16_t ab; // AlphaAddTerm 16 bit integer(no fraction)
61 /// Concatenate SWFCxForm c onto ours.
63 /// When transforming colors, c's transform is applied
64 /// first, then ours.
65 ///
66 void concatenate(const SWFCxForm& c);
68 /// Transform the given color, return the result.
69 rgba transform(const rgba& in) const;
71 /// Transform the given color.
72 void transform(boost::uint8_t& r, boost::uint8_t& g, boost::uint8_t& b,
73 boost::uint8_t& a) const;
77 inline bool
78 operator==(const SWFCxForm& a, const SWFCxForm& b)
80 return a.ra == b.ra &&
81 a.rb == b.rb &&
82 a.ga == b.ga &&
83 a.gb == b.gb &&
84 a.ba == b.ba &&
85 a.bb == b.bb &&
86 a.aa == b.aa &&
87 a.ab == b.ab;
90 inline bool
91 operator!=(const SWFCxForm& a, const SWFCxForm& b)
93 return !(a == b);
96 /// Returns true when the SWFCxForm leads to alpha == 0
98 /// Not the _alpha property, but the visible alpha related to dislpay.
99 /// The two might be completely different. eg. mc._alpha ranges in
100 /// [-32768, 32767], but the alpha on screen ranges in [0, 255]
101 inline bool
102 invisible(const SWFCxForm& cx)
104 return (255 * cx.aa >> 8) + cx.ab == 0;
107 std::ostream& operator<<(std::ostream& os, const SWFCxForm& cx);
109 } // namespace gnash
111 #endif
114 // Local Variables:
115 // mode: C++
116 // indent-tabs-mode: t
117 // End: