[gimp] app: add _gimp_image_update_color_profile() to update the cached profile
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add _gimp_image_update_color_profile() to update the cached profile
- Date: Wed, 26 Aug 2015 17:18:52 +0000 (UTC)
commit 05add456bb67933c2f7e980ffe20e4525c495b39
Author: Michael Natterer <mitch gimp org>
Date: Wed Aug 26 19:16:17 2015 +0200
app: add _gimp_image_update_color_profile() to update the cached profile
and call it when an "icc-profile" parssite is attached or detached.
This removes code duplication and creates a place to conveniently
update more cached profiles and transforms, such as from/to sRGB for
color picking and applying.
app/core/gimpimage-color-profile.c | 26 ++++++++++++++++++++++++++
app/core/gimpimage-color-profile.h | 24 +++++++++++++++---------
app/core/gimpimage.c | 24 ++----------------------
app/core/gimpimageundo.c | 19 +------------------
4 files changed, 44 insertions(+), 49 deletions(-)
---
diff --git a/app/core/gimpimage-color-profile.c b/app/core/gimpimage-color-profile.c
index de6cb29..d9fc273 100644
--- a/app/core/gimpimage-color-profile.c
+++ b/app/core/gimpimage-color-profile.c
@@ -613,3 +613,29 @@ gimp_image_convert_profile_indexed (GimpImage *image,
g_free (cmap);
}
+
+
+/* internal API */
+
+void
+_gimp_image_update_color_profile (GimpImage *image,
+ const GimpParasite *icc_parasite)
+{
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ if (private->color_profile)
+ {
+ g_object_unref (private->color_profile);
+ private->color_profile = NULL;
+ }
+
+ if (icc_parasite)
+ {
+ private->color_profile =
+ gimp_color_profile_new_from_icc_profile (gimp_parasite_data (icc_parasite),
+ gimp_parasite_data_size (icc_parasite),
+ NULL);
+ }
+
+ gimp_color_managed_profile_changed (GIMP_COLOR_MANAGED (image));
+}
diff --git a/app/core/gimpimage-color-profile.h b/app/core/gimpimage-color-profile.h
index d525a42..1ee41c0 100644
--- a/app/core/gimpimage-color-profile.h
+++ b/app/core/gimpimage-color-profile.h
@@ -57,17 +57,23 @@ gboolean gimp_image_set_color_profile (GimpImage *ima
GimpColorProfile * gimp_image_get_builtin_color_profile
(GimpImage *image);
-gboolean gimp_image_convert_color_profile (GimpImage *image,
- GimpColorProfile *dest_profile,
+gboolean gimp_image_convert_color_profile (GimpImage *image,
+ GimpColorProfile *dest_profile,
GimpColorRenderingIntent intent,
- gboolean bpc,
- GimpProgress *progress,
- GError **error);
+ gboolean bpc,
+ GimpProgress *progress,
+ GError **error);
+
+void gimp_image_import_color_profile (GimpImage *image,
+ GimpContext *context,
+ GimpProgress *progress,
+ gboolean interactive);
+
-void gimp_image_import_color_profile (GimpImage *image,
- GimpContext *context,
- GimpProgress *progress,
- gboolean interactive);
+/* internal API, to be called only from the icc-profile parasite setters */
+
+void _gimp_image_update_color_profile (GimpImage *image,
+ const GimpParasite *icc_parasite);
#endif /* __GIMP_IMAGE_COLOR_PROFILE_H__ */
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 3287e46..921bd64 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -3367,19 +3367,7 @@ gimp_image_parasite_attach (GimpImage *image,
gimp_parasite_name (parasite));
if (strcmp (gimp_parasite_name (parasite), GIMP_ICC_PROFILE_PARASITE_NAME) == 0)
- {
- GimpColorProfile *profile =
- gimp_color_profile_new_from_icc_profile (gimp_parasite_data (parasite),
- gimp_parasite_data_size (parasite),
- NULL);
-
- if (private->color_profile)
- g_object_unref (private->color_profile);
-
- private->color_profile = profile;
-
- gimp_color_managed_profile_changed (GIMP_COLOR_MANAGED (image));
- }
+ _gimp_image_update_color_profile (image, parasite);
}
void
@@ -3408,15 +3396,7 @@ gimp_image_parasite_detach (GimpImage *image,
name);
if (strcmp (name, GIMP_ICC_PROFILE_PARASITE_NAME) == 0)
- {
- if (private->color_profile)
- {
- g_object_unref (private->color_profile);
- private->color_profile = NULL;
- }
-
- gimp_color_managed_profile_changed (GIMP_COLOR_MANAGED (image));
- }
+ _gimp_image_update_color_profile (image, NULL);
}
diff --git a/app/core/gimpimageundo.c b/app/core/gimpimageundo.c
index 2806990..8aeb1b0 100644
--- a/app/core/gimpimageundo.c
+++ b/app/core/gimpimageundo.c
@@ -24,7 +24,6 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpbase/gimpbase.h"
-#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
@@ -489,23 +488,7 @@ gimp_image_undo_pop (GimpUndo *undo,
name = parasite ? parasite->name : image_undo->parasite_name;
if (strcmp (name, GIMP_ICC_PROFILE_PARASITE_NAME) == 0)
- {
- if (private->color_profile)
- {
- g_object_unref (private->color_profile);
- private->color_profile = NULL;
- }
-
- if (parasite)
- {
- private->color_profile =
- gimp_color_profile_new_from_icc_profile (gimp_parasite_data (parasite),
- gimp_parasite_data_size (parasite),
- NULL);
- }
-
- gimp_color_managed_profile_changed (GIMP_COLOR_MANAGED (image));
- }
+ _gimp_image_update_color_profile (image, parasite);
if (parasite)
gimp_parasite_free (parasite);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]