[gnome-photos/wip/rishi/imageview: 3/4] Rewrite gegl-gtk as PhotosImageSurface
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/imageview: 3/4] Rewrite gegl-gtk as PhotosImageSurface
- Date: Sun, 31 Jan 2016 19:37:15 +0000 (UTC)
commit 7d7e1f6af36bb994e9825ff2e2825ccab985e957
Author: Debarshi Ray <debarshir gnome org>
Date: Sun Jan 31 11:47:05 2016 +0100
Rewrite gegl-gtk as PhotosImageSurface
Our copy of gegl-gtk had diverged quite a bit:
- We don't use a processor inside the widget.
- Our AUTOSCALE_CONTENT logic always centres the image.
- Sharper renders on HiDpi displays.
- We don't care about GTK+ 2.x or the absence of Cairo.
The widget / helper split is also largely useless for us. While it
will be good to have tests for the automatic centring and scaling code,
we don't need a separate helper class for it.
While some of our changes can be upstreamed, we are ultimately going
to use the new image viewer widget in GTK+. We are also going to
use transitions when the output of the GeglNode changes. Having only
the bits that we need in a single class, and getting rid of the extra
fluff will help us evolve this code in future.
Since PhotosImageSurface largely constitutes code written by me, we can
license it as GPLv2+, unlike gegl-gtk, which was LGPLv3+.
src/Makefile.am | 48 +----
src/gegl-gtk-enums.h | 43 ----
src/gegl-gtk-marshal.list | 1 -
src/gegl-gtk-view-helper.c | 350 ----------------------------
src/gegl-gtk-view-helper.h | 90 --------
src/gegl-gtk-view.c | 538 --------------------------------------------
src/gegl-gtk-view.h | 76 -------
src/photos-image-surface.c | 449 ++++++++++++++++++++++++++++++++++++
src/photos-image-surface.h | 72 ++++++
src/photos-marshalers.list | 1 +
src/photos-preview-view.c | 12 +-
src/photos-tool-colors.c | 2 +-
src/photos-tool-crop.c | 28 ++--
src/photos-tool-enhance.c | 4 +-
src/photos-tool-filters.c | 2 +-
src/photos-tool.c | 4 +-
src/photos-tool.h | 10 +-
17 files changed, 554 insertions(+), 1176 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index de7a67a..f0f6cce 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,9 +1,6 @@
bin_PROGRAMS = gnome-photos
gnome_photos_built_sources = \
- gegl-gtk-enums.c \
- gegl-gtk-marshal.c \
- gegl-gtk-marshal.h \
photos-about-data.c \
photos-about-data.h \
photos-enums.c \
@@ -35,11 +32,6 @@ nodist_gnome_photos_SOURCES = \
$(NULL)
gnome_photos_SOURCES = \
- gegl-gtk-enums.h \
- gegl-gtk-view.c \
- gegl-gtk-view.h \
- gegl-gtk-view-helper.c \
- gegl-gtk-view-helper.h \
photos-application.c \
photos-application.h \
photos-base-manager.c \
@@ -101,6 +93,8 @@ gnome_photos_SOURCES = \
photos-header-bar.c \
photos-header-bar.h \
photos-icons.h \
+ photos-image-surface.c \
+ photos-image-surface.h \
photos-indexing-notification.c \
photos-indexing-notification.h \
photos-item-manager.c \
@@ -256,7 +250,6 @@ BUILT_SOURCES = \
$(NULL)
EXTRA_DIST = \
- gegl-gtk-marshal.list \
org.gnome.ShellSearchProvider2.xml \
photos-enums.c.template \
photos-enums.h.template \
@@ -332,7 +325,6 @@ gnome_photos_LDADD = \
CLEANFILES = \
$(BUILT_SOURCES) \
- stamp-gegl-gtk-marshal.h \
stamp-photos-about-data.h \
stamp-photos-enums.h \
stamp-photos-marshalers.h \
@@ -346,42 +338,6 @@ CLEANFILES = \
xgen-tmh \
$(NULL)
-gegl-gtk-enums.c: $(srcdir)/gegl-gtk-enums.h
- $(AM_V_GEN) ( \
- glib-mkenums \
- --fhead "/* This is a generated file, do not edit directly */\n\n#include
\"config.h\"\n#include <glib-object.h>\n#include \"gegl-gtk-enums.h\"" \
- --fprod "\n/* enumerations from \"@filename \" */" \
- --vhead "GType\n enum_name@_get_type (void)\n{\n static GType etype = 0;\n if
(etype == 0) {\n static const G Type@Value values[] = {" \
- --vprod " { @VALUENAME@, \"@valuenick \", \"@valuenick \" }," \
- --vtail " { 0, NULL, NULL }\n };\n etype = g_ type@_register_static
(\"@EnumName \", values);\n }\n return etype;\n}\n\n" \
- $(srcdir)/gegl-gtk-enums.h > gegl-gtk-enums.c \
- )
-
-gegl-gtk-marshal.h: stamp-gegl-gtk-marshal.h
- @true
-
-stamp-gegl-gtk-marshal.h: gegl-gtk-marshal.list Makefile
- $(AM_V_GEN) ( \
- ( glib-genmarshal \
- --prefix=gegl_gtk_marshal \
- --header $(srcdir)/gegl-gtk-marshal.list \
- ) >> xgen-gmh \
- && ( cmp -s xgen-gmh gegl-gtk-marshal.h || cp xgen-gmh gegl-gtk-marshal.h ) \
- && rm -f xgen-gmh \
- && echo timestamp > $(@F) \
- )
-
-gegl-gtk-marshal.c: gegl-gtk-marshal.list gegl-gtk-marshal.h Makefile
- $(AM_V_GEN) ( \
- echo "#include \"gegl-gtk-marshal.h\"" > xgen-gmc \
- && ( glib-genmarshal \
- --prefix=gegl_gtk_marshal \
- --body $(srcdir)/gegl-gtk-marshal.list \
- ) >> xgen-gmc \
- && cp xgen-gmc gegl-gtk-marshal.c \
- && rm -f xgen-gmc \
- )
-
photos-about-data.h: stamp-photos-about-data.h
@true
diff --git a/src/photos-image-surface.c b/src/photos-image-surface.c
new file mode 100644
index 0000000..b20ad91
--- /dev/null
+++ b/src/photos-image-surface.c
@@ -0,0 +1,449 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2015, 2016 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include <babl/babl.h>
+#include <cairo-gobject.h>
+#include <glib.h>
+
+#include "photos-debug.h"
+#include "photos-image-surface.h"
+#include "photos-marshalers.h"
+
+
+struct _PhotosImageSurface
+{
+ GtkDrawingArea parent_instance;
+ GeglNode *node;
+ gfloat x;
+ gfloat x_scaled;
+ gfloat y;
+ gfloat y_scaled;
+ gfloat zoom;
+ gfloat zoom_scaled;
+};
+
+struct _PhotosImageSurfaceClass
+{
+ GtkDrawingAreaClass parent_class;
+
+ /* signals */
+ void (*draw_background) (PhotosImageSurface *self, cairo_t *cr, GdkRectangle *rect);
+ void (*draw_overlay) (PhotosImageSurface *self, cairo_t *cr, GdkRectangle *rect);
+};
+
+
+enum
+ {
+ PROP_0,
+ PROP_NODE,
+ PROP_X,
+ PROP_Y,
+ PROP_ZOOM
+ };
+
+enum
+ {
+ DRAW_BACKGROUND,
+ DRAW_OVERLAY,
+ LAST_SIGNAL
+ };
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+
+G_DEFINE_TYPE (PhotosImageSurface, photos_image_surface, GTK_TYPE_DRAWING_AREA);
+
+
+static void
+photos_image_surface_update (PhotosImageSurface *self)
+{
+ GdkRectangle viewport;
+ GeglRectangle bbox;
+ float zoom_scaled = 1.0;
+ gint scale_factor;
+ gint viewport_height_real;
+ gint viewport_width_real;
+
+ if (self->node == NULL)
+ return;
+
+ gtk_widget_get_allocation (GTK_WIDGET (self), &viewport);
+
+ if (viewport.width < 0 || viewport.height < 0)
+ return;
+
+ bbox = gegl_node_get_bounding_box (self->node);
+ if (bbox.width < 0 || bbox.height < 0)
+ return;
+
+ scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (self));
+ viewport_height_real = viewport.height * scale_factor;
+ viewport_width_real = viewport.width * scale_factor;
+
+ if (bbox.height > viewport_height_real || bbox.width > viewport_width_real)
+ {
+ gfloat height_ratio = bbox.height / (gfloat) viewport_height_real;
+ gfloat width_ratio = bbox.width / (gfloat) viewport_width_real;
+ gfloat max_ratio = MAX (height_ratio, width_ratio);
+
+ zoom_scaled = 1.0 / max_ratio;
+
+ bbox.width = (gint) (zoom_scaled * bbox.width + 0.5);
+ bbox.height = (gint) (zoom_scaled * bbox.height + 0.5);
+ bbox.x = (gint) (zoom_scaled * bbox.x + 0.5);
+ bbox.y = (gint) (zoom_scaled * bbox.y + 0.5);
+ }
+
+ self->zoom_scaled = zoom_scaled;
+ self->zoom = self->zoom_scaled / (gfloat) scale_factor;
+
+ /* At this point, viewport is definitely bigger than bbox. */
+ self->x_scaled = (bbox.width - viewport_width_real) / 2.0 + bbox.x;
+ self->y_scaled = (bbox.height - viewport_height_real) / 2.0 + bbox.y;
+
+ self->x = self->x_scaled / (gfloat) scale_factor;
+ self->y = self->y_scaled / (gfloat) scale_factor;
+}
+
+
+static void
+photos_image_surface_computed (PhotosImageSurface *self)
+{
+ photos_image_surface_update (self);
+}
+
+
+static void
+photos_image_surface_draw_node (PhotosImageSurface *self, cairo_t *cr, GdkRectangle *rect)
+{
+ const Babl *format;
+ GeglRectangle roi;
+ cairo_surface_t *surface = NULL;
+ guchar *buf = NULL;
+ gint scale_factor;
+ gint stride;
+ gint64 end;
+ gint64 start;
+
+ scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (self));
+
+ roi.x = (gint) self->x_scaled + rect->x * scale_factor;
+ roi.y = (gint) self->y_scaled + rect->y * scale_factor;
+ roi.width = rect->width * scale_factor;
+ roi.height = rect->height * scale_factor;
+
+ format = babl_format ("cairo-ARGB32");
+ stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, roi.width);
+ buf = g_malloc0 (stride * roi.height);
+
+ start = g_get_monotonic_time ();
+
+ gegl_node_blit (self->node,
+ (gdouble) self->zoom_scaled,
+ &roi,
+ format,
+ buf,
+ GEGL_AUTO_ROWSTRIDE,
+ GEGL_BLIT_CACHE | GEGL_BLIT_DIRTY);
+
+ end = g_get_monotonic_time ();
+ photos_debug (PHOTOS_DEBUG_GEGL, "PhotosImageSurface: Node Blit: %" G_GINT64_FORMAT, end - start);
+
+ surface = cairo_image_surface_create_for_data (buf, CAIRO_FORMAT_ARGB32, roi.width, roi.height, stride);
+ cairo_surface_set_device_scale (surface, (gdouble) scale_factor, (gdouble) scale_factor);
+ cairo_set_source_surface (cr, surface, rect->x, rect->y);
+ cairo_paint (cr);
+
+ cairo_surface_destroy (surface);
+ g_free (buf);
+}
+
+
+static gboolean
+photos_image_surface_draw (GtkWidget *widget, cairo_t *cr)
+{
+ PhotosImageSurface *self = PHOTOS_IMAGE_SURFACE (widget);
+ GdkRectangle rect;
+
+ if (self->node == NULL)
+ goto out;
+
+ if (!gdk_cairo_get_clip_rectangle (cr, &rect))
+ goto out;
+
+ cairo_save (cr);
+ g_signal_emit (self, signals[DRAW_BACKGROUND], 0, cr, &rect);
+ cairo_restore(cr);
+
+ cairo_save (cr);
+ photos_image_surface_draw_node (self, cr, &rect);
+ cairo_restore (cr);
+
+ cairo_save (cr);
+ g_signal_emit (self, signals[DRAW_OVERLAY], 0, cr, &rect);
+ cairo_restore(cr);
+
+ out:
+ return GDK_EVENT_PROPAGATE;
+}
+
+
+static void
+photos_image_surface_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
+{
+ PhotosImageSurface *self = PHOTOS_IMAGE_SURFACE (widget);
+
+ GTK_WIDGET_CLASS (photos_image_surface_parent_class)->size_allocate (widget, allocation);
+
+ photos_image_surface_update (self);
+}
+
+
+static void
+photos_image_surface_dispose (GObject *object)
+{
+ PhotosImageSurface *self = PHOTOS_IMAGE_SURFACE (object);
+
+ g_clear_object (&self->node);
+
+ G_OBJECT_CLASS (photos_image_surface_parent_class)->dispose (object);
+}
+
+
+static void
+photos_image_surface_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+ PhotosImageSurface *self = PHOTOS_IMAGE_SURFACE (object);
+
+ switch (prop_id)
+ {
+ case PROP_NODE:
+ g_value_set_object (value, self->node);
+ break;
+
+ case PROP_X:
+ g_value_set_float (value, self->x);
+ break;
+
+ case PROP_Y:
+ g_value_set_float (value, self->y);
+ break;
+
+ case PROP_ZOOM:
+ g_value_set_float (value, self->zoom);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+static void
+photos_image_surface_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+ PhotosImageSurface *self = PHOTOS_IMAGE_SURFACE (object);
+
+ switch (prop_id)
+ {
+ case PROP_NODE:
+ {
+ GeglNode *node;
+
+ node = GEGL_NODE (g_value_get_object (value));
+ photos_image_surface_set_node (self, node);
+ break;
+ }
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+static void
+photos_image_surface_init (PhotosImageSurface *self)
+{
+ GtkStyleContext *context;
+
+ gtk_widget_add_events (GTK_WIDGET (self),
+ GDK_BUTTON_PRESS_MASK
+ | GDK_BUTTON_RELEASE_MASK
+ | GDK_POINTER_MOTION_MASK);
+
+ context = gtk_widget_get_style_context (view);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW);
+ gtk_style_context_add_class (context, "content-view");
+}
+
+
+static void
+photos_image_surface_class_init (PhotosImageSurfaceClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+
+ object_class->dispose = photos_image_surface_dispose;
+ object_class->get_property = photos_image_surface_get_property;
+ object_class->set_property = photos_image_surface_set_property;
+ widget_class->draw = photos_image_surface_draw;
+ widget_class->size_allocate = photos_image_surface_size_allocate;
+
+ g_object_class_install_property (object_class,
+ PROP_NODE,
+ g_param_spec_object ("node",
+ "GeglNode object",
+ "The GeglNode to render",
+ GEGL_TYPE_NODE,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_X,
+ g_param_spec_float ("x",
+ "X",
+ "X origin",
+ -G_MAXFLOAT,
+ G_MAXFLOAT,
+ 0.0,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_Y,
+ g_param_spec_float ("y",
+ "Y",
+ "Y origin",
+ -G_MAXFLOAT,
+ G_MAXFLOAT,
+ 0.0,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_ZOOM,
+ g_param_spec_float ("zoom",
+ "Zoom",
+ "Zoom factor",
+ 0.0f,
+ 100.0f,
+ 1.0f,
+ G_PARAM_READABLE));
+
+ signals[DRAW_BACKGROUND] = g_signal_new ("draw-background",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PhotosImageSurfaceClass, draw_background),
+ NULL, /* accumulator */
+ NULL, /* accu_data */
+ _photos_marshal_VOID__BOXED_BOXED,
+ G_TYPE_NONE,
+ 2,
+ CAIRO_GOBJECT_TYPE_CONTEXT,
+ GDK_TYPE_RECTANGLE);
+
+ signals[DRAW_OVERLAY] = g_signal_new ("draw-overlay",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PhotosImageSurfaceClass, draw_overlay),
+ NULL, /* accumulator */
+ NULL, /* accu_data */
+ _photos_marshal_VOID__BOXED_BOXED,
+ G_TYPE_NONE,
+ 2,
+ CAIRO_GOBJECT_TYPE_CONTEXT,
+ GDK_TYPE_RECTANGLE);
+}
+
+
+GtkWidget *
+photos_image_surface_new (void)
+{
+ return g_object_new (PHOTOS_TYPE_IMAGE_SURFACE, NULL);
+}
+
+
+GtkWidget *
+photos_image_surface_new_from_node (GeglNode *node)
+{
+ g_return_val_if_fail (node == NULL || GEGL_IS_NODE (node), NULL);
+ return g_object_new (PHOTOS_TYPE_IMAGE_SURFACE, "node", node, NULL);
+}
+
+
+GeglNode *
+photos_image_surface_get_node (PhotosImageSurface *self)
+{
+ g_return_val_if_fail (PHOTOS_IS_IMAGE_SURFACE (self), NULL);
+ return self->node;
+}
+
+
+gfloat
+photos_image_surface_get_x (PhotosImageSurface *self)
+{
+ g_return_val_if_fail (PHOTOS_IS_IMAGE_SURFACE (self), 0.0);
+ return self->x;
+}
+
+
+gfloat
+photos_image_surface_get_y (PhotosImageSurface *self)
+{
+ g_return_val_if_fail (PHOTOS_IS_IMAGE_SURFACE (self), 0.0);
+ return self->y;
+}
+
+
+gfloat
+photos_image_surface_get_zoom (PhotosImageSurface *self)
+{
+ g_return_val_if_fail (PHOTOS_IS_IMAGE_SURFACE (self), 0.0);
+ return self->zoom;
+}
+
+
+void
+photos_image_surface_set_node (PhotosImageSurface *self, GeglNode *node)
+{
+ g_return_if_fail (PHOTOS_IS_IMAGE_SURFACE (self));
+
+ if (self->node == node)
+ return;
+
+ if (self->node != NULL)
+ g_signal_handlers_disconnect_by_func (self->node, photos_image_surface_computed, self);
+
+ g_clear_object (&self->node);
+
+ if (node != NULL)
+ {
+ g_object_ref (node);
+ g_signal_connect_object (node,
+ "computed",
+ G_CALLBACK (photos_image_surface_computed),
+ self,
+ G_CONNECT_SWAPPED);
+ }
+
+ self->node = node;
+ photos_image_surface_update (self);
+}
diff --git a/src/photos-image-surface.h b/src/photos-image-surface.h
new file mode 100644
index 0000000..42b3857
--- /dev/null
+++ b/src/photos-image-surface.h
@@ -0,0 +1,72 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2015, 2016 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef PHOTOS_IMAGE_SURFACE_H
+#define PHOTOS_IMAGE_SURFACE_H
+
+#include <gegl.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_IMAGE_SURFACE (photos_image_surface_get_type ())
+
+#define PHOTOS_IMAGE_SURFACE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ PHOTOS_TYPE_IMAGE_SURFACE, PhotosImageSurface))
+
+#define PHOTOS_IMAGE_SURFACE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ PHOTOS_TYPE_IMAGE_SURFACE, PhotosImageSurfaceClass))
+
+#define PHOTOS_IS_IMAGE_SURFACE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ PHOTOS_TYPE_IMAGE_SURFACE))
+
+#define PHOTOS_IS_IMAGE_SURFACE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ PHOTOS_TYPE_IMAGE_SURFACE))
+
+#define PHOTOS_IMAGE_SURFACE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ PHOTOS_TYPE_IMAGE_SURFACE, PhotosImageSurfaceClass))
+
+typedef struct _PhotosImageSurface PhotosImageSurface;
+typedef struct _PhotosImageSurfaceClass PhotosImageSurfaceClass;
+
+GType photos_image_surface_get_type (void) G_GNUC_CONST;
+
+GtkWidget *photos_image_surface_new (void);
+
+GtkWidget *photos_image_surface_new_from_node (GeglNode *node);
+
+GeglNode *photos_image_surface_get_node (PhotosImageSurface *self);
+
+gfloat photos_image_surface_get_x (PhotosImageSurface *self);
+
+gfloat photos_image_surface_get_y (PhotosImageSurface *self);
+
+gfloat photos_image_surface_get_zoom (PhotosImageSurface *self);
+
+void photos_image_surface_set_node (PhotosImageSurface *self, GeglNode *node);
+
+G_END_DECLS
+
+#endif /* PHOTOS_IMAGE_SURFACE_H */
diff --git a/src/photos-marshalers.list b/src/photos-marshalers.list
index c9978a6..dbde703 100644
--- a/src/photos-marshalers.list
+++ b/src/photos-marshalers.list
@@ -1,3 +1,4 @@
+VOID:BOXED,BOXED
VOID:ENUM,ENUM
VOID:INT,INT
VOID:STRING,STRING
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index 8caa74b..e91af2b 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -29,8 +29,8 @@
#include <gio/gio.h>
#include <glib/gi18n.h>
-#include "gegl-gtk-view.h"
#include "photos-base-item.h"
+#include "photos-image-surface.h"
#include "photos-item-manager.h"
#include "photos-edit-palette.h"
#include "photos-operation-insta-common.h"
@@ -235,11 +235,7 @@ photos_preview_view_create_view_with_container (PhotosPreviewView *self)
context = gtk_widget_get_style_context (sw);
gtk_style_context_add_class (context, "documents-scrolledwin");
- view = GTK_WIDGET (gegl_gtk_view_new ());
- gtk_widget_add_events (view, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK);
- context = gtk_widget_get_style_context (view);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW);
- gtk_style_context_add_class (context, "content-view");
+ view = photos_image_surface_new ();
gtk_container_add (GTK_CONTAINER (sw), view);
g_signal_connect_swapped (view, "button-press-event", G_CALLBACK (photos_preview_view_button_press_event),
self);
g_signal_connect_swapped (view,
@@ -456,7 +452,7 @@ photos_preview_view_tool_changed (PhotosPreviewView *self, PhotosTool *tool)
g_object_add_weak_pointer (G_OBJECT (self->current_tool), (gpointer *) &self->current_tool);
item = PHOTOS_BASE_ITEM (photos_base_manager_get_active_object (self->item_mngr));
- photos_tool_activate (self->current_tool, item, GEGL_GTK_VIEW (view));
+ photos_tool_activate (self->current_tool, item, PHOTOS_IMAGE_SURFACE (view));
}
gtk_widget_queue_draw (view);
@@ -720,7 +716,7 @@ photos_preview_view_set_node (PhotosPreviewView *self, GeglNode *node)
self->node = g_object_ref (node);
view = photos_preview_view_get_view_from_view_container (view_container);
- gegl_gtk_view_set_node (GEGL_GTK_VIEW (view), self->node);
+ photos_image_surface_set_node (PHOTOS_IMAGE_SURFACE (view), self->node);
gtk_widget_queue_draw (view);
}
}
diff --git a/src/photos-tool-colors.c b/src/photos-tool-colors.c
index e4b11b2..e2c8023 100644
--- a/src/photos-tool-colors.c
+++ b/src/photos-tool-colors.c
@@ -142,7 +142,7 @@ photos_tool_colors_saturation_value_changed (PhotosToolColors *self)
static void
-photos_tool_colors_activate (PhotosTool *tool, PhotosBaseItem *item, GeglGtkView *view)
+photos_tool_colors_activate (PhotosTool *tool, PhotosBaseItem *item, PhotosImageSurface *view)
{
PhotosToolColors *self = PHOTOS_TOOL_COLORS (tool);
gdouble brightness;
diff --git a/src/photos-tool-crop.c b/src/photos-tool-crop.c
index a1fad27..3b72776 100644
--- a/src/photos-tool-crop.c
+++ b/src/photos-tool-crop.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2015 Red Hat, Inc.
+ * Copyright © 2015, 2016 Red Hat, Inc.
* Copyright © 2015 Umang Jain
* Copyright © 2011, 2012, 2013, 2014, 2015 Yorba Foundation
*
@@ -35,8 +35,8 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include "gegl-gtk-view.h"
#include "photos-icons.h"
+#include "photos-image-surface.h"
#include "photos-tool.h"
#include "photos-tool-crop.h"
#include "photos-utils.h"
@@ -214,10 +214,10 @@ photos_tool_crop_redraw_damaged_area (PhotosToolCrop *self)
gdouble x;
gdouble y;
- x = (gdouble) gegl_gtk_view_get_x (GEGL_GTK_VIEW (self->view));
+ x = (gdouble) photos_image_surface_get_x (PHOTOS_IMAGE_SURFACE (self->view));
x = -x + self->crop_x - damage_offset;
- y = (gdouble) gegl_gtk_view_get_y (GEGL_GTK_VIEW (self->view));
+ y = (gdouble) photos_image_surface_get_y (PHOTOS_IMAGE_SURFACE (self->view));
y = -y + self->crop_y - damage_offset;
area.height = (gint) (self->crop_height + 2 * damage_offset + 0.5) + 2;
@@ -240,7 +240,7 @@ photos_tool_crop_surface_create (PhotosToolCrop *self)
g_clear_pointer (&self->surface, (GDestroyNotify) cairo_surface_destroy);
window = gtk_widget_get_window (self->view);
- zoom = gegl_gtk_view_get_zoom (GEGL_GTK_VIEW (self->view));
+ zoom = photos_image_surface_get_zoom (PHOTOS_IMAGE_SURFACE (self->view));
self->bbox_zoomed.height = (gint) (zoom * self->bbox_source.height + 0.5);
self->bbox_zoomed.width = (gint) (zoom * self->bbox_source.width + 0.5);
self->surface = gdk_window_create_similar_surface (window,
@@ -857,7 +857,7 @@ photos_tool_crop_process (GObject *source_object, GAsyncResult *res, gpointer us
goto out;
}
- zoom = gegl_gtk_view_get_zoom (GEGL_GTK_VIEW (self->view));
+ zoom = photos_image_surface_get_zoom (PHOTOS_IMAGE_SURFACE (self->view));
self->crop_height *= zoom;
self->crop_width *= zoom;
self->crop_x *= zoom;
@@ -909,7 +909,7 @@ photos_tool_crop_size_allocate (PhotosToolCrop *self, GdkRectangle *allocation)
static void
-photos_tool_crop_activate (PhotosTool *tool, PhotosBaseItem *item, GeglGtkView *view)
+photos_tool_crop_activate (PhotosTool *tool, PhotosBaseItem *item, PhotosImageSurface *view)
{
PhotosToolCrop *self = PHOTOS_TOOL_CROP (tool);
gboolean got_bbox_source;
@@ -984,7 +984,7 @@ photos_tool_crop_deactivate (PhotosTool *tool)
GVariantType *parameter_type;
gfloat zoom;
- zoom = gegl_gtk_view_get_zoom (GEGL_GTK_VIEW (self->view));
+ zoom = photos_image_surface_get_zoom (PHOTOS_IMAGE_SURFACE (self->view));
/* GEGL needs the parameters to be in device pixels. So, we
* should multiply the extents of the crop rectangle and the
@@ -1024,10 +1024,10 @@ photos_tool_crop_draw (PhotosTool *tool, cairo_t *cr, GdkRectangle *rect)
g_return_if_fail (self->activated);
g_return_if_fail (self->view != NULL);
- x = (gdouble) gegl_gtk_view_get_x (GEGL_GTK_VIEW (self->view));
+ x = (gdouble) photos_image_surface_get_x (PHOTOS_IMAGE_SURFACE (self->view));
x = -x;
- y = (gdouble) gegl_gtk_view_get_y (GEGL_GTK_VIEW (self->view));
+ y = (gdouble) photos_image_surface_get_y (PHOTOS_IMAGE_SURFACE (self->view));
y = -y;
cairo_save (cr);
@@ -1057,8 +1057,8 @@ photos_tool_crop_left_click_event (PhotosTool *tool, GdkEventButton *event)
self->grabbed = TRUE;
- x = (gdouble) gegl_gtk_view_get_x (GEGL_GTK_VIEW (self->view));
- y = (gdouble) gegl_gtk_view_get_y (GEGL_GTK_VIEW (self->view));
+ x = (gdouble) photos_image_surface_get_x (PHOTOS_IMAGE_SURFACE (self->view));
+ y = (gdouble) photos_image_surface_get_y (PHOTOS_IMAGE_SURFACE (self->view));
self->event_x_last = event->x + x;
self->event_y_last = event->y + y;
@@ -1094,8 +1094,8 @@ photos_tool_crop_motion_event (PhotosTool *tool, GdkEventMotion *event)
g_return_val_if_fail (self->activated, GDK_EVENT_PROPAGATE);
g_return_val_if_fail (self->view != NULL, GDK_EVENT_PROPAGATE);
- x = (gdouble) gegl_gtk_view_get_x (GEGL_GTK_VIEW (self->view));
- y = (gdouble) gegl_gtk_view_get_y (GEGL_GTK_VIEW (self->view));
+ x = (gdouble) photos_image_surface_get_x (PHOTOS_IMAGE_SURFACE (self->view));
+ y = (gdouble) photos_image_surface_get_y (PHOTOS_IMAGE_SURFACE (self->view));
event_x = event->x + x;
event_y = event->y + y;
diff --git a/src/photos-tool-enhance.c b/src/photos-tool-enhance.c
index 2b18372..30d7778 100644
--- a/src/photos-tool-enhance.c
+++ b/src/photos-tool-enhance.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2015 Red Hat, Inc.
+ * Copyright © 2015, 2016 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -121,7 +121,7 @@ photos_tool_enhance_sharpen_value_changed (PhotosToolEnhance *self)
static void
-photos_tool_enhance_activate (PhotosTool *tool, PhotosBaseItem *item, GeglGtkView *view)
+photos_tool_enhance_activate (PhotosTool *tool, PhotosBaseItem *item, PhotosImageSurface *view)
{
PhotosToolEnhance *self = PHOTOS_TOOL_ENHANCE (tool);
gdouble sharpen_scale;
diff --git a/src/photos-tool-filters.c b/src/photos-tool-filters.c
index b4709fb..39a0e02 100644
--- a/src/photos-tool-filters.c
+++ b/src/photos-tool-filters.c
@@ -103,7 +103,7 @@ photos_tool_filters_create_preview_idle (gpointer user_data)
static void
-photos_tool_filters_activate (PhotosTool *tool, PhotosBaseItem *item, GeglGtkView *view)
+photos_tool_filters_activate (PhotosTool *tool, PhotosBaseItem *item, PhotosImageSurface *view)
{
PhotosToolFilters *self = PHOTOS_TOOL_FILTERS (tool);
diff --git a/src/photos-tool.c b/src/photos-tool.c
index c911e49..db942c7 100644
--- a/src/photos-tool.c
+++ b/src/photos-tool.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2015 Red Hat, Inc.
+ * Copyright © 2015, 2016 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -101,7 +101,7 @@ photos_tool_class_init (PhotosToolClass *class)
void
-photos_tool_activate (PhotosTool *self, PhotosBaseItem *item, GeglGtkView *view)
+photos_tool_activate (PhotosTool *self, PhotosBaseItem *item, PhotosImageSurface *view)
{
PHOTOS_TOOL_GET_CLASS (self)->activate (self, item, view);
}
diff --git a/src/photos-tool.h b/src/photos-tool.h
index a766555..f77b616 100644
--- a/src/photos-tool.h
+++ b/src/photos-tool.h
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2015 Red Hat, Inc.
+ * Copyright © 2015, 2016 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -25,8 +25,8 @@
#include <gdk/gdk.h>
#include <gtk/gtk.h>
-#include "gegl-gtk-view.h"
#include "photos-base-item.h"
+#include "photos-image-surface.h"
G_BEGIN_DECLS
@@ -70,7 +70,7 @@ struct _PhotosToolClass
const gchar *name;
/* virtual methods */
- void (*activate) (PhotosTool *self, PhotosBaseItem *item, GeglGtkView *view);
+ void (*activate) (PhotosTool *self, PhotosBaseItem *item, PhotosImageSurface
*view);
void (*deactivate) (PhotosTool *self);
void (*draw) (PhotosTool *self, cairo_t *cr, GdkRectangle *rect);
GtkWidget *(*get_widget) (PhotosTool *self);
@@ -84,7 +84,9 @@ struct _PhotosToolClass
GType photos_tool_get_type (void) G_GNUC_CONST;
-void photos_tool_activate (PhotosTool *self, PhotosBaseItem *item, GeglGtkView
*view);
+void photos_tool_activate (PhotosTool *self,
+ PhotosBaseItem *item,
+ PhotosImageSurface *view);
void photos_tool_deactivate (PhotosTool *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]