2 * Copyright (C) 2007 Benjamin Otte <otte@gnome.org>
3 * 2007 Pekka Lampila <pekka.lampila@iki.fi>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library 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 GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301 USA
25 #include "swfdec_filter.h"
26 #include "swfdec_debug.h"
28 G_DEFINE_ABSTRACT_TYPE (SwfdecFilter
, swfdec_filter
, SWFDEC_TYPE_AS_OBJECT
)
31 swfdec_filter_class_init (SwfdecFilterClass
*klass
)
36 swfdec_filter_init (SwfdecFilter
*array
)
41 swfdec_filter_apply (SwfdecFilter
*filter
, cairo_pattern_t
*pattern
)
43 SwfdecFilterClass
*klass
;
46 g_return_val_if_fail (SWFDEC_IS_FILTER (filter
), NULL
);
47 g_return_val_if_fail (pattern
!= NULL
, NULL
);
49 klass
= SWFDEC_FILTER_GET_CLASS (filter
);
50 g_assert (klass
->apply
);
52 ret
= klass
->apply (filter
, pattern
);
53 cairo_pattern_destroy (pattern
);
58 swfdec_filter_parse (SwfdecPlayer
*player
, SwfdecBits
*bits
)
60 GSList
*filters
= NULL
;
61 guint i
, n_filters
, filter_id
;
63 g_return_val_if_fail (SWFDEC_IS_PLAYER (player
), NULL
);
64 g_return_val_if_fail (bits
!= NULL
, NULL
);
66 n_filters
= swfdec_bits_get_u8 (bits
);
67 SWFDEC_LOG (" filters: %u", n_filters
);
68 for (i
= 0; i
< n_filters
&& swfdec_bits_left (bits
); i
++) {
69 filter_id
= swfdec_bits_get_u8 (bits
);
72 SWFDEC_WARNING (" drop shadow");
73 swfdec_bits_skip_bytes (bits
, 16);
76 SWFDEC_WARNING (" blur");
77 swfdec_bits_skip_bytes (bits
, 9);
80 SWFDEC_WARNING (" glow");
81 swfdec_bits_skip_bytes (bits
, 15);
84 SWFDEC_WARNING (" bevel");
85 swfdec_bits_skip_bytes (bits
, 27);
90 n
= swfdec_bits_get_u8 (bits
);
91 SWFDEC_WARNING (" gradient glow");
92 swfdec_bits_skip_bytes (bits
, n
* 5 + 19);
98 x
= swfdec_bits_get_u8 (bits
);
99 y
= swfdec_bits_get_u8 (bits
);
100 SWFDEC_WARNING (" %u x %u convolution", x
, y
);
101 swfdec_bits_skip_bytes (bits
, (x
+ y
) * 4 + 13);
105 SWFDEC_WARNING (" color matrix");
106 swfdec_bits_skip_bytes (bits
, 20 * 4);
111 n
= swfdec_bits_get_u8 (bits
);
112 SWFDEC_WARNING (" gradient bevel");
113 swfdec_bits_skip_bytes (bits
, n
* 5 + 19);
117 SWFDEC_ERROR ("unknown filter id %u", filter_id
);
122 filters
= g_slist_reverse (filters
);