2 * Copyright (C) 2007 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_video_movie.h"
25 #include "swfdec_player_internal.h"
27 G_DEFINE_TYPE (SwfdecVideoMovie
, swfdec_video_movie
, SWFDEC_TYPE_MOVIE
)
30 swfdec_video_movie_update_extents (SwfdecMovie
*movie
,
33 SwfdecVideoMovie
*video
= SWFDEC_VIDEO_MOVIE (movie
);
34 SwfdecRect rect
= { 0, 0,
35 SWFDEC_TWIPS_SCALE_FACTOR
* video
->video
->width
,
36 SWFDEC_TWIPS_SCALE_FACTOR
* video
->video
->height
};
38 swfdec_rect_union (extents
, extents
, &rect
);
42 swfdec_video_movie_render (SwfdecMovie
*mov
, cairo_t
*cr
,
43 const SwfdecColorTransform
*trans
, const SwfdecRect
*inval
)
45 SwfdecVideoMovie
*movie
= SWFDEC_VIDEO_MOVIE (mov
);
47 if (movie
->image
== NULL
)
51 (mov
->original_extents
.x1
- mov
->original_extents
.x0
) / movie
->image_width
,
52 (mov
->original_extents
.y1
- mov
->original_extents
.y0
) / movie
->image_height
);
53 cairo_set_source_surface (cr
, movie
->image
, 0.0, 0.0);
58 swfdec_video_movie_unset_input (SwfdecVideoMovie
*movie
)
60 if (movie
->input
== NULL
)
63 if (movie
->input
->disconnect
)
64 movie
->input
->disconnect (movie
->input
, movie
);
69 swfdec_video_movie_dispose (GObject
*object
)
71 SwfdecVideoMovie
*movie
= SWFDEC_VIDEO_MOVIE (object
);
73 swfdec_video_movie_unset_input (movie
);
75 cairo_surface_destroy (movie
->image
);
78 g_object_unref (movie
->video
);
80 G_OBJECT_CLASS (swfdec_video_movie_parent_class
)->dispose (object
);
84 swfdec_video_movie_iterate_end (SwfdecMovie
*mov
)
86 SwfdecVideoMovie
*movie
= SWFDEC_VIDEO_MOVIE (mov
);
88 if (!SWFDEC_MOVIE_CLASS (swfdec_video_movie_parent_class
)->iterate_end (mov
))
91 if (movie
->input
&& movie
->input
->iterate
) {
92 movie
->input
->iterate (movie
->input
);
99 swfdec_video_movie_init_movie (SwfdecMovie
*movie
)
101 SwfdecPlayer
*player
= SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie
)->context
);
103 swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (movie
), player
->Video
);
107 swfdec_video_movie_class_init (SwfdecVideoMovieClass
* g_class
)
109 GObjectClass
*object_class
= G_OBJECT_CLASS (g_class
);
110 SwfdecMovieClass
*movie_class
= SWFDEC_MOVIE_CLASS (g_class
);
112 object_class
->dispose
= swfdec_video_movie_dispose
;
114 movie_class
->update_extents
= swfdec_video_movie_update_extents
;
115 movie_class
->render
= swfdec_video_movie_render
;
116 movie_class
->init_movie
= swfdec_video_movie_init_movie
;
117 movie_class
->iterate_end
= swfdec_video_movie_iterate_end
;
121 swfdec_video_movie_init (SwfdecVideoMovie
* video_movie
)
126 swfdec_video_movie_set_input (SwfdecVideoMovie
*movie
, SwfdecVideoMovieInput
*input
)
128 g_return_if_fail (SWFDEC_IS_VIDEO_MOVIE (movie
));
130 swfdec_video_movie_unset_input (movie
);
131 movie
->input
= input
;
135 input
->connect (input
, movie
);
139 swfdec_video_movie_clear (SwfdecVideoMovie
*movie
)
141 g_return_if_fail (SWFDEC_IS_VIDEO_MOVIE (movie
));
143 if (movie
->image
== NULL
)
146 cairo_surface_destroy (movie
->image
);
148 swfdec_movie_invalidate (SWFDEC_MOVIE (movie
));
152 swfdec_video_movie_new_image (SwfdecVideoMovie
*movie
, cairo_surface_t
*image
)
154 g_return_if_fail (SWFDEC_IS_VIDEO_MOVIE (movie
));
155 g_return_if_fail (image
!= NULL
);
158 cairo_surface_destroy (movie
->image
);
159 cairo_surface_reference (image
);
160 movie
->image
= image
;
161 movie
->image_width
= cairo_image_surface_get_width (image
);
162 movie
->image_height
= cairo_image_surface_get_height (image
);
163 swfdec_movie_invalidate (SWFDEC_MOVIE (movie
));