Commit bdb32be7 authored by Daniel Sabo's avatar Daniel Sabo

Pixelize: Don't add Alpha to a RGB input

parent e7a8aeaf
......@@ -46,6 +46,8 @@ static void prepare (GeglOperation *operation)
op_area = GEGL_OPERATION_AREA_FILTER (operation);
o = GEGL_CHANT_PROPERTIES (operation);
const Babl *source_format = gegl_operation_get_source_format (operation, "input");
op_area->left =
op_area->right = o->size_x;
op_area->top =
......@@ -53,8 +55,11 @@ static void prepare (GeglOperation *operation)
gegl_operation_set_format (operation, "input",
babl_format ("RaGaBaA float"));
gegl_operation_set_format (operation, "output",
babl_format ("RaGaBaA float"));
if (source_format && !babl_format_has_alpha (source_format))
gegl_operation_set_format (operation, "output", babl_format ("RGB float"));
else
gegl_operation_set_format (operation, "output", babl_format ("RaGaBaA float"));
}
static void
......@@ -221,17 +226,18 @@ cl_process (GeglOperation *operation,
GeglBuffer *output,
const GeglRectangle *roi)
{
const Babl *in_format = gegl_operation_get_format (operation, "input");
const Babl *out_format = gegl_operation_get_format (operation, "output");
const Babl *in_format = babl_format ("RaGaBaA float");
const Babl *out_format = babl_format ("RaGaBaA float");
gboolean has_alpha = babl_format_has_alpha (gegl_operation_get_format (operation, "output"));
GeglAbyssPolicy read_abyss = has_alpha ? GEGL_ABYSS_NONE : GEGL_ABYSS_BLACK;
gint err;
cl_int cl_err;
gint j;
GeglOperationAreaFilter *op_area = GEGL_OPERATION_AREA_FILTER (operation);
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglBufferClIterator *i = gegl_buffer_cl_iterator_new (output, roi, out_format, GEGL_CL_BUFFER_WRITE);
gint read = gegl_buffer_cl_iterator_add_2 (i, input, roi, in_format, GEGL_CL_BUFFER_READ, op_area->left, op_area->right, op_area->top, op_area->bottom, GEGL_ABYSS_NONE);
gint read = gegl_buffer_cl_iterator_add_2 (i, input, roi, in_format, GEGL_CL_BUFFER_READ, op_area->left, op_area->right, op_area->top, op_area->bottom, read_abyss);
gint aux = gegl_buffer_cl_iterator_add_2 (i, NULL, roi, in_format, GEGL_CL_BUFFER_AUX, op_area->left, op_area->right, op_area->top, op_area->bottom, GEGL_ABYSS_NONE);
while (gegl_buffer_cl_iterator_next (i, &err))
{
......@@ -239,7 +245,7 @@ cl_process (GeglOperation *operation,
for (j=0; j < i->n; j++)
{
err = cl_pixelise(i->tex[read][j], i->tex[aux][j], i->tex[0][j],&i->roi[read][j], &i->roi[0][j], o->size_x, o->size_y);
if (cl_err != CL_SUCCESS)
if (err != CL_SUCCESS)
{
g_warning("[OpenCL] Error in gegl:pixelize");
return FALSE;
......@@ -260,6 +266,8 @@ process (GeglOperation *operation,
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglOperationAreaFilter *op_area;
gfloat* buf;
gboolean has_alpha = babl_format_has_alpha (gegl_operation_get_format (operation, "output"));
GeglAbyssPolicy read_abyss = has_alpha ? GEGL_ABYSS_NONE : GEGL_ABYSS_BLACK;
op_area = GEGL_OPERATION_AREA_FILTER (operation);
src_rect = *roi;
......@@ -274,7 +282,7 @@ process (GeglOperation *operation,
buf = g_new0 (gfloat, src_rect.width * src_rect.height * 4);
gegl_buffer_get (input, &src_rect, 1.0, babl_format ("RaGaBaA float"), buf, GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
gegl_buffer_get (input, &src_rect, 1.0, babl_format ("RaGaBaA float"), buf, GEGL_AUTO_ROWSTRIDE, read_abyss);
pixelize(buf, roi, o->size_x, o->size_y);
......
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