API: remove gdk_draw_{line,lines,segments}
Those were the 3 intermixed line drawing calls.
This commit is contained in:
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user