|
Packit Service |
2781ba |
/* This file is part of GEGL
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* GEGL is free software; you can redistribute it and/or
|
|
Packit Service |
2781ba |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
2781ba |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
2781ba |
* version 3 of the License, or (at your option) any later version.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* GEGL is distributed in the hope that it will be useful,
|
|
Packit Service |
2781ba |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
2781ba |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
2781ba |
* Lesser General Public License for more details.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
2781ba |
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Copyright 2006 Øyvind Kolås
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "config.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include <glib-object.h>
|
|
Packit Service |
2781ba |
#include <string.h>
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "gegl.h"
|
|
Packit Service |
2781ba |
#include "gegl-debug.h"
|
|
Packit Service |
2781ba |
#include "gegl-types-internal.h"
|
|
Packit Service |
2781ba |
#include "gegl-need-visitor.h"
|
|
Packit Service |
2781ba |
#include "operation/gegl-operation.h"
|
|
Packit Service |
2781ba |
#include "operation/gegl-operation-context.h"
|
|
Packit Service |
2781ba |
#include "graph/gegl-node.h"
|
|
Packit Service |
2781ba |
#include "graph/gegl-pad.h"
|
|
Packit Service |
2781ba |
#include "graph/gegl-visitable.h"
|
|
Packit Service |
2781ba |
#include "gegl-utils.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void gegl_need_visitor_class_init (GeglNeedVisitorClass *klass);
|
|
Packit Service |
2781ba |
static void gegl_need_visitor_visit_node (GeglVisitor *self,
|
|
Packit Service |
2781ba |
GeglNode *node);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
G_DEFINE_TYPE (GeglNeedVisitor, gegl_need_visitor, GEGL_TYPE_VISITOR)
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_need_visitor_class_init (GeglNeedVisitorClass *klass)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglVisitorClass *visitor_class = GEGL_VISITOR_CLASS (klass);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
visitor_class->visit_node = gegl_need_visitor_visit_node;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_need_visitor_init (GeglNeedVisitor *self)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
/* sets the context's result_rect and refs */
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_need_visitor_visit_node (GeglVisitor *self,
|
|
Packit Service |
2781ba |
GeglNode *node)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglOperationContext *context = gegl_node_get_context (node, self->context_id);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
GEGL_VISITOR_CLASS (gegl_need_visitor_parent_class)->visit_node (self, node);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_operation_calc_need_rects (node->operation, self->context_id);
|
|
Packit Service |
2781ba |
if (!context->cached)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
gegl_rectangle_intersect (&context->result_rect, &node->have_rect, &context->need_rect);
|
|
Packit Service |
2781ba |
/* here we expand to the size requested by the operation to be cached */
|
|
Packit Service |
2781ba |
context->result_rect = gegl_operation_get_cached_region (node->operation, &context->result_rect);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
GEGL_NOTE (GEGL_DEBUG_PROCESS,
|
|
Packit Service |
2781ba |
"For \"%s\" have_rect = %d, %d %d×%d need_rect = %d, %d %d×%d result_rect = %d, %d %d×%d",
|
|
Packit Service |
2781ba |
gegl_node_get_debug_name (node),
|
|
Packit Service |
2781ba |
node->have_rect.x, node->have_rect.y, node->have_rect.width, node->have_rect.height,
|
|
Packit Service |
2781ba |
context->need_rect.x, context->need_rect.y, context->need_rect.width, context->need_rect.height,
|
|
Packit Service |
2781ba |
context->result_rect.x, context->result_rect.y, context->result_rect.width, context->result_rect.height);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
context->refs = gegl_node_get_num_sinks (node);
|
|
Packit Service |
2781ba |
}
|