gimp r26173 - in branches/soc-2008-tagging: . app/core
- From: aurisj svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26173 - in branches/soc-2008-tagging: . app/core
- Date: Sun, 13 Jul 2008 10:50:19 +0000 (UTC)
Author: aurisj
Date: Sun Jul 13 10:50:19 2008
New Revision: 26173
URL: http://svn.gnome.org/viewvc/gimp?rev=26173&view=rev
Log:
2008-07-13 Aurimas JuÅka <aurisj svn gnome org>
* app/core/gimp.c: cache pattern, gradient and palette tags in addition
to brush tags.
* app/core/gimpbrush.c (gimp_brush_get_checksum)
* app/core/gimpgradient.c (gimp_gradient_tagged_init),
(gimp_gradient_get_checksum)
* app/core/gimppalette.c (gimp_palette_tagged_init),
(gimp_palette_get_checksum)
* app/core/gimppattern.c (gimp_pattern_tagged_init),
(gimp_pattern_get_checksum): implemented get_checksum method for all
tagged objects.
Modified:
branches/soc-2008-tagging/ChangeLog
branches/soc-2008-tagging/app/core/gimp.c
branches/soc-2008-tagging/app/core/gimpbrush.c
branches/soc-2008-tagging/app/core/gimpgradient.c
branches/soc-2008-tagging/app/core/gimppalette.c
branches/soc-2008-tagging/app/core/gimppattern.c
Modified: branches/soc-2008-tagging/app/core/gimp.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimp.c (original)
+++ branches/soc-2008-tagging/app/core/gimp.c Sun Jul 13 10:50:19 2008
@@ -872,15 +872,12 @@
gimp_tag_cache_load (gimp->tag_cache);
gimp_tag_cache_add_container (gimp->tag_cache,
gimp->brush_factory->container);
- /*
- gimp_container_foreach (gimp->brush_factory->container,
- gimp_tag_cache_update, gimp->tag_cache);
- gimp_container_foreach (gimp->pattern_factory->container,
- gimp_tag_cache_update, gimp->tag_cache);
- gimp_container_foreach (gimp->palette_factory->container,
- gimp_tag_cache_update, gimp->tag_cache);
- gimp_container_foreach (gimp->gradient_factory->container,
- gimp_tag_cache_update, gimp->tag_cache);*/
+ gimp_tag_cache_add_container (gimp->tag_cache,
+ gimp->pattern_factory->container);
+ gimp_tag_cache_add_container (gimp->tag_cache,
+ gimp->gradient_factory->container);
+ gimp_tag_cache_add_container (gimp->tag_cache,
+ gimp->palette_factory->container);
g_signal_emit (gimp, gimp_signals[RESTORE], 0, status_callback);
}
Modified: branches/soc-2008-tagging/app/core/gimpbrush.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimpbrush.c (original)
+++ branches/soc-2008-tagging/app/core/gimpbrush.c Sun Jul 13 10:50:19 2008
@@ -530,13 +530,18 @@
}
static gchar *
-gimp_brush_get_checksum(GimpTagged *tagged)
+gimp_brush_get_checksum (GimpTagged *tagged)
{
GimpBrush *brush = GIMP_BRUSH (tagged);
TempBuf *buffer;
GChecksum *checksum;
gchar *checksum_string;
+ if (! brush->mask)
+ {
+ return NULL;
+ }
+
checksum = g_checksum_new (G_CHECKSUM_MD5);
buffer = brush->pixmap;
@@ -546,11 +551,8 @@
buffer->width * buffer->height * buffer->bytes);
}
buffer = brush->mask;
- if (buffer)
- {
- g_checksum_update (checksum, temp_buf_data (buffer),
- buffer->width * buffer->height * buffer->bytes);
- }
+ g_checksum_update (checksum, temp_buf_data (buffer),
+ buffer->width * buffer->height * buffer->bytes);
checksum_string = g_strdup (g_checksum_get_string (checksum));
Modified: branches/soc-2008-tagging/app/core/gimpgradient.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimpgradient.c (original)
+++ branches/soc-2008-tagging/app/core/gimpgradient.c Sun Jul 13 10:50:19 2008
@@ -33,11 +33,13 @@
#include "gimpgradient.h"
#include "gimpgradient-load.h"
#include "gimpgradient-save.h"
+#include "gimptagged.h"
#define EPSILON 1e-10
+static void gimp_gradient_tagged_init (GimpTaggedInterface *iface);
static void gimp_gradient_finalize (GObject *object);
static gint64 gimp_gradient_get_memsize (GimpObject *object,
@@ -79,8 +81,12 @@
static inline gdouble gimp_gradient_calc_sphere_decreasing_factor (gdouble middle,
gdouble pos);
+static gchar * gimp_gradient_get_checksum (GimpTagged *tagged);
-G_DEFINE_TYPE (GimpGradient, gimp_gradient, GIMP_TYPE_DATA)
+
+G_DEFINE_TYPE_WITH_CODE (GimpGradient, gimp_gradient, GIMP_TYPE_DATA,
+ G_IMPLEMENT_INTERFACE (GIMP_TYPE_TAGGED,
+ gimp_gradient_tagged_init))
#define parent_class gimp_gradient_parent_class
@@ -114,6 +120,12 @@
}
static void
+gimp_gradient_tagged_init (GimpTaggedInterface *iface)
+{
+ iface->get_checksum = gimp_gradient_get_checksum;
+}
+
+static void
gimp_gradient_finalize (GObject *object)
{
GimpGradient *gradient = GIMP_GRADIENT (object);
@@ -1995,3 +2007,51 @@
/* Works for convex decreasing and concave increasing */
return 1.0 - sqrt(1.0 - pos * pos);
}
+
+static gchar *
+gimp_gradient_get_checksum (GimpTagged *tagged)
+{
+ GimpGradient *gradient = GIMP_GRADIENT (tagged);
+ GChecksum *checksum;
+ gchar *checksum_string;
+ GimpGradientSegment *segment;
+
+ if (! gradient->segments)
+ {
+ return NULL;
+ }
+
+ checksum = g_checksum_new (G_CHECKSUM_MD5);
+ segment = gradient->segments;
+ while (segment)
+ {
+ g_checksum_update (checksum, (const guchar *) &segment->left,
+ sizeof (segment->left));
+ g_checksum_update (checksum, (const guchar *) &segment->middle,
+ sizeof (segment->middle));
+ g_checksum_update (checksum, (const guchar *) &segment->right,
+ sizeof (segment->right));
+
+ g_checksum_update (checksum, (const guchar *) &segment->left_color_type,
+ sizeof (segment->left_color_type));
+ g_checksum_update (checksum, (const guchar *) &segment->left_color,
+ sizeof (segment->left_color));
+ g_checksum_update (checksum, (const guchar *) &segment->right_color_type,
+ sizeof (segment->right_color_type));
+ g_checksum_update (checksum, (const guchar *) &segment->right_color,
+ sizeof (segment->right_color));
+
+ g_checksum_update (checksum, (const guchar *) &segment->type,
+ sizeof (segment->type));
+ g_checksum_update (checksum, (const guchar *) &segment->color,
+ sizeof (segment->color));
+
+ segment = segment->next;
+ }
+
+ checksum_string = g_strdup (g_checksum_get_string (checksum));
+ g_checksum_free (checksum);
+
+ return checksum_string;
+}
+
Modified: branches/soc-2008-tagging/app/core/gimppalette.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimppalette.c (original)
+++ branches/soc-2008-tagging/app/core/gimppalette.c Sun Jul 13 10:50:19 2008
@@ -33,6 +33,7 @@
#include "gimppalette.h"
#include "gimppalette-load.h"
#include "gimppalette-save.h"
+#include "gimptagged.h"
#include "gimp-intl.h"
@@ -40,6 +41,7 @@
/* local function prototypes */
+static void gimp_palette_tagged_init (GimpTaggedInterface *iface);
static void gimp_palette_finalize (GObject *object);
static gint64 gimp_palette_get_memsize (GimpObject *object,
@@ -69,9 +71,12 @@
static void gimp_palette_entry_free (GimpPaletteEntry *entry);
static gint64 gimp_palette_entry_get_memsize(GimpPaletteEntry *entry,
gint64 *gui_size);
+static gchar * gimp_palette_get_checksum (GimpTagged *tagged);
-G_DEFINE_TYPE (GimpPalette, gimp_palette, GIMP_TYPE_DATA)
+G_DEFINE_TYPE_WITH_CODE (GimpPalette, gimp_palette, GIMP_TYPE_DATA,
+ G_IMPLEMENT_INTERFACE (GIMP_TYPE_TAGGED,
+ gimp_palette_tagged_init))
#define parent_class gimp_palette_parent_class
@@ -108,6 +113,12 @@
}
static void
+gimp_palette_tagged_init (GimpTaggedInterface *iface)
+{
+ iface->get_checksum = gimp_palette_get_checksum;
+}
+
+static void
gimp_palette_finalize (GObject *object)
{
GimpPalette *palette = GIMP_PALETTE (object);
@@ -507,3 +518,34 @@
return memsize;
}
+
+static gchar *
+gimp_palette_get_checksum (GimpTagged *tagged)
+{
+ GimpPalette *palette = GIMP_PALETTE (tagged);
+ GChecksum *checksum;
+ gchar *checksum_string;
+ GimpPaletteEntry *entry;
+ GList *color_iterator;
+
+ if (palette->n_colors < 1)
+ {
+ return NULL;
+ }
+
+ checksum = g_checksum_new (G_CHECKSUM_MD5);
+ g_checksum_update (checksum, (const guchar *) &palette->n_colors,
+ sizeof (palette->n_colors));
+ color_iterator = palette->colors;
+ while (color_iterator)
+ {
+ entry = (GimpPaletteEntry *) color_iterator->data;
+ g_checksum_update (checksum, (const guchar *) &entry->color,
+ sizeof (entry->color));
+ color_iterator = g_list_next (color_iterator);
+ }
+ checksum_string = g_strdup (g_checksum_get_string (checksum));
+ g_checksum_free (checksum);
+
+ return checksum_string;
+}
Modified: branches/soc-2008-tagging/app/core/gimppattern.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimppattern.c (original)
+++ branches/soc-2008-tagging/app/core/gimppattern.c Sun Jul 13 10:50:19 2008
@@ -30,10 +30,12 @@
#include "gimppattern.h"
#include "gimppattern-load.h"
+#include "gimptagged.h"
#include "gimp-intl.h"
+static void gimp_pattern_tagged_init (GimpTaggedInterface *iface);
static void gimp_pattern_finalize (GObject *object);
static gint64 gimp_pattern_get_memsize (GimpObject *object,
@@ -51,8 +53,12 @@
static gchar * gimp_pattern_get_extension (GimpData *data);
static GimpData * gimp_pattern_duplicate (GimpData *data);
+static gchar * gimp_pattern_get_checksum (GimpTagged *tagged);
-G_DEFINE_TYPE (GimpPattern, gimp_pattern, GIMP_TYPE_DATA)
+
+G_DEFINE_TYPE_WITH_CODE (GimpPattern, gimp_pattern, GIMP_TYPE_DATA,
+ G_IMPLEMENT_INTERFACE (GIMP_TYPE_TAGGED,
+ gimp_pattern_tagged_init))
#define parent_class gimp_pattern_parent_class
@@ -85,6 +91,12 @@
}
static void
+gimp_pattern_tagged_init (GimpTaggedInterface *iface)
+{
+ iface->get_checksum = gimp_pattern_get_checksum;
+}
+
+static void
gimp_pattern_finalize (GObject *object)
{
GimpPattern *pattern = GIMP_PATTERN (object);
@@ -230,3 +242,27 @@
return pattern->mask;
}
+
+static gchar *
+gimp_pattern_get_checksum (GimpTagged *tagged)
+{
+ GimpPattern *pattern = GIMP_PATTERN (tagged);
+ TempBuf *buffer;
+ GChecksum *checksum;
+ gchar *checksum_string;
+
+ if (! pattern->mask)
+ {
+ return NULL;
+ }
+
+ checksum = g_checksum_new (G_CHECKSUM_MD5);
+
+ buffer = pattern->mask;
+ g_checksum_update (checksum, temp_buf_data (buffer),
+ buffer->width * buffer->height * buffer->bytes);
+ checksum_string = g_strdup (g_checksum_get_string (checksum));
+ g_checksum_free (checksum);
+
+ return checksum_string;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]