buffer: refactor gegl_babl_model_is_linear into babl_model_flags

Also adds CMYK type model as a valid alternative to being linear in
buffer scale blitting algorithms.
parent 91b75446
......@@ -945,8 +945,10 @@ GeglDownscale2x2Fun gegl_downscale_2x2_get_fun (const Babl *format)
{
const Babl *comp_type = babl_format_get_type (format, 0);
const Babl *model = babl_format_get_model (format);
if (gegl_babl_model_is_linear (model))
BablModelFlag model_flags = babl_model_get_flags (model);
if ((model_flags & BABL_MODEL_FLAG_LINEAR)||
(model_flags & BABL_MODEL_FLAG_CMYK))
{
if (comp_type == gegl_babl_float())
{
......@@ -1079,8 +1081,10 @@ void gegl_resample_boxfilter (guchar *dest_buf,
const Babl *model = babl_format_get_model (format);
const Babl *comp_type = babl_format_get_type (format, 0);
const gint bpp = babl_format_get_bytes_per_pixel (format);
BablModelFlag model_flags = babl_model_get_flags (model);
if (gegl_babl_model_is_linear (model))
if ((model_flags & BABL_MODEL_FLAG_LINEAR)||
(model_flags & BABL_MODEL_FLAG_CMYK))
{
if (comp_type == gegl_babl_float())
......@@ -1186,7 +1190,10 @@ void gegl_resample_bilinear (guchar *dest_buf,
{
const Babl *model = babl_format_get_model (format);
const Babl *comp_type = babl_format_get_type (format, 0);
if (gegl_babl_model_is_linear (model))
BablModelFlag model_flags = babl_model_get_flags (model);
if ((model_flags & BABL_MODEL_FLAG_LINEAR)||
(model_flags & BABL_MODEL_FLAG_CMYK))
{
const gint bpp = babl_format_get_bytes_per_pixel (format);
......
......@@ -2095,9 +2095,10 @@ _gegl_buffer_get_unlocked (GeglBuffer *buffer,
CMYK based buffers
*/
const Babl *bfmt = gegl_buffer_get_format (buffer);
const char *babl_name = babl_get_name (bfmt);
if (babl_name[0] == 'c' ||
babl_name[0] == 'C')
const Babl *model = babl_format_get_model (bfmt);
BablModelFlag model_flags = babl_model_get_flags (model);
if (model_flags & BABL_MODEL_FLAG_CMYK)
{
interpolation = GEGL_BUFFER_FILTER_NEAREST;
}
......
......@@ -47,18 +47,6 @@ GEGL_CACHED_BABL(model, y_linear, "Y")
GEGL_CACHED_BABL(model, ya_linear, "YA")
GEGL_CACHED_BABL(model, yA_linear, "YaA")
static inline gboolean gegl_babl_model_is_linear (const Babl *babl)
{
if (babl == gegl_babl_rgba_linear() ||
babl == gegl_babl_rgbA_linear() ||
babl == gegl_babl_rgb_linear() ||
babl == gegl_babl_y_linear() ||
babl == gegl_babl_ya_linear() ||
babl == gegl_babl_yA_linear())
return TRUE;
return FALSE;
}
GEGL_CACHED_BABL(format, rgba_float, "R'G'B'A float")
GEGL_CACHED_BABL(format, rgba_u8, "R'G'B'A u8")
GEGL_CACHED_BABL(format, rgb_u8, "R'G'B' u8")
......
......@@ -85,18 +85,6 @@ GEGL_CACHED_BABL(model, y_linear, "Y")
GEGL_CACHED_BABL(model, ya_linear, "YA")
GEGL_CACHED_BABL(model, yA_linear, "YaA")
static inline gboolean gegl_babl_model_is_linear (const Babl *babl)
{
if (babl == gegl_babl_rgba_linear() ||
babl == gegl_babl_rgbA_linear() ||
babl == gegl_babl_rgb_linear() ||
babl == gegl_babl_y_linear() ||
babl == gegl_babl_ya_linear() ||
babl == gegl_babl_yA_linear())
return TRUE;
return FALSE;
}
GEGL_CACHED_BABL(format, rgba_float, "R'G'B'A float")
GEGL_CACHED_BABL(format, rgba_u8, "R'G'B'A u8")
GEGL_CACHED_BABL(format, rgb_u8, "R'G'B' u8")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment