2 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc.
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.
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.
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
22 #include "dsodefs.h" // for DSOEXPORT
33 /// Color transformation record
34 class DSOEXPORT SWFCxForm
38 /// Construct an identity CxForm
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
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;
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