2 * Copyright (C) 2006 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
24 #include "swfdec_morph_movie.h"
25 #include "swfdec_debug.h"
26 #include "swfdec_draw.h"
27 #include "swfdec_player_internal.h"
28 #include "swfdec_stroke.h"
30 G_DEFINE_TYPE (SwfdecMorphMovie
, swfdec_morph_movie
, SWFDEC_TYPE_MOVIE
)
33 swfdec_morph_movie_update_extents (SwfdecMovie
*movie
,
36 guint ratio
= movie
->original_ratio
;
37 SwfdecMorphShape
*morph
= SWFDEC_MORPH_SHAPE (movie
->graphic
);
38 SwfdecGraphic
*graphic
= SWFDEC_GRAPHIC (morph
);
39 extents
->x0
= ((65535 - ratio
) * graphic
->extents
.x0
+ ratio
* morph
->end_extents
.x0
) / 65535;
40 extents
->x1
= ((65535 - ratio
) * graphic
->extents
.x1
+ ratio
* morph
->end_extents
.x1
) / 65535;
41 extents
->y0
= ((65535 - ratio
) * graphic
->extents
.y0
+ ratio
* morph
->end_extents
.y0
) / 65535;
42 extents
->y1
= ((65535 - ratio
) * graphic
->extents
.y1
+ ratio
* morph
->end_extents
.y1
) / 65535;
46 swfdec_morph_movie_set_ratio (SwfdecMovie
*movie
)
48 SwfdecMorphMovie
*mmovie
= SWFDEC_MORPH_MOVIE (movie
);
50 swfdec_movie_invalidate_next (movie
);
51 g_slist_foreach (mmovie
->draws
, (GFunc
) g_object_unref
, NULL
);
52 g_slist_free (mmovie
->draws
);
54 swfdec_movie_queue_update (movie
, SWFDEC_MOVIE_INVALID_EXTENTS
);
58 swfdec_morph_movie_create_morphs (SwfdecMorphMovie
*mmovie
)
60 SwfdecShape
*shape
= SWFDEC_SHAPE (SWFDEC_MOVIE (mmovie
)->graphic
);
61 guint ratio
= SWFDEC_MOVIE (mmovie
)->original_ratio
;
64 for (walk
= shape
->draws
; walk
; walk
= walk
->next
) {
65 mmovie
->draws
= g_slist_prepend (mmovie
->draws
, swfdec_draw_morph (walk
->data
, ratio
));
67 mmovie
->draws
= g_slist_reverse (mmovie
->draws
);
71 swfdec_morph_movie_render (SwfdecMovie
*movie
, cairo_t
*cr
,
72 const SwfdecColorTransform
*trans
)
74 SwfdecMorphMovie
*morph
= SWFDEC_MORPH_MOVIE (movie
);
78 if (morph
->draws
== NULL
)
79 swfdec_morph_movie_create_morphs (morph
);
81 cairo_clip_extents (cr
, &inval
.x0
, &inval
.y0
, &inval
.x1
, &inval
.y1
);
83 for (walk
= morph
->draws
; walk
; walk
= walk
->next
) {
84 SwfdecDraw
*draw
= walk
->data
;
86 if (!swfdec_rect_intersect (NULL
, &draw
->extents
, &inval
))
89 swfdec_draw_paint (draw
, cr
, trans
);
94 swfdec_morph_movie_invalidate (SwfdecMovie
*movie
, const cairo_matrix_t
*matrix
, gboolean last
)
98 swfdec_rect_transform (&rect
, &movie
->original_extents
, matrix
);
99 swfdec_player_invalidate (SWFDEC_PLAYER (swfdec_gc_object_get_context (movie
)),
104 swfdec_morph_movie_dispose (GObject
*object
)
106 SwfdecMorphMovie
*morph
= SWFDEC_MORPH_MOVIE (object
);
108 g_slist_foreach (morph
->draws
, (GFunc
) g_object_unref
, NULL
);
109 g_slist_free (morph
->draws
);
112 G_OBJECT_CLASS (swfdec_morph_movie_parent_class
)->dispose (object
);
116 swfdec_morph_movie_class_init (SwfdecMorphMovieClass
* g_class
)
118 GObjectClass
*object_class
= G_OBJECT_CLASS (g_class
);
119 SwfdecMovieClass
*movie_class
= SWFDEC_MOVIE_CLASS (g_class
);
121 object_class
->dispose
= swfdec_morph_movie_dispose
;
123 movie_class
->update_extents
= swfdec_morph_movie_update_extents
;
124 movie_class
->render
= swfdec_morph_movie_render
;
125 movie_class
->invalidate
= swfdec_morph_movie_invalidate
;
126 movie_class
->set_ratio
= swfdec_morph_movie_set_ratio
;
128 //movie_class->handle_mouse = swfdec_morph_movie_handle_mouse;
132 swfdec_morph_movie_init (SwfdecMorphMovie
*morph
)