2 * Copyright (C) 2006-2008 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library 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 GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
20 #ifndef _SWFDEC_MOVIE_H_
21 #define _SWFDEC_MOVIE_H_
23 #include <glib-object.h>
24 #include <swfdec/swfdec_as_object.h>
25 #include <swfdec/swfdec_as_movie_value.h>
26 #include <swfdec/swfdec_color.h>
27 #include <swfdec/swfdec.h>
28 #include <swfdec/swfdec_event.h>
29 #include <swfdec/swfdec_rect.h>
30 #include <swfdec/swfdec_types.h>
35 typedef struct _SwfdecMovieClass SwfdecMovieClass
;
37 /* descriptions taken from http://www.kirupa.com/developer/actionscript/depths2.htm */
39 SWFDEC_DEPTH_CLASS_EMPTY
,
40 SWFDEC_DEPTH_CLASS_TIMELINE
,
41 SWFDEC_DEPTH_CLASS_DYNAMIC
,
42 SWFDEC_DEPTH_CLASS_RESERVED
46 SWFDEC_MOVIE_STATE_RUNNING
= 0, /* the movie has been created */
47 SWFDEC_MOVIE_STATE_REMOVED
, /* swfdec_movie_remove has been called */
48 SWFDEC_MOVIE_STATE_DESTROYED
/* swfdec_movie_destroy has been called */
52 SWFDEC_FLASH_MAYBE
= 0,
58 SWFDEC_MOVIE_PROPERTY_X
= 0,
59 SWFDEC_MOVIE_PROPERTY_Y
= 1,
60 SWFDEC_MOVIE_PROPERTY_XSCALE
= 2,
61 SWFDEC_MOVIE_PROPERTY_YSCALE
= 3,
62 SWFDEC_MOVIE_PROPERTY_CURRENTFRAME
= 4,
63 SWFDEC_MOVIE_PROPERTY_TOTALFRAMES
= 5,
64 SWFDEC_MOVIE_PROPERTY_ALPHA
= 6,
65 SWFDEC_MOVIE_PROPERTY_VISIBLE
= 7,
66 SWFDEC_MOVIE_PROPERTY_WIDTH
= 8,
67 SWFDEC_MOVIE_PROPERTY_HEIGHT
= 9,
68 SWFDEC_MOVIE_PROPERTY_ROTATION
= 10,
69 SWFDEC_MOVIE_PROPERTY_TARGET
= 11,
70 SWFDEC_MOVIE_PROPERTY_FRAMESLOADED
= 12,
71 SWFDEC_MOVIE_PROPERTY_NAME
= 13,
72 SWFDEC_MOVIE_PROPERTY_DROPTARGET
= 14,
73 SWFDEC_MOVIE_PROPERTY_URL
= 15,
74 SWFDEC_MOVIE_PROPERTY_HIGHQUALITY
= 16,
75 SWFDEC_MOVIE_PROPERTY_FOCUSRECT
= 17,
76 SWFDEC_MOVIE_PROPERTY_SOUNDBUFTIME
= 18,
77 SWFDEC_MOVIE_PROPERTY_QUALITY
= 19,
78 SWFDEC_MOVIE_PROPERTY_XMOUSE
= 20,
79 SWFDEC_MOVIE_PROPERTY_YMOUSE
= 21
80 } SwfdecMovieProperty
;
82 #define SWFDEC_BLEND_MODE_NONE 0
83 #define SWFDEC_BLEND_MODE_NORMAL 1
84 #define SWFDEC_BLEND_MODE_LAYER 2
85 #define SWFDEC_BLEND_MODE_MULTIPLY 3
86 #define SWFDEC_BLEND_MODE_SCREEN 4
87 #define SWFDEC_BLEND_MODE_LIGHTEN 5
88 #define SWFDEC_BLEND_MODE_DARKEN 6
89 #define SWFDEC_BLEND_MODE_DIFFERENCE 7
90 #define SWFDEC_BLEND_MODE_ADD 8
91 #define SWFDEC_BLEND_MODE_SUBTRACT 9
92 #define SWFDEC_BLEND_MODE_INVERT 10
93 #define SWFDEC_BLEND_MODE_ALPHA 11
94 #define SWFDEC_BLEND_MODE_ERASE 12
95 #define SWFDEC_BLEND_MODE_OVERLAY 13
96 #define SWFDEC_BLEND_MODE_HARDLIGHT 14
98 #define SWFDEC_TYPE_MOVIE (swfdec_movie_get_type())
99 #define SWFDEC_IS_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_MOVIE))
100 #define SWFDEC_IS_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_MOVIE))
101 #define SWFDEC_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_MOVIE, SwfdecMovie))
102 #define SWFDEC_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_MOVIE, SwfdecMovieClass))
103 #define SWFDEC_MOVIE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_MOVIE, SwfdecMovieClass))
105 /* NB: each following state includes the previous */
107 SWFDEC_MOVIE_UP_TO_DATE
= 0, /* everything OK */
108 SWFDEC_MOVIE_INVALID_CHILDREN
, /* call update on children */
109 SWFDEC_MOVIE_INVALID_EXTENTS
, /* recalculate extents */
110 } SwfdecMovieCacheState
;
112 typedef void (*SwfdecMovieVariableListenerFunction
) (gpointer data
,
113 const char *name
, const SwfdecAsValue
*val
);
118 SwfdecMovieVariableListenerFunction function
;
119 } SwfdecMovieVariableListener
;
121 struct _SwfdecMovie
{
124 SwfdecGraphic
* graphic
; /* graphic represented by this movie or NULL if script-created */
125 const char * name
; /* name of movie - GC'd */
126 GList
* list
; /* our contained movie clips (ordered by depth) */
127 int depth
; /* depth of movie (equals content->depth unless explicitly set) */
128 SwfdecMovieCacheState cache_state
; /* whether we are up to date */
129 SwfdecMovieState state
; /* state the movie is in */
130 GSList
*variable_listeners
; /* textfield's listening to changes in variables - SwfdecMovieVariableListener */
132 /* static properties (set by PlaceObject tags) */
133 cairo_matrix_t original_transform
; /* initial transform used */
134 guint original_ratio
; /* ratio used in this movie */
135 int clip_depth
; /* up to which movie this movie clips */
137 /* scripting stuff */
138 SwfdecAsMovieValue
* as_value
; /* This movie's value in the script engine or %NULL if not accessible by scripts */
140 /* parenting information */
141 SwfdecMovie
* parent
; /* movie that contains us or NULL for root movies */
142 gboolean lockroot
; /* when looking for _root we should use this movie, even if it has a parent */
143 SwfdecResource
* resource
; /* the resource that created us */
145 /* positioning - the values are applied in this order */
146 SwfdecRect extents
; /* the extents occupied after transform is applied */
147 SwfdecRect original_extents
; /* the extents from all children - unmodified */
148 gboolean modified
; /* TRUE if the transform has been modified by scripts */
149 double xscale
; /* x scale in percent */
150 double yscale
; /* y scale in percent */
151 double rotation
; /* rotation in degrees [-180, 180] */
152 cairo_matrix_t matrix
; /* cairo matrix computed from above and content->transform */
153 cairo_matrix_t inverse_matrix
; /* the inverse of the cairo matrix */
154 SwfdecColorTransform color_transform
; /* scripted color transformation */
155 guint blend_mode
; /* blend mode to use - see to-cairo conversion code for what they mean */
157 /* iteration state */
158 gboolean visible
; /* whether we currently can be seen or iterate */
161 SwfdecMovie
* mask_of
; /* movie this movie is a mask of or NULL if none */
162 SwfdecMovie
* masked_by
; /* movie we are masked by or NULL if none */
163 GSList
* filters
; /* filters to apply to movie */
164 gboolean cache_as_bitmap
; /* the movie should be cached */
165 /* FIXME: could it be that shape drawing (SwfdecGraphicMovie etc) uses these same objects? */
166 SwfdecImage
* image
; /* image loaded via loadMovie */
167 SwfdecRect draw_extents
; /* extents of the items in the following list */
168 GSList
* draws
; /* all the items to draw */
169 SwfdecDraw
* draw_fill
; /* current fill style or NULL */
170 SwfdecDraw
* draw_line
; /* current line style or NULL */
171 int draw_x
; /* current x position for drawing */
172 int draw_y
; /* current y position for drawing */
174 /* invalidatation state */
175 gboolean invalidate_last
; /* TRUE if this movie's previous contents are already invalidated */
176 gboolean invalidate_next
; /* TRUE if this movie should be invalidated before unlocking */
178 /* leftover unimplemented variables from the Actionscript spec */
184 struct _SwfdecMovieClass
{
185 SwfdecAsRelayClass relay_class
;
188 void (* init_movie
) (SwfdecMovie
* movie
);
189 void (* finish_movie
) (SwfdecMovie
* movie
);
190 SwfdecAsValue (* property_get
) (SwfdecMovie
* movie
,
192 void (* property_set
) (SwfdecMovie
* movie
,
194 SwfdecAsValue value
);
195 void (* replace
) (SwfdecMovie
* movie
,
196 SwfdecGraphic
* graphic
);
197 void (* set_ratio
) (SwfdecMovie
* movie
);
198 void (* update_extents
) (SwfdecMovie
* movie
,
199 SwfdecRect
* extents
);
200 void (* render
) (SwfdecMovie
* movie
,
202 const SwfdecColorTransform
*trans
);
203 void (* invalidate
) (SwfdecMovie
* movie
,
204 const cairo_matrix_t
* movie_to_global
,
205 gboolean new_contents
);
207 SwfdecMovie
* (* contains
) (SwfdecMovie
* movie
,
213 GType
swfdec_movie_get_type (void);
215 SwfdecMovie
* swfdec_movie_new (SwfdecPlayer
* player
,
217 SwfdecMovie
* parent
,
218 SwfdecResource
* resource
,
219 SwfdecGraphic
* graphic
,
221 SwfdecMovie
* swfdec_movie_duplicate (SwfdecMovie
* movie
,
224 void swfdec_movie_initialize (SwfdecMovie
* movie
);
225 SwfdecMovie
* swfdec_movie_find (SwfdecMovie
* movie
,
227 SwfdecMovie
* swfdec_movie_get_by_name (SwfdecMovie
* movie
,
230 SwfdecMovie
* swfdec_movie_get_root (SwfdecMovie
* movie
);
231 void swfdec_movie_property_set (SwfdecMovie
* movie
,
234 SwfdecAsValue
swfdec_movie_property_get (SwfdecMovie
* movie
,
236 void swfdec_movie_call_variable_listeners
237 (SwfdecMovie
* movie
,
239 const SwfdecAsValue
* val
);
240 void swfdec_movie_remove (SwfdecMovie
* movie
);
241 void swfdec_movie_destroy (SwfdecMovie
* movie
);
242 void swfdec_movie_set_static_properties
243 (SwfdecMovie
* movie
,
244 const cairo_matrix_t
* transform
,
245 const SwfdecColorTransform
*ctrans
,
249 SwfdecEventList
* events
);
250 void swfdec_movie_invalidate_last (SwfdecMovie
* movie
);
251 void swfdec_movie_invalidate_next (SwfdecMovie
* movie
);
252 void swfdec_movie_invalidate (SwfdecMovie
* movie
,
253 const cairo_matrix_t
* parent_to_global
,
255 void swfdec_movie_queue_update (SwfdecMovie
* movie
,
256 SwfdecMovieCacheState state
);
257 void swfdec_movie_update (SwfdecMovie
* movie
);
258 void swfdec_movie_begin_update_matrix(SwfdecMovie
* movie
);
259 void swfdec_movie_end_update_matrix (SwfdecMovie
* movie
);
260 void swfdec_movie_local_to_global (SwfdecMovie
* movie
,
263 void swfdec_movie_global_to_local (SwfdecMovie
* movie
,
266 void swfdec_movie_global_to_local_matrix
267 (SwfdecMovie
* movie
,
268 cairo_matrix_t
* matrix
);
269 void swfdec_movie_local_to_global_matrix
270 (SwfdecMovie
* movie
,
271 cairo_matrix_t
* matrix
);
272 void swfdec_movie_rect_local_to_global (SwfdecMovie
* movie
,
274 void swfdec_movie_rect_global_to_local (SwfdecMovie
* movie
,
276 void swfdec_movie_set_depth (SwfdecMovie
* movie
,
279 void swfdec_movie_get_mouse (SwfdecMovie
* movie
,
282 #define swfdec_movie_contains(movie, x, y) \
283 (swfdec_movie_get_movie_at ((movie), (x), (y), FALSE) != NULL)
284 SwfdecMovie
* swfdec_movie_get_movie_at (SwfdecMovie
* movie
,
288 char * swfdec_movie_get_path (SwfdecMovie
* movie
,
290 void swfdec_movie_render (SwfdecMovie
* movie
,
292 const SwfdecColorTransform
*trans
);
293 gboolean
swfdec_movie_is_scriptable (SwfdecMovie
* movie
);
294 guint
swfdec_movie_get_version (SwfdecMovie
* movie
);
296 int swfdec_movie_compare_depths (gconstpointer a
,
299 swfdec_depth_classify (int depth
);
301 /* in swfdec_movie_asprops.c */
302 guint
swfdec_movie_property_lookup (const char * name
);
303 void swfdec_movie_property_do_set (SwfdecMovie
* movie
,
306 SwfdecAsValue
swfdec_movie_property_do_get (SwfdecMovie
* movie
,
309 void swfdec_movie_add_variable_listener (SwfdecMovie
* movie
,
312 const SwfdecMovieVariableListenerFunction function
);
313 void swfdec_movie_remove_variable_listener (SwfdecMovie
* movie
,
316 const SwfdecMovieVariableListenerFunction function
);
317 SwfdecResource
*swfdec_movie_get_own_resource (SwfdecMovie
* movie
);