[gimp] app: in GimpImageProxy, implement GimpPickable
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: in GimpImageProxy, implement GimpPickable
- Date: Mon, 4 Nov 2019 11:33:35 +0000 (UTC)
commit 0e02795128ae1372cea888161291c70790f1c52a
Author: Ell <ell_se yahoo com>
Date: Mon Nov 4 12:55:23 2019 +0200
app: in GimpImageProxy, implement GimpPickable
In GimpImageProxy, implement the GimpPickable interface, so that
the proxy can be used as both a viewable and a pickable for the
image projection, with direct control over the show-all mode. This
will allow us to use a GimpImageProxy as input for a GimpLineArt.
app/core/gimpimageproxy.c | 307 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 239 insertions(+), 68 deletions(-)
---
diff --git a/app/core/gimpimageproxy.c b/app/core/gimpimageproxy.c
index e2716becc4..92f81635bb 100644
--- a/app/core/gimpimageproxy.c
+++ b/app/core/gimpimageproxy.c
@@ -45,7 +45,8 @@ enum
{
PROP_0,
PROP_IMAGE,
- PROP_SHOW_ALL
+ PROP_SHOW_ALL,
+ PROP_BUFFER
};
@@ -61,62 +62,92 @@ struct _GimpImageProxyPrivate
/* local function prototypes */
-static void gimp_image_proxy_finalize (GObject *object);
-static void gimp_image_proxy_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_image_proxy_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-
-static gboolean gimp_image_proxy_get_size (GimpViewable *viewable,
- gint *width,
- gint *height);
-static void gimp_image_proxy_get_preview_size (GimpViewable *viewable,
- gint size,
- gboolean is_popup,
- gboolean dot_for_dot,
- gint *width,
- gint *height);
-static gboolean gimp_image_proxy_get_popup_size (GimpViewable *viewable,
- gint width,
- gint height,
- gboolean dot_for_dot,
- gint *popup_width,
- gint *popup_height);
-static GimpTempBuf * gimp_image_proxy_get_new_preview (GimpViewable *viewable,
- GimpContext *context,
- gint width,
- gint height);
-static GdkPixbuf * gimp_image_proxy_get_new_pixbuf (GimpViewable *viewable,
- GimpContext *context,
- gint width,
- gint height);
-static gchar * gimp_image_proxy_get_description (GimpViewable *viewable,
- gchar **tooltip);
-
-static void gimp_image_proxy_image_frozen_notify (GimpImage *image,
- const GParamSpec *pspec,
- GimpImageProxy *image_proxy);
-static void gimp_image_proxy_image_invalidate_preview (GimpImage *image,
- GimpImageProxy *image_proxy);
-static void gimp_image_proxy_image_size_changed (GimpImage *image,
- GimpImageProxy *image_proxy);
-static void gimp_image_proxy_image_bounds_changed (GimpImage *image,
- gint old_x,
- gint old_y,
- GimpImageProxy *image_proxy);
-
-static void gimp_image_proxy_set_image (GimpImageProxy *image_proxy,
- GimpImage *image);
-static void gimp_image_proxy_update_bounding_box (GimpImageProxy *image_proxy);
-static void gimp_image_proxy_update_frozen (GimpImageProxy *image_proxy);
-
-
-G_DEFINE_TYPE_WITH_PRIVATE (GimpImageProxy, gimp_image_proxy,
- GIMP_TYPE_VIEWABLE)
+static void gimp_image_proxy_pickable_iface_init (GimpPickableInterface *iface);
+
+static void gimp_image_proxy_finalize (GObject *object);
+static void gimp_image_proxy_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_image_proxy_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static gboolean gimp_image_proxy_get_size (GimpViewable *viewable,
+ gint *width,
+ gint *height);
+static void gimp_image_proxy_get_preview_size (GimpViewable *viewable,
+ gint size,
+ gboolean is_popup,
+ gboolean dot_for_dot,
+ gint *width,
+ gint *height);
+static gboolean gimp_image_proxy_get_popup_size (GimpViewable *viewable,
+ gint width,
+ gint height,
+ gboolean dot_for_dot,
+ gint *popup_width,
+ gint *popup_height);
+static GimpTempBuf * gimp_image_proxy_get_new_preview (GimpViewable *viewable,
+ GimpContext *context,
+ gint width,
+ gint height);
+static GdkPixbuf * gimp_image_proxy_get_new_pixbuf (GimpViewable *viewable,
+ GimpContext *context,
+ gint width,
+ gint height);
+static gchar * gimp_image_proxy_get_description (GimpViewable *viewable,
+ gchar **tooltip);
+
+static void gimp_image_proxy_flush (GimpPickable *pickable);
+static const Babl * gimp_image_proxy_get_format (GimpPickable *pickable);
+static const Babl * gimp_image_proxy_get_format_with_alpha (GimpPickable *pickable);
+static GeglBuffer * gimp_image_proxy_get_buffer (GimpPickable *pickable);
+static gboolean gimp_image_proxy_get_pixel_at (GimpPickable *pickable,
+ gint x,
+ gint y,
+ const Babl *format,
+ gpointer pixel);
+static gdouble gimp_image_proxy_get_opacity_at (GimpPickable *pickable,
+ gint x,
+ gint y);
+static void gimp_image_proxy_get_pixel_average (GimpPickable *pickable,
+ const GeglRectangle *rect,
+ const Babl *format,
+ gpointer pixel);
+static void gimp_image_proxy_pixel_to_srgb (GimpPickable *pickable,
+ const Babl *format,
+ gpointer pixel,
+ GimpRGB *color);
+static void gimp_image_proxy_srgb_to_pixel (GimpPickable *pickable,
+ const GimpRGB *color,
+ const Babl *format,
+ gpointer pixel);
+
+static void gimp_image_proxy_image_frozen_notify (GimpImage *image,
+ const GParamSpec *pspec,
+ GimpImageProxy *image_proxy);
+static void gimp_image_proxy_image_invalidate_preview (GimpImage *image,
+ GimpImageProxy *image_proxy);
+static void gimp_image_proxy_image_size_changed (GimpImage *image,
+ GimpImageProxy *image_proxy);
+static void gimp_image_proxy_image_bounds_changed (GimpImage *image,
+ gint old_x,
+ gint old_y,
+ GimpImageProxy *image_proxy);
+
+static void gimp_image_proxy_set_image (GimpImageProxy *image_proxy,
+ GimpImage *image);
+static GimpPickable * gimp_image_proxy_get_pickable (GimpImageProxy *image_proxy);
+static void gimp_image_proxy_update_bounding_box (GimpImageProxy *image_proxy);
+static void gimp_image_proxy_update_frozen (GimpImageProxy *image_proxy);
+
+
+G_DEFINE_TYPE_WITH_CODE (GimpImageProxy, gimp_image_proxy, GIMP_TYPE_VIEWABLE,
+ G_ADD_PRIVATE (GimpImageProxy)
+ G_IMPLEMENT_INTERFACE (GIMP_TYPE_PICKABLE,
+ gimp_image_proxy_pickable_iface_init))
#define parent_class gimp_image_proxy_parent_class
@@ -124,7 +155,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (GimpImageProxy, gimp_image_proxy,
/* private functions */
-static void-
+static void
gimp_image_proxy_class_init (GimpImageProxyClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -155,6 +186,23 @@ gimp_image_proxy_class_init (GimpImageProxyClass *klass)
FALSE,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
+
+ g_object_class_override_property (object_class, PROP_BUFFER, "buffer");
+}
+
+static void
+gimp_image_proxy_pickable_iface_init (GimpPickableInterface *iface)
+{
+ iface->flush = gimp_image_proxy_flush;
+ iface->get_image = (gpointer) gimp_image_proxy_get_image;
+ iface->get_format = gimp_image_proxy_get_format;
+ iface->get_format_with_alpha = gimp_image_proxy_get_format_with_alpha;
+ iface->get_buffer = gimp_image_proxy_get_buffer;
+ iface->get_pixel_at = gimp_image_proxy_get_pixel_at;
+ iface->get_opacity_at = gimp_image_proxy_get_opacity_at;
+ iface->get_pixel_average = gimp_image_proxy_get_pixel_average;
+ iface->pixel_to_srgb = gimp_image_proxy_pixel_to_srgb;
+ iface->srgb_to_pixel = gimp_image_proxy_srgb_to_pixel;
}
static void
@@ -219,6 +267,12 @@ gimp_image_proxy_get_property (GObject *object,
gimp_image_proxy_get_show_all (image_proxy));
break;
+ case PROP_BUFFER:
+ g_value_set_object (value,
+ gimp_pickable_get_buffer (
+ GIMP_PICKABLE (image_proxy)));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -323,11 +377,7 @@ gimp_image_proxy_get_new_preview (GimpViewable *viewable,
gdouble scale_y;
gdouble scale;
- if (! image_proxy->priv->show_all)
- pickable = GIMP_PICKABLE (image);
- else
- pickable = GIMP_PICKABLE (gimp_image_get_projection (image));
-
+ pickable = gimp_image_proxy_get_pickable (image_proxy);
bounding_box = gimp_image_proxy_get_bounding_box (image_proxy);
scale_x = (gdouble) width / (gdouble) bounding_box.width;
@@ -368,11 +418,7 @@ gimp_image_proxy_get_new_pixbuf (GimpViewable *viewable,
gdouble scale;
GimpColorTransform *transform;
- if (! image_proxy->priv->show_all)
- pickable = GIMP_PICKABLE (image);
- else
- pickable = GIMP_PICKABLE (gimp_image_get_projection (image));
-
+ pickable = gimp_image_proxy_get_pickable (image_proxy);
bounding_box = gimp_image_proxy_get_bounding_box (image_proxy);
scale_x = (gdouble) width / (gdouble) bounding_box.width;
@@ -451,6 +497,120 @@ gimp_image_proxy_get_description (GimpViewable *viewable,
gimp_image_get_id (image));
}
+static void
+gimp_image_proxy_flush (GimpPickable *pickable)
+{
+ GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (pickable);
+ GimpPickable *proxy_pickable;
+
+ proxy_pickable = gimp_image_proxy_get_pickable (image_proxy);
+
+ gimp_pickable_flush (proxy_pickable);
+}
+
+static const Babl *
+gimp_image_proxy_get_format (GimpPickable *pickable)
+{
+ GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (pickable);
+ GimpPickable *proxy_pickable;
+
+ proxy_pickable = gimp_image_proxy_get_pickable (image_proxy);
+
+ return gimp_pickable_get_format (proxy_pickable);
+}
+
+static const Babl *
+gimp_image_proxy_get_format_with_alpha (GimpPickable *pickable)
+{
+ GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (pickable);
+ GimpPickable *proxy_pickable;
+
+ proxy_pickable = gimp_image_proxy_get_pickable (image_proxy);
+
+ return gimp_pickable_get_format_with_alpha (proxy_pickable);
+}
+
+static GeglBuffer *
+gimp_image_proxy_get_buffer (GimpPickable *pickable)
+{
+ GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (pickable);
+ GimpPickable *proxy_pickable;
+
+ proxy_pickable = gimp_image_proxy_get_pickable (image_proxy);
+
+ return gimp_pickable_get_buffer (proxy_pickable);
+}
+
+static gboolean
+gimp_image_proxy_get_pixel_at (GimpPickable *pickable,
+ gint x,
+ gint y,
+ const Babl *format,
+ gpointer pixel)
+{
+ GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (pickable);
+ GimpPickable *proxy_pickable;
+
+ proxy_pickable = gimp_image_proxy_get_pickable (image_proxy);
+
+ return gimp_pickable_get_pixel_at (proxy_pickable, x, y, format, pixel);
+}
+
+static gdouble
+gimp_image_proxy_get_opacity_at (GimpPickable *pickable,
+ gint x,
+ gint y)
+{
+ GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (pickable);
+ GimpPickable *proxy_pickable;
+
+ proxy_pickable = gimp_image_proxy_get_pickable (image_proxy);
+
+ return gimp_pickable_get_opacity_at (proxy_pickable, x, y);
+}
+
+static void
+gimp_image_proxy_get_pixel_average (GimpPickable *pickable,
+ const GeglRectangle *rect,
+ const Babl *format,
+ gpointer pixel)
+{
+ GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (pickable);
+ GimpPickable *proxy_pickable;
+
+ proxy_pickable = gimp_image_proxy_get_pickable (image_proxy);
+
+ gimp_pickable_get_pixel_average (proxy_pickable, rect, format, pixel);
+}
+
+static void
+gimp_image_proxy_pixel_to_srgb (GimpPickable *pickable,
+ const Babl *format,
+ gpointer pixel,
+ GimpRGB *color)
+{
+ GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (pickable);
+ GimpPickable *proxy_pickable;
+
+ proxy_pickable = gimp_image_proxy_get_pickable (image_proxy);
+
+ gimp_pickable_pixel_to_srgb (proxy_pickable, format, pixel, color);
+}
+
+static void
+gimp_image_proxy_srgb_to_pixel (GimpPickable *pickable,
+ const GimpRGB *color,
+ const Babl *format,
+ gpointer pixel)
+{
+ GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (pickable);
+ GimpPickable *proxy_pickable;
+
+ proxy_pickable = gimp_image_proxy_get_pickable (image_proxy);
+
+ gimp_pickable_srgb_to_pixel (proxy_pickable, color, format, pixel);
+}
+
static void
gimp_image_proxy_image_frozen_notify (GimpImage *image,
const GParamSpec *pspec,
@@ -538,6 +698,17 @@ gimp_image_proxy_set_image (GimpImageProxy *image_proxy,
}
}
+static GimpPickable *
+gimp_image_proxy_get_pickable (GimpImageProxy *image_proxy)
+{
+ GimpImage *image = image_proxy->priv->image;
+
+ if (! image_proxy->priv->show_all)
+ return GIMP_PICKABLE (image);
+ else
+ return GIMP_PICKABLE (gimp_image_get_projection (image));
+}
+
static void
gimp_image_proxy_update_bounding_box (GimpImageProxy *image_proxy)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]