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_stroke.h"
29 G_DEFINE_TYPE (SwfdecMorphMovie
, swfdec_morph_movie
, SWFDEC_TYPE_MOVIE
)
32 swfdec_morph_movie_update_extents (SwfdecMovie
*movie
,
35 guint ratio
= movie
->original_ratio
;
36 SwfdecMorphMovie
*mmovie
= SWFDEC_MORPH_MOVIE (movie
);
37 SwfdecMorphShape
*morph
= mmovie
->morph
;
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 g_slist_foreach (mmovie
->draws
, (GFunc
) g_object_unref
, NULL
);
51 g_slist_free (mmovie
->draws
);
53 swfdec_movie_queue_update (movie
, SWFDEC_MOVIE_INVALID_CONTENTS
);
57 swfdec_morph_movie_create_morphs (SwfdecMorphMovie
*mmovie
)
59 SwfdecShape
*shape
= SWFDEC_SHAPE (mmovie
->morph
);
60 guint ratio
= SWFDEC_MOVIE (mmovie
)->original_ratio
;
63 for (walk
= shape
->draws
; walk
; walk
= walk
->next
) {
64 mmovie
->draws
= g_slist_prepend (mmovie
->draws
, swfdec_draw_morph (walk
->data
, ratio
));
66 mmovie
->draws
= g_slist_reverse (mmovie
->draws
);
70 swfdec_morph_movie_render (SwfdecMovie
*movie
, cairo_t
*cr
,
71 const SwfdecColorTransform
*trans
, const SwfdecRect
*inval
)
73 SwfdecMorphMovie
*morph
= SWFDEC_MORPH_MOVIE (movie
);
76 if (morph
->draws
== NULL
)
77 swfdec_morph_movie_create_morphs (morph
);
79 for (walk
= morph
->draws
; walk
; walk
= walk
->next
) {
80 SwfdecDraw
*draw
= walk
->data
;
82 if (!swfdec_rect_intersect (NULL
, &draw
->extents
, inval
))
85 swfdec_draw_paint (draw
, cr
, trans
);
90 swfdec_morph_movie_dispose (GObject
*object
)
92 SwfdecMorphMovie
*morph
= SWFDEC_MORPH_MOVIE (object
);
94 g_slist_foreach (morph
->draws
, (GFunc
) g_object_unref
, NULL
);
95 g_slist_free (morph
->draws
);
97 g_object_unref (morph
->morph
);
99 G_OBJECT_CLASS (swfdec_morph_movie_parent_class
)->dispose (object
);
103 swfdec_morph_movie_class_init (SwfdecMorphMovieClass
* g_class
)
105 GObjectClass
*object_class
= G_OBJECT_CLASS (g_class
);
106 SwfdecMovieClass
*movie_class
= SWFDEC_MOVIE_CLASS (g_class
);
108 object_class
->dispose
= swfdec_morph_movie_dispose
;
110 movie_class
->update_extents
= swfdec_morph_movie_update_extents
;
111 movie_class
->render
= swfdec_morph_movie_render
;
112 movie_class
->set_ratio
= swfdec_morph_movie_set_ratio
;
114 //movie_class->handle_mouse = swfdec_morph_movie_handle_mouse;
118 swfdec_morph_movie_init (SwfdecMorphMovie
*morph
)