Commit eaf72ddb authored by Daniel Sabo's avatar Daniel Sabo

Enable the scale parameter of gegl_node_blit

parent bbc65d17
......@@ -1444,6 +1444,42 @@ resample_boxfilter_T (guchar *dest_buf,
}
}
/* Expand roi by scale so it uncludes all pixels needed
* to satisfy a gegl_buffer_get() call at level 0.
*/
GeglRectangle
_gegl_get_required_for_scale (const Babl *format,
const GeglRectangle *roi,
gdouble scale)
{
if (GEGL_FLOAT_EQUAL (scale, 1.0))
return *roi;
else
{
gint x1 = floor (roi->x / scale + EPSILON);
gint x2 = ceil ((roi->x + roi->width) / scale - EPSILON);
gint y1 = floor (roi->y / scale + EPSILON);
gint y2 = ceil ((roi->y + roi->height) / scale - EPSILON);
gint pad = (1.0 / scale > 1.0) ? ceil (1.0 / scale) : 1;
if ((babl_format_get_type (format, 0) == projectionT) ||
(scale < 1.0))
{
return *GEGL_RECTANGLE (x1 - pad,
y1 - pad,
x2 - x1 + 2 * pad,
y2 - y1 + 2 * pad);
}
else
{
return *GEGL_RECTANGLE (x1,
y1,
x2 - x1,
y2 - y1);
}
}
}
void
gegl_buffer_get_unlocked (GeglBuffer *buffer,
......
......@@ -186,6 +186,10 @@ struct _GeglTile
void _gegl_buffer_drop_hot_tile (GeglBuffer *buffer);
GeglRectangle _gegl_get_required_for_scale (const Babl *format,
const GeglRectangle *roi,
gdouble scale);
gboolean gegl_buffer_scan_compatible (GeglBuffer *bufferA,
gint xA,
gint yA,
......
......@@ -925,25 +925,24 @@ gegl_node_blit (GeglNode *self,
{
GeglBuffer *buffer;
buffer = gegl_node_apply_roi (self, roi);
if (buffer && destination_buf)
if (scale != 1.0)
{
if (destination_buf)
{
gegl_buffer_get (buffer, roi, 1.0, format, destination_buf, rowstride, GEGL_ABYSS_NONE);
}
const GeglRectangle unscaled_roi = _gegl_get_required_for_scale (format, roi, scale);
if (scale != 1.0)
{
g_warning ("scale %f=1.0 in blit without cache", scale);
}
buffer = gegl_node_apply_roi (self, &unscaled_roi);
}
else
{
buffer = gegl_node_apply_roi (self, roi);
}
if (buffer && destination_buf)
gegl_buffer_get (buffer, roi, scale, format, destination_buf, rowstride, GEGL_ABYSS_NONE);
if (buffer)
g_object_unref (buffer);
}
else
if ((flags & GEGL_BLIT_CACHE))
else if (flags & GEGL_BLIT_CACHE)
{
GeglCache *cache = gegl_node_get_cache (self);
if (!(flags & GEGL_BLIT_DIRTY))
......
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