Update with current status
[gnash.git] / libcore / SWFCxForm.h
blob74ccbaec85bb0c4ff8de533e4d427bd2e3993638
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
19 #ifndef GNASHCXFORM_H
20 #define GNASHCXFORM_H
22 #include "dsodefs.h" // for DSOEXPORT
24 #include <iosfwd>
25 #include <cstdint>
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 std::int16_t ra; // RedMultTerm, 8.8 fixed point
53 std::int16_t ga; // GreenMultTerm 8.8 fixed point
54 std::int16_t ba; // BlueMultTerm 8.8 fixed point
55 std::int16_t aa; // AlphaMultTerm 8.8 fixed point
56 std::int16_t rb; // RedAddTerm, 16 bit integer(no fraction)
57 std::int16_t gb; // GreenAddTerm 16 bit integer(no fraction)
58 std::int16_t bb; // BlueAddTerm 16 bit integer(no fraction)
59 std::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(std::uint8_t& r, std::uint8_t& g, std::uint8_t& b,
73 std::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: