2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 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 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
27 static GList *masks = NULL;
32 _gst_barboxwipes_register ();
36 gst_mask_compare (GstMaskDefinition * def1, GstMaskDefinition * def2)
38 return (def1->type - def2->type);
42 _gst_mask_register (const GstMaskDefinition * definition)
45 g_list_insert_sorted (masks, (gpointer) definition,
46 (GCompareFunc) gst_mask_compare);
50 gst_mask_get_definitions (void)
55 static GstMaskDefinition *
56 gst_mask_find_definition (gint type)
61 GstMaskDefinition *def = (GstMaskDefinition *) walk->data;
63 if (def->type == type)
66 walk = g_list_next (walk);
72 gst_mask_factory_new (gint type, gboolean invert, gint bpp, gint width,
75 GstMaskDefinition *definition;
78 definition = gst_mask_find_definition (type);
80 mask = g_new0 (GstMask, 1);
82 mask->type = definition->type;
85 mask->height = height;
86 mask->destroy_func = definition->destroy_func;
87 mask->user_data = definition->user_data;
88 mask->data = g_malloc (width * height * sizeof (guint32));
90 definition->draw_func (mask);
94 guint32 *datap = mask->data;
95 guint32 max = (1 << bpp);
97 for (i = 0; i < height; i++) {
98 for (j = 0; j < width; j++) {
99 *datap = max - *datap;
110 _gst_mask_default_destroy (GstMask * mask)
117 gst_mask_destroy (GstMask * mask)
119 if (mask->destroy_func)
120 mask->destroy_func (mask);