2 * Copyright (C) 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
24 #include "swfdec_cached_video.h"
25 #include "swfdec_debug.h"
27 G_DEFINE_TYPE (SwfdecCachedVideo
, swfdec_cached_video
, SWFDEC_TYPE_CACHED
)
30 swfdec_cached_video_dispose (GObject
*object
)
32 SwfdecCachedVideo
*video
= SWFDEC_CACHED_VIDEO (object
);
35 cairo_surface_destroy (video
->surface
);
36 video
->surface
= NULL
;
39 G_OBJECT_CLASS (swfdec_cached_video_parent_class
)->dispose (object
);
43 swfdec_cached_video_class_init (SwfdecCachedVideoClass
* g_class
)
45 GObjectClass
*object_class
= G_OBJECT_CLASS (g_class
);
47 object_class
->dispose
= swfdec_cached_video_dispose
;
51 swfdec_cached_video_init (SwfdecCachedVideo
*cached
)
56 swfdec_cached_video_new (cairo_surface_t
*surface
, gsize size
)
58 SwfdecCachedVideo
*video
;
60 g_return_val_if_fail (surface
!= NULL
, NULL
);
61 g_return_val_if_fail (size
> 0, NULL
);
63 size
+= sizeof (SwfdecCachedVideo
);
64 video
= g_object_new (SWFDEC_TYPE_CACHED_VIDEO
, "size", size
, NULL
);
65 video
->surface
= cairo_surface_reference (surface
);
71 swfdec_cached_video_get_surface (SwfdecCachedVideo
*video
)
73 g_return_val_if_fail (SWFDEC_IS_CACHED_VIDEO (video
), NULL
);
75 return cairo_surface_reference (video
->surface
);
79 swfdec_cached_video_get_frame (SwfdecCachedVideo
*video
)
81 g_return_val_if_fail (SWFDEC_IS_CACHED_VIDEO (video
), 0);
87 swfdec_cached_video_set_frame (SwfdecCachedVideo
*video
, guint frame
)
89 g_return_if_fail (SWFDEC_IS_CACHED_VIDEO (video
));
95 swfdec_cached_video_get_size (SwfdecCachedVideo
*video
, guint
*width
, guint
*height
)
97 g_return_if_fail (SWFDEC_IS_CACHED_VIDEO (video
));
100 *width
= video
->width
;
102 *height
= video
->height
;
106 swfdec_cached_video_set_size (SwfdecCachedVideo
*video
, guint width
, guint height
)
108 g_return_if_fail (SWFDEC_IS_CACHED_VIDEO (video
));
110 video
->width
= width
;
111 video
->height
= height
;