[babl/wip/pippin/inverted-cmyk] babl: do collisions in a different manner
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl/wip/pippin/inverted-cmyk] babl: do collisions in a different manner
- Date: Fri, 23 Nov 2018 14:06:57 +0000 (UTC)
commit 0fd60986e9c9a2a84e70f7917600b94995d5e82a
Author: Øyvind Kolås <pippin gimp org>
Date: Fri Nov 23 00:40:46 2018 +0100
babl: do collisions in a different manner
babl/babl-conversion.c | 26 ++++++++++++++++----------
babl/babl-fish.c | 8 ++++----
babl/babl-icc.c | 4 ++--
babl/babl-internal.h | 7 +++++--
babl/babl-model.c | 12 ++++++++++--
babl/babl-model.h | 1 +
6 files changed, 38 insertions(+), 20 deletions(-)
---
diff --git a/babl/babl-conversion.c b/babl/babl-conversion.c
index ef68fd3..b7f66b7 100644
--- a/babl/babl-conversion.c
+++ b/babl/babl-conversion.c
@@ -152,7 +152,8 @@ _conversion_new (const char *name,
BablFuncLinear linear,
BablFuncPlane plane,
BablFuncPlanar planar,
- void *user_data)
+ void *user_data,
+ int allow_collision)
{
Babl *babl = NULL;
@@ -237,16 +238,17 @@ _conversion_new (const char *name,
BABL (babl->conversion.destination),
babl_type_from_id (BABL_DOUBLE));
- if(0){
+ if(allow_collision){
const Babl *fish = babl_conversion_find (src_format, dst_format);
if (fish)
- return fish;
+ return (void*)fish;
}
babl_conversion_new (
src_format,
dst_format,
"linear", linear,
"data", user_data,
+ allow_collision?"allow-collision":NULL,
NULL);
babl->conversion.error = 0.0;
}
@@ -283,13 +285,12 @@ create_name (Babl *source, Babl *destination, int type)
}
return buf;
}
-const char *
-babl_conversion_create_name (Babl *source, Babl *destination, int type);
int _babl_loaded = 0;
const char *
-babl_conversion_create_name (Babl *source, Babl *destination, int type)
+babl_conversion_create_name (Babl *source, Babl *destination, int type,
+ int allow_collision)
{
Babl *babl;
char *name;
@@ -297,7 +298,8 @@ babl_conversion_create_name (Babl *source, Babl *destination, int type)
collisions = 0;
name = create_name (source, destination, type);
- if (!_babl_loaded)
+ if (_babl_loaded == 0 ||
+ allow_collision == 0)
{
babl = babl_db_exist (db, id, name);
while (babl)
@@ -331,8 +333,8 @@ babl_conversion_new (const void *first_arg,
Babl *source;
Babl *destination;
-
char *name;
+ int allow_collision = 0;
va_start (varg, first_arg);
source = (Babl *) arg;
@@ -355,6 +357,10 @@ babl_conversion_new (const void *first_arg,
user_data = va_arg (varg, void*);
}
+ else if (!strcmp (arg, "allow-collision"))
+ {
+ allow_collision = 1;
+ }
else if (!strcmp (arg, "linear"))
{
if (got_func++)
@@ -408,10 +414,10 @@ babl_conversion_new (const void *first_arg,
type = BABL_CONVERSION_PLANAR;
}
- name = (void*) babl_conversion_create_name (source, destination, type);
+ name = (void*) babl_conversion_create_name (source, destination, type, allow_collision);
babl = _conversion_new (name, id, source, destination, linear, plane, planar,
- user_data);
+ user_data, allow_collision);
/* Since there is not an already registered instance by the required
* id/name, inserting newly created class into database.
diff --git a/babl/babl-fish.c b/babl/babl-fish.c
index d23481f..a3d299c 100644
--- a/babl/babl-fish.c
+++ b/babl/babl-fish.c
@@ -126,7 +126,7 @@ babl_conversion_find (const void *source,
babl_list_each (BABL (source)->type.from_list, match_conversion, &data);
if (data != (void*)destination) /* didn't change */
{
- return data;
+ return data; /* found conversion */
}
data = NULL;
@@ -160,19 +160,19 @@ babl_conversion_find (const void *source,
reference->conversion.function.linear,
NULL,
NULL,
- reference->conversion.data);
+ reference->conversion.data, 1);
case BABL_CONVERSION_PLANE:
return _conversion_new ("", 0, source, destination,
NULL,
reference->conversion.function.plane,
NULL,
- reference->conversion.data);
+ reference->conversion.data, 1);
case BABL_CONVERSION_PLANAR:
return _conversion_new ("", 0, source, destination,
NULL,
NULL,
reference->conversion.function.planar,
- reference->conversion.data);
+ reference->conversion.data, 1);
}
}
return NULL;
diff --git a/babl/babl-icc.c b/babl/babl-icc.c
index 6a29e5b..4ac2126 100644
--- a/babl/babl-icc.c
+++ b/babl/babl-icc.c
@@ -784,10 +784,10 @@ babl_space_from_icc (const char *icc_data,
ret->space.cmyk.lcms_to_rgba = cmsCreateTransform(ret->space.cmyk.lcms_profile, TYPE_CMYKA_DBL,
sRGBProfile, TYPE_RGBA_DBL,
- 1,0);//intent & 7, 0);
+ INTENT_PERCEPTUAL,0);//intent & 7, 0);
ret->space.cmyk.lcms_from_rgba = cmsCreateTransform(sRGBProfile, TYPE_RGBA_DBL,
ret->space.cmyk.lcms_profile, TYPE_CMYKA_DBL,
- 1,0);//intent & 7, 0);
+ INTENT_PERCEPTUAL,0);//intent & 7, 0);
cmsCloseProfile (ret->space.cmyk.lcms_profile); // XXX keep it open in case of CMYK to CMYK
transforms needed?
#endif
return ret;
diff --git a/babl/babl-internal.h b/babl/babl-internal.h
index ed91e4d..95ca661 100644
--- a/babl/babl-internal.h
+++ b/babl/babl-internal.h
@@ -347,7 +347,8 @@ _conversion_new (const char *name,
BablFuncLinear linear,
BablFuncPlane plane,
BablFuncPlanar planar,
- void *user_data);
+ void *user_data,
+ int allow_collision);
double _babl_legal_error (void);
void babl_init_db (void);
@@ -373,7 +374,9 @@ Babl * format_new_from_format_with_space (const Babl *format, const Babl *space)
int babl_list_destroy (void *data);
const char *
-babl_conversion_create_name (Babl *source, Babl *destination, int is_reference);
+babl_conversion_create_name (Babl *source, Babl *destination, int type,
+ int allow_collision);
+
void _babl_space_add_universal_rgb (const Babl *space);
const Babl *
babl_trc_formula_srgb (double gamma, double a, double b, double c, double d);
diff --git a/babl/babl-model.c b/babl/babl-model.c
index f5330fe..4ce2211 100644
--- a/babl/babl-model.c
+++ b/babl/babl-model.c
@@ -56,7 +56,8 @@ model_new (const char *name,
const Babl *space,
int id,
int components,
- BablComponent **component)
+ BablComponent **component,
+ int is_cmyk)
{
Babl *babl;
@@ -73,6 +74,7 @@ model_new (const char *name,
babl->model.space = space;
babl->model.data = NULL;
babl->model.model = NULL;
+ babl->model.is_cmyk = is_cmyk;
strcpy (babl->instance.name, name);
memcpy (babl->model.component, component, sizeof (BablComponent *) * components);
@@ -114,6 +116,7 @@ babl_model_new (void *first_argument,
char *name = NULL;
const Babl *space = babl_space ("sRGB");
BablComponent *component [BABL_MAX_COMPONENTS];
+ int is_cmyk = 0;
va_start (varg, first_argument);
@@ -130,6 +133,11 @@ babl_model_new (void *first_argument,
assigned_name = va_arg (varg, char *);
}
+ else if (!strcmp (arg, "cmyk"))
+ {
+ is_cmyk = 1;
+ }
+
/* if we didn't point to a known string, we assume argument to be babl */
else if (BABL_IS_BABL (arg))
{
@@ -211,7 +219,7 @@ babl_model_new (void *first_argument,
if (! babl)
{
- babl = model_new (name, space, id, components, component);
+ babl = model_new (name, space, id, components, component, is_cmyk);
babl_db_insert (db, babl);
construct_double_format (babl);
}
diff --git a/babl/babl-model.h b/babl/babl-model.h
index ee0e51f..74595a8 100644
--- a/babl/babl-model.h
+++ b/babl/babl-model.h
@@ -32,6 +32,7 @@ typedef struct
void *data; /* user-data, used for palette */
const Babl *space;
void *model; /* back pointer to model with sRGB space */
+ int is_cmyk; /* is an cmyk based model */
} BablModel;
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]