buffer: use hot tile under tile_storage lock protection

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