[babl] babl: do not use model.data for storing original model backpointer
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] babl: do not use model.data for storing original model backpointer
- Date: Wed, 4 Oct 2017 14:18:42 +0000 (UTC)
commit eb4d8943a6c8077c4f5858e5385aa795fb461f09
Author: Øyvind Kolås <pippin gimp org>
Date: Wed Oct 4 16:16:45 2017 +0200
babl: do not use model.data for storing original model backpointer
Fixing bug #788471
babl/babl-conversion.c | 2 +-
babl/babl-fish-path.c | 4 +++-
babl/babl-fish.c | 4 ++--
babl/babl-model.c | 14 ++++++++++----
babl/babl-model.h | 5 ++---
5 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/babl/babl-conversion.c b/babl/babl-conversion.c
index b08f835..75e5c93 100644
--- a/babl/babl-conversion.c
+++ b/babl/babl-conversion.c
@@ -29,7 +29,7 @@
static int model_is_rgba (const Babl *model)
{
const Babl *RGBA = babl_model_from_id (BABL_RGBA);
- if (model == RGBA || model->model.data == RGBA)
+ if (model == RGBA || model->model.model == RGBA)
return 1;
return 0;
}
diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c
index 2a71464..6a1e194 100644
--- a/babl/babl-fish-path.c
+++ b/babl/babl-fish-path.c
@@ -330,7 +330,9 @@ alias_conversion (Babl *babl,
BablSpace *space = user_data;
if ((conv->source->class_type == BABL_FORMAT) &&
- (conv->destination->class_type == BABL_FORMAT))
+ (conv->destination->class_type == BABL_FORMAT) &&
+ (!babl_format_is_palette (conv->source)) &&
+ (!babl_format_is_palette (conv->destination)))
{
if ((conv->source->format.space == (void*)babl_space ("sRGB")) &&
(conv->destination->format.space == babl_space ("sRGB")))
diff --git a/babl/babl-fish.c b/babl/babl-fish.c
index 6e22f89..749b075 100644
--- a/babl/babl-fish.c
+++ b/babl/babl-fish.c
@@ -126,8 +126,8 @@ babl_conversion_find (const void *source,
if (BABL (source)->class_type == BABL_MODEL)
{
- const Babl *srgb_source = BABL (source)->model.data ? BABL (source)->model.data:source;
- const Babl *srgb_destination = BABL (destination)->model.data ? BABL
(destination)->model.data:destination;
+ const Babl *srgb_source = BABL (source)->model.model ? BABL (source)->model.model:source;
+ const Babl *srgb_destination = BABL (destination)->model.model ? BABL
(destination)->model.model:destination;
Babl *reference = babl_conversion_find (srgb_source, srgb_destination);
/* when conversions are sought between models, with non-sRGB chromaticities,
diff --git a/babl/babl-model.c b/babl/babl-model.c
index 0e28a17..d553aca 100644
--- a/babl/babl-model.c
+++ b/babl/babl-model.c
@@ -72,6 +72,7 @@ model_new (const char *name,
babl->model.components = components;
babl->model.space = space;
babl->model.data = NULL;
+ babl->model.model = NULL;
strcpy (babl->instance.name, name);
memcpy (babl->model.component, component, sizeof (BablComponent *) * components);
@@ -373,17 +374,22 @@ babl_remodel_with_space (const Babl *model, const Babl *space)
{
Babl *ret;
int i;
+ assert (BABL_IS_BABL (model));
if (model->model.space == space)
return (void*)model;
+ assert (BABL_IS_BABL (model));
+
/* get back to the sRGB model if we are in a COW clone of it */
- if (model->model.data)
- model = (void*)model->model.data;
+ if (model->model.model)
+ model = (void*)model->model.model;
+
+ assert (BABL_IS_BABL (model));
for (i = 0; i < babl_n_remodels; i++)
{
- if (babl_remodels[i]->model.data == model &&
+ if (babl_remodels[i]->model.model == model &&
babl_remodels[i]->model.space == space)
return babl_remodels[i];
}
@@ -391,7 +397,7 @@ babl_remodel_with_space (const Babl *model, const Babl *space)
ret = babl_calloc (sizeof (BablModel), 1);
memcpy (ret, model, sizeof (BablModel));
ret->model.space = space;
- ret->model.data = (void*)model; /* use the data as a backpointer to original model */
+ ret->model.model = (void*)model; /* use the data as a backpointer to original model */
return babl_remodels[babl_n_remodels++] = ret;
return (Babl*)ret;
}
diff --git a/babl/babl-model.h b/babl/babl-model.h
index 2395005..96ff903 100644
--- a/babl/babl-model.h
+++ b/babl/babl-model.h
@@ -29,9 +29,8 @@ typedef struct
BablComponent **component;
BablType **type; /*< must be doubles,
used here for convenience in code */
- void *data; /* used for palette - and maybe back pointer
- to actual model?
- */
+ void *data; /* user-data, used for palette */
+ void *model; /* back pointer to model with sRGB space */
const Babl *space;
} BablModel;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]