mirror of https://github.com/GNOME/gimp.git
app, libgimp*, pdb: new "format" type in the PDB.
We have a bunch of special-casing format passing through the PDB, but either we were only passing the encoding, or else we were reconstructing the full format through private intermediate functions. In the space-invasion world, this is not right. Let's have a proper "format" type for PDB which does all the relevant data-passing for us, once and for all! Note that I am creating a wrapper boxed type GimpBablFormat whose only goal is to have recognizable GValue since Babl types don't have GType-s. Moreover I'm not using the GeglParamSpecFormat either, because it just uses pointers which again are a bit annoying in our various PDB code. Having a simple boxed arg is better.
This commit is contained in:
parent
94c7ca6809
commit
aa31d22e9f
|
@ -966,9 +966,9 @@ plug_in_proc_arg_deserialize (GScanner *scanner,
|
|||
|
||||
memcpy (default_val->data, data, bpp);
|
||||
default_val->size = bpp;
|
||||
default_val->encoding = encoding;
|
||||
default_val->profile_size = profile_size;
|
||||
default_val->profile_data = profile_data;
|
||||
default_val->format.encoding = encoding;
|
||||
default_val->format.profile_size = profile_size;
|
||||
default_val->format.profile_data = profile_data;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1065,8 +1065,8 @@ plug_in_proc_arg_deserialize (GScanner *scanner,
|
|||
case GP_PARAM_DEF_TYPE_GEGL_COLOR:
|
||||
if (param_def.meta.m_gegl_color.default_val)
|
||||
{
|
||||
g_free (param_def.meta.m_gegl_color.default_val->encoding);
|
||||
g_free (param_def.meta.m_gegl_color.default_val->profile_data);
|
||||
g_free (param_def.meta.m_gegl_color.default_val->format.encoding);
|
||||
g_free (param_def.meta.m_gegl_color.default_val->format.profile_data);
|
||||
g_free (param_def.meta.m_gegl_color.default_val);
|
||||
}
|
||||
break;
|
||||
|
@ -1241,9 +1241,9 @@ plug_in_rc_write_proc_arg (GimpConfigWriter *writer,
|
|||
{
|
||||
bpp = param_def.meta.m_gegl_color.default_val->size;
|
||||
data = param_def.meta.m_gegl_color.default_val->data;
|
||||
encoding = param_def.meta.m_gegl_color.default_val->encoding;
|
||||
profile_size = param_def.meta.m_gegl_color.default_val->profile_size;
|
||||
profile_data = param_def.meta.m_gegl_color.default_val->profile_data;
|
||||
encoding = param_def.meta.m_gegl_color.default_val->format.encoding;
|
||||
profile_size = param_def.meta.m_gegl_color.default_val->format.profile_size;
|
||||
profile_data = param_def.meta.m_gegl_color.default_val->format.profile_data;
|
||||
|
||||
gimp_config_writer_printf (writer, "%d", bpp);
|
||||
gimp_config_writer_data (writer, bpp, data);
|
||||
|
|
|
@ -80,6 +80,10 @@ _gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
|
|||
! strcmp (param_def->value_type_name, "GimpColorArray"))
|
||||
return g_param_spec_boxed (name, nick, blurb, GIMP_TYPE_COLOR_ARRAY, flags);
|
||||
|
||||
if (! strcmp (param_def->type_name, "GParamBoxed") &&
|
||||
! strcmp (param_def->value_type_name, "GimpBablFormat"))
|
||||
return g_param_spec_boxed (name, nick, blurb, GIMP_TYPE_BABL_FORMAT, flags);
|
||||
|
||||
break;
|
||||
|
||||
case GP_PARAM_DEF_TYPE_CHOICE:
|
||||
|
@ -178,12 +182,12 @@ _gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
|
|||
|
||||
default_color = gegl_color_new ("black");
|
||||
|
||||
if (default_val->profile_data)
|
||||
if (default_val->format.profile_data)
|
||||
{
|
||||
GimpColorProfile *profile;
|
||||
|
||||
profile = gimp_color_profile_new_from_icc_profile (default_val->profile_data,
|
||||
default_val->profile_size,
|
||||
profile = gimp_color_profile_new_from_icc_profile (default_val->format.profile_data,
|
||||
default_val->format.profile_size,
|
||||
NULL);
|
||||
if (profile)
|
||||
{
|
||||
|
@ -203,12 +207,12 @@ _gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
|
|||
}
|
||||
}
|
||||
|
||||
format = babl_format_with_space (default_val->encoding, space);
|
||||
format = babl_format_with_space (default_val->format.encoding, space);
|
||||
bpp = babl_format_get_bytes_per_pixel (format);
|
||||
|
||||
if (bpp != default_val->size)
|
||||
g_printerr ("%s: encoding \"%s\" expects %d bpp but data size is %d bpp.\n",
|
||||
G_STRFUNC, default_val->encoding, bpp, default_val->size);
|
||||
G_STRFUNC, default_val->format.encoding, bpp, default_val->size);
|
||||
else
|
||||
gegl_color_set_pixel (default_color, format, default_val->data);
|
||||
}
|
||||
|
@ -447,10 +451,10 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
|
|||
default_val = g_new0 (GPParamColor, 1);
|
||||
|
||||
default_val->size = babl_format_get_bytes_per_pixel (format);
|
||||
default_val->encoding = (gchar *) g_strdup (babl_format_get_encoding (format));
|
||||
default_val->format.encoding = (gchar *) g_strdup (babl_format_get_encoding (format));
|
||||
|
||||
default_val->profile_data = NULL;
|
||||
default_val->profile_size = 0;
|
||||
default_val->format.profile_data = NULL;
|
||||
default_val->format.profile_size = 0;
|
||||
if (babl_format_get_space (format) != babl_space ("sRGB"))
|
||||
{
|
||||
const char *icc;
|
||||
|
@ -460,10 +464,10 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
|
|||
|
||||
if (icc_length > 0)
|
||||
{
|
||||
default_val->profile_data = g_new0 (guint8, icc_length);
|
||||
memcpy (default_val->profile_data, icc, icc_length);
|
||||
default_val->format.profile_data = g_new0 (guint8, icc_length);
|
||||
memcpy (default_val->format.profile_data, icc, icc_length);
|
||||
}
|
||||
default_val->profile_size = icc_length;
|
||||
default_val->format.profile_size = icc_length;
|
||||
}
|
||||
}
|
||||
param_def->meta.m_gegl_color.default_val = default_val;
|
||||
|
@ -752,6 +756,39 @@ gimp_gp_param_to_value (gpointer gimp,
|
|||
g_file_new_for_uri (param->data.d_string) :
|
||||
NULL));
|
||||
}
|
||||
else if (GIMP_VALUE_HOLDS_BABL_FORMAT (value))
|
||||
{
|
||||
const Babl *format = NULL;
|
||||
const Babl *space = NULL;
|
||||
const gchar *encoding;
|
||||
GimpColorProfile *profile;
|
||||
|
||||
encoding = param->data.d_format.encoding;
|
||||
profile = gimp_color_profile_new_from_icc_profile (param->data.d_format.profile_data,
|
||||
param->data.d_format.profile_size,
|
||||
NULL);
|
||||
|
||||
if (profile)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
space = gimp_color_profile_get_space (profile,
|
||||
GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
|
||||
&error);
|
||||
|
||||
if (! space)
|
||||
{
|
||||
g_printerr ("%s: failed to create Babl space from profile: %s\n",
|
||||
G_STRFUNC, error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
g_object_unref (profile);
|
||||
}
|
||||
|
||||
format = babl_format_with_space (encoding, space);
|
||||
|
||||
g_value_set_boxed (value, format);
|
||||
}
|
||||
else if (GIMP_VALUE_HOLDS_COLOR (value))
|
||||
{
|
||||
GeglColor *color;
|
||||
|
@ -761,9 +798,9 @@ gimp_gp_param_to_value (gpointer gimp,
|
|||
GimpColorProfile *profile;
|
||||
gint bpp;
|
||||
|
||||
encoding = param->data.d_gegl_color.encoding;
|
||||
profile = gimp_color_profile_new_from_icc_profile (param->data.d_gegl_color.profile_data,
|
||||
param->data.d_gegl_color.profile_size,
|
||||
encoding = param->data.d_gegl_color.format.encoding;
|
||||
profile = gimp_color_profile_new_from_icc_profile (param->data.d_gegl_color.format.profile_data,
|
||||
param->data.d_gegl_color.format.profile_size,
|
||||
NULL);
|
||||
|
||||
if (profile)
|
||||
|
@ -829,10 +866,10 @@ gimp_gp_param_to_value (gpointer gimp,
|
|||
const gchar *encoding;
|
||||
gint bpp;
|
||||
|
||||
encoding = param->data.d_color_array.colors[i].encoding;
|
||||
if (param->data.d_color_array.colors[i].profile_size > 0)
|
||||
profile = gimp_color_profile_new_from_icc_profile (param->data.d_color_array.colors[i].profile_data,
|
||||
param->data.d_color_array.colors[i].profile_size,
|
||||
encoding = param->data.d_color_array.colors[i].format.encoding;
|
||||
if (param->data.d_color_array.colors[i].format.profile_size > 0)
|
||||
profile = gimp_color_profile_new_from_icc_profile (param->data.d_color_array.colors[i].format.profile_data,
|
||||
param->data.d_color_array.colors[i].format.profile_size,
|
||||
NULL);
|
||||
|
||||
if (profile)
|
||||
|
@ -1132,6 +1169,46 @@ gimp_value_to_gp_param (const GValue *value,
|
|||
|
||||
param->data.d_string = file ? g_file_get_uri (file) : NULL;
|
||||
}
|
||||
else if (GIMP_VALUE_HOLDS_BABL_FORMAT (value))
|
||||
{
|
||||
const Babl *format;
|
||||
int icc_length = 0;
|
||||
|
||||
param->param_type = GP_PARAM_TYPE_BABL_FORMAT;
|
||||
|
||||
format = g_value_get_boxed (value);
|
||||
|
||||
/* TODO: For indexed colors, we'll convert to R'G'B'(A) u8 as that
|
||||
* is currently what we support. As indexed format support improves,
|
||||
* we'll want to make this space and encoding agnostic. */
|
||||
if (babl_format_is_palette (format))
|
||||
{
|
||||
const Babl *indexed_format = NULL;
|
||||
gint bpp;
|
||||
|
||||
g_warning ("%s: GValue of type '%s' holds an indexed format. "
|
||||
"This is unsupported and replaced with \"R'G'B' u8\".",
|
||||
G_STRFUNC, param->type_name);
|
||||
bpp = babl_format_get_bytes_per_pixel (format);
|
||||
if (bpp == 1)
|
||||
indexed_format = babl_format_with_space ("R'G'B' u8",
|
||||
babl_format_get_space (format));
|
||||
else if (bpp == 2)
|
||||
indexed_format = babl_format_with_space ("R'G'B'A u8",
|
||||
babl_format_get_space (format));
|
||||
|
||||
/* TODO: This is to notify us in the future when indexed image can have more than
|
||||
* 256 colors - we'll need to update encoding support accordingly */
|
||||
g_return_if_fail (indexed_format != NULL);
|
||||
|
||||
format = indexed_format;
|
||||
}
|
||||
|
||||
param->data.d_format.encoding = (gchar *) babl_format_get_encoding (format);
|
||||
param->data.d_format.profile_data = (guint8 *) babl_space_get_icc (babl_format_get_space (format),
|
||||
&icc_length);
|
||||
param->data.d_format.profile_size = icc_length;
|
||||
}
|
||||
else if (GIMP_VALUE_HOLDS_COLOR (value))
|
||||
{
|
||||
GeglColor *color;
|
||||
|
@ -1169,10 +1246,10 @@ gimp_value_to_gp_param (const GValue *value,
|
|||
param->data.d_gegl_color.size = babl_format_get_bytes_per_pixel (format);
|
||||
gegl_color_get_pixel (color, format, ¶m->data.d_gegl_color.data);
|
||||
|
||||
param->data.d_gegl_color.encoding = (gchar *) babl_format_get_encoding (format);
|
||||
param->data.d_gegl_color.profile_data = (guint8 *) babl_space_get_icc (babl_format_get_space (format),
|
||||
param->data.d_gegl_color.format.encoding = (gchar *) babl_format_get_encoding (format);
|
||||
param->data.d_gegl_color.format.profile_data = (guint8 *) babl_space_get_icc (babl_format_get_space (format),
|
||||
&icc_length);
|
||||
param->data.d_gegl_color.profile_size = icc_length;
|
||||
param->data.d_gegl_color.format.profile_size = icc_length;
|
||||
}
|
||||
else if (GIMP_VALUE_HOLDS_PARASITE (value))
|
||||
{
|
||||
|
@ -1251,12 +1328,12 @@ gimp_value_to_gp_param (const GValue *value,
|
|||
param->data.d_color_array.colors[i].size = babl_format_get_bytes_per_pixel (format);
|
||||
gegl_color_get_pixel (colors[i], format, ¶m->data.d_color_array.colors[i].data);
|
||||
|
||||
param->data.d_color_array.colors[i].encoding = (gchar *) babl_format_get_encoding (format);
|
||||
param->data.d_color_array.colors[i].format.encoding = (gchar *) babl_format_get_encoding (format);
|
||||
|
||||
if (babl_format_get_space (format) != babl_space ("sRGB"))
|
||||
param->data.d_color_array.colors[i].profile_data = (guint8 *) babl_space_get_icc (babl_format_get_space (format),
|
||||
param->data.d_color_array.colors[i].format.profile_data = (guint8 *) babl_space_get_icc (babl_format_get_space (format),
|
||||
&icc_length);
|
||||
param->data.d_gegl_color.profile_size = icc_length;
|
||||
param->data.d_gegl_color.format.profile_size = icc_length;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1475,6 +1552,7 @@ _gimp_gp_params_free (GPParam *params,
|
|||
g_free (params[i].data.d_string);
|
||||
break;
|
||||
|
||||
case GP_PARAM_TYPE_BABL_FORMAT:
|
||||
case GP_PARAM_TYPE_GEGL_COLOR:
|
||||
break;
|
||||
|
||||
|
|
|
@ -1234,7 +1234,7 @@ _gp_param_def_read (GIOChannel *channel,
|
|||
{
|
||||
default_val = g_new0 (GPParamColor, 1);
|
||||
|
||||
default_val->encoding = encoding;
|
||||
default_val->format.encoding = encoding;
|
||||
default_val->size = g_bytes_get_size (pixel_data);
|
||||
if (default_val->size > 40)
|
||||
{
|
||||
|
@ -1251,14 +1251,13 @@ _gp_param_def_read (GIOChannel *channel,
|
|||
{
|
||||
gsize profile_size;
|
||||
|
||||
default_val->profile_data = g_bytes_unref_to_data (icc_data,
|
||||
&profile_size);
|
||||
default_val->profile_size = (guint32) profile_size;
|
||||
default_val->format.profile_data = g_bytes_unref_to_data (icc_data, &profile_size);
|
||||
default_val->format.profile_size = (guint32) profile_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
default_val->profile_data = NULL;
|
||||
default_val->profile_size = 0;
|
||||
default_val->format.profile_data = NULL;
|
||||
default_val->format.profile_size = 0;
|
||||
}
|
||||
}
|
||||
param_def->meta.m_gegl_color.default_val = default_val;
|
||||
|
@ -1338,8 +1337,8 @@ _gp_param_def_destroy (GPParamDef *param_def)
|
|||
case GP_PARAM_DEF_TYPE_GEGL_COLOR:
|
||||
if (param_def->meta.m_gegl_color.default_val)
|
||||
{
|
||||
g_free (param_def->meta.m_gegl_color.default_val->encoding);
|
||||
g_free (param_def->meta.m_gegl_color.default_val->profile_data);
|
||||
g_free (param_def->meta.m_gegl_color.default_val->format.encoding);
|
||||
g_free (param_def->meta.m_gegl_color.default_val->format.profile_data);
|
||||
}
|
||||
g_free (param_def->meta.m_gegl_color.default_val);
|
||||
break;
|
||||
|
@ -1598,9 +1597,9 @@ _gp_param_def_write (GIOChannel *channel,
|
|||
{
|
||||
pixel_data = g_bytes_new_static (param_def->meta.m_gegl_color.default_val->data,
|
||||
param_def->meta.m_gegl_color.default_val->size);
|
||||
icc_data = g_bytes_new_static (param_def->meta.m_gegl_color.default_val->profile_data,
|
||||
param_def->meta.m_gegl_color.default_val->profile_size);
|
||||
encoding = param_def->meta.m_gegl_color.default_val->encoding;
|
||||
icc_data = g_bytes_new_static (param_def->meta.m_gegl_color.default_val->format.profile_data,
|
||||
param_def->meta.m_gegl_color.default_val->format.profile_size);
|
||||
encoding = param_def->meta.m_gegl_color.default_val->format.encoding;
|
||||
}
|
||||
|
||||
if (! _gimp_wire_write_gegl_color (channel,
|
||||
|
@ -1853,6 +1852,35 @@ _gp_params_read (GIOChannel *channel,
|
|||
goto cleanup;
|
||||
break;
|
||||
|
||||
case GP_PARAM_TYPE_BABL_FORMAT:
|
||||
/* Read encoding. */
|
||||
if (! _gimp_wire_read_string (channel,
|
||||
&(*params)[i].data.d_format.encoding, 1,
|
||||
user_data))
|
||||
goto cleanup;
|
||||
|
||||
/* Read space (profile data). */
|
||||
if (! _gimp_wire_read_int32 (channel,
|
||||
&(*params)[i].data.d_format.profile_size, 1,
|
||||
user_data))
|
||||
{
|
||||
g_clear_pointer (&(*params)[i].data.d_format.encoding, g_free);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
(*params)[i].data.d_format.profile_data = g_new0 (guint8, (*params)[i].data.d_format.profile_size);
|
||||
if (! _gimp_wire_read_int8 (channel,
|
||||
(*params)[i].data.d_format.profile_data,
|
||||
(*params)[i].data.d_format.profile_size,
|
||||
user_data))
|
||||
{
|
||||
g_clear_pointer (&(*params)[i].data.d_format.encoding, g_free);
|
||||
g_clear_pointer (&(*params)[i].data.d_format.profile_data, g_free);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case GP_PARAM_TYPE_GEGL_COLOR:
|
||||
/* Read the color data. */
|
||||
if (! _gimp_wire_read_int32 (channel,
|
||||
|
@ -1869,27 +1897,27 @@ _gp_params_read (GIOChannel *channel,
|
|||
|
||||
/* Read encoding. */
|
||||
if (! _gimp_wire_read_string (channel,
|
||||
&(*params)[i].data.d_gegl_color.encoding, 1,
|
||||
&(*params)[i].data.d_gegl_color.format.encoding, 1,
|
||||
user_data))
|
||||
goto cleanup;
|
||||
|
||||
/* Read space (profile data). */
|
||||
if (! _gimp_wire_read_int32 (channel,
|
||||
&(*params)[i].data.d_gegl_color.profile_size, 1,
|
||||
&(*params)[i].data.d_gegl_color.format.profile_size, 1,
|
||||
user_data))
|
||||
{
|
||||
g_clear_pointer (&(*params)[i].data.d_gegl_color.encoding, g_free);
|
||||
g_clear_pointer (&(*params)[i].data.d_gegl_color.format.encoding, g_free);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
(*params)[i].data.d_gegl_color.profile_data = g_new0 (guint8, (*params)[i].data.d_gegl_color.profile_size);
|
||||
(*params)[i].data.d_gegl_color.format.profile_data = g_new0 (guint8, (*params)[i].data.d_gegl_color.format.profile_size);
|
||||
if (! _gimp_wire_read_int8 (channel,
|
||||
(*params)[i].data.d_gegl_color.profile_data,
|
||||
(*params)[i].data.d_gegl_color.profile_size,
|
||||
(*params)[i].data.d_gegl_color.format.profile_data,
|
||||
(*params)[i].data.d_gegl_color.format.profile_size,
|
||||
user_data))
|
||||
{
|
||||
g_clear_pointer (&(*params)[i].data.d_gegl_color.encoding, g_free);
|
||||
g_clear_pointer (&(*params)[i].data.d_gegl_color.profile_data, g_free);
|
||||
g_clear_pointer (&(*params)[i].data.d_gegl_color.format.encoding, g_free);
|
||||
g_clear_pointer (&(*params)[i].data.d_gegl_color.format.profile_data, g_free);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -1913,8 +1941,8 @@ _gp_params_read (GIOChannel *channel,
|
|||
{
|
||||
for (gint k = 0; k < j; k++)
|
||||
{
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].encoding);
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].profile_data);
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].format.encoding);
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].format.profile_data);
|
||||
}
|
||||
g_clear_pointer (&(*params)[i].data.d_color_array.colors, g_free);
|
||||
goto cleanup;
|
||||
|
@ -1928,8 +1956,8 @@ _gp_params_read (GIOChannel *channel,
|
|||
{
|
||||
for (gint k = 0; k < j; k++)
|
||||
{
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].encoding);
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].profile_data);
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].format.encoding);
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].format.profile_data);
|
||||
}
|
||||
g_clear_pointer (&(*params)[i].data.d_color_array.colors, g_free);
|
||||
goto cleanup;
|
||||
|
@ -1937,13 +1965,13 @@ _gp_params_read (GIOChannel *channel,
|
|||
|
||||
/* Read encoding. */
|
||||
if (! _gimp_wire_read_string (channel,
|
||||
&(*params)[i].data.d_color_array.colors[j].encoding, 1,
|
||||
&(*params)[i].data.d_color_array.colors[j].format.encoding, 1,
|
||||
user_data))
|
||||
{
|
||||
for (gint k = 0; k < j; k++)
|
||||
{
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].encoding);
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].profile_data);
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].format.encoding);
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].format.profile_data);
|
||||
}
|
||||
g_clear_pointer (&(*params)[i].data.d_color_array.colors, g_free);
|
||||
goto cleanup;
|
||||
|
@ -1951,34 +1979,34 @@ _gp_params_read (GIOChannel *channel,
|
|||
|
||||
/* Read space (profile data). */
|
||||
if (! _gimp_wire_read_int32 (channel,
|
||||
&(*params)[i].data.d_color_array.colors[j].profile_size, 1,
|
||||
&(*params)[i].data.d_color_array.colors[j].format.profile_size, 1,
|
||||
user_data))
|
||||
{
|
||||
for (gint k = 0; k < j; k++)
|
||||
{
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].encoding);
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].profile_data);
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].format.encoding);
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].format.profile_data);
|
||||
}
|
||||
g_clear_pointer (&(*params)[i].data.d_color_array.colors[j].encoding, g_free);
|
||||
g_clear_pointer (&(*params)[i].data.d_color_array.colors[j].format.encoding, g_free);
|
||||
g_clear_pointer (&(*params)[i].data.d_color_array.colors, g_free);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ((*params)[i].data.d_color_array.colors[j].profile_size > 0)
|
||||
if ((*params)[i].data.d_color_array.colors[j].format.profile_size > 0)
|
||||
{
|
||||
(*params)[i].data.d_color_array.colors[j].profile_data = g_new0 (guint8, (*params)[i].data.d_color_array.colors[j].profile_size);
|
||||
(*params)[i].data.d_color_array.colors[j].format.profile_data = g_new0 (guint8, (*params)[i].data.d_color_array.colors[j].format.profile_size);
|
||||
if (! _gimp_wire_read_int8 (channel,
|
||||
(*params)[i].data.d_color_array.colors[j].profile_data,
|
||||
(*params)[i].data.d_color_array.colors[j].profile_size,
|
||||
(*params)[i].data.d_color_array.colors[j].format.profile_data,
|
||||
(*params)[i].data.d_color_array.colors[j].format.profile_size,
|
||||
user_data))
|
||||
{
|
||||
for (gint k = 0; k < j; k++)
|
||||
{
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].encoding);
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].profile_data);
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].format.encoding);
|
||||
g_free ((*params)[i].data.d_color_array.colors[k].format.profile_data);
|
||||
}
|
||||
g_clear_pointer (&(*params)[i].data.d_color_array.colors[j].encoding, g_free);
|
||||
g_clear_pointer (&(*params)[i].data.d_color_array.colors[j].profile_data, g_free);
|
||||
g_clear_pointer (&(*params)[i].data.d_color_array.colors[j].format.encoding, g_free);
|
||||
g_clear_pointer (&(*params)[i].data.d_color_array.colors[j].format.profile_data, g_free);
|
||||
g_clear_pointer (&(*params)[i].data.d_color_array.colors, g_free);
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -2180,6 +2208,20 @@ _gp_params_write (GIOChannel *channel,
|
|||
return;
|
||||
break;
|
||||
|
||||
case GP_PARAM_TYPE_BABL_FORMAT:
|
||||
if (! _gimp_wire_write_string (channel,
|
||||
¶ms[i].data.d_format.encoding, 1,
|
||||
user_data) ||
|
||||
! _gimp_wire_write_int32 (channel,
|
||||
(const guint32 *) ¶ms[i].data.d_format.profile_size, 1,
|
||||
user_data) ||
|
||||
! _gimp_wire_write_int8 (channel,
|
||||
(const guint8 *) params[i].data.d_format.profile_data,
|
||||
params[i].data.d_format.profile_size,
|
||||
user_data))
|
||||
return;
|
||||
break;
|
||||
|
||||
case GP_PARAM_TYPE_GEGL_COLOR:
|
||||
if (! _gimp_wire_write_int32 (channel,
|
||||
(const guint32 *) ¶ms[i].data.d_gegl_color.size, 1,
|
||||
|
@ -2189,14 +2231,14 @@ _gp_params_write (GIOChannel *channel,
|
|||
params[i].data.d_gegl_color.size,
|
||||
user_data) ||
|
||||
! _gimp_wire_write_string (channel,
|
||||
¶ms[i].data.d_gegl_color.encoding, 1,
|
||||
¶ms[i].data.d_gegl_color.format.encoding, 1,
|
||||
user_data) ||
|
||||
! _gimp_wire_write_int32 (channel,
|
||||
(const guint32 *) ¶ms[i].data.d_gegl_color.profile_size, 1,
|
||||
(const guint32 *) ¶ms[i].data.d_gegl_color.format.profile_size, 1,
|
||||
user_data) ||
|
||||
! _gimp_wire_write_int8 (channel,
|
||||
(const guint8 *) params[i].data.d_gegl_color.profile_data,
|
||||
params[i].data.d_gegl_color.profile_size,
|
||||
(const guint8 *) params[i].data.d_gegl_color.format.profile_data,
|
||||
params[i].data.d_gegl_color.format.profile_size,
|
||||
user_data))
|
||||
return;
|
||||
break;
|
||||
|
@ -2217,14 +2259,14 @@ _gp_params_write (GIOChannel *channel,
|
|||
params[i].data.d_color_array.colors[j].size,
|
||||
user_data) ||
|
||||
! _gimp_wire_write_string (channel,
|
||||
¶ms[i].data.d_color_array.colors[j].encoding, 1,
|
||||
¶ms[i].data.d_color_array.colors[j].format.encoding, 1,
|
||||
user_data) ||
|
||||
! _gimp_wire_write_int32 (channel,
|
||||
(const guint32 *) ¶ms[i].data.d_color_array.colors[j].profile_size, 1,
|
||||
(const guint32 *) ¶ms[i].data.d_color_array.colors[j].format.profile_size, 1,
|
||||
user_data) ||
|
||||
! _gimp_wire_write_int8 (channel,
|
||||
(const guint8 *) params[i].data.d_color_array.colors[j].profile_data,
|
||||
params[i].data.d_color_array.colors[j].profile_size,
|
||||
(const guint8 *) params[i].data.d_color_array.colors[j].format.profile_data,
|
||||
params[i].data.d_color_array.colors[j].format.profile_size,
|
||||
user_data))
|
||||
return;
|
||||
}
|
||||
|
@ -2356,16 +2398,20 @@ _gp_params_destroy (GPParam *params,
|
|||
g_free (params[i].data.d_string);
|
||||
break;
|
||||
|
||||
case GP_PARAM_TYPE_BABL_FORMAT:
|
||||
g_free (params[i].data.d_format.profile_data);
|
||||
break;
|
||||
|
||||
case GP_PARAM_TYPE_GEGL_COLOR:
|
||||
g_free (params[i].data.d_gegl_color.encoding);
|
||||
g_free (params[i].data.d_gegl_color.profile_data);
|
||||
g_free (params[i].data.d_gegl_color.format.encoding);
|
||||
g_free (params[i].data.d_gegl_color.format.profile_data);
|
||||
break;
|
||||
|
||||
case GP_PARAM_TYPE_COLOR_ARRAY:
|
||||
for (gint j = 0; j < params[i].data.d_color_array.size; j++)
|
||||
{
|
||||
g_free (params[i].data.d_color_array.colors[j].encoding);
|
||||
g_free (params[i].data.d_color_array.colors[j].profile_data);
|
||||
g_free (params[i].data.d_color_array.colors[j].format.encoding);
|
||||
g_free (params[i].data.d_color_array.colors[j].format.profile_data);
|
||||
}
|
||||
g_free (params[i].data.d_color_array.colors);
|
||||
break;
|
||||
|
|
|
@ -26,7 +26,7 @@ G_BEGIN_DECLS
|
|||
|
||||
/* Increment every time the protocol changes
|
||||
*/
|
||||
#define GIMP_PROTOCOL_VERSION 0x0112
|
||||
#define GIMP_PROTOCOL_VERSION 0x0113
|
||||
|
||||
|
||||
enum
|
||||
|
@ -71,6 +71,7 @@ typedef enum
|
|||
GP_PARAM_TYPE_STRV,
|
||||
GP_PARAM_TYPE_BYTES,
|
||||
GP_PARAM_TYPE_FILE,
|
||||
GP_PARAM_TYPE_BABL_FORMAT,
|
||||
GP_PARAM_TYPE_GEGL_COLOR,
|
||||
GP_PARAM_TYPE_COLOR_ARRAY,
|
||||
GP_PARAM_TYPE_PARASITE,
|
||||
|
@ -102,6 +103,7 @@ typedef struct _GPParamDefResource GPParamDefResource;
|
|||
typedef struct _GPParam GPParam;
|
||||
typedef struct _GPParamArray GPParamArray;
|
||||
typedef struct _GPParamIDArray GPParamIDArray;
|
||||
typedef struct _GPParamFormat GPParamFormat;
|
||||
typedef struct _GPParamColor GPParamColor;
|
||||
typedef struct _GPParamColorArray GPParamColorArray;
|
||||
typedef struct _GPParamExportOptions GPParamExportOptions;
|
||||
|
@ -281,15 +283,20 @@ struct _GPParamIDArray
|
|||
gint32 *data;
|
||||
};
|
||||
|
||||
struct _GPParamFormat
|
||||
{
|
||||
/* Transferring a BablFormat with the encoding and the ICC data. */
|
||||
gchar *encoding;
|
||||
guint32 profile_size;
|
||||
guint8 *profile_data;
|
||||
};
|
||||
|
||||
struct _GPParamColor
|
||||
{
|
||||
guint32 size;
|
||||
guint8 data[40];
|
||||
|
||||
/* Transferring a BablFormat with the encoding and the ICC data. */
|
||||
gchar *encoding;
|
||||
guint32 profile_size;
|
||||
guint8 *profile_data;
|
||||
GPParamFormat format;
|
||||
};
|
||||
|
||||
struct _GPParamColorArray
|
||||
|
@ -315,6 +322,7 @@ struct _GPParam
|
|||
gchar *d_string;
|
||||
gchar **d_strv;
|
||||
GBytes *d_bytes;
|
||||
GPParamFormat d_format;
|
||||
GPParamColor d_gegl_color;
|
||||
GPParamColorArray d_color_array;
|
||||
GimpParasite d_parasite;
|
||||
|
|
|
@ -753,3 +753,39 @@ gimp_color_get_CIE2000_distance (GeglColor *color1,
|
|||
|
||||
return dE00;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GIMP_TYPE_BABL_FORMAT
|
||||
*/
|
||||
|
||||
static const Babl * gimp_babl_object_copy (const Babl *object);
|
||||
static void gimp_babl_object_free (const Babl *object);
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GimpBablFormat, gimp_babl_format, (GBoxedCopyFunc) gimp_babl_object_copy, (GBoxedFreeFunc) gimp_babl_object_free)
|
||||
|
||||
/**
|
||||
* gimp_babl_object_copy: (skip)
|
||||
* @object: a Babl object.
|
||||
*
|
||||
* Bogus function since [struct@Babl.Object] should just be used as
|
||||
* never-ending pointers.
|
||||
*
|
||||
* Returns: (transfer none): the passed @object.
|
||||
**/
|
||||
const Babl *
|
||||
gimp_babl_object_copy (const Babl *object)
|
||||
{
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_babl_object_free: (skip)
|
||||
* @object: a Babl object.
|
||||
*
|
||||
* Bogus function since [struct@Babl.Object] must not be freed.
|
||||
**/
|
||||
void
|
||||
gimp_babl_object_free (const Babl *object)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
EXPORTS
|
||||
gimp_adaptive_supersample_area
|
||||
gimp_babl_format_get_type
|
||||
gimp_bilinear
|
||||
gimp_bilinear_16
|
||||
gimp_bilinear_32
|
||||
|
|
|
@ -95,6 +95,33 @@ GParamSpec * gimp_param_spec_color_from_string (const gchar *name,
|
|||
|
||||
gboolean gimp_param_spec_color_has_alpha (GParamSpec *pspec);
|
||||
|
||||
|
||||
/*
|
||||
* GIMP_TYPE_BABL_FORMAT
|
||||
*/
|
||||
|
||||
/**
|
||||
* GimpBablFormat:
|
||||
*
|
||||
* This type is simply a wrapper around [struct@Babl.Object] when used as
|
||||
* a color format.
|
||||
*
|
||||
* The only reason of this wrapper is to be able to assign a %GType to
|
||||
* Babl formats, e.g. to have typed `GValue`, which is mostly used
|
||||
* internally by our plug-in protocol.
|
||||
*
|
||||
* There is no reason whatsoever to use this type directly.
|
||||
*
|
||||
* Since: 3.0
|
||||
*/
|
||||
typedef const Babl * GimpBablFormat;
|
||||
|
||||
#define GIMP_TYPE_BABL_FORMAT gimp_babl_format_get_type ()
|
||||
#define GIMP_VALUE_HOLDS_BABL_FORMAT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), GIMP_TYPE_BABL_FORMAT))
|
||||
|
||||
GType gimp_babl_format_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIMP_COLOR_H__ */
|
||||
|
|
|
@ -609,6 +609,15 @@ gimp_param_spec_color ("$name",
|
|||
$has_alpha,
|
||||
$default,
|
||||
$flags)
|
||||
CODE
|
||||
}
|
||||
elsif ($pdbtype eq 'format') {
|
||||
$pspec = <<CODE;
|
||||
g_param_spec_boxed ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
GIMP_TYPE_BABL_FORMAT,
|
||||
$flags)
|
||||
CODE
|
||||
}
|
||||
elsif ($pdbtype eq 'parasite') {
|
||||
|
|
11
pdb/pdb.pl
11
pdb/pdb.pl
|
@ -264,6 +264,17 @@ package Gimp::CodeGen::pdb;
|
|||
take_value_func => 'g_value_take_object ($value, $var)',
|
||||
headers => [ qw(<cairo.h> "libgimpcolor/gimpcolor.h") ] },
|
||||
|
||||
format => { name => 'FORMAT',
|
||||
gtype => 'GIMP_TYPE_BABL_FORMAT',
|
||||
type => 'const Babl *',
|
||||
const_type => 'const Babl *',
|
||||
init_value => 'NULL',
|
||||
out_annotate => '(transfer none)',
|
||||
get_value_func => '$var = g_value_get_boxed ($value)',
|
||||
dup_value_func => '$var = g_value_get_boxed (gimp_value_array_index ($value))',
|
||||
set_value_func => 'g_value_set_boxed ($value, $var)',
|
||||
take_value_func => 'g_value_set_boxed ($value, $var)' },
|
||||
|
||||
display => { name => 'DISPLAY',
|
||||
gtype => 'GIMP_TYPE_DISPLAY',
|
||||
type => 'GimpDisplay *',
|
||||
|
|
Loading…
Reference in New Issue