[gegl] warp: avoid processing input when the cached output is valid
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] warp: avoid processing input when the cached output is valid
- Date: Wed, 17 May 2017 19:21:20 +0000 (UTC)
commit e8b674b2da891915b75f47d824a4d0ec28e1c462
Author: Ell <ell_se yahoo com>
Date: Wed May 17 11:08:40 2017 -0400
warp: avoid processing input when the cached output is valid
When the previously processed stroke is valid, we pass the cached
buffer directly as output, and don't need the input. Make sure
GEGL doesn't process the op's input for nothing.
OTH, when the processed stroke is invalid, require the entire input,
since the next call to process() is going to cache it.
operations/common/warp.c | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/operations/common/warp.c b/operations/common/warp.c
index ecb630c..ca39fb6 100644
--- a/operations/common/warp.c
+++ b/operations/common/warp.c
@@ -469,6 +469,24 @@ stamp (GeglProperties *o,
priv->last_y = y;
}
+static GeglRectangle
+get_required_for_output (GeglOperation *operation,
+ const gchar *input_pad,
+ const GeglRectangle *output_roi)
+{
+ GeglProperties *o = GEGL_PROPERTIES (operation);
+ WarpPrivate *priv = (WarpPrivate*) o->user_data;
+ GeglRectangle rect = {0, 0, 0, 0};
+
+ /* we only need the input if the processed stroke is invalid, i.e., if
+ * there's work to do; otherwise, we just output the cached buffer directly.
+ */
+ if (! priv->processed_stroke_valid)
+ rect = *gegl_operation_source_get_bounding_box (operation, input_pad);
+
+ return rect;
+}
+
static gboolean
process (GeglOperation *operation,
GeglOperationContext *context,
@@ -629,10 +647,11 @@ gegl_op_class_init (GeglOpClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
- object_class->finalize = finalize;
- operation_class->attach = attach;
- operation_class->prepare = prepare;
- operation_class->process = process;
+ object_class->finalize = finalize;
+ operation_class->attach = attach;
+ operation_class->prepare = prepare;
+ operation_class->get_required_for_output = get_required_for_output;
+ operation_class->process = process;
operation_class->no_cache = TRUE; /* we're effectively doing the caching
* ourselves.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]