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:
@ -536,7 +536,7 @@ void
|
|||||||
gimp_display_shell_draw_layer_boundary (GimpDisplayShell *shell,
|
gimp_display_shell_draw_layer_boundary (GimpDisplayShell *shell,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
BoundSeg *segs,
|
GdkSegment *segs,
|
||||||
gint n_segs)
|
gint n_segs)
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
|
@ -51,7 +51,7 @@ void gimp_display_shell_draw_sample_points (GimpDisplayShell *shell,
|
|||||||
void gimp_display_shell_draw_layer_boundary (GimpDisplayShell *shell,
|
void gimp_display_shell_draw_layer_boundary (GimpDisplayShell *shell,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
BoundSeg *segs,
|
GdkSegment *segs,
|
||||||
gint n_segs);
|
gint n_segs);
|
||||||
void gimp_display_shell_draw_vector (GimpDisplayShell *shell,
|
void gimp_display_shell_draw_vector (GimpDisplayShell *shell,
|
||||||
GimpVectors *vectors);
|
GimpVectors *vectors);
|
||||||
|
@ -57,7 +57,7 @@ struct _Selection
|
|||||||
GdkSegment *segs_out; /* gdk segments of area boundary */
|
GdkSegment *segs_out; /* gdk segments of area boundary */
|
||||||
gint n_segs_out; /* number of segments in segs_out */
|
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 */
|
gint n_segs_layer; /* number of segments in segs_layer */
|
||||||
|
|
||||||
guint index; /* index of current stipple pattern */
|
guint index; /* index of current stipple pattern */
|
||||||
@ -91,13 +91,9 @@ static void selection_add_point (GdkPoint *points[8],
|
|||||||
gint y);
|
gint y);
|
||||||
static void selection_render_points (Selection *selection);
|
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,
|
static void selection_transform_segs (Selection *selection,
|
||||||
const BoundSeg *src_segs,
|
const BoundSeg *src_segs,
|
||||||
BoundSeg *dest_segs,
|
GdkSegment *dest_segs,
|
||||||
gint n_segs);
|
gint n_segs);
|
||||||
static void selection_generate_segs (Selection *selection);
|
static void selection_generate_segs (Selection *selection);
|
||||||
static void selection_free_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
|
static void
|
||||||
selection_transform_segs (Selection *selection,
|
selection_transform_segs (Selection *selection,
|
||||||
const BoundSeg *src_segs,
|
const BoundSeg *src_segs,
|
||||||
BoundSeg *dest_segs,
|
GdkSegment *dest_segs,
|
||||||
gint n_segs)
|
gint n_segs)
|
||||||
{
|
{
|
||||||
gint xclamp = selection->shell->disp_width + 1;
|
gint xclamp = selection->shell->disp_width + 1;
|
||||||
@ -642,7 +595,7 @@ selection_transform_segs (Selection *selection,
|
|||||||
* lie outside the region...
|
* lie outside the region...
|
||||||
* we need to transform it by one display pixel
|
* we need to transform it by one display pixel
|
||||||
*/
|
*/
|
||||||
if (! dest_segs[i].open)
|
if (!src_segs[i].open)
|
||||||
{
|
{
|
||||||
/* If it is vertical */
|
/* If it is vertical */
|
||||||
if (dest_segs[i].x1 == dest_segs[i].x2)
|
if (dest_segs[i].x1 == dest_segs[i].x2)
|
||||||
@ -678,8 +631,8 @@ selection_generate_segs (Selection *selection)
|
|||||||
if (selection->n_segs_in)
|
if (selection->n_segs_in)
|
||||||
{
|
{
|
||||||
selection->segs_in = g_new (GdkSegment, selection->n_segs_in);
|
selection->segs_in = g_new (GdkSegment, selection->n_segs_in);
|
||||||
selection_transform_segs_old (selection, segs_in,
|
selection_transform_segs (selection, segs_in,
|
||||||
selection->segs_in, selection->n_segs_in);
|
selection->segs_in, selection->n_segs_in);
|
||||||
|
|
||||||
#ifdef USE_DRAWPOINTS
|
#ifdef USE_DRAWPOINTS
|
||||||
selection_render_points (selection);
|
selection_render_points (selection);
|
||||||
@ -694,8 +647,8 @@ selection_generate_segs (Selection *selection)
|
|||||||
if (selection->n_segs_out)
|
if (selection->n_segs_out)
|
||||||
{
|
{
|
||||||
selection->segs_out = g_new (GdkSegment, selection->n_segs_out);
|
selection->segs_out = g_new (GdkSegment, selection->n_segs_out);
|
||||||
selection_transform_segs_old (selection, segs_out,
|
selection_transform_segs (selection, segs_out,
|
||||||
selection->segs_out, selection->n_segs_out);
|
selection->segs_out, selection->n_segs_out);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -712,7 +665,7 @@ selection_generate_segs (Selection *selection)
|
|||||||
|
|
||||||
if (selection->n_segs_layer)
|
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,
|
selection_transform_segs (selection,
|
||||||
segs,
|
segs,
|
||||||
|
@ -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:
|
* gimp_display_shell_transform_segments:
|
||||||
* @shell: a #GimpDisplayShell
|
* @shell: a #GimpDisplayShell
|
||||||
@ -445,7 +390,7 @@ gimp_display_shell_transform_segments_old (const GimpDisplayShell *shell,
|
|||||||
void
|
void
|
||||||
gimp_display_shell_transform_segments (const GimpDisplayShell *shell,
|
gimp_display_shell_transform_segments (const GimpDisplayShell *shell,
|
||||||
const BoundSeg *src_segs,
|
const BoundSeg *src_segs,
|
||||||
BoundSeg *dest_segs,
|
GdkSegment *dest_segs,
|
||||||
gint n_segs,
|
gint n_segs,
|
||||||
gboolean use_offsets)
|
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].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].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].y2 = CLAMP (y2 - shell->offset_y, G_MININT, G_MAXINT);
|
||||||
|
|
||||||
dest_segs[i].open = src_segs[i].open;
|
|
||||||
dest_segs[i].visited = FALSE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,14 +63,9 @@ void gimp_display_shell_transform_coords (const GimpDisplayShell *shell,
|
|||||||
GdkPoint *disp_coords,
|
GdkPoint *disp_coords,
|
||||||
gint n_coords,
|
gint n_coords,
|
||||||
gboolean use_offsets);
|
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,
|
void gimp_display_shell_transform_segments (const GimpDisplayShell *shell,
|
||||||
const BoundSeg *src_segs,
|
const BoundSeg *src_segs,
|
||||||
BoundSeg *dest_segs,
|
GdkSegment *dest_segs,
|
||||||
gint n_segs,
|
gint n_segs,
|
||||||
gboolean use_offsets);
|
gboolean use_offsets);
|
||||||
|
|
||||||
|
@ -383,8 +383,8 @@ gimp_region_select_tool_calculate (GimpRegionSelectTool *region_sel,
|
|||||||
|
|
||||||
segs = g_new (GdkSegment, *num_segs);
|
segs = g_new (GdkSegment, *num_segs);
|
||||||
|
|
||||||
gimp_display_shell_transform_segments_old (shell, bsegs, segs, *num_segs,
|
gimp_display_shell_transform_segments (shell, bsegs, segs, *num_segs,
|
||||||
! options->sample_merged);
|
! options->sample_merged);
|
||||||
g_free (bsegs);
|
g_free (bsegs);
|
||||||
|
|
||||||
gimp_display_shell_unset_override_cursor (shell);
|
gimp_display_shell_unset_override_cursor (shell);
|
||||||
|
Reference in New Issue
Block a user