API: remove gdk_draw_{line,lines,segments}

Those were the 3 intermixed line drawing calls.
This commit is contained in:
Benjamin Otte 2010-07-15 17:58:50 +02:00
parent c661eb73a1
commit a9e99e7f5b
13 changed files with 0 additions and 893 deletions

View File

@ -336,10 +336,6 @@ gdk_drawable_get_visible_region
<SUBSECTION>
gdk_draw_point
gdk_draw_points
gdk_draw_line
gdk_draw_lines
gdk_draw_segments
GdkSegment
gdk_draw_rectangle
gdk_draw_layout_line
gdk_draw_layout_line_with_colors

View File

@ -147,50 +147,6 @@ or a #GdkWindow.
@n_points:
<!-- ##### FUNCTION gdk_draw_line ##### -->
<para>
</para>
@drawable:
@gc:
@x1_:
@y1_:
@x2_:
@y2_:
<!-- ##### FUNCTION gdk_draw_lines ##### -->
<para>
</para>
@drawable:
@gc:
@points:
lines.
@n_points:
<!-- ##### FUNCTION gdk_draw_segments ##### -->
<para>
</para>
@drawable:
@gc:
@segs:
@n_segs:
<!-- ##### STRUCT GdkSegment ##### -->
<para>
Specifies the start and end point of a line for use by the gdk_draw_segments()
function.
</para>
@x1: the x coordinate of the start point.
@y1: the y coordinate of the start point.
@x2: the x coordinate of the end point.
@y2: the y coordinate of the end point.
<!-- ##### FUNCTION gdk_draw_rectangle ##### -->
<para>
</para>

View File

@ -117,10 +117,6 @@ do {\
static GdkScreen * gdk_directfb_get_screen (GdkDrawable *drawable);
static void gdk_drawable_impl_directfb_class_init (GdkDrawableImplDirectFBClass *klass);
static void gdk_directfb_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints);
static cairo_surface_t *gdk_directfb_ref_cairo_surface (GdkDrawable *drawable);
@ -657,151 +653,6 @@ gdk_directfb_draw_points (GdkDrawable *drawable,
temp_region_deinit( &clip );
}
static void
gdk_directfb_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs)
{
GdkDrawableImplDirectFB *impl;
cairo_region_t clip;
gint i;
// DFBRegion region = { segs->x1, segs->y1, segs->x2, segs->y2 };
D_DEBUG_AT( GDKDFB_Drawable, "%s( %p, %p, %p, %d )\n", G_STRFUNC, drawable, gc, segs, nsegs );
if (nsegs < 1)
return;
impl = GDK_DRAWABLE_IMPL_DIRECTFB (drawable);
if (!gdk_directfb_setup_for_drawing (impl, GDK_GC_DIRECTFB (gc)))
return;
gdk_directfb_clip_region (drawable, gc, NULL, &clip);
for (i = 0; i < clip.numRects; i++)
{
DFBRegion reg = { clip.rects[i].x1, clip.rects[i].y1,
clip.rects[i].x2, clip.rects[i].y2 };
impl->surface->SetClip (impl->surface, &reg);
impl->surface->DrawLines (impl->surface, (DFBRegion *)segs, nsegs);
}
temp_region_deinit( &clip );
/* everything below can be omitted if the drawing is buffered */
/* if (impl->buffered)
return;
if (region.x1 > region.x2)
{
region.x1 = segs->x2;
region.x2 = segs->x1;
}
if (region.y1 > region.y2)
{
region.y1 = segs->y2;
region.y2 = segs->y1;
}
while (nsegs > 1)
{
nsegs--;
segs++;
if (segs->x1 < region.x1)
region.x1 = segs->x1;
if (segs->x2 < region.x1)
region.x1 = segs->x2;
if (segs->y1 < region.y1)
region.y1 = segs->y1;
if (segs->y2 < region.y1)
region.y1 = segs->y2;
if (segs->x1 > region.x2)
region.x2 = segs->x1;
if (segs->x2 > region.x2)
region.x2 = segs->x2;
if (segs->y1 > region.y2)
region.y2 = segs->y1;
if (segs->y2 > region.y2)
region.y2 = segs->y2;
}*/
}
static void
gdk_directfb_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
GdkDrawableImplDirectFB *impl;
cairo_region_t clip;
gint i;
DFBRegion lines[npoints > 1 ? npoints - 1 : 1];
DFBRegion region = { points->x, points->y, points->x, points->y };
D_DEBUG_AT( GDKDFB_Drawable, "%s( %p, %p, %p, %d )\n", G_STRFUNC, drawable, gc, points, npoints );
if (npoints < 2)
return;
impl = GDK_DRAWABLE_IMPL_DIRECTFB (drawable);
if (!gdk_directfb_setup_for_drawing (impl, GDK_GC_DIRECTFB (gc)))
return;
/* create an array of DFBRegions so we can use DrawLines */
lines[0].x1 = points->x;
lines[0].y1 = points->y;
for (i = 0; i < npoints - 2; i++)
{
points++;
lines[i].x2 = lines[i+1].x1 = points->x;
lines[i].y2 = lines[i+1].y1 = points->y;
if (points->x < region.x1)
region.x1 = points->x;
if (points->y < region.y1)
region.y1 = points->y;
if (points->x > region.x2)
region.x2 = points->x;
if (points->y > region.y2)
region.y2 = points->y;
}
points++;
lines[i].x2 = points->x;
lines[i].y2 = points->y;
gdk_directfb_clip_region (drawable, gc, NULL, &clip);
for (i = 0; i < clip.numRects; i++)
{
DFBRegion reg = { clip.rects[i].x1, clip.rects[i].y1,
clip.rects[i].x2, clip.rects[i].y2 };
impl->surface->SetClip (impl->surface, &reg);
impl->surface->DrawLines (impl->surface, lines, npoints - 1);
}
temp_region_deinit( &clip );
}
static inline void
convert_rgba_pixbuf_to_image (guint32 *src,
guint src_pitch,
@ -901,8 +752,6 @@ gdk_drawable_impl_directfb_class_init (GdkDrawableImplDirectFBClass *klass)
drawable_class->draw_rectangle = gdk_directfb_draw_rectangle;
drawable_class->draw_drawable = gdk_directfb_draw_drawable;
drawable_class->draw_points = gdk_directfb_draw_points;
drawable_class->draw_segments = gdk_directfb_draw_segments;
drawable_class->draw_lines = gdk_directfb_draw_lines;
drawable_class->ref_cairo_surface = gdk_directfb_ref_cairo_surface;
drawable_class->set_colormap = gdk_directfb_set_colormap;

View File

@ -550,12 +550,9 @@ gdk_drawable_get_visible_region
gdk_drawable_get_visual
gdk_drawable_set_colormap
gdk_draw_drawable
gdk_draw_line
gdk_draw_lines
gdk_draw_point
gdk_draw_points
gdk_draw_rectangle
gdk_draw_segments
#endif
#endif

View File

@ -241,38 +241,6 @@ gdk_draw_point (GdkDrawable *drawable,
GDK_DRAWABLE_GET_CLASS (drawable)->draw_points (drawable, gc, &point, 1);
}
/**
* gdk_draw_line:
* @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
* @gc: a #GdkGC.
* @x1_: the x coordinate of the start point.
* @y1_: the y coordinate of the start point.
* @x2_: the x coordinate of the end point.
* @y2_: the y coordinate of the end point.
*
* Draws a line, using the foreground color and other attributes of
* the #GdkGC.
**/
void
gdk_draw_line (GdkDrawable *drawable,
GdkGC *gc,
gint x1,
gint y1,
gint x2,
gint y2)
{
GdkSegment segment;
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
g_return_if_fail (GDK_IS_GC (gc));
segment.x1 = x1;
segment.y1 = y1;
segment.x2 = x2;
segment.y2 = y2;
GDK_DRAWABLE_GET_CLASS (drawable)->draw_segments (drawable, gc, &segment, 1);
}
/**
* gdk_draw_rectangle:
* @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
@ -442,66 +410,6 @@ gdk_draw_points (GdkDrawable *drawable,
(GdkPoint *) points, n_points);
}
/**
* gdk_draw_segments:
* @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
* @gc: a #GdkGC.
* @segs: an array of #GdkSegment structures specifying the start and
* end points of the lines to be drawn.
* @n_segs: the number of line segments to draw, i.e. the size of the
* @segs array.
*
* Draws a number of unconnected lines.
**/
void
gdk_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
const GdkSegment *segs,
gint n_segs)
{
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
if (n_segs == 0)
return;
g_return_if_fail (segs != NULL);
g_return_if_fail (GDK_IS_GC (gc));
g_return_if_fail (n_segs >= 0);
GDK_DRAWABLE_GET_CLASS (drawable)->draw_segments (drawable, gc,
(GdkSegment *) segs, n_segs);
}
/**
* gdk_draw_lines:
* @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
* @gc: a #GdkGC.
* @points: an array of #GdkPoint structures specifying the endpoints of the
* @n_points: the size of the @points array.
*
* Draws a series of lines connecting the given points.
* The way in which joins between lines are draw is determined by the
* #GdkCapStyle value in the #GdkGC. This can be set with
* gdk_gc_set_line_attributes().
**/
void
gdk_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
const GdkPoint *points,
gint n_points)
{
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
g_return_if_fail (points != NULL);
g_return_if_fail (GDK_IS_GC (gc));
g_return_if_fail (n_points >= 0);
if (n_points == 0)
return;
GDK_DRAWABLE_GET_CLASS (drawable)->draw_lines (drawable, gc,
(GdkPoint *) points, n_points);
}
static GdkDrawable *
gdk_drawable_real_get_composite_drawable (GdkDrawable *drawable,
gint x,

View File

@ -80,14 +80,6 @@ struct _GdkDrawableClass
GdkGC *gc,
GdkPoint *points,
gint npoints);
void (*draw_segments) (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs);
void (*draw_lines) (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints);
gint (*get_depth) (GdkDrawable *drawable);
void (*get_size) (GdkDrawable *drawable,
@ -166,12 +158,6 @@ void gdk_draw_point (GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y);
void gdk_draw_line (GdkDrawable *drawable,
GdkGC *gc,
gint x1_,
gint y1_,
gint x2_,
gint y2_);
void gdk_draw_rectangle (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
@ -192,14 +178,6 @@ void gdk_draw_points (GdkDrawable *drawable,
GdkGC *gc,
const GdkPoint *points,
gint n_points);
void gdk_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
const GdkSegment *segs,
gint n_segs);
void gdk_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
const GdkPoint *points,
gint n_points);
void gdk_draw_layout_line (GdkDrawable *drawable,
GdkGC *gc,

View File

@ -360,67 +360,6 @@ gdk_offscreen_window_draw_points (GdkDrawable *drawable,
}
}
static void
gdk_offscreen_window_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs)
{
GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (drawable);
GdkDrawable *real_drawable = get_real_drawable (offscreen);
gdk_draw_segments (real_drawable,
gc,
segs,
nsegs);
if (nsegs > 0)
{
int min_x, min_y, max_x, max_y, i;
min_x = max_x = segs[0].x1;
min_y = max_y = segs[0].y1;
for (i = 0; i < nsegs; i++)
{
min_x = MIN (min_x, segs[i].x1);
max_x = MAX (max_x, segs[i].x1);
min_x = MIN (min_x, segs[i].x2);
max_x = MAX (max_x, segs[i].x2);
min_y = MIN (min_y, segs[i].y1);
max_y = MAX (max_y, segs[i].y1);
min_y = MIN (min_y, segs[i].y2);
max_y = MAX (max_y, segs[i].y2);
}
add_damage (offscreen, min_x, min_y,
max_x - min_x,
max_y - min_y, TRUE);
}
}
static void
gdk_offscreen_window_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (drawable);
GdkDrawable *real_drawable = get_real_drawable (offscreen);
GdkWindowObject *private = GDK_WINDOW_OBJECT (offscreen->wrapper);
gdk_draw_lines (real_drawable,
gc,
points,
npoints);
/* Hard to compute the minimal size, as we don't know the line
width, and since joins are hard to calculate.
Its not that often used anyway, damage it all */
add_damage (offscreen, 0, 0, private->width, private->height, TRUE);
}
void
_gdk_offscreen_window_new (GdkWindow *window,
GdkScreen *screen,
@ -1048,8 +987,6 @@ gdk_offscreen_window_class_init (GdkOffscreenWindowClass *klass)
drawable_class->draw_rectangle = gdk_offscreen_window_draw_rectangle;
drawable_class->draw_drawable_with_src = gdk_offscreen_window_draw_drawable;
drawable_class->draw_points = gdk_offscreen_window_draw_points;
drawable_class->draw_segments = gdk_offscreen_window_draw_segments;
drawable_class->draw_lines = gdk_offscreen_window_draw_lines;
}
static void

View File

@ -55,14 +55,6 @@ static void gdk_pixmap_draw_points (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints);
static void gdk_pixmap_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs);
static void gdk_pixmap_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints);
static void gdk_pixmap_real_get_size (GdkDrawable *drawable,
gint *width,
@ -124,8 +116,6 @@ gdk_pixmap_class_init (GdkPixmapObjectClass *klass)
drawable_class->draw_rectangle = gdk_pixmap_draw_rectangle;
drawable_class->draw_drawable_with_src = gdk_pixmap_draw_drawable;
drawable_class->draw_points = gdk_pixmap_draw_points;
drawable_class->draw_segments = gdk_pixmap_draw_segments;
drawable_class->draw_lines = gdk_pixmap_draw_lines;
drawable_class->get_depth = gdk_pixmap_real_get_depth;
drawable_class->get_screen = gdk_pixmap_real_get_screen;
drawable_class->get_size = gdk_pixmap_real_get_size;
@ -256,30 +246,6 @@ gdk_pixmap_draw_points (GdkDrawable *drawable,
gdk_draw_points (private->impl, gc, points, npoints);
}
static void
gdk_pixmap_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs)
{
GdkPixmapObject *private = (GdkPixmapObject *)drawable;
_gdk_gc_remove_drawable_clip (gc);
gdk_draw_segments (private->impl, gc, segs, nsegs);
}
static void
gdk_pixmap_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
GdkPixmapObject *private = (GdkPixmapObject *)drawable;
_gdk_gc_remove_drawable_clip (gc);
gdk_draw_lines (private->impl, gc, points, npoints);
}
static void
gdk_pixmap_real_get_size (GdkDrawable *drawable,
gint *width,

View File

@ -75,7 +75,6 @@ G_BEGIN_DECLS
*/
typedef struct _GdkPoint GdkPoint;
typedef cairo_rectangle_int_t GdkRectangle;
typedef struct _GdkSegment GdkSegment;
typedef struct _GdkSpan GdkSpan;
typedef struct _GdkAtom *GdkAtom;
@ -270,14 +269,6 @@ struct _GdkPoint
gint y;
};
struct _GdkSegment
{
gint x1;
gint y1;
gint x2;
gint y2;
};
struct _GdkSpan
{
gint x;

View File

@ -250,14 +250,6 @@ static void gdk_window_draw_points (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints);
static void gdk_window_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs);
static void gdk_window_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints);
static cairo_surface_t *gdk_window_ref_cairo_surface (GdkDrawable *drawable);
static cairo_surface_t *gdk_window_create_cairo_surface (GdkDrawable *drawable,
@ -439,8 +431,6 @@ gdk_window_class_init (GdkWindowObjectClass *klass)
drawable_class->draw_rectangle = gdk_window_draw_rectangle;
drawable_class->draw_drawable_with_src = gdk_window_draw_drawable;
drawable_class->draw_points = gdk_window_draw_points;
drawable_class->draw_segments = gdk_window_draw_segments;
drawable_class->draw_lines = gdk_window_draw_lines;
drawable_class->get_depth = gdk_window_real_get_depth;
drawable_class->get_screen = gdk_window_real_get_screen;
drawable_class->get_size = gdk_window_real_get_size;
@ -4239,78 +4229,6 @@ gdk_window_draw_points (GdkDrawable *drawable,
END_DRAW;
}
static void
gdk_window_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs)
{
GdkSegment *new_segs;
if (GDK_WINDOW_DESTROYED (drawable))
return;
BEGIN_DRAW;
if (x_offset != 0 || y_offset != 0)
{
gint i;
new_segs = g_new (GdkSegment, nsegs);
for (i=0; i<nsegs; i++)
{
new_segs[i].x1 = segs[i].x1 - x_offset;
new_segs[i].y1 = segs[i].y1 - y_offset;
new_segs[i].x2 = segs[i].x2 - x_offset;
new_segs[i].y2 = segs[i].y2 - y_offset;
}
}
else
new_segs = segs;
gdk_draw_segments (impl, gc, new_segs, nsegs);
if (new_segs != segs)
g_free (new_segs);
END_DRAW;
}
static void
gdk_window_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
GdkPoint *new_points;
if (GDK_WINDOW_DESTROYED (drawable))
return;
BEGIN_DRAW;
if (x_offset != 0 || y_offset != 0)
{
gint i;
new_points = g_new (GdkPoint, npoints);
for (i=0; i<npoints; i++)
{
new_points[i].x = points[i].x - x_offset;
new_points[i].y = points[i].y - y_offset;
}
}
else
new_points = points;
gdk_draw_lines (impl, gc, new_points, npoints);
if (new_points != points)
g_free (new_points);
END_DRAW;
}
static cairo_t *
setup_backing_rect (GdkWindow *window, GdkWindowPaint *paint, int x_offset_cairo, int y_offset_cairo)
{

View File

@ -318,80 +318,6 @@ gdk_quartz_fix_cap_not_last_line (GdkGCQuartz *private,
}
}
static void
gdk_quartz_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs)
{
CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
GdkGCQuartz *private;
int i;
if (!context)
return;
private = GDK_GC_QUARTZ (gc);
_gdk_quartz_gc_update_cg_context (gc, drawable, context,
GDK_QUARTZ_CONTEXT_STROKE);
for (i = 0; i < nsegs; i++)
{
gint xfix, yfix;
gdk_quartz_fix_cap_not_last_line (private,
segs[i].x1, segs[i].y1,
segs[i].x2, segs[i].y2,
&xfix, &yfix);
CGContextMoveToPoint (context, segs[i].x1 + 0.5, segs[i].y1 + 0.5);
CGContextAddLineToPoint (context, segs[i].x2 + 0.5 + xfix, segs[i].y2 + 0.5 + yfix);
}
CGContextStrokePath (context);
gdk_quartz_drawable_release_context (drawable, context);
}
static void
gdk_quartz_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
GdkGCQuartz *private;
gint xfix, yfix;
gint i;
if (!context)
return;
private = GDK_GC_QUARTZ (gc);
_gdk_quartz_gc_update_cg_context (gc, drawable, context,
GDK_QUARTZ_CONTEXT_STROKE);
CGContextMoveToPoint (context, points[0].x + 0.5, points[0].y + 0.5);
for (i = 1; i < npoints - 1; i++)
CGContextAddLineToPoint (context, points[i].x + 0.5, points[i].y + 0.5);
gdk_quartz_fix_cap_not_last_line (private,
points[npoints - 2].x, points[npoints - 2].y,
points[npoints - 1].x, points[npoints - 1].y,
&xfix, &yfix);
CGContextAddLineToPoint (context,
points[npoints - 1].x + 0.5 + xfix,
points[npoints - 1].y + 0.5 + yfix);
CGContextStrokePath (context);
gdk_quartz_drawable_release_context (drawable, context);
}
static void
gdk_drawable_impl_quartz_finalize (GObject *object)
{
@ -417,8 +343,6 @@ gdk_drawable_impl_quartz_class_init (GdkDrawableImplQuartzClass *klass)
drawable_class->draw_rectangle = gdk_quartz_draw_rectangle;
drawable_class->draw_drawable_with_src = gdk_quartz_draw_drawable;
drawable_class->draw_points = gdk_quartz_draw_points;
drawable_class->draw_segments = gdk_quartz_draw_segments;
drawable_class->draw_lines = gdk_quartz_draw_lines;
drawable_class->ref_cairo_surface = gdk_quartz_ref_cairo_surface;

View File

@ -69,14 +69,6 @@ static void gdk_win32_draw_points (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints);
static void gdk_win32_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs);
static void gdk_win32_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints);
static cairo_surface_t *gdk_win32_ref_cairo_surface (GdkDrawable *drawable);
@ -110,8 +102,6 @@ _gdk_drawable_impl_win32_class_init (GdkDrawableImplWin32Class *klass)
drawable_class->draw_rectangle = gdk_win32_draw_rectangle;
drawable_class->draw_drawable_with_src = gdk_win32_draw_drawable;
drawable_class->draw_points = gdk_win32_draw_points;
drawable_class->draw_segments = gdk_win32_draw_segments;
drawable_class->draw_lines = gdk_win32_draw_lines;
drawable_class->ref_cairo_surface = gdk_win32_ref_cairo_surface;
@ -816,229 +806,6 @@ gdk_win32_draw_points (GdkDrawable *drawable,
gdk_win32_hdc_release (drawable, gc, GDK_GC_FOREGROUND);
}
static void
draw_segments (GdkGCWin32 *gcwin32,
HDC hdc,
gint x_offset,
gint y_offset,
va_list args)
{
GdkSegment *segs;
gint nsegs;
gint i;
segs = va_arg (args, GdkSegment *);
nsegs = va_arg (args, gint);
if (x_offset != 0 || y_offset != 0)
{
/* must not modify in place, but could splice in the offset all below */
segs = g_memdup (segs, nsegs * sizeof (GdkSegment));
for (i = 0; i < nsegs; i++)
{
segs[i].x1 -= x_offset;
segs[i].y1 -= y_offset;
segs[i].x2 -= x_offset;
segs[i].y2 -= y_offset;
}
}
if (MUST_RENDER_DASHES_MANUALLY (gcwin32))
{
for (i = 0; i < nsegs; i++)
{
if (segs[i].x1 == segs[i].x2)
{
int y1, y2;
if (segs[i].y1 <= segs[i].y2)
y1 = segs[i].y1, y2 = segs[i].y2;
else
y1 = segs[i].y2, y2 = segs[i].y1;
render_line_vertical (gcwin32, segs[i].x1, y1, y2);
}
else if (segs[i].y1 == segs[i].y2)
{
int x1, x2;
if (segs[i].x1 <= segs[i].x2)
x1 = segs[i].x1, x2 = segs[i].x2;
else
x1 = segs[i].x2, x2 = segs[i].x1;
render_line_horizontal (gcwin32, x1, x2, segs[i].y1);
}
else
GDI_CALL (MoveToEx, (hdc, segs[i].x1, segs[i].y1, NULL)) &&
GDI_CALL (LineTo, (hdc, segs[i].x2, segs[i].y2));
}
}
else
{
for (i = 0; i < nsegs; i++)
{
const GdkSegment *ps = &segs[i];
const int x1 = ps->x1, y1 = ps->y1;
int x2 = ps->x2, y2 = ps->y2;
GDK_NOTE (DRAW, g_print (" +%d+%d..+%d+%d", x1, y1, x2, y2));
GDI_CALL (MoveToEx, (hdc, x1, y1, NULL)) &&
GDI_CALL (LineTo, (hdc, x2, y2));
}
GDK_NOTE (DRAW, g_print ("\n"));
}
if (x_offset != 0 || y_offset != 0)
g_free (segs);
}
static void
gdk_win32_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs)
{
GdkRectangle bounds;
cairo_region_t *region;
gint i;
GDK_NOTE (DRAW, g_print ("gdk_win32_draw_segments: %s %d segs\n",
_gdk_win32_drawable_description (drawable),
nsegs));
bounds.x = G_MAXINT;
bounds.y = G_MAXINT;
bounds.width = 0;
bounds.height = 0;
for (i = 0; i < nsegs; i++)
{
bounds.x = MIN (bounds.x, segs[i].x1);
bounds.x = MIN (bounds.x, segs[i].x2);
bounds.y = MIN (bounds.y, segs[i].y1);
bounds.y = MIN (bounds.y, segs[i].y2);
}
for (i = 0; i < nsegs; i++)
{
bounds.width = MAX (bounds.width, segs[i].x1 - bounds.x);
bounds.width = MAX (bounds.width, segs[i].x2 - bounds.x);
bounds.height = MAX (bounds.height, segs[i].y1 - bounds.y);
bounds.height = MAX (bounds.height, segs[i].y2 - bounds.y);
}
region = widen_bounds (&bounds, GDK_GC_WIN32 (gc)->pen_width);
generic_draw (drawable, gc, GDK_GC_FOREGROUND | LINE_ATTRIBUTES,
draw_segments, region, segs, nsegs);
cairo_region_destroy (region);
}
static void
draw_lines (GdkGCWin32 *gcwin32,
HDC hdc,
gint x_offset,
gint y_offset,
va_list args)
{
POINT *pts;
gint npoints;
gint i;
pts = va_arg (args, POINT *);
npoints = va_arg (args, gint);
if (x_offset != 0 || y_offset != 0)
for (i = 0; i < npoints; i++)
{
pts[i].x -= x_offset;
pts[i].y -= y_offset;
}
if (MUST_RENDER_DASHES_MANUALLY (gcwin32))
{
for (i = 0; i < npoints - 1; i++)
{
if (pts[i].x == pts[i+1].x)
{
int y1, y2;
if (pts[i].y > pts[i+1].y)
y1 = pts[i+1].y, y2 = pts[i].y;
else
y1 = pts[i].y, y2 = pts[i+1].y;
render_line_vertical (gcwin32, pts[i].x, y1, y2);
}
else if (pts[i].y == pts[i+1].y)
{
int x1, x2;
if (pts[i].x > pts[i+1].x)
x1 = pts[i+1].x, x2 = pts[i].x;
else
x1 = pts[i].x, x2 = pts[i+1].x;
render_line_horizontal (gcwin32, x1, x2, pts[i].y);
}
else
GDI_CALL (MoveToEx, (hdc, pts[i].x, pts[i].y, NULL)) &&
GDI_CALL (LineTo, (hdc, pts[i+1].x, pts[i+1].y));
}
}
else
GDI_CALL (Polyline, (hdc, pts, npoints));
}
static void
gdk_win32_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
GdkRectangle bounds;
cairo_region_t *region;
POINT *pts;
int i;
GDK_NOTE (DRAW, g_print ("gdk_win32_draw_lines: %s %d points\n",
_gdk_win32_drawable_description (drawable),
npoints));
if (npoints < 2)
return;
bounds.x = G_MAXINT;
bounds.y = G_MAXINT;
bounds.width = 0;
bounds.height = 0;
pts = g_new (POINT, npoints);
for (i = 0; i < npoints; i++)
{
bounds.x = MIN (bounds.x, points[i].x);
bounds.y = MIN (bounds.y, points[i].y);
pts[i].x = points[i].x;
pts[i].y = points[i].y;
}
for (i = 0; i < npoints; i++)
{
bounds.width = MAX (bounds.width, points[i].x - bounds.x);
bounds.height = MAX (bounds.height, points[i].y - bounds.y);
}
region = widen_bounds (&bounds, GDK_GC_WIN32 (gc)->pen_width);
generic_draw (drawable, gc, GDK_GC_FOREGROUND | GDK_GC_BACKGROUND |
LINE_ATTRIBUTES,
draw_lines, region, pts, npoints);
cairo_region_destroy (region);
g_free (pts);
}
static void
blit_from_pixmap (gboolean use_fg_bg,
GdkDrawableImplWin32 *dest,

View File

@ -69,14 +69,6 @@ static void gdk_x11_draw_points (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints);
static void gdk_x11_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs);
static void gdk_x11_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints);
static cairo_surface_t *gdk_x11_ref_cairo_surface (GdkDrawable *drawable);
@ -106,8 +98,6 @@ _gdk_drawable_impl_x11_class_init (GdkDrawableImplX11Class *klass)
drawable_class->draw_rectangle = gdk_x11_draw_rectangle;
drawable_class->draw_drawable_with_src = gdk_x11_draw_drawable;
drawable_class->draw_points = gdk_x11_draw_points;
drawable_class->draw_segments = gdk_x11_draw_segments;
drawable_class->draw_lines = gdk_x11_draw_lines;
drawable_class->ref_cairo_surface = gdk_x11_ref_cairo_surface;
@ -453,76 +443,6 @@ gdk_x11_draw_points (GdkDrawable *drawable,
}
}
static void
gdk_x11_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs)
{
GdkDrawableImplX11 *impl;
impl = GDK_DRAWABLE_IMPL_X11 (drawable);
/* We special-case nsegs == 1, because X will merge multiple
* consecutive XDrawLine requests into a PolySegment request
*/
if (nsegs == 1)
{
XDrawLine (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,
GDK_GC_GET_XGC (gc), segs[0].x1, segs[0].y1,
segs[0].x2, segs[0].y2);
}
else
{
gint i;
XSegment *tmp_segs = g_new (XSegment, nsegs);
for (i=0; i<nsegs; i++)
{
tmp_segs[i].x1 = segs[i].x1;
tmp_segs[i].x2 = segs[i].x2;
tmp_segs[i].y1 = segs[i].y1;
tmp_segs[i].y2 = segs[i].y2;
}
XDrawSegments (GDK_SCREEN_XDISPLAY (impl->screen),
impl->xid,
GDK_GC_GET_XGC (gc),
tmp_segs, nsegs);
g_free (tmp_segs);
}
}
static void
gdk_x11_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
gint i;
XPoint *tmp_points = g_new (XPoint, npoints);
GdkDrawableImplX11 *impl;
impl = GDK_DRAWABLE_IMPL_X11 (drawable);
for (i=0; i<npoints; i++)
{
tmp_points[i].x = points[i].x;
tmp_points[i].y = points[i].y;
}
XDrawLines (GDK_SCREEN_XDISPLAY (impl->screen),
impl->xid,
GDK_GC_GET_XGC (gc),
tmp_points, npoints,
CoordModeOrigin);
g_free (tmp_points);
}
static gint
gdk_x11_get_depth (GdkDrawable *drawable)
{