summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2008-11-17 16:36:15 +0100
committerBenjamin Otte <otte@gnome.org>2008-11-17 16:36:15 +0100
commit9fcfcf14dd8a907fbe85df5d4abe238f79e2f557 (patch)
tree41931dc2d0707860feb7b3694c628afa403ba045
parent5cb5bfd415cdd1ef5d4f4581815f55fe9259bd1e (diff)
add naive implementation of BitmapData.fillRect
-rw-r--r--swfdec/swfdec_bitmap_data.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/swfdec/swfdec_bitmap_data.c b/swfdec/swfdec_bitmap_data.c
index 5a7d0f05..ba0439fa 100644
--- a/swfdec/swfdec_bitmap_data.c
+++ b/swfdec/swfdec_bitmap_data.c
@@ -340,14 +340,6 @@ swfdec_bitmap_data_setPixel (SwfdecAsContext *cx, SwfdecAsObject *object,
swfdec_bitmap_data_set_pixel (bitmap, x, y, color);
}
-SWFDEC_AS_NATIVE (1100, 3, swfdec_bitmap_data_fillRect)
-void
-swfdec_bitmap_data_fillRect (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.fillRect");
-}
-
static gboolean
swfdec_rectangle_from_as_object (SwfdecRectangle *rect, SwfdecAsObject *object)
{
@@ -391,6 +383,33 @@ swfdec_point_from_as_object (int *x, int *y, SwfdecAsObject *object)
*y = swfdec_as_value_to_integer (cx, *val);
}
+SWFDEC_AS_NATIVE (1100, 3, swfdec_bitmap_data_fillRect)
+void
+swfdec_bitmap_data_fillRect (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecBitmapData *bitmap;
+ guint color;
+ SwfdecAsObject *recto;
+ SwfdecRectangle rect;
+ cairo_t *cr;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_BITMAP_DATA, &bitmap, "oi", &recto, &color);
+
+ if (!swfdec_rectangle_from_as_object (&rect, recto) || bitmap->surface == NULL)
+ return;
+
+ /* We can treat a guint as a SwfdecColor */
+ if (SWFDEC_COLOR_ALPHA (color) == 0)
+ color = SWFDEC_COLOR_OPAQUE (color);
+
+ cr = cairo_create (bitmap->surface);
+ swfdec_color_set_source (cr, color);
+ cairo_rectangle (cr, rect.x, rect.y, rect.width, rect.height);
+ cairo_fill (cr);
+ swfdec_bitmap_data_invalidate (bitmap, rect.x, rect.y, rect.width, rect.height);
+}
+
SWFDEC_AS_NATIVE (1100, 4, swfdec_bitmap_data_copyPixels)
void
swfdec_bitmap_data_copyPixels (SwfdecAsContext *cx, SwfdecAsObject *object,