[gegl] buffer: add gegl_tile_handler_damage_rect()
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: add gegl_tile_handler_damage_rect()
- Date: Mon, 2 Apr 2018 11:41:00 +0000 (UTC)
commit f665979d1602136a017f990b7a20072940627fb4
Author: Ell <ell_se yahoo com>
Date: Sat Mar 31 11:59:29 2018 -0400
buffer: add gegl_tile_handler_damage_rect()
Should really be part of the next commit, but splitting the patch
should help with GIMP testing.
gegl/buffer/gegl-tile-handler.c | 71 +++++++++++++++++++++++++++++++++++++++
gegl/buffer/gegl-tile-handler.h | 3 ++
2 files changed, 74 insertions(+), 0 deletions(-)
---
diff --git a/gegl/buffer/gegl-tile-handler.c b/gegl/buffer/gegl-tile-handler.c
index 72f610e..53a9cda 100644
--- a/gegl/buffer/gegl-tile-handler.c
+++ b/gegl/buffer/gegl-tile-handler.c
@@ -19,6 +19,7 @@
#include "config.h"
#include <string.h>
+#include <math.h>
#include <glib-object.h>
@@ -27,6 +28,7 @@
#include "gegl-tile-handler-private.h"
#include "gegl-tile-storage.h"
#include "gegl-buffer-private.h"
+#include "gegl-config.h"
struct _GeglTileHandlerPrivate
{
@@ -222,3 +224,72 @@ gegl_tile_handler_dup_tile (GeglTileHandler *handler,
return tile;
}
+
+void
+gegl_tile_handler_damage_rect (GeglTileHandler *handler,
+ const GeglRectangle *rect)
+{
+ GeglTileSource *source;
+ gint tile_width;
+ gint tile_height;
+ gint X1, Y1;
+ gint X2, Y2;
+ gint x1, y1;
+ gint x2, y2;
+ gint z;
+
+ g_return_if_fail (GEGL_IS_TILE_HANDLER (handler));
+ g_return_if_fail (rect != NULL);
+
+ if (! handler->priv->tile_storage ||
+ ! handler->priv->tile_storage->seen_zoom ||
+ rect->width <= 0 ||
+ rect->height <= 0)
+ {
+ return;
+ }
+
+ source = GEGL_TILE_SOURCE (handler);
+
+ if (gegl_config_threads()>1)
+ g_rec_mutex_lock (&handler->priv->tile_storage->mutex);
+
+ tile_width = handler->priv->tile_storage->tile_width;
+ tile_height = handler->priv->tile_storage->tile_height;
+
+ X1 = rect->x;
+ Y1 = rect->y;
+ X2 = rect->x + rect->width - 1;
+ Y2 = rect->y + rect->height - 1;
+
+ x1 = floor ((gdouble) X1 / tile_width);
+ y1 = floor ((gdouble) Y1 / tile_height);
+ x2 = floor ((gdouble) X2 / tile_width);
+ y2 = floor ((gdouble) Y2 / tile_height);
+
+ for (z = 1; z <= handler->priv->tile_storage->seen_zoom; z++)
+ {
+ gint x, y;
+
+ X1 >>= 1;
+ Y1 >>= 1;
+ X2 >>= 1;
+ Y2 >>= 1;
+
+ x1 >>= 1;
+ y1 >>= 1;
+ x2 >>= 1;
+ y2 >>= 1;
+
+ for (x = x1; x <= x2; x++)
+ {
+ for (y = y1; y <= y2; y++)
+ {
+ gegl_tile_source_void (source, x, y, z);
+ }
+ }
+ }
+
+ if (gegl_config_threads()>1)
+ g_rec_mutex_unlock (&handler->priv->tile_storage->mutex);
+}
diff --git a/gegl/buffer/gegl-tile-handler.h b/gegl/buffer/gegl-tile-handler.h
index 2145274..4a5ab55 100644
--- a/gegl/buffer/gegl-tile-handler.h
+++ b/gegl/buffer/gegl-tile-handler.h
@@ -101,6 +101,9 @@ GeglTile * gegl_tile_handler_dup_tile (GeglTileHandler *handler,
gint y,
gint z);
+void gegl_tile_handler_damage_rect (GeglTileHandler *handler,
+ const GeglRectangle *rect);
+
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]