static GeglRectangle gegl_affine_get_bounding_box (GeglOperation *op) { OpAffine *affine = OP_AFFINE (op); GeglMatrix3 matrix; GeglRectangle in_rect = {0,0,0,0}, have_rect; gdouble have_points [8]; gint i; GeglRectangle context_rect; GeglSampler *sampler; sampler = gegl_buffer_sampler_new (NULL, babl_format("RaGaBaA float"), gegl_sampler_type_from_string (affine->filter)); context_rect = *gegl_sampler_get_context_rect (sampler); g_object_unref (sampler); if (gegl_operation_source_get_bounding_box (op, "input")) in_rect = *gegl_operation_source_get_bounding_box (op, "input"); gegl_affine_create_composite_matrix (affine, &matrix); if (gegl_affine_is_intermediate_node (affine) || gegl_matrix3_is_identity (&matrix)) { return in_rect; } in_rect.x += context_rect.x; in_rect.y += context_rect.y; in_rect.width += context_rect.width; in_rect.height += context_rect.height; have_points [0] = in_rect.x; have_points [1] = in_rect.y; have_points [2] = in_rect.x + in_rect.width ; have_points [3] = in_rect.y; have_points [4] = in_rect.x + in_rect.width ; have_points [5] = in_rect.y + in_rect.height ; have_points [6] = in_rect.x; have_points [7] = in_rect.y + in_rect.height ; for (i = 0; i < 8; i += 2) gegl_matrix3_transform_point (&matrix, have_points + i, have_points + i + 1); gegl_affine_bounding_box (have_points, 4, &have_rect); return have_rect; }
/* Compute the region for which this operation is defined. */ static GeglRectangle get_bounding_box (GeglOperation *operation) { GeglRectangle result = {0,0,0,0}; GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input"); GeglProperties *o = GEGL_PROPERTIES (operation); if (!in_rect){ return result; } if (o->clip) { gegl_rectangle_copy(&result, in_rect); } else { result.x = in_rect->x; result.y = in_rect->y; result.width = result.height = sqrt (in_rect->width * in_rect->width + in_rect->height * in_rect->height) * MAX ((o->o_x + 1), (o->o_y + 1)) * 2; } result.width = result.width * o->output_scale; result.height = result.height * o->output_scale; #ifdef TRACE g_warning ("< get_bounding_box result = %dx%d+%d+%d", result.width, result.height, result.x, result.y); #endif return result; }
/* Pass-through when trying to perform IIR on an infinite plane */ static gboolean operation_process (GeglOperation *operation, GeglOperationContext *context, const gchar *output_prop, const GeglRectangle *result, gint level) { GeglOperationClass *operation_class; GeglProperties *o = GEGL_PROPERTIES (operation); GeglGblur1dFilter filter = filter_disambiguation (o->filter, o->std_dev); operation_class = GEGL_OPERATION_CLASS (gegl_op_parent_class); if (filter == GEGL_GBLUR_1D_IIR) { const GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input"); if (in_rect && gegl_rectangle_is_infinite_plane (in_rect)) { gpointer in = gegl_operation_context_get_object (context, "input"); gegl_operation_context_take_object (context, "output", g_object_ref (G_OBJECT (in))); return TRUE; } } /* chain up, which will create the needed buffers for our actual * process function */ return operation_class->process (operation, context, output_prop, result, gegl_operation_context_get_level (context)); }
static GeglRectangle get_required_for_output (GeglOperation *operation, const gchar *input_pad, const GeglRectangle *roi) { GeglRectangle result = *roi; if (! is_nop (operation)) { GeglProperties *o = GEGL_PROPERTIES (operation); GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input"); if (in_rect) { switch (o->mode) { case GEGL_SPHERIZE_MODE_RADIAL: result = *in_rect; break; case GEGL_SPHERIZE_MODE_HORIZONTAL: result.x = in_rect->x; result.width = in_rect->width; break; case GEGL_SPHERIZE_MODE_VERTICAL: result.y = in_rect->y; result.height = in_rect->height; break; } } } return result; }
static GeglRectangle get_bounding_box (GeglOperation *operation) { GeglProperties *o = GEGL_PROPERTIES (operation); GeglRectangle result = {0,0,0,0}; if (o->width <= 0 || o->height <= 0) { GeglRectangle *in_rect; in_rect = gegl_operation_source_get_bounding_box (operation, "input"); if (in_rect) { result = *in_rect; } else { result.width = 320; result.height = 200; } } else { result.width = o->width; result.height = o->height; } return result; }
static gboolean operation_process (GeglOperation *operation, GeglOperationContext *context, const gchar *output_prop, const GeglRectangle *result, gint level) { GeglOperationClass *operation_class; const GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input"); operation_class = GEGL_OPERATION_CLASS (gegl_op_parent_class); if (in_rect && gegl_rectangle_is_infinite_plane (in_rect)) { gpointer in = gegl_operation_context_get_object (context, "input"); gegl_operation_context_take_object (context, "output", g_object_ref (G_OBJECT (in))); return TRUE; } return operation_class->process (operation, context, output_prop, result, gegl_operation_context_get_level (context)); }
/** * Returns the cached region. This is an area filter, which acts on the whole image. * @param operation given Gegl operation * @param roi the rectangle of interest * @return result the new rectangle */ static GeglRectangle get_cached_region (GeglOperation *operation, const GeglRectangle *roi) { GeglRectangle result = *gegl_operation_source_get_bounding_box (operation, "input"); return result; }
static gboolean is_nop (GeglOperation *operation) { GeglProperties *o = GEGL_PROPERTIES (operation); GeglRectangle *in_rect; if (fabs (o->curvature) < EPSILON || fabs (o->amount) < EPSILON) return TRUE; in_rect = gegl_operation_source_get_bounding_box (operation, "input"); switch (o->mode) { case GEGL_SPHERIZE_MODE_RADIAL: return in_rect->width < 1 || in_rect->height < 1; case GEGL_SPHERIZE_MODE_HORIZONTAL: return in_rect->width < 1; case GEGL_SPHERIZE_MODE_VERTICAL: return in_rect->height < 1; } g_return_val_if_reached (TRUE); }
static GeglRectangle get_bounding_box (GeglOperation *operation) { GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation); GeglRectangle result = { 0, }; GeglRectangle *in_rect; in_rect = gegl_operation_source_get_bounding_box (operation,"input"); if (!in_rect) return result; if (gegl_rectangle_is_infinite_plane (in_rect)) return *in_rect; result = *in_rect; if (result.width != 0 && result.height != 0) { result.x-= area->left; result.y-= area->top; result.width += area->left + area->right; result.height += area->top + area->bottom; } return result; }
static void prepare (GeglOperation *operation) { GeglProperties *o = GEGL_PROPERTIES (operation); const Babl *format = babl_format ("RGBA float"); GeglRectangle *whole_region; AlParamsType *params; if (! o->user_data) o->user_data = g_slice_new0 (AlParamsType); params = (AlParamsType *) o->user_data; whole_region = gegl_operation_source_get_bounding_box (operation, "input"); if (whole_region) { params->a = 0.5 * whole_region->width; params->b = 0.5 * whole_region->height; params->c = MIN (params->a, params->b); params->asqr = params->a * params->a; params->bsqr = params->b * params->b; params->csqr = params->c * params->c; } gegl_color_get_pixel (o->background_color, format, params->bg_color); gegl_operation_set_format (operation, "input", format); gegl_operation_set_format (operation, "output", format); }
static GeglRectangle get_required_for_output (GeglOperation *operation, const gchar *input_pad, const GeglRectangle *roi) { return *gegl_operation_source_get_bounding_box (operation, "input"); }
static GeglRectangle get_required_for_output (GeglOperation *operation, const gchar *input_pad, const GeglRectangle *region) { GeglRectangle result = *gegl_operation_source_get_bounding_box (operation, "input"); return result; }
GeglRectangle gimp_operation_cage_transform_get_bounding_box (GeglOperation *operation) { GeglRectangle result = *gegl_operation_source_get_bounding_box (operation, "input"); return result; }
static GeglRectangle get_effective_area (GeglOperation *operation) { GeglRectangle result = {0,0,0,0}; GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input"); gegl_rectangle_copy(&result, in_rect); return result; }
static GeglRectangle get_required_for_output (GeglOperation *operation, const gchar *input_pad, const GeglRectangle *roi) { GeglRectangle result = *gegl_operation_source_get_bounding_box (operation, "input"); if (gegl_rectangle_is_infinite_plane (&result)) return *roi; return result; }
GeglRectangle gimp_operation_cage_transform_get_required_for_output (GeglOperation *operation, const gchar *input_pad, const GeglRectangle *roi) { GeglRectangle result = *gegl_operation_source_get_bounding_box (operation, "input"); return result; }
static GeglRectangle get_bounding_box (GeglOperation *operation) { GeglRectangle result = {0,0,0,0}; GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input"); if (!in_rect) return result; return *in_rect; }
static GeglRectangle get_bounding_box (GeglOperation *self) { GeglRectangle result = { 0, 0, 0, 0 }; GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (self, "input"); GeglRectangle *aux_rect = gegl_operation_source_get_bounding_box (self, "aux"); GeglRectangle *aux2_rect = gegl_operation_source_get_bounding_box (self, "aux2"); if (in_rect) result = *in_rect; if (aux_rect) gegl_rectangle_bounding_box (&result, &result, aux_rect); if (aux2_rect) gegl_rectangle_bounding_box (&result, &result, aux2_rect); return result; }
static GeglRectangle get_cached_region (GeglOperation *operation, const GeglRectangle *output_roi) { GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input"); if (in_rect) return *in_rect; else return (GeglRectangle){0, 0, 0, 0}; }
static GeglRectangle get_cached_region (GeglOperation *self, const GeglRectangle *roi) { GeglProperties *o = GEGL_PROPERTIES (self); if (o->dither_strategy == GEGL_DITHER_FLOYD_STEINBERG) return *gegl_operation_source_get_bounding_box (self, "input"); else return *roi; }
static GeglRectangle get_cached_region (GeglOperation *operation, const GeglRectangle *roi) { GeglRectangle result = *gegl_operation_source_get_bounding_box (operation, "input"); if (gegl_rectangle_is_infinite_plane (&result)) return *roi; return result; }
static GeglRectangle get_required_for_output (GeglOperation *self, const gchar *input_pad, const GeglRectangle *roi) { GeglProperties *o = GEGL_PROPERTIES (self); if (o->dither_method == GEGL_DITHER_FLOYD_STEINBERG) return *gegl_operation_source_get_bounding_box (self, "input"); else return *roi; }
static GeglRectangle get_required_for_output (GeglOperation *operation, const gchar *input_pad, const GeglRectangle *output_roi) { GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, input_pad); if (in_rect) return *in_rect; else return (GeglRectangle){0, 0, 0, 0}; }
static GeglRectangle get_bounding_box (GeglOperation *operation) { GeglRectangle *region; region = gegl_operation_source_get_bounding_box (operation, "input"); if (region != NULL) return *region; else return *GEGL_RECTANGLE (0, 0, 0, 0); }
static GeglRectangle get_required_for_output (GeglOperation *operation, const gchar *input_pad, const GeglRectangle *roi) { GeglRectangle result = {0,0,0,0}; GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input"); if (!in_rect) return result; else return *in_rect; }
static void create_matrix (OpTransform *op, GeglMatrix3 *matrix) { GeglProperties *o = GEGL_PROPERTIES (op); GeglOperation *operation = GEGL_OPERATION (op); GeglRectangle in_rect = {0,0,0,0}; gdouble height_over_width = 1.0; if (gegl_operation_source_get_bounding_box (operation, "input")) in_rect = *gegl_operation_source_get_bounding_box (operation, "input"); // Avoid divide-by-zero if(in_rect.width < 1) in_rect.width = 1; if(in_rect.height < 1) in_rect.height = 1; height_over_width = in_rect.height/(gdouble)in_rect.width; if (o->x <= 0.0 && o->y <= 0.0) { // No dimensions specified, pass through matrix->coeff [0][0] = 1.0; matrix->coeff [1][1] = 1.0; } else if (o->x <= 0.0 && o->y > 0.0) { // X free, Y specified const gdouble target_x = o->y / height_over_width; matrix->coeff [0][0] = target_x / (gdouble) in_rect.width; matrix->coeff [1][1] = o->y / (gdouble) in_rect.height; } else if (o->y <= 0.0 && o->x > 0.0) { // Y free, X specified const gdouble target_y = o->x * height_over_width; matrix->coeff [0][0] = o->x / (gdouble) in_rect.width; matrix->coeff [1][1] = target_y / (gdouble) in_rect.height; } else { // Fully specified matrix->coeff [0][0] = o->x / (gdouble) in_rect.width; matrix->coeff [1][1] = o->y / (gdouble) in_rect.height; } }
static void prepare_transform2 (Transform *transform, GeglOperation *operation, gint level) { gint factor = 1 << level; GeglProperties *o = GEGL_PROPERTIES (operation); GeglRectangle in_rect = *gegl_operation_source_get_bounding_box (operation, "input"); prepare_transform (transform, o->pan, o->spin, o->zoom, o->tilt, o->little_planet, o->width / factor, o->height / factor, in_rect.width, in_rect.height); }
static GeglRectangle get_required_for_output (GeglOperation *self, const gchar *input_pad, const GeglRectangle *roi) { GeglRectangle request = *roi; if (!strcmp (input_pad, "aux")) { GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (self, "input"); GeglRectangle *aux_rect = gegl_operation_source_get_bounding_box (self, "aux"); if (request.width != 0 && request.height != 0) { request.x -= in_rect->width + aux_rect->x; } } return request; }
static GeglRectangle get_bounding_box (GeglOperation *operation) { GeglRectangle result = {0,0,0,0}; GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input"); GeglRectangle *aux_rect = gegl_operation_source_get_bounding_box (operation, "aux"); if (!in_rect || !aux_rect) return result; result = *in_rect; if (result.width != 0 && result.height != 0) { result.width += aux_rect->width; if (aux_rect->height > result.height) result.height = aux_rect->height; } return result; }
static gboolean process (GeglOperation *operation, GeglBuffer *input, const GeglRectangle *result, gint level) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); if (o->pixbuf) { GdkPixbuf **pixbuf = o->pixbuf; const Babl *babl; const Babl *format; guchar *temp; GeglRectangle *rect = gegl_operation_source_get_bounding_box (operation, "input"); gchar *name; gboolean has_alpha; gint bps; g_object_get (input, "format", &format, NULL); has_alpha = babl_format_has_alpha (format); /* pixbuf from data only support 8bit bps */ bps = 8; name = g_strdup_printf ("R'G'B'%s u%i", has_alpha ? "A" : "", bps); babl = babl_format (name); temp = g_malloc (rect->width * rect->height * bps); gegl_buffer_get (input, rect, 1.0, babl, temp, GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE); if (temp) { *pixbuf = gdk_pixbuf_new_from_data (temp, GDK_COLORSPACE_RGB, has_alpha, bps, rect->width, rect->height, rect->width * (has_alpha ? 4 : 3) * bps/8, (GdkPixbufDestroyNotify) g_free, NULL); } else { g_warning (G_STRLOC ": inexistant data, unable to create GdkPixbuf."); } g_free (name); } return TRUE; }