[libchamplain] Fixes for cairo surface export
- From: Jiří Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Fixes for cairo surface export
- Date: Tue, 17 Nov 2015 22:34:56 +0000 (UTC)
commit 79c563d772675f1b5f8649e6419254943713c941
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Tue Nov 17 20:41:39 2015 +0100
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
champlain/champlain-path-layer.c | 7 ++++++-
champlain/champlain-view.c | 7 +++++--
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);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]