[gnome-photos/wip/baedert/gtkimageview: 45/47] Foo
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/baedert/gtkimageview: 45/47] Foo
- Date: Fri, 15 Apr 2016 13:51:20 +0000 (UTC)
commit 3f5732fb6ed0d8b531acd325e6e8d182cab64600
Author: Timm Bäder <mail baedert org>
Date: Thu Apr 14 19:32:36 2016 +0200
Foo
src/photos-gegl-image.c | 103 ++++++++++++++++++++++++++++++++------
src/photos-gegl-image.h | 7 ++-
src/photos-preview-nav-buttons.c | 3 +-
3 files changed, 96 insertions(+), 17 deletions(-)
---
diff --git a/src/photos-gegl-image.c b/src/photos-gegl-image.c
index 1c38699..d17c224 100644
--- a/src/photos-gegl-image.c
+++ b/src/photos-gegl-image.c
@@ -27,11 +27,14 @@ photos_gegl_image_render_surface (PhotosGeglImage *image)
{
GeglRectangle roi = image->roi;
+ g_message ("rendering for scale %f", image->view_scale);
+
roi.x *= image->view_scale;
roi.y *= image->view_scale;
gegl_node_blit (image->node,
image->view_scale,
+ /*image->rendered_scale,*/
&roi,
image->format,
image->buf,
@@ -40,13 +43,16 @@ photos_gegl_image_render_surface (PhotosGeglImage *image)
/*if (!image->surface)*/
/*{*/
+ g_message ("Surface size: %d, %d", (int)(image->width * image->view_scale), (int)(image->height *
image->view_scale));
image->surface = cairo_image_surface_create_for_data (image->buf,
CAIRO_FORMAT_ARGB32,
- image->width,
- image->height,
+ image->width * image->view_scale,
+ image->height * image->view_scale,
image->stride);
/*}*/
+ image->rendered_scale = image->view_scale;
+
g_signal_emit_by_name (G_OBJECT (image), "changed", 0);
}
@@ -55,9 +61,13 @@ photos_gegl_image_draw (GtkAbstractImage *_image, cairo_t *ct)
{
PhotosGeglImage *image = PHOTOS_GEGL_IMAGE (_image);
+ g_message ("View scale: %f, rendered scale: %f", image->view_scale, image->rendered_scale);
+
if (image->surface)
{
- cairo_scale (ct, 1.0 / image->view_scale, 1.0 / image->view_scale);
+ /*cairo_pattern_set_filter (cairo_get_source (ct), CAIRO_FILTER_FAST);*/
+ cairo_scale (ct, 1.0 / image->rendered_scale, 1.0 / image->rendered_scale);
+ /*cairo_scale (ct, 1.0 / image->view_scale, 1.0 / image->view_scale);*/
cairo_set_source_surface (ct, image->surface, 0, 0);
}
}
@@ -72,40 +82,83 @@ photos_gegl_image_update_bbox (PhotosGeglImage *image)
box = gegl_node_get_bounding_box (image->node);
+ g_message ("%s: %d, %d, %d, %d", __FUNCTION__, box.x, box.y, box.width, box.height);
+
#if 0
g_message ("old size: %d, %d; new size: %d, %d", image->width, image->height,
box.width, box.height);
g_message ("bbox: %d, %d, %d, %d", box.x, box.y, box.width, box.height);
#endif
- /*if (image->width != box.width || image->height != box.height ||*/
- /*image->roi.x != box.x || image->roi.y != box.y)*/
+
+ image->width = box.width;
+ image->height = box.height;
+
+ box.width *= image->view_scale;
+ box.height *= image->view_scale;
+
+ /*if (image->roi.width != box.width || image->roi.height != box.height ||*/
+ /*image->roi.x != box.x || image->roi.y != box.y)*/
/*{*/
- image->width = box.width;
- image->height = box.height;
+ /*image->width = box.width / image->view_scale;*/
+ /*image->height = box.height / image->view_scale;*/
+
+ image->roi.x = box.x;// * image->view_scale;
+ image->roi.y = box.y;// * image->view_scale;
+ image->roi.width = box.width;// * /*image->scale_factor **/ image->view_scale;
+ image->roi.height = box.height;// * /*image->scale_factor **/ image->view_scale;
+
+
+ /*image->roi.x = box.x * image->rendered_scale;*/
+ /*image->roi.y = box.y * image->rendered_scale;*/
+ /*image->roi.width = box.width [> * image->scale_factor <]* image->rendered_scale;*/
+ /*image->roi.height = box.height[> * image->scale_factor <]* image->rendered_scale;*/
+
+
- image->roi.x = box.x * image->view_scale;
- image->roi.y = box.y * image->view_scale;
- image->roi.width = box.width * image->scale_factor * image->view_scale;
- image->roi.height = box.height * image->scale_factor * image->view_scale;
image->stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, image->roi.width);
g_clear_pointer (&image->buf, g_free);
- g_clear_pointer (&image->buf, cairo_surface_destroy);
+ g_clear_pointer (&image->surface, cairo_surface_destroy);
- image->buf = g_malloc (image->stride * image->roi.height * image->view_scale);
+ /*image->buf = g_malloc (image->stride * image->roi.height * image->view_scale);*/
+ /*image->buf = g_malloc (image->stride * image->roi.height * image->rendered_scale);*/
+ image->buf = g_malloc (image->stride * image->roi.height);
/*}*/
}
+
+static gboolean
+redraw_image_cb (gpointer data)
+{
+ PhotosGeglImage *image = data;
+
+ photos_gegl_image_update_bbox (image);
+ photos_gegl_image_render_surface (image);
+
+ image->redraw_id = 0;
+
+ return G_SOURCE_REMOVE;
+}
static void
photos_gegl_image_computed (PhotosGeglImage *image)
{
+ g_message (__FUNCTION__);
+
photos_gegl_image_update_bbox (image);
- photos_gegl_image_render_surface (image);
+
+ if (image->redraw_id != 0)
+ {
+ g_source_remove (image->redraw_id);
+ image->redraw_id = 0;
+ }
+
+ image->redraw_id = g_timeout_add (500, redraw_image_cb, image);
}
+
PhotosGeglImage *
photos_gegl_image_new (GeglNode *node, int scale_factor)
{
@@ -119,6 +172,9 @@ photos_gegl_image_new (GeglNode *node, int scale_factor)
photos_gegl_image_update_bbox (image);
photos_gegl_image_render_surface (image);
+
+ g_message ("-----------------------------------");
+
return image;
}
@@ -127,6 +183,7 @@ photos_gegl_image_init (PhotosGeglImage *image)
{
image->surface = NULL;
image->view_scale = 1.0;
+ image->rendered_scale = 1.0;
}
static void
@@ -157,9 +214,25 @@ photos_gegl_image_class_init (PhotosGeglImageClass *klass)
image_class->get_scale_factor = photos_gegl_image_get_scale_factor;
}
+
+
void
photos_gegl_image_set_view_scale (PhotosGeglImage *image, double view_scale)
{
+
+ if (view_scale == image->view_scale)
+ return;
+
+ g_message ("%s: New view scale: %f", __FUNCTION__, view_scale);
image->view_scale = view_scale;
- photos_gegl_image_render_surface (image);
+ photos_gegl_image_update_bbox (image);
+
+ if (image->redraw_id != 0)
+ {
+ g_source_remove (image->redraw_id);
+ image->redraw_id = 0;
+ }
+
+ image->redraw_id = g_timeout_add (1000, redraw_image_cb, image);
}
+
diff --git a/src/photos-gegl-image.h b/src/photos-gegl-image.h
index 57c8e05..82c4275 100644
--- a/src/photos-gegl-image.h
+++ b/src/photos-gegl-image.h
@@ -19,13 +19,18 @@ struct _PhotosGeglImage
GeglNode *node;
int width;
int height;
- double view_scale;
cairo_surface_t *surface;
guchar *buf;
const Babl *format;
GeglRectangle roi;
int stride;
int scale_factor;
+
+
+ double view_scale;
+ double rendered_scale;
+
+ guint redraw_id;
};
struct _PhotosGeglImageClass
diff --git a/src/photos-preview-nav-buttons.c b/src/photos-preview-nav-buttons.c
index 166e8d8..df8a7e8 100644
--- a/src/photos-preview-nav-buttons.c
+++ b/src/photos-preview-nav-buttons.c
@@ -114,7 +114,8 @@ photos_preview_nav_buttons_fade_in_button (PhotosPreviewNavButtons *self, GtkWid
return;
gtk_widget_show_all (widget);
- gtk_revealer_set_reveal_child (GTK_REVEALER (widget), TRUE);
+ /*gtk_revealer_set_reveal_child (GTK_REVEALER (widget), TRUE);*/
+ gtk_revealer_set_reveal_child (GTK_REVEALER (widget), FALSE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]