Commit 3f11ecec authored by Jiří Techet's avatar Jiří Techet

Remove the unnecessary ChamplainRenderCallbackData structure

parent af0f05d8
......@@ -193,17 +193,14 @@ render (ChamplainRenderer *renderer, ChamplainTile *tile)
ChamplainErrorTileRenderer *error_renderer = CHAMPLAIN_ERROR_TILE_RENDERER (renderer);
ChamplainErrorTileRendererPrivate *priv = error_renderer->priv;
ClutterActor *clone;
guint size;
ChamplainRenderCallbackData callback_data;
callback_data.data = NULL;
callback_data.size = 0;
callback_data.error = FALSE;
gpointer data = NULL;
guint size = 0;
gboolean error = FALSE;
if (champlain_tile_get_state (tile) == CHAMPLAIN_STATE_LOADED)
{
/* cache is just validating tile - don't generate error tile in this case - instead use what we have */
g_signal_emit_by_name (tile, "render-complete", &callback_data);
g_signal_emit_by_name (tile, "render-complete", data, size, error);
return;
}
......@@ -250,7 +247,7 @@ render (ChamplainRenderer *renderer, ChamplainTile *tile)
clone = clutter_texture_new ();
clutter_texture_set_cogl_texture (CLUTTER_TEXTURE (clone), priv->error_tex);
champlain_tile_set_content (tile, clone);
g_signal_emit_by_name (tile, "render-complete", &callback_data);
g_signal_emit_by_name (tile, "render-complete", data, size, error);
}
......
......@@ -514,7 +514,9 @@ typedef struct
static void
tile_rendered_cb (ChamplainTile *tile,
ChamplainRenderCallbackData *data,
gpointer data,
guint size,
gboolean error,
FileLoadedData *user_data)
{
ChamplainMapSource *map_source = user_data->map_source;
......@@ -533,7 +535,7 @@ tile_rendered_cb (ChamplainTile *tile,
file_cache = CHAMPLAIN_FILE_CACHE (map_source);
priv = file_cache->priv;
if (data->error)
if (error)
{
DEBUG ("Tile rendering failed");
goto load_next;
......
......@@ -151,7 +151,9 @@ champlain_file_tile_source_load_map_data (ChamplainFileTileSource *self,
static void
tile_rendered_cb (ChamplainTile *tile,
ChamplainRenderCallbackData *data,
gpointer data,
guint size,
gboolean error,
ChamplainMapSource *map_source)
{
ChamplainMapSource *next_source;
......@@ -160,13 +162,13 @@ tile_rendered_cb (ChamplainTile *tile,
next_source = champlain_map_source_get_next_source (map_source);
if (!data->error)
if (!error)
{
ChamplainTileSource *tile_source = CHAMPLAIN_TILE_SOURCE (map_source);
ChamplainTileCache *tile_cache = champlain_tile_source_get_cache (tile_source);
if (tile_cache && data->data)
champlain_tile_cache_store_tile (tile_cache, tile, data->data, data->size);
if (tile_cache && data)
champlain_tile_cache_store_tile (tile_cache, tile, data, size);
champlain_tile_set_fade_in (tile, TRUE);
champlain_tile_set_state (tile, CHAMPLAIN_STATE_DONE);
......
......@@ -124,37 +124,35 @@ static void
render (ChamplainRenderer *renderer, ChamplainTile *tile)
{
ChamplainImageRendererPrivate *priv = GET_PRIVATE (renderer);
ChamplainRenderCallbackData callback_data;
gboolean error = TRUE;
GdkPixbufLoader *loader = NULL;
GError *error = NULL;
GError *gerror = NULL;
ClutterActor *actor = NULL;
GdkPixbuf *pixbuf;
callback_data.error = FALSE;
if (!priv->data || priv->size == 0)
goto error;
goto finish;
loader = gdk_pixbuf_loader_new ();
if (!gdk_pixbuf_loader_write (loader,
(const guchar *) priv->data,
priv->size,
&error))
&gerror))
{
if (error)
if (gerror)
{
g_warning ("Unable to load the pixbuf: %s", error->message);
g_error_free (error);
g_warning ("Unable to load the pixbuf: %s", gerror->message);
g_error_free (gerror);
}
goto error;
goto finish;
}
gdk_pixbuf_loader_close (loader, &error);
if (error)
gdk_pixbuf_loader_close (loader, &gerror);
if (gerror)
{
g_warning ("Unable to close the pixbuf loader: %s", error->message);
g_error_free (error);
goto error;
g_warning ("Unable to close the pixbuf loader: %s", gerror->message);
g_error_free (gerror);
goto finish;
}
/* Load the image into clutter */
......@@ -168,32 +166,27 @@ render (ChamplainRenderer *renderer, ChamplainTile *tile)
gdk_pixbuf_get_rowstride (pixbuf),
gdk_pixbuf_get_bits_per_sample (pixbuf) *
gdk_pixbuf_get_n_channels (pixbuf) / 8,
0, &error))
0, &gerror))
{
if (error)
if (gerror)
{
g_warning ("Unable to transfer to clutter: %s", error->message);
g_error_free (error);
g_warning ("Unable to transfer to clutter: %s", gerror->message);
g_error_free (gerror);
}
g_object_unref (actor);
actor = NULL;
goto error;
goto finish;
}
goto finish;
error:
callback_data.error = TRUE;
error = FALSE;
finish:
callback_data.data = priv->data;
callback_data.size = priv->size;
if (actor)
champlain_tile_set_content (tile, actor);
g_signal_emit_by_name (tile, "render-complete", &callback_data);
g_signal_emit_by_name (tile, "render-complete", priv->data, priv->size, error);
if (loader)
g_object_unref (loader);
......
VOID:DOUBLE,DOUBLE
VOID:POINTER,UINT,BOOLEAN
......@@ -292,7 +292,9 @@ delete_queue_member (QueueMember *member, gpointer user_data)
static void
tile_rendered_cb (ChamplainTile *tile,
ChamplainRenderCallbackData *data,
gpointer data,
guint size,
gboolean error,
ChamplainMapSource *map_source)
{
ChamplainMapSource *next_source;
......@@ -301,7 +303,7 @@ tile_rendered_cb (ChamplainTile *tile,
next_source = champlain_map_source_get_next_source (map_source);
if (!data->error)
if (!error)
{
if (CHAMPLAIN_IS_TILE_CACHE (next_source))
champlain_tile_cache_on_tile_filled (CHAMPLAIN_TILE_CACHE (next_source), tile);
......
......@@ -302,11 +302,12 @@ tile_loaded_cb (gpointer worker_data)
ChamplainTile *tile = data->tile;
cairo_surface_t *cst = data->cst;
ChamplainRenderer *renderer = CHAMPLAIN_RENDERER (data->renderer);
ChamplainRenderCallbackData callback_data;
gpointer ret_data = NULL;
guint ret_size = 0;
gboolean ret_error = TRUE;
cairo_t *cr_clutter;
ClutterActor *actor;
guint size = data->size;
GError *error = NULL;
GdkPixbuf *pixbuf = NULL;
gchar *buffer = NULL;
gsize buffer_size;
......@@ -316,11 +317,11 @@ tile_loaded_cb (gpointer worker_data)
if (!tile)
{
DEBUG ("Tile destroyed while loading");
goto error;
goto finish;
}
if (!cst)
goto error;
goto finish;
/* draw the clutter texture */
actor = clutter_cairo_texture_new (size, size);
......@@ -339,24 +340,18 @@ tile_loaded_cb (gpointer worker_data)
GDK_COLORSPACE_RGB, TRUE, 8, size, size,
cairo_image_surface_get_stride (cst), NULL, NULL);
if (!gdk_pixbuf_save_to_buffer (pixbuf, &buffer, &buffer_size, "png", &error, NULL))
goto error;
if (!gdk_pixbuf_save_to_buffer (pixbuf, &buffer, &buffer_size, "png", NULL, NULL))
goto finish;
champlain_tile_set_content (tile, actor);
callback_data.error = FALSE;
callback_data.data = buffer;
callback_data.size = buffer_size;
goto finish;
error:
callback_data.error = TRUE;
callback_data.data = NULL;
callback_data.size = 0;
ret_data = buffer;
ret_size = buffer_size;
ret_error = FALSE;
finish:
if (tile)
g_signal_emit_by_name (tile, "render-complete", &callback_data);
g_signal_emit_by_name (tile, "render-complete", ret_data, ret_size, ret_error);
if (pixbuf)
g_object_unref (pixbuf);
......
......@@ -376,7 +376,9 @@ champlain_network_bbox_tile_source_load_map_data (
static void
tile_rendered_cb (ChamplainTile *tile,
ChamplainRenderCallbackData *data,
gpointer data,
guint size,
gboolean error,
ChamplainMapSource *map_source)
{
ChamplainMapSource *next_source;
......@@ -385,13 +387,13 @@ tile_rendered_cb (ChamplainTile *tile,
next_source = champlain_map_source_get_next_source (map_source);
if (!data->error)
if (!error)
{
ChamplainTileSource *tile_source = CHAMPLAIN_TILE_SOURCE (map_source);
ChamplainTileCache *tile_cache = champlain_tile_source_get_cache (tile_source);
if (tile_cache && data->data)
champlain_tile_cache_store_tile (tile_cache, tile, data->data, data->size);
if (tile_cache && data)
champlain_tile_cache_store_tile (tile_cache, tile, data, size);
champlain_tile_set_fade_in (tile, TRUE);
champlain_tile_set_state (tile, CHAMPLAIN_STATE_DONE);
......
......@@ -533,7 +533,9 @@ get_tile_uri (ChamplainNetworkTileSource *tile_source,
static void
tile_rendered_cb (ChamplainTile *tile,
ChamplainRenderCallbackData *data,
gpointer data,
guint size,
gboolean error,
TileRenderedData *user_data)
{
ChamplainMapSource *map_source = user_data->map_source;
......@@ -545,7 +547,7 @@ tile_rendered_cb (ChamplainTile *tile,
next_source = champlain_map_source_get_next_source (map_source);
if (!data->error)
if (!error)
{
ChamplainTileSource *tile_source = CHAMPLAIN_TILE_SOURCE (map_source);
ChamplainTileCache *tile_cache = champlain_tile_source_get_cache (tile_source);
......@@ -553,8 +555,8 @@ tile_rendered_cb (ChamplainTile *tile,
if (etag != NULL)
champlain_tile_set_etag (tile, etag);
if (tile_cache && data->data)
champlain_tile_cache_store_tile (tile_cache, tile, data->data, data->size);
if (tile_cache && data)
champlain_tile_cache_store_tile (tile_cache, tile, data, size);
champlain_tile_set_fade_in (tile, TRUE);
champlain_tile_set_state (tile, CHAMPLAIN_STATE_DONE);
......
......@@ -96,7 +96,9 @@ champlain_null_tile_source_new_full (ChamplainRenderer *renderer)
static void
tile_rendered_cb (ChamplainTile *tile,
ChamplainRenderCallbackData *data,
gpointer data,
guint size,
gboolean error,
ChamplainMapSource *map_source)
{
ChamplainMapSource *next_source;
......@@ -105,13 +107,13 @@ tile_rendered_cb (ChamplainTile *tile,
next_source = champlain_map_source_get_next_source (map_source);
if (!data->error)
if (!error)
{
ChamplainTileSource *tile_source = CHAMPLAIN_TILE_SOURCE (map_source);
ChamplainTileCache *tile_cache = champlain_tile_source_get_cache (tile_source);
if (tile_cache && data->data)
champlain_tile_cache_store_tile (tile_cache, tile, data->data, data->size);
if (tile_cache && data)
champlain_tile_cache_store_tile (tile_cache, tile, data, size);
champlain_tile_set_fade_in (tile, TRUE);
champlain_tile_set_state (tile, CHAMPLAIN_STATE_DONE);
......
......@@ -47,7 +47,6 @@ G_BEGIN_DECLS
typedef struct _ChamplainRenderer ChamplainRenderer;
typedef struct _ChamplainRendererClass ChamplainRendererClass;
typedef struct _ChamplainRenderCallbackData ChamplainRenderCallbackData;
struct _ChamplainRenderer
{
......
......@@ -27,6 +27,7 @@
#include "champlain-enum-types.h"
#include "champlain-private.h"
#include "champlain-marshal.h"
#include <math.h>
#include <errno.h>
......@@ -379,7 +380,7 @@ champlain_tile_class_init (ChamplainTileClass *klass)
FALSE,
G_PARAM_READWRITE));
/**
/*
* ChamplainTile::render-complete:
* @self: a #ChamplainTile
* @calback_data: a #ChamplainRenderCallbackData struct
......@@ -392,8 +393,8 @@ champlain_tile_class_init (ChamplainTileClass *klass)
champlain_tile_signals[RENDER_COMPLETE] =
g_signal_new ("render-complete", G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE,
1, G_TYPE_POINTER);
_champlain_marshal_VOID__POINTER_UINT_BOOLEAN, G_TYPE_NONE,
3, G_TYPE_POINTER, G_TYPE_UINT, G_TYPE_BOOLEAN);
}
......
......@@ -67,22 +67,6 @@ typedef enum
CHAMPLAIN_STATE_DONE
} ChamplainState;
/**
* ChamplainRenderCallbackData:
* @error: TRUE if there was an error during tile rendering
* @data: the data used for tile rendering
* @size: the size of the data
*
* Used by the #ChamplainTile::render-complete signal.
*
* Since: 0.8
*/
struct _ChamplainRenderCallbackData
{
gboolean error;
const gchar *data;
gsize size;
};
struct _ChamplainTile
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment