Don't alloc/free saved_points_(lower|higher)_segment on each move, instead
* app/tools/gimpfreeselecttool.c: Don't alloc/free saved_points_(lower|higher)_segment on each move, instead realloc on demand and free on tool destruction, just as we do e.g. for points. svn path=/trunk/; revision=25968
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
2008-06-20 Martin Nordholts <martinn@svn.gnome.org>
|
||||||
|
|
||||||
|
* app/tools/gimpfreeselecttool.c: Don't alloc/free
|
||||||
|
saved_points_(lower|higher)_segment on each move, instead realloc
|
||||||
|
on demand and free on tool destruction, just as we do e.g. for
|
||||||
|
points.
|
||||||
|
|
||||||
2008-06-20 Martin Nordholts <martinn@svn.gnome.org>
|
2008-06-20 Martin Nordholts <martinn@svn.gnome.org>
|
||||||
|
|
||||||
* app/tools/gimpfreeselecttool.c: Remove
|
* app/tools/gimpfreeselecttool.c: Remove
|
||||||
|
@ -72,6 +72,8 @@ typedef struct _Private
|
|||||||
*/
|
*/
|
||||||
GimpVector2 *saved_points_lower_segment;
|
GimpVector2 *saved_points_lower_segment;
|
||||||
GimpVector2 *saved_points_higher_segment;
|
GimpVector2 *saved_points_higher_segment;
|
||||||
|
gint max_n_saved_points_lower_segment;
|
||||||
|
gint max_n_saved_points_higher_segment;
|
||||||
|
|
||||||
/* Keeps track wether or not a modification of the polygon has been
|
/* Keeps track wether or not a modification of the polygon has been
|
||||||
* made between _button_press and _button_release
|
* made between _button_press and _button_release
|
||||||
@ -230,29 +232,31 @@ gimp_free_select_tool_init (GimpFreeSelectTool *fst)
|
|||||||
gimp_tool_control_set_tool_cursor (tool->control,
|
gimp_tool_control_set_tool_cursor (tool->control,
|
||||||
GIMP_TOOL_CURSOR_FREE_SELECT);
|
GIMP_TOOL_CURSOR_FREE_SELECT);
|
||||||
|
|
||||||
priv->grabbed_segment_index = INVALID_INDEX;
|
priv->grabbed_segment_index = INVALID_INDEX;
|
||||||
|
|
||||||
priv->button1_down = FALSE;
|
priv->button1_down = FALSE;
|
||||||
|
|
||||||
priv->saved_points_lower_segment = NULL;
|
priv->saved_points_lower_segment = NULL;
|
||||||
priv->saved_points_higher_segment = NULL;
|
priv->saved_points_higher_segment = NULL;
|
||||||
|
priv->max_n_saved_points_lower_segment = 0;
|
||||||
|
priv->max_n_saved_points_higher_segment = 0;
|
||||||
|
|
||||||
priv->polygon_modified = FALSE;
|
priv->polygon_modified = FALSE;
|
||||||
|
|
||||||
priv->show_pending_point = FALSE;
|
priv->show_pending_point = FALSE;
|
||||||
|
|
||||||
priv->points = NULL;
|
priv->points = NULL;
|
||||||
priv->n_points = 0;
|
priv->n_points = 0;
|
||||||
priv->max_n_points = 0;
|
priv->max_n_points = 0;
|
||||||
|
|
||||||
priv->segment_indices = NULL;
|
priv->segment_indices = NULL;
|
||||||
priv->n_segment_indices = 0;
|
priv->n_segment_indices = 0;
|
||||||
priv->max_n_segment_indices = 0;
|
priv->max_n_segment_indices = 0;
|
||||||
|
|
||||||
priv->constrain_angle = FALSE;
|
priv->constrain_angle = FALSE;
|
||||||
priv->supress_handles = FALSE;
|
priv->supress_handles = FALSE;
|
||||||
|
|
||||||
priv->last_click_time = NO_CLICK_TIME_AVAILABLE;
|
priv->last_click_time = NO_CLICK_TIME_AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -263,6 +267,8 @@ gimp_free_select_tool_finalize (GObject *object)
|
|||||||
|
|
||||||
g_free (priv->points);
|
g_free (priv->points);
|
||||||
g_free (priv->segment_indices);
|
g_free (priv->segment_indices);
|
||||||
|
g_free (priv->saved_points_lower_segment);
|
||||||
|
g_free (priv->saved_points_higher_segment);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@ -293,18 +299,6 @@ gimp_free_select_tool_get_last_point (GimpFreeSelectTool *fst,
|
|||||||
*start_point_y = priv->points[priv->segment_indices[priv->n_segment_indices - 1]].y;
|
*start_point_y = priv->points[priv->segment_indices[priv->n_segment_indices - 1]].y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_free_select_tool_cleanup_after_move (GimpFreeSelectTool *fst)
|
|
||||||
{
|
|
||||||
Private *priv = GET_PRIVATE (fst);
|
|
||||||
|
|
||||||
g_free (priv->saved_points_lower_segment);
|
|
||||||
priv->saved_points_lower_segment = NULL;
|
|
||||||
|
|
||||||
g_free (priv->saved_points_higher_segment);
|
|
||||||
priv->saved_points_higher_segment = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_free_select_tool_get_double_click_settings (gint *double_click_time,
|
gimp_free_select_tool_get_double_click_settings (gint *double_click_time,
|
||||||
gint *double_click_distance)
|
gint *double_click_distance)
|
||||||
@ -925,7 +919,13 @@ gimp_free_select_tool_prepare_for_move (GimpFreeSelectTool *fst)
|
|||||||
priv->grabbed_segment_index - 1,
|
priv->grabbed_segment_index - 1,
|
||||||
priv->grabbed_segment_index);
|
priv->grabbed_segment_index);
|
||||||
|
|
||||||
priv->saved_points_lower_segment = g_new0 (GimpVector2, n_points);
|
if (n_points > priv->max_n_saved_points_lower_segment)
|
||||||
|
{
|
||||||
|
priv->max_n_saved_points_lower_segment = n_points;
|
||||||
|
|
||||||
|
priv->saved_points_lower_segment = g_realloc (priv->saved_points_lower_segment,
|
||||||
|
sizeof (GimpVector2) * n_points);
|
||||||
|
}
|
||||||
|
|
||||||
memcpy (priv->saved_points_lower_segment,
|
memcpy (priv->saved_points_lower_segment,
|
||||||
source,
|
source,
|
||||||
@ -940,7 +940,13 @@ gimp_free_select_tool_prepare_for_move (GimpFreeSelectTool *fst)
|
|||||||
priv->grabbed_segment_index,
|
priv->grabbed_segment_index,
|
||||||
priv->grabbed_segment_index + 1);
|
priv->grabbed_segment_index + 1);
|
||||||
|
|
||||||
priv->saved_points_higher_segment = g_new0 (GimpVector2, n_points);
|
if (n_points > priv->max_n_saved_points_higher_segment)
|
||||||
|
{
|
||||||
|
priv->max_n_saved_points_higher_segment = n_points;
|
||||||
|
|
||||||
|
priv->saved_points_higher_segment = g_realloc (priv->saved_points_higher_segment,
|
||||||
|
sizeof (GimpVector2) * n_points);
|
||||||
|
}
|
||||||
|
|
||||||
memcpy (priv->saved_points_higher_segment,
|
memcpy (priv->saved_points_higher_segment,
|
||||||
source,
|
source,
|
||||||
@ -951,7 +957,13 @@ gimp_free_select_tool_prepare_for_move (GimpFreeSelectTool *fst)
|
|||||||
if (priv->grabbed_segment_index == 0 &&
|
if (priv->grabbed_segment_index == 0 &&
|
||||||
priv->n_segment_indices == 1)
|
priv->n_segment_indices == 1)
|
||||||
{
|
{
|
||||||
priv->saved_points_lower_segment = g_new0 (GimpVector2, 1);
|
if (priv->max_n_saved_points_lower_segment == 0)
|
||||||
|
{
|
||||||
|
priv->max_n_saved_points_lower_segment = 1;
|
||||||
|
|
||||||
|
priv->saved_points_lower_segment = g_new0 (GimpVector2, 1);
|
||||||
|
}
|
||||||
|
|
||||||
*priv->saved_points_lower_segment = priv->points[0];
|
*priv->saved_points_lower_segment = priv->points[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1269,11 +1281,6 @@ gimp_free_select_tool_button_release (GimpTool *tool,
|
|||||||
gimp_free_select_tool_handle_normal_release (fst,
|
gimp_free_select_tool_handle_normal_release (fst,
|
||||||
coords,
|
coords,
|
||||||
display);
|
display);
|
||||||
|
|
||||||
if (priv->polygon_modified)
|
|
||||||
{
|
|
||||||
gimp_free_select_tool_cleanup_after_move (fst);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_BUTTON_RELEASE_CANCEL:
|
case GIMP_BUTTON_RELEASE_CANCEL:
|
||||||
|
Reference in New Issue
Block a user