[gimp/gimp-2-10] app: implement GimpColorManaged for GimpImageProxy



commit efb97fa7bdeeb3574443d1b442cf2071e6b925e1
Author: Ell <ell_se yahoo com>
Date:   Fri May 22 16:28:02 2020 +0300

    app: implement GimpColorManaged for GimpImageProxy
    
    In GimpImageProxy, implement GimpColorManaged by forwarding the
    functions to the underlying GimpImage, and forwarding the signals
    in the other direction.  This fixes color-managed view in the
    Navigation dockable.
    
    (cherry picked from commit 258c8454d5666fdb3a7f3a8958ccf46d5c42459c)

 app/core/gimpimageproxy.c | 221 +++++++++++++++++++++++++++++-----------------
 1 file changed, 140 insertions(+), 81 deletions(-)
---
diff --git a/app/core/gimpimageproxy.c b/app/core/gimpimageproxy.c
index 0e36b27510..6007d6cd5f 100644
--- a/app/core/gimpimageproxy.c
+++ b/app/core/gimpimageproxy.c
@@ -61,92 +61,102 @@ struct _GimpImageProxyPrivate
 
 /*  local function prototypes  */
 
-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);
+static void               gimp_image_proxy_pickable_iface_init      (GimpPickableInterface      *iface);
+static void               gimp_image_proxy_color_managed_iface_init (GimpColorManagedInterface  *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 const guint8     * gimp_image_proxy_get_icc_profile          (GimpColorManaged           *managed,
+                                                                     gsize                      *len);
+static GimpColorProfile * gimp_image_proxy_get_color_profile        (GimpColorManaged           *managed);
+static void               gimp_image_proxy_profile_changed          (GimpColorManaged           *managed);
+
+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_image_profile_changed    (GimpImage                  *image,
+                                                                     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))
+                                                gimp_image_proxy_pickable_iface_init)
+                         G_IMPLEMENT_INTERFACE (GIMP_TYPE_COLOR_MANAGED,
+                                                gimp_image_proxy_color_managed_iface_init))
 
 #define parent_class gimp_image_proxy_parent_class
 
@@ -204,6 +214,14 @@ gimp_image_proxy_pickable_iface_init (GimpPickableInterface *iface)
   iface->srgb_to_pixel         = gimp_image_proxy_srgb_to_pixel;
 }
 
+static void
+gimp_image_proxy_color_managed_iface_init (GimpColorManagedInterface *iface)
+{
+  iface->get_icc_profile   = gimp_image_proxy_get_icc_profile;
+  iface->get_color_profile = gimp_image_proxy_get_color_profile;
+  iface->profile_changed   = gimp_image_proxy_profile_changed;
+}
+
 static void
 gimp_image_proxy_init (GimpImageProxy *image_proxy)
 {
@@ -610,6 +628,32 @@ gimp_image_proxy_srgb_to_pixel (GimpPickable  *pickable,
   gimp_pickable_srgb_to_pixel (proxy_pickable, color, format, pixel);
 }
 
+static const guint8 *
+gimp_image_proxy_get_icc_profile (GimpColorManaged *managed,
+                                  gsize            *len)
+{
+  GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (managed);
+
+  return gimp_color_managed_get_icc_profile (
+    GIMP_COLOR_MANAGED (image_proxy->priv->image),
+    len);
+}
+
+static GimpColorProfile *
+gimp_image_proxy_get_color_profile (GimpColorManaged *managed)
+{
+  GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (managed);
+
+  return gimp_color_managed_get_color_profile (
+    GIMP_COLOR_MANAGED (image_proxy->priv->image));
+}
+
+static void
+gimp_image_proxy_profile_changed (GimpColorManaged *managed)
+{
+  gimp_viewable_invalidate_preview (GIMP_VIEWABLE (managed));
+}
+
 static void
 gimp_image_proxy_image_frozen_notify (GimpImage        *image,
                                       const GParamSpec *pspec,
@@ -641,6 +685,13 @@ gimp_image_proxy_image_bounds_changed (GimpImage      *image,
   gimp_image_proxy_update_bounding_box (image_proxy);
 }
 
+static void
+gimp_image_proxy_image_profile_changed (GimpImage      *image,
+                                        GimpImageProxy *image_proxy)
+{
+  gimp_color_managed_profile_changed (GIMP_COLOR_MANAGED (image_proxy));
+}
+
 static void
 gimp_image_proxy_set_image (GimpImageProxy *image_proxy,
                             GimpImage      *image)
@@ -663,6 +714,10 @@ gimp_image_proxy_set_image (GimpImageProxy *image_proxy,
         image_proxy->priv->image,
         gimp_image_proxy_image_bounds_changed,
         image_proxy);
+      g_signal_handlers_disconnect_by_func (
+        image_proxy->priv->image,
+        gimp_image_proxy_image_profile_changed,
+        image_proxy);
 
       g_object_unref (image_proxy->priv->image);
     }
@@ -689,6 +744,10 @@ gimp_image_proxy_set_image (GimpImageProxy *image_proxy,
         image_proxy->priv->image, "bounds-changed",
         G_CALLBACK (gimp_image_proxy_image_bounds_changed),
         image_proxy);
+      g_signal_connect (
+        image_proxy->priv->image, "profile-changed",
+        G_CALLBACK (gimp_image_proxy_image_profile_changed),
+        image_proxy);
 
       gimp_image_proxy_update_bounding_box (image_proxy);
       gimp_image_proxy_update_frozen (image_proxy);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]