void swfdec_color_transform_get_transform (SwfdecColorTransformAs *trans, SwfdecColorTransform *ctrans) { g_return_if_fail (SWFDEC_IS_COLOR_TRANSFORM_AS (trans)); g_return_if_fail (ctrans != NULL); SWFDEC_FIXME ("This conversion needs serious testing with NaN and overflows"); ctrans->mask = FALSE; ctrans->ra = trans->ra * 256.0; ctrans->ga = trans->ga * 256.0; ctrans->ba = trans->ba * 256.0; ctrans->aa = trans->aa * 256.0; ctrans->rb = trans->rb; ctrans->gb = trans->gb; ctrans->bb = trans->bb; ctrans->ab = trans->ab; }
void swfdec_color_transform_as_concat (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret) { SwfdecColorTransformAs *transform, *other; SwfdecAsObject *other_object; SWFDEC_AS_CHECK (SWFDEC_TYPE_COLOR_TRANSFORM_AS, &transform, "o", &other_object); if (!SWFDEC_IS_COLOR_TRANSFORM_AS (other_object->relay)) return; other = SWFDEC_COLOR_TRANSFORM_AS (other_object->relay); transform->rb += (transform->ra * other->rb); transform->gb += (transform->ga * other->gb); transform->bb += (transform->ba * other->bb); transform->ab += (transform->aa * other->ab); transform->ra *= other->ra; transform->ga *= other->ga; transform->ba *= other->ba; transform->aa *= other->aa; }
void swfdec_bitmap_data_draw (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret) { SwfdecAsObject *o, *matrix = NULL, *trans = NULL; cairo_t *cr; SwfdecColorTransform ctrans; SwfdecBitmapData *bitmap; SwfdecRenderer *renderer; cairo_matrix_t mat; SWFDEC_AS_CHECK (SWFDEC_TYPE_BITMAP_DATA, &bitmap, "o|OO", &o, &matrix, &trans); if (bitmap->surface == NULL) return; if (argc >= 2) { if (matrix == NULL || !swfdec_matrix_from_as_object (&mat, matrix)) return; } else { cairo_matrix_init_identity (&mat); } if (SWFDEC_IS_COLOR_TRANSFORM_AS (trans)) { swfdec_color_transform_get_transform (SWFDEC_COLOR_TRANSFORM_AS (trans), &ctrans); } else { swfdec_color_transform_init_identity (&ctrans); } if (argc > 3) { SWFDEC_FIXME ("only the first 3 arguments to Bitmap.draw() are implemented"); } cr = cairo_create (bitmap->surface); /* FIXME: Do we have a better renderer? */ renderer = SWFDEC_PLAYER (cx)->priv->renderer; swfdec_renderer_attach (renderer, cr); cairo_transform (cr, &mat); if (SWFDEC_IS_BITMAP_DATA (o)) { SwfdecBitmapData *src = SWFDEC_BITMAP_DATA (o); if (src->surface) { if (swfdec_color_transform_is_identity (&ctrans)) { cairo_set_source_surface (cr, SWFDEC_BITMAP_DATA (o)->surface, 0, 0); } else { cairo_surface_t *transformed = swfdec_renderer_transform (renderer, SWFDEC_BITMAP_DATA (o)->surface, &ctrans); SWFDEC_FIXME ("unmodified pixels will be treated as -1, not as 0 as in our " "transform code, but we don't know if a pixel is unmodified."); cairo_set_source_surface (cr, transformed, 0, 0); cairo_surface_destroy (transformed); } cairo_paint (cr); } } else if (SWFDEC_IS_MOVIE (o)) { SwfdecMovie *movie = SWFDEC_MOVIE (o); swfdec_movie_update (movie); cairo_scale (cr, 1.0 / SWFDEC_TWIPS_SCALE_FACTOR, 1.0 / SWFDEC_TWIPS_SCALE_FACTOR); cairo_transform (cr, &movie->inverse_matrix); swfdec_movie_render (movie, cr, &ctrans); } else { SWFDEC_FIXME ("BitmapData.draw() with a %s?", G_OBJECT_TYPE_NAME (o)); } cairo_destroy (cr); }