summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Danielsson <jonas@threetimestwo.org>2015-11-17 20:41:39 +0100
committerJiří Techet <techet@gmail.com>2015-11-17 23:21:39 +0100
commit79c563d772675f1b5f8649e6419254943713c941 (patch)
tree5b8c37224ed9ba4674016ff868ff7e0592ad04d1
parent5cb2cb3c40fc3139781279cd0c94d26da3a07daf (diff)
downloadlibchamplain-79c563d772675f1b5f8649e6419254943713c941.tar.gz
Fixes for cairo surface export
Return NULL for surface when PathLayer is not visible. And do not try to export layers where surface is NULL. Also honor the tile opacity. https://bugzilla.gnome.org/show_bug.cgi?id=757350
-rw-r--r--champlain/champlain-path-layer.c7
-rw-r--r--champlain/champlain-view.c7
2 files changed, 11 insertions, 3 deletions
diff --git a/champlain/champlain-path-layer.c b/champlain/champlain-path-layer.c
index 0669929..4a8c0fc 100644
--- a/champlain/champlain-path-layer.c
+++ b/champlain/champlain-path-layer.c
@@ -435,7 +435,12 @@ get_surface (ChamplainExportable *exportable)
{
g_return_val_if_fail (CHAMPLAIN_IS_PATH_LAYER (exportable), NULL);
- return CHAMPLAIN_PATH_LAYER (exportable)->priv->surface;
+ ChamplainPathLayer *self = CHAMPLAIN_PATH_LAYER (exportable);
+
+ if (self->priv->visible)
+ return CHAMPLAIN_PATH_LAYER (exportable)->priv->surface;
+ else
+ return NULL;
}
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index 85ea530..7e9718f 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -1775,6 +1775,8 @@ layers_to_surface (ChamplainView *view,
continue;
surface = champlain_exportable_get_surface (CHAMPLAIN_EXPORTABLE (layer));
+ if (!surface)
+ continue;
cairo_set_source_surface (cr, surface, 0, 0);
cairo_paint(cr);
}
@@ -1832,7 +1834,7 @@ champlain_view_to_surface (ChamplainView *view,
if (tile_in_tile_map (view, tile_x, tile_y))
{
cairo_surface_t *tile_surface;
- double x, y;
+ double x, y, opacity;
tile_surface = champlain_exportable_get_surface (CHAMPLAIN_EXPORTABLE (tile));
if (!tile_surface)
@@ -1841,12 +1843,13 @@ champlain_view_to_surface (ChamplainView *view,
cairo_surface_destroy (surface);
return NULL;
}
+ opacity = ((double) clutter_actor_get_opacity (CLUTTER_ACTOR (tile))) / 255.0;
x = ((double) tile_x * tile_size) - priv->viewport_x;
y = ((double) tile_y * tile_size) - priv->viewport_y;
cairo_set_source_surface (cr,
tile_surface,
x, y);
- cairo_paint(cr);
+ cairo_paint_with_alpha(cr, opacity);
}
}