buffer: use hot tile under tile_storage lock protection

parent 95adb26c
......@@ -68,6 +68,8 @@ gegl_buffer_get_pixel (GeglBuffer *buffer,
const GeglRectangle *abyss = &buffer->abyss;
guchar *buf = data;
if (y < abyss->y ||
x < abyss->x ||
y >= abyss->y + abyss->height ||
......@@ -113,6 +115,7 @@ gegl_buffer_get_pixel (GeglBuffer *buffer,
}
}
if (gegl_config_threads()>1)
g_rec_mutex_lock (&buffer->tile_storage->mutex);
{
gint tile_width = buffer->tile_width;
......@@ -125,7 +128,6 @@ gegl_buffer_get_pixel (GeglBuffer *buffer,
GeglTile *tile = buffer->tile_storage->hot_tile;
const Babl *fish = NULL;
if (!(tile &&
tile->x == indice_x &&
tile->y == indice_y))
......@@ -160,6 +162,7 @@ gegl_buffer_get_pixel (GeglBuffer *buffer,
}
}
}
if (gegl_config_threads()>1)
g_rec_mutex_unlock (&buffer->tile_storage->mutex);
}
......@@ -179,6 +182,7 @@ __gegl_buffer_set_pixel (GeglBuffer *buffer,
x >= abyss->x + abyss->width)
return;
if (gegl_config_threads()>1)
g_rec_mutex_lock (&buffer->tile_storage->mutex);
{
gint tile_width = buffer->tile_width;
......@@ -232,6 +236,7 @@ __gegl_buffer_set_pixel (GeglBuffer *buffer,
gegl_tile_unlock (tile);
}
}
if (gegl_config_threads()>1)
g_rec_mutex_unlock (&buffer->tile_storage->mutex);
}
......@@ -1319,8 +1324,7 @@ gegl_buffer_set (GeglBuffer *buffer,
if (format == NULL)
format = buffer->soft_format;
if (rect && (rect->width == 1 && rect->height == 1) &&
gegl_config()->threads == 1)
if (rect && (rect->width == 1 && rect->height == 1))
_gegl_buffer_set_pixel (buffer, rect->x, rect->y, format, src,
GEGL_BUFFER_SET_FLAG_LOCK|GEGL_BUFFER_SET_FLAG_NOTIFY);
else
......@@ -1378,7 +1382,7 @@ _gegl_buffer_get_unlocked (GeglBuffer *buffer,
if (format == NULL)
format = buffer->soft_format;
/*
if (scale == 1.0 &&
rect &&
rect->width == 1 &&
......@@ -1387,7 +1391,7 @@ _gegl_buffer_get_unlocked (GeglBuffer *buffer,
gegl_buffer_get_pixel (buffer, rect->x, rect->y, format, dest_buf, repeat_mode);
return;
}
*/
if (gegl_cl_is_accelerated ())
{
gegl_buffer_cl_cache_flush (buffer, rect);
......
......@@ -353,11 +353,18 @@ void
_gegl_buffer_drop_hot_tile (GeglBuffer *buffer)
{
GeglTileStorage *storage = buffer->tile_storage;
if (gegl_config_threads()>1)
g_rec_mutex_lock (&storage->mutex);
if (storage->hot_tile)
{
gegl_tile_unref (storage->hot_tile);
storage->hot_tile = NULL;
}
if (gegl_config_threads()>1)
g_rec_mutex_unlock (&storage->mutex);
}
static void
......
......@@ -84,7 +84,6 @@ gegl_sampler_get_pixel (GeglSampler *sampler,
const GeglRectangle *abyss = &buffer->abyss;
guchar *buf = data;
gegl_buffer_lock (sampler->buffer);
if (y < abyss->y ||
x < abyss->x ||
......@@ -131,6 +130,9 @@ gegl_sampler_get_pixel (GeglSampler *sampler,
}
}
gegl_buffer_lock (sampler->buffer);
g_rec_mutex_lock (&buffer->tile_storage->mutex);
{
gint tile_width = buffer->tile_width;
gint tile_height = buffer->tile_height;
......@@ -164,6 +166,7 @@ gegl_sampler_get_pixel (GeglSampler *sampler,
babl_process (sampler->fish, tp, buf, 1);
}
}
g_rec_mutex_unlock (&buffer->tile_storage->mutex);
gegl_buffer_unlock (sampler->buffer);
}
......
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