static void meta_background_actor_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { ClutterContent *content; gfloat width; content = clutter_actor_get_content (actor); if (content) clutter_content_get_preferred_size (content, &width, NULL); else width = 0; if (min_width_p) *min_width_p = width; if (natural_width_p) *natural_width_p = width; }
static void meta_background_actor_get_preferred_height (ClutterActor *actor, gfloat for_width, gfloat *min_height_p, gfloat *natural_height_p) { ClutterContent *content; gfloat height; content = clutter_actor_get_content (actor); if (content) clutter_content_get_preferred_size (content, NULL, &height); else height = 0; if (min_height_p) *min_height_p = height; if (natural_height_p) *natural_height_p = height; }
static void image_rendered_cb (GInputStream *stream, GAsyncResult *res, RendererData *data) { ChamplainTile *tile = data->tile; gboolean error = TRUE; GError *gerror = NULL; ClutterActor *actor = NULL; GdkPixbuf *pixbuf; ClutterContent *content; gfloat width, height; pixbuf = gdk_pixbuf_new_from_stream_finish (res, NULL); if (!pixbuf) { g_warning ("NULL pixbuf"); goto finish; } /* Load the image into clutter */ content = clutter_image_new (); if (!clutter_image_set_data (CLUTTER_IMAGE (content), gdk_pixbuf_get_pixels (pixbuf), gdk_pixbuf_get_has_alpha (pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), gdk_pixbuf_get_rowstride (pixbuf), &gerror)) { if (gerror) { g_warning ("Unable to transfer to clutter: %s", gerror->message); g_error_free (gerror); } g_object_unref (content); goto finish; } clutter_content_get_preferred_size (content, &width, &height); actor = clutter_actor_new (); clutter_actor_set_size (actor, width, height); clutter_actor_set_content (actor, content); g_object_unref (content); /* has to be set for proper opacity */ clutter_actor_set_offscreen_redirect (actor, CLUTTER_OFFSCREEN_REDIRECT_AUTOMATIC_FOR_OPACITY); error = FALSE; finish: if (actor) champlain_tile_set_content (tile, actor); g_signal_emit_by_name (tile, "render-complete", data->data, data->size, error); if (pixbuf) g_object_unref (pixbuf); g_object_unref (data->renderer); g_object_unref (tile); g_object_unref (stream); g_free (data->data); g_slice_free (RendererData, data); }