2 // Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
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.
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.
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
21 #include "dsodefs.h" // for DSOEXPORT
25 #include <boost/cstdint.hpp>
33 /// Color transformation record
34 class DSOEXPORT SWFCxForm
38 /// Construct an identity CxForm
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
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;
78 operator==(const SWFCxForm
& a
, const SWFCxForm
& b
)
80 return a
.ra
== b
.ra
&&
91 operator!=(const SWFCxForm
& a
, const SWFCxForm
& 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]
102 invisible(const SWFCxForm
& cx
)
104 return (255 * cx
.aa
>> 8) + cx
.ab
== 0;
107 std::ostream
& operator<<(std::ostream
& os
, const SWFCxForm
& cx
);
116 // indent-tabs-mode: t