add blend mode tests
[swfdec.git] / swfdec / swfdec_blur_filter_as.c
blob8da57e0009e99294adb5c4ae24cb3bfcb89dc795
1 /* Swfdec
2 * Copyright (C) 2007 Pekka Lampila <pekka.lampila@iki.fi>
3 * 2008 Benjamin Otte <otte@gnome.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301 USA
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
25 #include "swfdec_as_internal.h"
26 #include "swfdec_blur_filter.h"
27 #include "swfdec_debug.h"
29 SWFDEC_AS_NATIVE (1102, 1, swfdec_blur_filter_get_blurX)
30 void
31 swfdec_blur_filter_get_blurX (SwfdecAsContext *cx, SwfdecAsObject *object,
32 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
34 SwfdecBlurFilter *filter;
36 SWFDEC_AS_CHECK (SWFDEC_TYPE_BLUR_FILTER, &filter, "");
38 *ret = swfdec_as_value_from_number (cx, filter->x);
41 SWFDEC_AS_NATIVE (1102, 2, swfdec_blur_filter_set_blurX)
42 void
43 swfdec_blur_filter_set_blurX (SwfdecAsContext *cx, SwfdecAsObject *object,
44 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
46 SwfdecBlurFilter *filter;
47 double d;
49 SWFDEC_AS_CHECK (SWFDEC_TYPE_BLUR_FILTER, &filter, "n", &d);
51 filter->x = CLAMP (d, 0, 255);
52 swfdec_blur_filter_invalidate (filter);
55 SWFDEC_AS_NATIVE (1102, 3, swfdec_blur_filter_get_blurY)
56 void
57 swfdec_blur_filter_get_blurY (SwfdecAsContext *cx, SwfdecAsObject *object,
58 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
60 SwfdecBlurFilter *filter;
62 SWFDEC_AS_CHECK (SWFDEC_TYPE_BLUR_FILTER, &filter, "");
64 *ret = swfdec_as_value_from_number (cx, filter->y);
67 SWFDEC_AS_NATIVE (1102, 4, swfdec_blur_filter_set_blurY)
68 void
69 swfdec_blur_filter_set_blurY (SwfdecAsContext *cx, SwfdecAsObject *object,
70 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
72 SwfdecBlurFilter *filter;
73 double d;
75 SWFDEC_AS_CHECK (SWFDEC_TYPE_BLUR_FILTER, &filter, "n", &d);
77 filter->y = CLAMP (d, 0, 255);
78 swfdec_blur_filter_invalidate (filter);
81 SWFDEC_AS_NATIVE (1102, 5, swfdec_blur_filter_get_quality)
82 void
83 swfdec_blur_filter_get_quality (SwfdecAsContext *cx, SwfdecAsObject *object,
84 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
86 SwfdecBlurFilter *filter;
88 SWFDEC_AS_CHECK (SWFDEC_TYPE_BLUR_FILTER, &filter, "");
90 *ret = swfdec_as_value_from_integer (cx, filter->quality);
93 SWFDEC_AS_NATIVE (1102, 6, swfdec_blur_filter_set_quality)
94 void
95 swfdec_blur_filter_set_quality (SwfdecAsContext *cx, SwfdecAsObject *object,
96 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
98 SwfdecBlurFilter *filter;
99 int i;
101 SWFDEC_AS_CHECK (SWFDEC_TYPE_BLUR_FILTER, &filter, "i", &i);
103 filter->y = CLAMP (i, 0, 15);
104 swfdec_blur_filter_invalidate (filter);
107 // constructor
108 SWFDEC_AS_NATIVE (1102, 0, swfdec_blur_filter_construct)
109 void
110 swfdec_blur_filter_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
111 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
113 SwfdecBlurFilter *filter;
114 double x = 4, y = 4;
115 int quality = 1;
117 SWFDEC_AS_CHECK (0, NULL, "|nni", &x, &y, &quality);
119 if (!swfdec_as_context_is_constructing (cx))
120 return;
122 filter = g_object_new (SWFDEC_TYPE_BLUR_FILTER, "context", cx, NULL);
123 filter->x = CLAMP (x, 0, 255);
124 filter->y = CLAMP (y, 0, 255);
125 filter->quality = CLAMP (quality, 0, 15);
127 swfdec_as_object_set_relay (object, SWFDEC_AS_RELAY (filter));
128 SWFDEC_AS_VALUE_SET_OBJECT (ret, object);