[gnome-photos/wip/rishi/double-buffering: 12/12] image-view: ...
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/double-buffering: 12/12] image-view: ...
- Date: Tue, 17 Jan 2017 12:39:40 +0000 (UTC)
commit acb94c4ea0bb7742c13e83e70b06304f25771fc6
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Jan 17 13:37:51 2017 +0100
image-view: ...
src/photos-image-view.c | 59 +++++++++++++++++-----------------------------
1 files changed, 22 insertions(+), 37 deletions(-)
---
diff --git a/src/photos-image-view.c b/src/photos-image-view.c
index ad4aa78..cb7253c 100644
--- a/src/photos-image-view.c
+++ b/src/photos-image-view.c
@@ -34,8 +34,7 @@
struct _PhotosImageView
{
GtkDrawingArea parent_instance;
- GeglNode *buffer_source;
- GeglNode *graph;
+ GeglBuffer *buffer;
GeglNode *node;
cairo_region_t *bbox_region;
cairo_region_t *region;
@@ -73,31 +72,16 @@ static void photos_image_view_computed (PhotosImageView *self, GeglRectangle *re
static void
-photos_image_view_update_graph (PhotosImageView *self)
+photos_image_view_update_buffer (PhotosImageView *self)
{
const Babl *format;
GeglBuffer *buffer = NULL;
- gint64 end;
- gint64 start;
- g_clear_object (&self->graph);
+ g_clear_object (&self->buffer);
g_signal_handlers_block_by_func (self->node, photos_image_view_computed, self);
format = babl_format ("cairo-ARGB32");
- buffer = photos_utils_dup_buffer_from_node (self->node, format);
-
- self->graph = gegl_node_new ();
- self->buffer_source = gegl_node_new_child (self->graph,
- "operation", "gegl:buffer-source",
- "buffer", buffer,
- NULL);
-
- start = g_get_monotonic_time ();
-
- gegl_node_process (self->buffer_source);
-
- end = g_get_monotonic_time ();
- photos_debug (PHOTOS_DEBUG_GEGL, "PhotosImageView: Process Buffer: %" G_GINT64_FORMAT, end - start);
+ self->buffer = photos_utils_dup_buffer_from_node (self->node, format);
g_signal_handlers_unblock_by_func (self->node, photos_image_view_computed, self);
g_object_unref (buffer);
@@ -139,14 +123,14 @@ photos_image_view_update (PhotosImageView *self)
if (self->node == NULL)
return;
- g_return_if_fail (GEGL_IS_NODE (self->buffer_source));
+ g_return_if_fail (GEGL_IS_BUFFER (self->buffer));
gtk_widget_get_allocation (GTK_WIDGET (self), &viewport);
if (viewport.width < 0 || viewport.height < 0)
return;
- bbox = gegl_node_get_bounding_box (self->buffer_source);
+ bbox = *gegl_buffer_get_extent (self->buffer);
if (bbox.width < 0 || bbox.height < 0)
return;
@@ -186,9 +170,8 @@ photos_image_view_computed (PhotosImageView *self, GeglRectangle *rect)
cairo_status_t status;
g_return_if_fail (PHOTOS_IS_IMAGE_VIEW (self));
- g_return_if_fail (GEGL_IS_NODE (self->buffer_source));
- g_return_if_fail (GEGL_IS_NODE (self->graph));
g_return_if_fail (GEGL_IS_NODE (self->node));
+ g_return_if_fail (GEGL_IS_BUFFER (self->buffer));
g_return_if_fail (self->bbox_region != NULL);
g_return_if_fail (self->region != NULL);
@@ -208,7 +191,7 @@ photos_image_view_computed (PhotosImageView *self, GeglRectangle *rect)
photos_debug (PHOTOS_DEBUG_GEGL, "PhotosImageView: Node (%p) Computing Completed", self->node);
- photos_image_view_update_graph (self);
+ photos_image_view_update_buffer (self);
photos_image_view_update (self);
gtk_widget_queue_draw (GTK_WIDGET (self));
}
@@ -232,12 +215,13 @@ photos_image_view_draw_node (PhotosImageView *self, cairo_t *cr, GdkRectangle *r
GeglRectangle roi;
cairo_surface_t *surface = NULL;
guchar *buf = NULL;
+ gint bpp;
gint scale_factor;
gint stride;
gint64 end;
gint64 start;
- g_return_if_fail (GEGL_IS_NODE (self->buffer_source));
+ g_return_if_fail (GEGL_IS_BUFFER (self->buffer));
scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (self));
@@ -252,13 +236,15 @@ photos_image_view_draw_node (PhotosImageView *self, cairo_t *cr, GdkRectangle *r
start = g_get_monotonic_time ();
- gegl_node_blit (self->buffer_source,
- (gdouble) self->zoom_scaled,
- &roi,
- format,
- buf,
- GEGL_AUTO_ROWSTRIDE,
- GEGL_BLIT_CACHE | GEGL_BLIT_DIRTY);
+ bpp = babl_format_get_bytes_per_pixel (format);
+ stride = bpp * roi.width;
+ gegl_buffer_get (self->buffer,
+ &roi,
+ (gdouble) self->zoom_scaled,
+ format,
+ buf,
+ stride,
+ GEGL_ABYSS_NONE);
end = g_get_monotonic_time ();
photos_debug (PHOTOS_DEBUG_GEGL, "PhotosImageView: Node Blit: %" G_GINT64_FORMAT, end - start);
@@ -318,7 +304,7 @@ photos_image_view_dispose (GObject *object)
{
PhotosImageView *self = PHOTOS_IMAGE_VIEW (object);
- g_clear_object (&self->graph);
+ g_clear_object (&self->buffer);
g_clear_object (&self->node);
G_OBJECT_CLASS (photos_image_view_parent_class)->dispose (object);
@@ -544,8 +530,7 @@ photos_image_view_set_node (PhotosImageView *self, GeglNode *node)
g_signal_handlers_disconnect_by_func (self->node, photos_image_view_invalidated, self);
}
- self->buffer_source = NULL;
- g_clear_object (&self->graph);
+ g_clear_object (&self->buffer);
g_clear_object (&self->node);
g_clear_pointer (&self->bbox_region, (GDestroyNotify) cairo_region_destroy);
g_clear_pointer (&self->region, (GDestroyNotify) cairo_region_destroy);
@@ -555,7 +540,7 @@ photos_image_view_set_node (PhotosImageView *self, GeglNode *node)
self->node = g_object_ref (node);
photos_image_view_update_region (self);
- photos_image_view_update_graph (self);
+ photos_image_view_update_buffer (self);
g_signal_connect_object (node, "computed", G_CALLBACK (photos_image_view_computed), self,
G_CONNECT_SWAPPED);
g_signal_connect_object (node,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]