[gnome-color-manager] Remove GcmClut, it's now not required



commit cc22cb5fe0e278030887d0ff70f990e32e4dd0d0
Author: Richard Hughes <richard hughsie com>
Date:   Tue Apr 30 15:05:07 2013 +0100

    Remove GcmClut, it's now not required

 src/Makefile.am      |    2 -
 src/gcm-clut.c       |  251 --------------------------------------------------
 src/gcm-clut.h       |   69 --------------
 src/gcm-self-test.c  |   49 +---------
 src/gcm-trc-widget.c |   70 +++++++--------
 src/gcm-utils.c      |   33 +++----
 src/gcm-utils.h      |    3 +-
 src/gcm-viewer.c     |   53 ++---------
 8 files changed, 63 insertions(+), 467 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index a960060..a9cefa1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,8 +30,6 @@ libgcmshared_a_SOURCES =                              \
        gcm-hull.h                                      \
        gcm-cie-widget.c                                \
        gcm-cie-widget.h                                \
-       gcm-clut.c                                      \
-       gcm-clut.h                                      \
        gcm-debug.c                                     \
        gcm-debug.h                                     \
        gcm-exif.c                                      \
diff --git a/src/gcm-self-test.c b/src/gcm-self-test.c
index 51740bd..7e5a9fc 100644
--- a/src/gcm-self-test.c
+++ b/src/gcm-self-test.c
@@ -29,7 +29,6 @@
 #include "gcm-brightness.h"
 #include "gcm-calibrate.h"
 #include "gcm-cie-widget.h"
-#include "gcm-clut.h"
 #include "gcm-debug.h"
 #include "gcm-exif.h"
 #include "gcm-gamma-widget.h"
@@ -103,7 +102,6 @@ gcm_test_profile_func (void)
 {
        CdIcc *profile;
        GFile *file;
-       GcmClut *clut;
        gboolean ret;
        GError *error = NULL;
        GcmHull *hull;
@@ -139,44 +137,6 @@ gcm_test_profile_func (void)
 }
 
 static void
-gcm_test_clut_func (void)
-{
-       GcmClut *clut;
-       GPtrArray *array;
-       const GcmClutData *data;
-
-       clut = gcm_clut_new ();
-       g_assert (clut != NULL);
-
-       /* set some initial properties */
-       g_object_set (clut,
-                     "size", 3,
-                     NULL);
-
-       array = gcm_clut_get_array (clut);
-       g_assert_cmpint (array->len, ==, 3);
-
-       data = g_ptr_array_index (array, 0);
-       g_assert_cmpint (data->red, ==, 0);
-       g_assert_cmpint (data->green, ==, 0);
-       g_assert_cmpint (data->blue, ==, 0);
-
-       data = g_ptr_array_index (array, 1);
-       g_assert_cmpint (data->red, ==, 32767);
-       g_assert_cmpint (data->green, ==, 32767);
-       g_assert_cmpint (data->blue, ==, 32767);
-
-       data = g_ptr_array_index (array, 2);
-       g_assert_cmpint (data->red, ==, 65535);
-       g_assert_cmpint (data->green, ==, 65535);
-       g_assert_cmpint (data->blue, ==, 65535);
-
-       g_ptr_array_unref (array);
-
-       g_object_unref (clut);
-}
-
-static void
 gcm_test_brightness_func (void)
 {
        GcmBrightness *brightness;
@@ -496,7 +456,7 @@ gcm_test_trc_widget_func (void)
        GtkWidget *image;
        GtkWidget *dialog;
        GtkWidget *vbox;
-       GcmClut *clut;
+       GPtrArray *clut;
        CdIcc *profile;
        gint response;
        GFile *file;
@@ -507,6 +467,10 @@ gcm_test_trc_widget_func (void)
        profile = cd_icc_new ();
        file = g_file_new_for_path (TESTDATADIR "/AdobeGammaTest.icm");
        cd_icc_load_file (profile, file, CD_ICC_LOAD_FLAGS_NONE, NULL, NULL);
+       clut = cd_icc_get_vcgt (profile, 256, NULL);
+       g_object_set (widget,
+                     "data", clut,
+                     NULL);
        g_object_unref (file);
 
        /* show in a dialog as an example */
@@ -526,7 +490,7 @@ gcm_test_trc_widget_func (void)
 
        gtk_widget_destroy (dialog);
 
-       g_object_unref (clut);
+       g_ptr_array_unref (clut);
        g_object_unref (profile);
 }
 
@@ -590,7 +554,6 @@ main (int argc, char **argv)
        g_test_add_func ("/color/utils", gcm_test_utils_func);
        g_test_add_func ("/color/hull", gcm_test_hull_func);
        g_test_add_func ("/color/profile", gcm_test_profile_func);
-       g_test_add_func ("/color/clut", gcm_test_clut_func);
        if (g_test_thorough ()) {
                g_test_add_func ("/color/brightness", gcm_test_brightness_func);
                g_test_add_func ("/color/image", gcm_test_image_func);
diff --git a/src/gcm-trc-widget.c b/src/gcm-trc-widget.c
index df74e14..f521b4e 100644
--- a/src/gcm-trc-widget.c
+++ b/src/gcm-trc-widget.c
@@ -24,8 +24,8 @@
 #include <glib/gi18n.h>
 #include <stdlib.h>
 #include <math.h>
+#include <colord.h>
 
-#include "gcm-clut.h"
 #include "gcm-trc-widget.h"
 
 G_DEFINE_TYPE (GcmTrcWidget, gcm_trc_widget, GTK_TYPE_DRAWING_AREA);
@@ -35,7 +35,7 @@ G_DEFINE_TYPE (GcmTrcWidget, gcm_trc_widget, GTK_TYPE_DRAWING_AREA);
 struct GcmTrcWidgetPrivate
 {
        gboolean                 use_grid;
-       GcmClut                 *clut;
+       GPtrArray               *data;
        guint                    chart_width;
        guint                    chart_height;
        PangoLayout             *layout;
@@ -50,15 +50,15 @@ enum
 {
        PROP_0,
        PROP_USE_GRID,
-       PROP_CLUT,
+       PROP_DATA,
        PROP_LAST
 };
 
 /**
- * dkp_trc_get_property:
+ * gcm_trc_widget_get_property:
  **/
 static void
-dkp_trc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gcm_trc_widget_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
 {
        GcmTrcWidget *trc = GCM_TRC_WIDGET (object);
        switch (prop_id) {
@@ -72,10 +72,10 @@ dkp_trc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec
 }
 
 /**
- * dkp_trc_set_property:
+ * gcm_trc_widget_set_property:
  **/
 static void
-dkp_trc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gcm_trc_widget_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 {
        GcmTrcWidget *trc = GCM_TRC_WIDGET (object);
 
@@ -83,10 +83,10 @@ dkp_trc_set_property (GObject *object, guint prop_id, const GValue *value, GPara
        case PROP_USE_GRID:
                trc->priv->use_grid = g_value_get_boolean (value);
                break;
-       case PROP_CLUT:
-               if (trc->priv->clut != NULL)
-                       g_object_unref (trc->priv->clut);
-               trc->priv->clut = g_value_dup_object (value);
+       case PROP_DATA:
+               if (trc->priv->data != NULL)
+                       g_ptr_array_unref (trc->priv->data);
+               trc->priv->data = g_ptr_array_ref (g_value_get_boxed (value));
                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -108,8 +108,8 @@ gcm_trc_widget_class_init (GcmTrcWidgetClass *class)
        GObjectClass *object_class = G_OBJECT_CLASS (class);
 
        widget_class->draw = gcm_trc_widget_draw;
-       object_class->get_property = dkp_trc_get_property;
-       object_class->set_property = dkp_trc_set_property;
+       object_class->get_property = gcm_trc_widget_get_property;
+       object_class->set_property = gcm_trc_widget_set_property;
        object_class->finalize = gcm_trc_widget_finalize;
 
        g_type_class_add_private (class, sizeof (GcmTrcWidgetPrivate));
@@ -121,10 +121,10 @@ gcm_trc_widget_class_init (GcmTrcWidgetClass *class)
                                                               TRUE,
                                                               G_PARAM_READWRITE));
        g_object_class_install_property (object_class,
-                                        PROP_CLUT,
-                                        g_param_spec_object ("clut", NULL, NULL,
-                                                             GCM_TYPE_CLUT,
-                                                             G_PARAM_WRITABLE));
+                                        PROP_DATA,
+                                        g_param_spec_boxed ("data", NULL, NULL,
+                                                            G_TYPE_PTR_ARRAY,
+                                                            G_PARAM_WRITABLE));
 }
 
 /**
@@ -138,7 +138,7 @@ gcm_trc_widget_init (GcmTrcWidget *trc)
 
        trc->priv = GCM_TRC_WIDGET_GET_PRIVATE (trc);
        trc->priv->use_grid = TRUE;
-       trc->priv->clut = NULL;
+       trc->priv->data = NULL;
 
        /* do pango stuff */
        context = gtk_widget_get_pango_context (GTK_WIDGET (trc));
@@ -159,8 +159,8 @@ gcm_trc_widget_finalize (GObject *object)
        GcmTrcWidget *trc = (GcmTrcWidget*) object;
 
        g_object_unref (trc->priv->layout);
-       if (trc->priv->clut != NULL)
-               g_object_unref (trc->priv->clut);
+       if (trc->priv->data != NULL)
+               g_object_unref (trc->priv->data);
        G_OBJECT_CLASS (gcm_trc_widget_parent_class)->finalize (object);
 }
 
@@ -222,32 +222,28 @@ gcm_trc_widget_draw_line (GcmTrcWidget *trc, cairo_t *cr)
 {
        gdouble wx, wy;
        GcmTrcWidgetPrivate *priv = trc->priv;
-       GPtrArray *array;
-       GcmClutData *tmp;
+       CdColorRGB *tmp;
        gfloat i;
        gfloat value;
        gfloat size;
        gfloat linewidth;
 
        /* nothing set yet */
-       if (priv->clut == NULL)
+       if (priv->data == NULL)
                return;
 
        /* set according to widget width */
        linewidth = priv->chart_width / 250.0f;
-
-       /* get data */
-       array = gcm_clut_get_array (priv->clut);
-       size = array->len;
+       size = priv->data->len;
 
        cairo_save (cr);
 
        /* do red */
        cairo_set_line_width (cr, linewidth + 1.0f);
        cairo_set_source_rgb (cr, 0.5f, 0.0f, 0.0f);
-       for (i=0; i<size; i++) {
-               tmp = g_ptr_array_index (array, (guint) i);
-               value = tmp->red/65536.0f;
+       for (i = 0; i < size; i++) {
+               tmp = g_ptr_array_index (priv->data, (guint) i);
+               value = tmp->R;
                gcm_trc_widget_map_to_display (trc, i/(size-1), value, &wx, &wy);
                if (i == 0)
                        cairo_move_to (cr, wx, wy+1);
@@ -262,9 +258,9 @@ gcm_trc_widget_draw_line (GcmTrcWidget *trc, cairo_t *cr)
        /* do green */
        cairo_set_line_width (cr, linewidth + 1.0f);
        cairo_set_source_rgb (cr, 0.0f, 0.5f, 0.0f);
-       for (i=0; i<size; i++) {
-               tmp = g_ptr_array_index (array, (guint) i);
-               value = tmp->green/65536.0f;
+       for (i = 0; i < size; i++) {
+               tmp = g_ptr_array_index (priv->data, (guint) i);
+               value = tmp->G;
                gcm_trc_widget_map_to_display (trc, i/(size-1), value, &wx, &wy);
                if (i == 0)
                        cairo_move_to (cr, wx, wy-1);
@@ -279,9 +275,9 @@ gcm_trc_widget_draw_line (GcmTrcWidget *trc, cairo_t *cr)
        /* do blue */
        cairo_set_line_width (cr, linewidth + 1.0f);
        cairo_set_source_rgb (cr, 0.0f, 0.0f, 0.5f);
-       for (i=0; i<size; i++) {
-               tmp = g_ptr_array_index (array, (guint) i);
-               value = tmp->blue/65536.0f;
+       for (i = 0; i < size; i++) {
+               tmp = g_ptr_array_index (priv->data, (guint) i);
+               value = tmp->B;
                gcm_trc_widget_map_to_display (trc, i/(size-1), value, &wx, &wy);
                if (i == 0)
                        cairo_move_to (cr, wx, wy);
@@ -293,8 +289,6 @@ gcm_trc_widget_draw_line (GcmTrcWidget *trc, cairo_t *cr)
        cairo_set_source_rgb (cr, 0.0f, 0.0f, 1.0f);
        cairo_stroke (cr);
 
-       g_ptr_array_unref (array);
-
        cairo_restore (cr);
 }
 
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index 07933a7..dfbe98f 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -376,16 +376,15 @@ cd_icc_has_colorspace_description (CdProfile *profile)
  *
  * Generates a curve of a specified size.
  *
- * Return value: A #GcmClut object, or %NULL. Free with g_object_unref()
+ * Return value: A #GPtrArray object, or %NULL. Free with g_object_unref()
  **/
-GcmClut *
+GPtrArray *
 cd_icc_generate_curve (CdIcc *icc, guint size)
 {
-       GcmClut *clut = NULL;
        gdouble *values_in = NULL;
        gdouble *values_out = NULL;
        guint i;
-       GcmClutData *data;
+       CdColorRGB *data;
        GPtrArray *array = NULL;
        gfloat divamount;
        gfloat divadd;
@@ -447,39 +446,35 @@ cd_icc_generate_curve (CdIcc *icc, guint size)
                array = g_ptr_array_new_with_free_func (g_free);
 
                for (i = 0; i < size; i++) {
-                       data = g_new0 (GcmClutData, 1);
+                       data = g_new0 (CdColorRGB, 1);
 
                        /* default values */
-                       data->red = 0;
-                       data->green = 0;
-                       data->blue = 0;
+                       data->R = 0.0f;
+                       data->G = 0.0f;
+                       data->B = 0.0f;
 
                        /* only save curve data if it is positive */
-                       tmp = values_out[(i * 3 * component_width)+0] * (gfloat) 0xffff;
+                       tmp = values_out[(i * 3 * component_width)+0];
                        if (tmp > 0.0f)
-                               data->red = tmp;
-                       tmp = values_out[(i * 3 * component_width)+4] * (gfloat) 0xffff;
+                               data->R = tmp;
+                       tmp = values_out[(i * 3 * component_width)+4];
                        if (tmp > 0.0f)
-                               data->green = tmp;
-                       tmp = values_out[(i * 3 * component_width)+8] * (gfloat) 0xffff;
+                               data->G = tmp;
+                       tmp = values_out[(i * 3 * component_width)+8];
                        if (tmp > 0.0f)
-                               data->blue = tmp;
+                               data->B = tmp;
                        g_ptr_array_add (array, data);
                }
-               clut = gcm_clut_new ();
-               gcm_clut_set_source_array (clut, array);
        }
 
 out:
        g_free (values_in);
        g_free (values_out);
-       if (array != NULL)
-               g_ptr_array_unref (array);
        if (transform != NULL)
                cmsDeleteTransform (transform);
        if (srgb_profile != NULL)
                cmsCloseProfile (srgb_profile);
-       return clut;
+       return array;
 }
 
 #define HYP(a,b)               (sqrt((a)*(a) + (b)*(b)))
diff --git a/src/gcm-utils.h b/src/gcm-utils.h
index d0e6a84..4f67491 100644
--- a/src/gcm-utils.h
+++ b/src/gcm-utils.h
@@ -25,7 +25,6 @@
 #include <glib-object.h>
 #include <gtk/gtk.h>
 
-#include "gcm-clut.h"
 #include "gcm-hull.h"
 
 #define GCM_STOCK_ICON                                 "gnome-color-manager"
@@ -51,7 +50,7 @@ gboolean       gcm_utils_install_package              (const gchar            *package_name,
 gchar          *gcm_utils_linkify                      (const gchar            *text);
 const gchar    *cd_colorspace_to_localised_string      (CdColorspace            colorspace);
 gboolean        cd_icc_has_colorspace_description      (CdProfile              *profile);
-GcmClut                *cd_icc_generate_curve                  (CdIcc                  *icc,
+GPtrArray      *cd_icc_generate_curve                  (CdIcc                  *icc,
                                                         guint                   size);
 GcmHull                *cd_icc_generate_gamut_hull             (CdIcc                  *icc,
                                                         guint                   res);
diff --git a/src/gcm-viewer.c b/src/gcm-viewer.c
index da27a0f..e7af7b1 100644
--- a/src/gcm-viewer.c
+++ b/src/gcm-viewer.c
@@ -40,7 +40,6 @@
 #include "gcm-image.h"
 #include "gcm-trc-widget.h"
 #include "gcm-utils.h"
-#include "gcm-clut.h"
 #include "gcm-debug.h"
 
 #ifdef HAVE_CLUTTER
@@ -975,28 +974,6 @@ cd_icc_warning_to_string (CdProfileWarning kind_enum)
 }
 
 /**
- * cd_icc_generate_vcgt:
- **/
-static GcmClut *
-cd_icc_generate_vcgt (CdIcc *icc, guint size)
-{
-       GcmClut *clut = NULL;
-       GPtrArray *array = NULL;
-
-       array = cd_icc_get_vcgt (icc, size, NULL);
-       if (array == NULL) {
-               g_debug ("icc does not have any VCGT data");
-               goto out;
-       }
-       clut = gcm_clut_new ();
-       gcm_clut_set_source_array (clut, array);
-out:
-       if (array != NULL)
-               g_ptr_array_unref (array);
-       return clut;
-}
-
-/**
  * gcm_viewer_set_profile:
  **/
 static void
@@ -1005,8 +982,8 @@ gcm_viewer_set_profile (GcmViewerPrivate *viewer, CdProfile *profile)
        GtkWidget *widget;
        GtkWindow *window;
        CdIcc *icc = NULL;
-       GcmClut *clut_trc = NULL;
-       GcmClut *clut_vcgt = NULL;
+       GPtrArray *clut_trc = NULL;
+       GPtrArray *clut_vcgt = NULL;
        const gchar *profile_copyright;
        const gchar *profile_manufacturer;
        const gchar *profile_model ;
@@ -1075,16 +1052,11 @@ gcm_viewer_set_profile (GcmViewerPrivate *viewer, CdProfile *profile)
        }
 
        /* get curve data */
-       clut_trc = cd_icc_generate_curve (icc, 256);
-
-       /* only show if there is useful information */
-       size = 0;
-       if (clut_trc != NULL)
-               size = gcm_clut_get_size (clut_trc);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "vbox_trc"));
-       if (size > 0) {
+       clut_trc = cd_icc_generate_curve (icc, 256);
+       if (clut_trc != NULL) {
                g_object_set (viewer->trc_widget,
-                             "clut", clut_trc,
+                             "data", clut_trc,
                              NULL);
                gtk_widget_show (widget);
        } else {
@@ -1101,16 +1073,11 @@ gcm_viewer_set_profile (GcmViewerPrivate *viewer, CdProfile *profile)
 #endif
 
        /* get vcgt data */
-       clut_vcgt = cd_icc_generate_vcgt (icc, 256);
-
-       /* only show if there is useful information */
-       size = 0;
-       if (clut_vcgt != NULL)
-               size = gcm_clut_get_size (clut_vcgt);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "vbox_vcgt"));
-       if (size > 0) {
+       clut_vcgt = cd_icc_get_vcgt (icc, 256, NULL);
+       if (clut_vcgt != NULL) {
                g_object_set (viewer->vcgt_widget,
-                             "clut", clut_vcgt,
+                             "data", clut_vcgt,
                              NULL);
                gtk_widget_show (widget);
        } else {
@@ -1305,9 +1272,9 @@ out:
        if (icc != NULL)
                g_object_unref (icc);
        if (clut_trc != NULL)
-               g_object_unref (clut_trc);
+               g_ptr_array_unref (clut_trc);
        if (clut_vcgt != NULL)
-               g_object_unref (clut_vcgt);
+               g_ptr_array_unref (clut_vcgt);
        g_free (size_text);
 }
 


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