app: undo some of the previous refactorings and keep using GdkSegment

It's not going to be deprecated, so there is no harm in using it; get
rid of all the added _old() functions too.
This commit is contained in:
Michael Natterer 2010-08-25 21:21:16 +02:00
parent d73f088408
commit cd192adf09
6 changed files with 15 additions and 125 deletions

View File

@ -536,7 +536,7 @@ void
gimp_display_shell_draw_layer_boundary (GimpDisplayShell *shell,
cairo_t *cr,
GimpDrawable *drawable,
BoundSeg *segs,
GdkSegment *segs,
gint n_segs)
{
gint i;

View File

@ -51,7 +51,7 @@ void gimp_display_shell_draw_sample_points (GimpDisplayShell *shell,
void gimp_display_shell_draw_layer_boundary (GimpDisplayShell *shell,
cairo_t *cr,
GimpDrawable *drawable,
BoundSeg *segs,
GdkSegment *segs,
gint n_segs);
void gimp_display_shell_draw_vector (GimpDisplayShell *shell,
GimpVectors *vectors);

View File

@ -57,7 +57,7 @@ struct _Selection
GdkSegment *segs_out; /* gdk segments of area boundary */
gint n_segs_out; /* number of segments in segs_out */
BoundSeg *segs_layer; /* segments of layer boundary */
GdkSegment *segs_layer; /* segments of layer boundary */
gint n_segs_layer; /* number of segments in segs_layer */
guint index; /* index of current stipple pattern */
@ -91,13 +91,9 @@ static void selection_add_point (GdkPoint *points[8],
gint y);
static void selection_render_points (Selection *selection);
static void selection_transform_segs_old (Selection *selection,
const BoundSeg *src_segs,
GdkSegment *dest_segs,
gint n_segs);
static void selection_transform_segs (Selection *selection,
const BoundSeg *src_segs,
BoundSeg *dest_segs,
GdkSegment *dest_segs,
gint n_segs);
static void selection_generate_segs (Selection *selection);
static void selection_free_segs (Selection *selection);
@ -573,53 +569,10 @@ selection_render_points (Selection *selection)
}
}
static void
selection_transform_segs_old (Selection *selection,
const BoundSeg *src_segs,
GdkSegment *dest_segs,
gint n_segs)
{
gint xclamp = selection->shell->disp_width + 1;
gint yclamp = selection->shell->disp_height + 1;
gint i;
gimp_display_shell_transform_segments_old (selection->shell,
src_segs, dest_segs, n_segs, FALSE);
for (i = 0; i < n_segs; i++)
{
dest_segs[i].x1 = CLAMP (dest_segs[i].x1, -1, xclamp);
dest_segs[i].y1 = CLAMP (dest_segs[i].y1, -1, yclamp);
dest_segs[i].x2 = CLAMP (dest_segs[i].x2, -1, xclamp);
dest_segs[i].y2 = CLAMP (dest_segs[i].y2, -1, yclamp);
/* If this segment is a closing segment && the segments lie inside
* the region, OR if this is an opening segment and the segments
* lie outside the region...
* we need to transform it by one display pixel
*/
if (!src_segs[i].open)
{
/* If it is vertical */
if (dest_segs[i].x1 == dest_segs[i].x2)
{
dest_segs[i].x1 -= 1;
dest_segs[i].x2 -= 1;
}
else
{
dest_segs[i].y1 -= 1;
dest_segs[i].y2 -= 1;
}
}
}
}
static void
selection_transform_segs (Selection *selection,
const BoundSeg *src_segs,
BoundSeg *dest_segs,
GdkSegment *dest_segs,
gint n_segs)
{
gint xclamp = selection->shell->disp_width + 1;
@ -642,7 +595,7 @@ selection_transform_segs (Selection *selection,
* lie outside the region...
* we need to transform it by one display pixel
*/
if (! dest_segs[i].open)
if (!src_segs[i].open)
{
/* If it is vertical */
if (dest_segs[i].x1 == dest_segs[i].x2)
@ -678,8 +631,8 @@ selection_generate_segs (Selection *selection)
if (selection->n_segs_in)
{
selection->segs_in = g_new (GdkSegment, selection->n_segs_in);
selection_transform_segs_old (selection, segs_in,
selection->segs_in, selection->n_segs_in);
selection_transform_segs (selection, segs_in,
selection->segs_in, selection->n_segs_in);
#ifdef USE_DRAWPOINTS
selection_render_points (selection);
@ -694,8 +647,8 @@ selection_generate_segs (Selection *selection)
if (selection->n_segs_out)
{
selection->segs_out = g_new (GdkSegment, selection->n_segs_out);
selection_transform_segs_old (selection, segs_out,
selection->segs_out, selection->n_segs_out);
selection_transform_segs (selection, segs_out,
selection->segs_out, selection->n_segs_out);
}
else
{
@ -712,7 +665,7 @@ selection_generate_segs (Selection *selection)
if (selection->n_segs_layer)
{
selection->segs_layer = g_new (BoundSeg, selection->n_segs_layer);
selection->segs_layer = g_new (GdkSegment, selection->n_segs_layer);
selection_transform_segs (selection,
segs,

View File

@ -375,61 +375,6 @@ gimp_display_shell_transform_coords (const GimpDisplayShell *shell,
}
}
/**
* gimp_display_shell_transform_segments_old:
* @shell: a #GimpDisplayShell
* @src_segs: array of segments in image coordinates
* @dest_segs: returns the corresponding segments in display coordinates
* @n_segs: number of segments
* @use_offsets: if %TRUE, the source coordinates are in the coordinate
* system of the active drawable instead of the image
*
* Transforms from image coordinates to display coordinates, so that
* objects can be rendered at the correct points on the display.
**/
void
gimp_display_shell_transform_segments_old (const GimpDisplayShell *shell,
const BoundSeg *src_segs,
GdkSegment *dest_segs,
gint n_segs,
gboolean use_offsets)
{
gint offset_x = 0;
gint offset_y = 0;
gint i;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (use_offsets)
{
GimpImage *image = gimp_display_get_image (shell->display);
GimpItem *item = GIMP_ITEM (gimp_image_get_active_drawable (image));
gimp_item_get_offset (item, &offset_x, &offset_y);
}
for (i = 0; i < n_segs ; i++)
{
gint64 x1, x2;
gint64 y1, y2;
x1 = src_segs[i].x1 + offset_x;
x2 = src_segs[i].x2 + offset_x;
y1 = src_segs[i].y1 + offset_y;
y2 = src_segs[i].y2 + offset_y;
x1 = (x1 * shell->x_src_dec) / shell->x_dest_inc;
x2 = (x2 * shell->x_src_dec) / shell->x_dest_inc;
y1 = (y1 * shell->y_src_dec) / shell->y_dest_inc;
y2 = (y2 * shell->y_src_dec) / shell->y_dest_inc;
dest_segs[i].x1 = CLAMP (x1 - shell->offset_x, G_MININT, G_MAXINT);
dest_segs[i].x2 = CLAMP (x2 - shell->offset_x, G_MININT, G_MAXINT);
dest_segs[i].y1 = CLAMP (y1 - shell->offset_y, G_MININT, G_MAXINT);
dest_segs[i].y2 = CLAMP (y2 - shell->offset_y, G_MININT, G_MAXINT);
}
}
/**
* gimp_display_shell_transform_segments:
* @shell: a #GimpDisplayShell
@ -445,7 +390,7 @@ gimp_display_shell_transform_segments_old (const GimpDisplayShell *shell,
void
gimp_display_shell_transform_segments (const GimpDisplayShell *shell,
const BoundSeg *src_segs,
BoundSeg *dest_segs,
GdkSegment *dest_segs,
gint n_segs,
gboolean use_offsets)
{
@ -482,9 +427,6 @@ gimp_display_shell_transform_segments (const GimpDisplayShell *shell,
dest_segs[i].x2 = CLAMP (x2 - shell->offset_x, G_MININT, G_MAXINT);
dest_segs[i].y1 = CLAMP (y1 - shell->offset_y, G_MININT, G_MAXINT);
dest_segs[i].y2 = CLAMP (y2 - shell->offset_y, G_MININT, G_MAXINT);
dest_segs[i].open = src_segs[i].open;
dest_segs[i].visited = FALSE;
}
}

View File

@ -63,14 +63,9 @@ void gimp_display_shell_transform_coords (const GimpDisplayShell *shell,
GdkPoint *disp_coords,
gint n_coords,
gboolean use_offsets);
void gimp_display_shell_transform_segments_old (const GimpDisplayShell *shell,
const BoundSeg *src_segs,
GdkSegment *dest_segs,
gint n_segs,
gboolean use_offsets);
void gimp_display_shell_transform_segments (const GimpDisplayShell *shell,
const BoundSeg *src_segs,
BoundSeg *dest_segs,
GdkSegment *dest_segs,
gint n_segs,
gboolean use_offsets);

View File

@ -383,8 +383,8 @@ gimp_region_select_tool_calculate (GimpRegionSelectTool *region_sel,
segs = g_new (GdkSegment, *num_segs);
gimp_display_shell_transform_segments_old (shell, bsegs, segs, *num_segs,
! options->sample_merged);
gimp_display_shell_transform_segments (shell, bsegs, segs, *num_segs,
! options->sample_merged);
g_free (bsegs);
gimp_display_shell_unset_override_cursor (shell);