gdouble gimp_paint_options_get_dynamic_color (GimpPaintOptions *paint_options, const GimpCoords *coords) { gdouble color = 1.0; g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), 1.0); g_return_val_if_fail (coords != NULL, 1.0); if (paint_options->pressure_options->color || paint_options->velocity_options->color || paint_options->random_options->color) { gdouble pressure = -1.0; gdouble velocity = -1.0; gdouble random = -1.0; if (paint_options->pressure_options->color) pressure = GIMP_PAINT_PRESSURE_SCALE * coords->pressure; if (paint_options->velocity_options->color) velocity = GIMP_PAINT_VELOCITY_SCALE * coords->velocity; if (paint_options->random_options->color) random = g_random_double_range (0.0, 1.0); color = gimp_paint_options_get_dynamics_mix (pressure, paint_options->pressure_options->prescale, velocity, paint_options->velocity_options->prescale, random, paint_options->random_options->prescale); } return color; }
GimpBrushApplicationMode gimp_paint_options_get_brush_mode (GimpPaintOptions *paint_options) { GimpDynamics *dynamics; GimpDynamicsOutput *force_output; g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), GIMP_BRUSH_SOFT); if (paint_options->hard) return GIMP_BRUSH_HARD; dynamics = gimp_context_get_dynamics (GIMP_CONTEXT (paint_options)); force_output = gimp_dynamics_get_output (dynamics, GIMP_DYNAMICS_OUTPUT_FORCE); if (!force_output) return GIMP_BRUSH_SOFT; if (gimp_dynamics_output_is_enabled (force_output)) return GIMP_BRUSH_PRESSURE; return GIMP_BRUSH_SOFT; }
gboolean gimp_paint_core_start (GimpPaintCore *core, GimpDrawable *drawable, GimpPaintOptions *paint_options, const GimpCoords *coords, GError **error) { GimpImage *image; GimpItem *item; GimpChannel *mask; g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), FALSE); g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE); g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE); g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), FALSE); g_return_val_if_fail (coords != NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); item = GIMP_ITEM (drawable); image = gimp_item_get_image (item); if (core->stroke_buffer) { g_array_free (core->stroke_buffer, TRUE); core->stroke_buffer = NULL; } core->stroke_buffer = g_array_sized_new (TRUE, TRUE, sizeof (GimpCoords), STROKE_BUFFER_INIT_SIZE); /* remember the last stroke's endpoint for later undo */ core->start_coords = core->last_coords; core->cur_coords = *coords; if (! GIMP_PAINT_CORE_GET_CLASS (core)->start (core, drawable, paint_options, coords, error)) { return FALSE; } /* Allocate the undo structure */ if (core->undo_buffer) g_object_unref (core->undo_buffer); core->undo_buffer = gegl_buffer_dup (gimp_drawable_get_buffer (drawable)); /* Allocate the saved proj structure */ if (core->saved_proj_buffer) { g_object_unref (core->saved_proj_buffer); core->saved_proj_buffer = NULL; } if (core->use_saved_proj) { GeglBuffer *buffer = gimp_pickable_get_buffer (GIMP_PICKABLE (image)); core->saved_proj_buffer = gegl_buffer_dup (buffer); } /* Allocate the canvas blocks structure */ if (core->canvas_buffer) g_object_unref (core->canvas_buffer); core->canvas_buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0, gimp_item_get_width (item), gimp_item_get_height (item)), babl_format ("Y float")); /* Get the initial undo extents */ core->x1 = core->x2 = core->cur_coords.x; core->y1 = core->y2 = core->cur_coords.y; core->last_paint.x = -1e6; core->last_paint.y = -1e6; mask = gimp_image_get_mask (image); /* don't apply the mask to itself and don't apply an empty mask */ if (GIMP_DRAWABLE (mask) != drawable && ! gimp_channel_is_empty (mask)) { GeglBuffer *mask_buffer; gint offset_x; gint offset_y; mask_buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (mask)); gimp_item_get_offset (item, &offset_x, &offset_y); core->mask_buffer = g_object_ref (mask_buffer); core->mask_x_offset = -offset_x; core->mask_y_offset = -offset_y; } else { core->mask_buffer = NULL; } core->linear_mode = gimp_drawable_get_linear (drawable); if (paint_options->use_applicator) { core->applicator = gimp_applicator_new (NULL, core->linear_mode); if (core->mask_buffer) { gimp_applicator_set_mask_buffer (core->applicator, core->mask_buffer); gimp_applicator_set_mask_offset (core->applicator, core->mask_x_offset, core->mask_y_offset); } gimp_applicator_set_affect (core->applicator, gimp_drawable_get_active_mask (drawable)); gimp_applicator_set_dest_buffer (core->applicator, gimp_drawable_get_buffer (drawable)); } else { if (core->comp_buffer) { g_object_unref (core->comp_buffer); core->comp_buffer = NULL; } /* Allocate the scratch buffer if there's a component mask */ if (gimp_drawable_get_active_mask (drawable) != GIMP_COMPONENT_ALL) { const Babl *format; if (core->linear_mode) format = babl_format ("RGBA float"); else format = babl_format ("R'G'B'A float"); core->comp_buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0, gimp_item_get_width (item), gimp_item_get_height (item)), format); } } /* Freeze the drawable preview so that it isn't constantly updated. */ gimp_viewable_preview_freeze (GIMP_VIEWABLE (drawable)); return TRUE; }
gdouble gimp_paint_options_get_fade (GimpPaintOptions *paint_options, GimpImage *image, gdouble pixel_dist) { GimpFadeOptions *fade_options; gdouble z = -1.0; gdouble fade_out = 0.0; gdouble unit_factor; gdouble pos; g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), DYNAMIC_MAX_VALUE); g_return_val_if_fail (GIMP_IS_IMAGE (image), DYNAMIC_MAX_VALUE); fade_options = paint_options->fade_options; switch (fade_options->fade_unit) { case GIMP_UNIT_PIXEL: fade_out = fade_options->fade_length; break; case GIMP_UNIT_PERCENT: fade_out = (MAX (gimp_image_get_width (image), gimp_image_get_height (image)) * fade_options->fade_length / 100); break; default: { gdouble xres; gdouble yres; gimp_image_get_resolution (image, &xres, &yres); unit_factor = gimp_unit_get_factor (fade_options->fade_unit); fade_out = (fade_options->fade_length * MAX (xres, yres) / unit_factor); } break; } /* factor in the fade out value */ if (fade_out > 0.0) { pos = pixel_dist / fade_out; } else pos = DYNAMIC_MAX_VALUE; /* for no repeat, set pos close to 1.0 after the first chunk */ if (fade_options->fade_repeat == GIMP_REPEAT_NONE && pos >= DYNAMIC_MAX_VALUE) pos = DYNAMIC_MAX_VALUE - 0.0000001; if (((gint) pos & 1) && fade_options->fade_repeat != GIMP_REPEAT_SAWTOOTH) pos = DYNAMIC_MAX_VALUE - (pos - (gint) pos); else pos = pos - (gint) pos; z = pos; if (fade_options->fade_reverse) z = 1.0 - z; return z; /* ln (1/255) */ }
gboolean gimp_paint_options_get_gradient_color (GimpPaintOptions *paint_options, GimpImage *image, gdouble grad_point, gdouble pixel_dist, GimpRGB *color) { GimpGradientOptions *gradient_options; GimpGradient *gradient; g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), FALSE); g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE); g_return_val_if_fail (color != NULL, FALSE); gradient_options = paint_options->gradient_options; gradient = gimp_context_get_gradient (GIMP_CONTEXT (paint_options)); if (paint_options->pressure_options->color || paint_options->velocity_options->color || paint_options->random_options->color) { gimp_gradient_get_color_at (gradient, GIMP_CONTEXT (paint_options), NULL, grad_point, gradient_options->gradient_reverse, color); return TRUE; } else if (gradient_options->use_gradient) { gdouble gradient_length = 0.0; gdouble unit_factor; gdouble pos; switch (gradient_options->gradient_unit) { case GIMP_UNIT_PIXEL: gradient_length = gradient_options->gradient_length; break; case GIMP_UNIT_PERCENT: gradient_length = (MAX (gimp_image_get_width (image), gimp_image_get_height (image)) * gradient_options->gradient_length / 100); break; default: { gdouble xres; gdouble yres; gimp_image_get_resolution (image, &xres, &yres); unit_factor = gimp_unit_get_factor (gradient_options->gradient_unit); gradient_length = (gradient_options->gradient_length * MAX (xres, yres) / unit_factor); } break; } if (gradient_length > 0.0) pos = pixel_dist / gradient_length; else pos = 1.0; /* for no repeat, set pos close to 1.0 after the first chunk */ if (gradient_options->gradient_repeat == GIMP_REPEAT_NONE && pos >= 1.0) pos = 0.9999999; if (((gint) pos & 1) && gradient_options->gradient_repeat != GIMP_REPEAT_SAWTOOTH) pos = 1.0 - (pos - (gint) pos); else pos = pos - (gint) pos; gimp_gradient_get_color_at (gradient, GIMP_CONTEXT (paint_options), NULL, pos, gradient_options->gradient_reverse, color); return TRUE; } return FALSE; }
gboolean gimp_paint_core_start (GimpPaintCore *core, GimpDrawable *drawable, GimpPaintOptions *paint_options, const GimpCoords *coords, GError **error) { GimpItem *item; g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), FALSE); g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE); g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE); g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), FALSE); g_return_val_if_fail (coords != NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); item = GIMP_ITEM (drawable); if (core->stroke_buffer) { g_array_free (core->stroke_buffer, TRUE); core->stroke_buffer = NULL; } core->stroke_buffer = g_array_sized_new (TRUE, TRUE, sizeof (GimpCoords), STROKE_BUFFER_INIT_SIZE); core->cur_coords = *coords; if (! GIMP_PAINT_CORE_GET_CLASS (core)->start (core, drawable, paint_options, coords, error)) { return FALSE; } /* Allocate the undo structure */ if (core->undo_buffer) g_object_unref (core->undo_buffer); core->undo_buffer = gegl_buffer_dup (gimp_drawable_get_buffer (drawable)); /* Allocate the saved proj structure */ if (core->saved_proj_buffer) { g_object_unref (core->saved_proj_buffer); core->saved_proj_buffer = NULL; } if (core->use_saved_proj) { GimpImage *image = gimp_item_get_image (item); GimpPickable *pickable = GIMP_PICKABLE (gimp_image_get_projection (image)); GeglBuffer *buffer = gimp_pickable_get_buffer (pickable); core->saved_proj_buffer = gegl_buffer_dup (buffer); } /* Allocate the canvas blocks structure */ if (core->canvas_buffer) g_object_unref (core->canvas_buffer); core->canvas_buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0, gimp_item_get_width (item), gimp_item_get_height (item)), babl_format ("Y u8")); /* Get the initial undo extents */ core->x1 = core->x2 = core->cur_coords.x; core->y1 = core->y2 = core->cur_coords.y; core->last_paint.x = -1e6; core->last_paint.y = -1e6; { GimpImage *image; GimpChannel *mask; GeglBuffer *mask_buffer = NULL; gint offset_x = 0; gint offset_y = 0; image = gimp_item_get_image (item); mask = gimp_image_get_mask (image); /* don't apply the mask to itself and don't apply an empty mask */ if (GIMP_DRAWABLE (mask) == drawable || gimp_channel_is_empty (mask)) mask = NULL; if (mask) { mask_buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (mask)); gimp_item_get_offset (item, &offset_x, &offset_y); } core->applicator = gimp_applicator_new (gimp_drawable_get_buffer (drawable), gimp_drawable_get_active_mask (drawable), mask_buffer, -offset_x, -offset_y); } /* Freeze the drawable preview so that it isn't constantly updated. */ gimp_viewable_preview_freeze (GIMP_VIEWABLE (drawable)); return TRUE; }
static void tool_manager_preset_changed (GimpContext *user_context, GimpToolPreset *preset, GimpToolManager *tool_manager) { GimpToolInfo *preset_tool; gchar *options_name; gboolean tool_change = FALSE; if (! preset || user_context->gimp->busy) return; preset_tool = gimp_context_get_tool (GIMP_CONTEXT (preset->tool_options)); if (preset_tool != gimp_context_get_tool (user_context)) tool_change = TRUE; if (! tool_change) tool_manager_disconnect_options (tool_manager, user_context, preset_tool); /* save the name, we don't want to overwrite it */ options_name = g_strdup (gimp_object_get_name (preset_tool->tool_options)); gimp_config_copy (GIMP_CONFIG (preset->tool_options), GIMP_CONFIG (preset_tool->tool_options), 0); /* restore the saved name */ gimp_object_take_name (GIMP_OBJECT (preset_tool->tool_options), options_name); if (tool_change) gimp_context_set_tool (user_context, preset_tool); else tool_manager_connect_options (tool_manager, user_context, preset_tool); gimp_context_copy_properties (GIMP_CONTEXT (preset->tool_options), user_context, gimp_tool_preset_get_prop_mask (preset)); if (GIMP_IS_PAINT_OPTIONS (preset->tool_options)) { GimpCoreConfig *config = user_context->gimp->config; GimpToolOptions *src = preset->tool_options; GimpToolOptions *dest = tool_manager->active_tool->tool_info->tool_options; /* if connect_options() did overwrite the brush options and the * preset contains a brush, use the brush options from the * preset */ if (config->global_brush && preset->use_brush) gimp_paint_options_copy_brush_props (GIMP_PAINT_OPTIONS (src), GIMP_PAINT_OPTIONS (dest)); if (config->global_dynamics && preset->use_dynamics) gimp_paint_options_copy_dynamics_props (GIMP_PAINT_OPTIONS (src), GIMP_PAINT_OPTIONS (dest)); if (config->global_gradient && preset->use_gradient) gimp_paint_options_copy_gradient_props (GIMP_PAINT_OPTIONS (src), GIMP_PAINT_OPTIONS (dest)); } }
gboolean gimp_paint_core_stroke_boundary (GimpPaintCore *core, GimpDrawable *drawable, GimpPaintOptions *paint_options, gboolean emulate_dynamics, const GimpBoundSeg *bound_segs, gint n_bound_segs, gint offset_x, gint offset_y, gboolean push_undo, GError **error) { GimpBoundSeg *stroke_segs; gint n_stroke_segs; gint off_x; gint off_y; GimpCoords *coords; gboolean initialized = FALSE; gint n_coords; gint seg; gint s; g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), FALSE); g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE); g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE); g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), FALSE); g_return_val_if_fail (bound_segs != NULL && n_bound_segs > 0, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); stroke_segs = gimp_boundary_sort (bound_segs, n_bound_segs, &n_stroke_segs); if (n_stroke_segs == 0) return TRUE; gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y); off_x -= offset_x; off_y -= offset_y; coords = g_new0 (GimpCoords, n_bound_segs + 4); seg = 0; n_coords = 0; /* we offset all coordinates by 0.5 to align the brush with the path */ coords[n_coords] = default_coords; coords[n_coords].x = (gdouble) (stroke_segs[0].x1 - off_x + 0.5); coords[n_coords].y = (gdouble) (stroke_segs[0].y1 - off_y + 0.5); n_coords++; for (s = 0; s < n_stroke_segs; s++) { while (stroke_segs[seg].x1 != -1 || stroke_segs[seg].x2 != -1 || stroke_segs[seg].y1 != -1 || stroke_segs[seg].y2 != -1) { coords[n_coords] = default_coords; coords[n_coords].x = (gdouble) (stroke_segs[seg].x1 - off_x + 0.5); coords[n_coords].y = (gdouble) (stroke_segs[seg].y1 - off_y + 0.5); n_coords++; seg++; } /* Close the stroke points up */ coords[n_coords] = coords[0]; n_coords++; if (emulate_dynamics) gimp_paint_core_stroke_emulate_dynamics (coords, n_coords); if (initialized || gimp_paint_core_start (core, drawable, paint_options, &coords[0], error)) { gint i; initialized = TRUE; core->cur_coords = coords[0]; core->last_coords = coords[0]; gimp_paint_core_paint (core, drawable, paint_options, GIMP_PAINT_STATE_INIT, 0); gimp_paint_core_paint (core, drawable, paint_options, GIMP_PAINT_STATE_MOTION, 0); for (i = 1; i < n_coords; i++) { gimp_paint_core_interpolate (core, drawable, paint_options, &coords[i], 0); } gimp_paint_core_paint (core, drawable, paint_options, GIMP_PAINT_STATE_FINISH, 0); } else { break; } n_coords = 0; seg++; coords[n_coords] = default_coords; coords[n_coords].x = (gdouble) (stroke_segs[seg].x1 - off_x + 0.5); coords[n_coords].y = (gdouble) (stroke_segs[seg].y1 - off_y + 0.5); n_coords++; } if (initialized) { gimp_paint_core_finish (core, drawable, push_undo); gimp_paint_core_cleanup (core); } g_free (coords); g_free (stroke_segs); return initialized; }
gboolean gimp_paint_core_stroke_vectors (GimpPaintCore *core, GimpDrawable *drawable, GimpPaintOptions *paint_options, gboolean emulate_dynamics, GimpVectors *vectors, gboolean push_undo, GError **error) { GList *stroke; gboolean initialized = FALSE; gboolean due_to_lack_of_points = FALSE; gint off_x, off_y; gint vectors_off_x, vectors_off_y; g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), FALSE); g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE); g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE); g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), FALSE); g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); gimp_item_get_offset (GIMP_ITEM (vectors), &vectors_off_x, &vectors_off_y); gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y); off_x -= vectors_off_x; off_y -= vectors_off_y; for (stroke = vectors->strokes; stroke; stroke = stroke->next) { GArray *coords; gboolean closed; coords = gimp_stroke_interpolate (GIMP_STROKE (stroke->data), 1.0, &closed); if (coords && coords->len) { gint i; for (i = 0; i < coords->len; i++) { g_array_index (coords, GimpCoords, i).x -= off_x; g_array_index (coords, GimpCoords, i).y -= off_y; } if (emulate_dynamics) gimp_paint_core_stroke_emulate_dynamics ((GimpCoords *) coords->data, coords->len); if (initialized || gimp_paint_core_start (core, drawable, paint_options, &g_array_index (coords, GimpCoords, 0), error)) { initialized = TRUE; core->cur_coords = g_array_index (coords, GimpCoords, 0); core->last_coords = g_array_index (coords, GimpCoords, 0); gimp_paint_core_paint (core, drawable, paint_options, GIMP_PAINT_STATE_INIT, 0); gimp_paint_core_paint (core, drawable, paint_options, GIMP_PAINT_STATE_MOTION, 0); for (i = 1; i < coords->len; i++) { gimp_paint_core_interpolate (core, drawable, paint_options, &g_array_index (coords, GimpCoords, i), 0); } gimp_paint_core_paint (core, drawable, paint_options, GIMP_PAINT_STATE_FINISH, 0); } else { if (coords) g_array_free (coords, TRUE); break; } } else { due_to_lack_of_points = TRUE; } if (coords) g_array_free (coords, TRUE); } if (initialized) { gimp_paint_core_finish (core, drawable, push_undo); gimp_paint_core_cleanup (core); } if (! initialized && due_to_lack_of_points && *error == NULL) { g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED, _("Not enough points to stroke")); } return initialized; }
static void tool_manager_preset_changed (GimpContext *user_context, GimpToolPreset *preset, GimpToolManager *tool_manager) { GimpToolInfo *preset_tool; gchar *options_name; gboolean tool_change = FALSE; if (! preset || user_context->gimp->busy) return; preset_tool = gimp_context_get_tool (GIMP_CONTEXT (preset->tool_options)); if (preset_tool != gimp_context_get_tool (user_context)) tool_change = TRUE; if (! tool_change) tool_manager_disconnect_options (tool_manager, user_context, preset_tool); /* save the name, we don't want to overwrite it */ options_name = g_strdup (gimp_object_get_name (preset_tool->tool_options)); gimp_config_copy (GIMP_CONFIG (preset->tool_options), GIMP_CONFIG (preset_tool->tool_options), 0); /* restore the saved name */ gimp_object_take_name (GIMP_OBJECT (preset_tool->tool_options), options_name); if (tool_change) gimp_context_set_tool (user_context, preset_tool); else tool_manager_connect_options (tool_manager, user_context, preset_tool); gimp_context_copy_properties (GIMP_CONTEXT (preset->tool_options), user_context, gimp_tool_preset_get_prop_mask (preset)); if (GIMP_IS_PAINT_OPTIONS (preset->tool_options)) { GimpToolOptions *src = preset->tool_options; GimpToolOptions *dest = tool_manager->active_tool->tool_info->tool_options; /* copy various data objects' additional tool options again * manually, they might have been overwritten by e.g. the "link * brush stuff to brush defaults" logic in * gimptooloptions-gui.c */ if (preset->use_brush) gimp_paint_options_copy_brush_props (GIMP_PAINT_OPTIONS (src), GIMP_PAINT_OPTIONS (dest)); if (preset->use_dynamics) gimp_paint_options_copy_dynamics_props (GIMP_PAINT_OPTIONS (src), GIMP_PAINT_OPTIONS (dest)); if (preset->use_gradient) gimp_paint_options_copy_gradient_props (GIMP_PAINT_OPTIONS (src), GIMP_PAINT_OPTIONS (dest)); } }
gboolean gimp_paint_core_start (GimpPaintCore *core, GimpDrawable *drawable, GimpPaintOptions *paint_options, const GimpCoords *coords, GError **error) { GimpItem *item; g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), FALSE); g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE); g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE); g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), FALSE); g_return_val_if_fail (coords != NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); item = GIMP_ITEM (drawable); if (core->stroke_buffer) { g_array_free (core->stroke_buffer, TRUE); core->stroke_buffer = NULL; } core->stroke_buffer = g_array_sized_new (TRUE, TRUE, sizeof (GimpCoords), STROKE_BUFFER_INIT_SIZE); core->cur_coords = *coords; if (! GIMP_PAINT_CORE_GET_CLASS (core)->start (core, drawable, paint_options, coords, error)) { return FALSE; } /* Allocate the undo structure */ if (core->undo_tiles) tile_manager_unref (core->undo_tiles); core->undo_tiles = tile_manager_new (gimp_item_get_width (item), gimp_item_get_height (item), gimp_drawable_bytes (drawable)); /* Allocate the saved proj structure */ if (core->saved_proj_tiles) tile_manager_unref (core->saved_proj_tiles); core->saved_proj_tiles = NULL; if (core->use_saved_proj) { GimpImage *image = gimp_item_get_image (item); GimpPickable *pickable = GIMP_PICKABLE (gimp_image_get_projection (image)); TileManager *tiles = gimp_pickable_get_tiles (pickable); core->saved_proj_tiles = tile_manager_new (tile_manager_width (tiles), tile_manager_height (tiles), tile_manager_bpp (tiles)); } /* Allocate the canvas blocks structure */ if (core->canvas_tiles) tile_manager_unref (core->canvas_tiles); core->canvas_tiles = tile_manager_new (gimp_item_get_width (item), gimp_item_get_height (item), 1); /* Get the initial undo extents */ core->x1 = core->x2 = core->cur_coords.x; core->y1 = core->y2 = core->cur_coords.y; core->last_paint.x = -1e6; core->last_paint.y = -1e6; /* Freeze the drawable preview so that it isn't constantly updated. */ gimp_viewable_preview_freeze (GIMP_VIEWABLE (drawable)); return TRUE; }