2 * Copyright (C) 2003-2006 David Schleef <ds@schleef.org>
3 * 2005-2006 Eric Anholt <eric@anholt.net>
4 * 2006 Benjamin Otte <otte@gnome.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301 USA
26 #include "swfdec_morphshape.h"
27 #include "swfdec_debug.h"
28 #include "swfdec_image.h"
29 #include "swfdec_morph_movie.h"
31 G_DEFINE_TYPE (SwfdecMorphShape
, swfdec_morph_shape
, SWFDEC_TYPE_SHAPE
)
34 swfdec_graphic_create_movie (SwfdecGraphic
*graphic
, gsize
*size
)
37 SwfdecMorphShape
*morph
= SWFDEC_MORPH_SHAPE (graphic
);
38 SwfdecMorphMovie
*movie
= g_object_new (SWFDEC_TYPE_MORPH_MOVIE
, NULL
);
43 *size
= sizeof (SwfdecMorphMovie
) + sizeof (cairo_path_t
) * morph
->end_vecs
->len
;
44 movie
->paths
= g_new0 (cairo_path_t
, morph
->end_vecs
->len
);
45 for (i
= 0; i
< morph
->end_vecs
->len
; i
++) {
46 movie
->paths
[i
].num_data
= g_array_index (morph
->end_vecs
, SwfdecShapeVec
, i
).path
.num_data
;
47 movie
->paths
[i
].data
= g_new (cairo_path_data_t
, movie
->paths
[i
].num_data
);
48 *size
+= sizeof (cairo_path_data_t
) * movie
->paths
[i
].num_data
;
51 return SWFDEC_MOVIE (movie
);
55 swfdec_morph_shape_dispose (GObject
*object
)
57 SwfdecMorphShape
*morph
= SWFDEC_MORPH_SHAPE (object
);
60 if (morph
->end_vecs
!= NULL
) {
61 for (i
= 0; i
< morph
->end_vecs
->len
; i
++)
62 g_free (g_array_index (morph
->end_vecs
, SwfdecShapeVec
, i
).path
.data
);
63 g_array_free (morph
->end_vecs
, TRUE
);
64 morph
->end_vecs
= NULL
;
67 G_OBJECT_CLASS (swfdec_morph_shape_parent_class
)->dispose (object
);
71 swfdec_morph_shape_class_init (SwfdecMorphShapeClass
* g_class
)
73 GObjectClass
*object_class
= G_OBJECT_CLASS (g_class
);
74 SwfdecGraphicClass
*graphic_class
= SWFDEC_GRAPHIC_CLASS (g_class
);
76 object_class
->dispose
= swfdec_morph_shape_dispose
;
78 graphic_class
->create_movie
= swfdec_graphic_create_movie
;
82 swfdec_morph_shape_init (SwfdecMorphShape
* morph
)
84 morph
->end_vecs
= g_array_new (FALSE
, TRUE
, sizeof (SwfdecShapeVec
));