[gegl] gegl/buffer: remove some function call overhead from sampler upkeep
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gegl/buffer: remove some function call overhead from sampler upkeep
- Date: Wed, 17 Jan 2018 17:19:44 +0000 (UTC)
commit 995e17f28b820e97ecf5fb73a0172fc419a5a056
Author: Øyvind Kolås <pippin gimp org>
Date: Wed Jan 10 01:19:08 2018 +0100
gegl/buffer: remove some function call overhead from sampler upkeep
gegl/buffer/gegl-sampler.c | 53 ----------------------------------------
gegl/buffer/gegl-sampler.h | 58 ++++++++++++++++++++++++++++++++++++++++---
2 files changed, 54 insertions(+), 57 deletions(-)
---
diff --git a/gegl/buffer/gegl-sampler.c b/gegl/buffer/gegl-sampler.c
index 3428906..9569f3a 100644
--- a/gegl/buffer/gegl-sampler.c
+++ b/gegl/buffer/gegl-sampler.c
@@ -246,59 +246,6 @@ dispose (GObject *gobject)
G_OBJECT_CLASS (gegl_sampler_parent_class)->dispose (gobject);
}
-GeglRectangle _gegl_sampler_compute_rectangle (GeglSampler *sampler,
- gint x,
- gint y,
- gint level_no)
-{
- GeglRectangle rectangle;
- GeglSamplerLevel *level = &sampler->level[level_no];
-
- rectangle.width = level->context_rect.width + 2;
- rectangle.height = level->context_rect.height + 2;
-
- /* grow in direction of prediction */
- if (level->delta_x * level->delta_x >
- level->delta_y * level->delta_y)
- {
- rectangle.width *= 2;
- }
- else
- {
- rectangle.height *= 2;
- }
-
- rectangle.x = x + level->context_rect.x;
- rectangle.y = y + level->context_rect.y;
-
- rectangle.x -= 1;
- rectangle.y -= 1;
- rectangle.width += 2;
- rectangle.height += 2;
-
- //fprintf (stderr, "{%f %f}", level->delta_x, level->delta_y);
-
-#if 1
- /* shift area based on prediction */
- if (level->delta_x >=0.01)
- rectangle.x -= rectangle.width * 0.3;
- if (level->delta_y >=0.01)
- rectangle.y -= rectangle.height * 0.3;
-#endif
-
- if (rectangle.width >= GEGL_SAMPLER_MAXIMUM_WIDTH)
- rectangle.width = GEGL_SAMPLER_MAXIMUM_WIDTH;
- if (rectangle.height >= GEGL_SAMPLER_MAXIMUM_HEIGHT)
- rectangle.height = GEGL_SAMPLER_MAXIMUM_HEIGHT;
-
- if (rectangle.width < level->context_rect.width)
- rectangle.width = level->context_rect.width;
- if (rectangle.height < level->context_rect.height)
- rectangle.height = level->context_rect.height;
-
- return rectangle;
-}
-
gfloat *
gegl_sampler_get_from_mipmap (GeglSampler *sampler,
diff --git a/gegl/buffer/gegl-sampler.h b/gegl/buffer/gegl-sampler.h
index efb9e08..bc2052f 100644
--- a/gegl/buffer/gegl-sampler.h
+++ b/gegl/buffer/gegl-sampler.h
@@ -105,10 +105,60 @@ gfloat * _gegl_sampler_get_ptr (GeglSampler *sampler,
gint y,
GeglAbyssPolicy repeat_mode);
-GeglRectangle _gegl_sampler_compute_rectangle (GeglSampler *sampler,
- gint x,
- gint y,
- gint level);
+static inline GeglRectangle _gegl_sampler_compute_rectangle (
+ GeglSampler *sampler,
+ gint x,
+ gint y,
+ gint level_no)
+{
+ GeglRectangle rectangle;
+ GeglSamplerLevel *level = &sampler->level[level_no];
+
+ rectangle.width = level->context_rect.width + 2;
+ rectangle.height = level->context_rect.height + 2;
+
+ /* grow in direction of prediction */
+ if (level->delta_x * level->delta_x >
+ level->delta_y * level->delta_y)
+ {
+ rectangle.width *= 2;
+ }
+ else
+ {
+ rectangle.height *= 2;
+ }
+
+ rectangle.x = x + level->context_rect.x;
+ rectangle.y = y + level->context_rect.y;
+
+ rectangle.x -= 1;
+ rectangle.y -= 1;
+ rectangle.width += 2;
+ rectangle.height += 2;
+
+ //fprintf (stderr, "{%f %f}", level->delta_x, level->delta_y);
+
+#if 1
+ /* shift area based on prediction */
+ if (level->delta_x >=0.01)
+ rectangle.x -= rectangle.width * 0.3;
+ if (level->delta_y >=0.01)
+ rectangle.y -= rectangle.height * 0.3;
+#endif
+
+ if (rectangle.width >= GEGL_SAMPLER_MAXIMUM_WIDTH)
+ rectangle.width = GEGL_SAMPLER_MAXIMUM_WIDTH;
+ if (rectangle.height >= GEGL_SAMPLER_MAXIMUM_HEIGHT)
+ rectangle.height = GEGL_SAMPLER_MAXIMUM_HEIGHT;
+
+ if (rectangle.width < level->context_rect.width)
+ rectangle.width = level->context_rect.width;
+ if (rectangle.height < level->context_rect.height)
+ rectangle.height = level->context_rect.height;
+
+ return rectangle;
+}
+
/*
* Gets a pointer to the center pixel, within a buffer that has a
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]