gimp r25968 - in trunk: . app/tools
- From: martinn svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25968 - in trunk: . app/tools
- Date: Fri, 20 Jun 2008 12:22:46 +0000 (UTC)
Author: martinn
Date: Fri Jun 20 12:22:46 2008
New Revision: 25968
URL: http://svn.gnome.org/viewvc/gimp?rev=25968&view=rev
Log:
* 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.
Modified:
trunk/ChangeLog
trunk/app/tools/gimpfreeselecttool.c
Modified: trunk/app/tools/gimpfreeselecttool.c
==============================================================================
--- trunk/app/tools/gimpfreeselecttool.c (original)
+++ trunk/app/tools/gimpfreeselecttool.c Fri Jun 20 12:22:46 2008
@@ -72,6 +72,8 @@
*/
GimpVector2 *saved_points_lower_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
* made between _button_press and _button_release
@@ -230,29 +232,31 @@
gimp_tool_control_set_tool_cursor (tool->control,
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_higher_segment = NULL;
+ priv->saved_points_lower_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->n_points = 0;
- priv->max_n_points = 0;
+ priv->points = NULL;
+ priv->n_points = 0;
+ priv->max_n_points = 0;
- priv->segment_indices = NULL;
- priv->n_segment_indices = 0;
- priv->max_n_segment_indices = 0;
+ priv->segment_indices = NULL;
+ priv->n_segment_indices = 0;
+ priv->max_n_segment_indices = 0;
- priv->constrain_angle = FALSE;
- priv->supress_handles = FALSE;
+ priv->constrain_angle = FALSE;
+ priv->supress_handles = FALSE;
- priv->last_click_time = NO_CLICK_TIME_AVAILABLE;
+ priv->last_click_time = NO_CLICK_TIME_AVAILABLE;
}
static void
@@ -263,6 +267,8 @@
g_free (priv->points);
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);
}
@@ -294,18 +300,6 @@
}
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
gimp_free_select_tool_get_double_click_settings (gint *double_click_time,
gint *double_click_distance)
{
@@ -925,7 +919,13 @@
priv->grabbed_segment_index - 1,
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,
source,
@@ -940,7 +940,13 @@
priv->grabbed_segment_index,
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,
source,
@@ -951,7 +957,13 @@
if (priv->grabbed_segment_index == 0 &&
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];
}
}
@@ -1269,11 +1281,6 @@
gimp_free_select_tool_handle_normal_release (fst,
coords,
display);
-
- if (priv->polygon_modified)
- {
- gimp_free_select_tool_cleanup_after_move (fst);
- }
break;
case GIMP_BUTTON_RELEASE_CANCEL:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]