API: remove gdk_draw_polygon()

This commit is contained in:
Benjamin Otte 2010-07-14 19:23:45 +02:00
parent d2b1da4e84
commit e85dfc7cc4
12 changed files with 0 additions and 407 deletions

View File

@ -341,7 +341,6 @@ gdk_draw_lines
gdk_draw_segments
GdkSegment
gdk_draw_rectangle
gdk_draw_polygon
gdk_draw_layout_line
gdk_draw_layout_line_with_colors
gdk_draw_layout

View File

@ -208,17 +208,6 @@ function.
@height:
<!-- ##### FUNCTION gdk_draw_polygon ##### -->
<para>
</para>
@drawable:
@gc:
@filled:
@points:
@n_points:
<!-- ##### FUNCTION gdk_draw_layout_line ##### -->
<para>

View File

@ -553,80 +553,6 @@ gdk_directfb_draw_rectangle (GdkDrawable *drawable,
}
}
static void
gdk_directfb_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
GdkPoint *points,
gint npoints)
{
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
D_DEBUG_AT( GDKDFB_Drawable, "%s( %p, %p, %s, %p, %d )\n", G_STRFUNC,
drawable, gc, filled ? " filled" : "outline", points, npoints );
if (npoints < 3)
return;
if (filled)
{
if (npoints == 3 || (npoints == 4 &&
points[0].x == points[npoints-1].x &&
points[0].y == points[npoints-1].y))
{
GdkDrawableImplDirectFB *impl;
cairo_region_t clip;
gint i;
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->FillTriangle (impl->surface,
points[0].x, points[0].y,
points[1].x, points[1].y,
points[2].x, points[2].y);
}
temp_region_deinit( &clip );
return;
}
else
g_message ("filled polygons with n > 3 are not yet supported, "
"drawing outlines");
}
if (points[0].x != points[npoints-1].x ||
points[0].y != points[npoints-1].y)
{
GdkPoint *tmp_points;
tmp_points = g_new (GdkPoint, npoints + 1);
memcpy (tmp_points, points, npoints * sizeof (GdkPoint));
tmp_points[npoints].x = points[0].x;
tmp_points[npoints].y = points[0].y;
gdk_directfb_draw_lines (drawable, gc, tmp_points, npoints + 1);
g_free (tmp_points);
}
else
{
gdk_directfb_draw_lines (drawable, gc, points, npoints);
}
}
static void
gdk_directfb_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,
@ -973,7 +899,6 @@ gdk_drawable_impl_directfb_class_init (GdkDrawableImplDirectFBClass *klass)
drawable_class->create_gc = _gdk_directfb_gc_new;
drawable_class->draw_rectangle = gdk_directfb_draw_rectangle;
drawable_class->draw_polygon = gdk_directfb_draw_polygon;
drawable_class->draw_drawable = gdk_directfb_draw_drawable;
drawable_class->draw_points = gdk_directfb_draw_points;
drawable_class->draw_segments = gdk_directfb_draw_segments;

View File

@ -554,7 +554,6 @@ gdk_draw_line
gdk_draw_lines
gdk_draw_point
gdk_draw_points
gdk_draw_polygon
gdk_draw_rectangle
gdk_draw_segments
#endif

View File

@ -323,34 +323,6 @@ gdk_draw_rectangle (GdkDrawable *drawable,
width, height);
}
/**
* gdk_draw_polygon:
* @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
* @gc: a #GdkGC.
* @filled: %TRUE if the polygon should be filled. The polygon is closed
* automatically, connecting the last point to the first point if
* necessary.
* @points: an array of #GdkPoint structures specifying the points making
* up the polygon.
* @n_points: the number of points.
*
* Draws an outlined or filled polygon.
**/
void
gdk_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
const GdkPoint *points,
gint n_points)
{
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
g_return_if_fail (GDK_IS_GC (gc));
GDK_DRAWABLE_GET_CLASS (drawable)->draw_polygon (drawable, gc, filled,
(GdkPoint *) points,
n_points);
}
/**
* gdk_draw_drawable:
* @drawable: a #GdkDrawable

View File

@ -67,11 +67,6 @@ struct _GdkDrawableClass
gint y,
gint width,
gint height);
void (*draw_polygon) (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
GdkPoint *points,
gint npoints);
void (*draw_drawable) (GdkDrawable *drawable,
GdkGC *gc,
GdkDrawable *src,
@ -184,11 +179,6 @@ void gdk_draw_rectangle (GdkDrawable *drawable,
gint y,
gint width,
gint height);
void gdk_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
const GdkPoint *points,
gint n_points);
void gdk_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,
GdkDrawable *src,

View File

@ -323,43 +323,6 @@ gdk_offscreen_window_draw_rectangle (GdkDrawable *drawable,
}
static void
gdk_offscreen_window_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
GdkPoint *points,
gint npoints)
{
GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (drawable);
GdkDrawable *real_drawable = get_real_drawable (offscreen);
gdk_draw_polygon (real_drawable,
gc,
filled,
points,
npoints);
if (npoints > 0)
{
int min_x, min_y, max_x, max_y, i;
min_x = max_x = points[0].x;
min_y = max_y = points[0].y;
for (i = 1; i < npoints; i++)
{
min_x = MIN (min_x, points[i].x);
max_x = MAX (max_x, points[i].x);
min_y = MIN (min_y, points[i].y);
max_y = MAX (max_y, points[i].y);
}
add_damage (offscreen, min_x, min_y,
max_x - min_x,
max_y - min_y, !filled);
}
}
static void
gdk_offscreen_window_draw_points (GdkDrawable *drawable,
GdkGC *gc,
@ -1083,7 +1046,6 @@ gdk_offscreen_window_class_init (GdkOffscreenWindowClass *klass)
drawable_class->get_composite_drawable = gdk_offscreen_window_get_composite_drawable;
drawable_class->draw_rectangle = gdk_offscreen_window_draw_rectangle;
drawable_class->draw_polygon = gdk_offscreen_window_draw_polygon;
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;

View File

@ -41,11 +41,6 @@ static void gdk_pixmap_draw_rectangle (GdkDrawable *drawable,
gint y,
gint width,
gint height);
static void gdk_pixmap_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
GdkPoint *points,
gint npoints);
static void gdk_pixmap_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,
GdkPixmap *src,
@ -127,7 +122,6 @@ gdk_pixmap_class_init (GdkPixmapObjectClass *klass)
drawable_class->create_gc = gdk_pixmap_create_gc;
drawable_class->draw_rectangle = gdk_pixmap_draw_rectangle;
drawable_class->draw_polygon = gdk_pixmap_draw_polygon;
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;
@ -226,19 +220,6 @@ gdk_pixmap_draw_rectangle (GdkDrawable *drawable,
x, y, width, height);
}
static void
gdk_pixmap_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
GdkPoint *points,
gint npoints)
{
GdkPixmapObject *private = (GdkPixmapObject *)drawable;
_gdk_gc_remove_drawable_clip (gc);
gdk_draw_polygon (private->impl, gc, filled, points, npoints);
}
static void
gdk_pixmap_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,

View File

@ -236,11 +236,6 @@ static void gdk_window_draw_rectangle (GdkDrawable *drawable,
gint y,
gint width,
gint height);
static void gdk_window_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
GdkPoint *points,
gint npoints);
static void gdk_window_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,
GdkPixmap *src,
@ -442,7 +437,6 @@ gdk_window_class_init (GdkWindowObjectClass *klass)
drawable_class->create_gc = gdk_window_create_gc;
drawable_class->draw_rectangle = gdk_window_draw_rectangle;
drawable_class->draw_polygon = gdk_window_draw_polygon;
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;
@ -3937,42 +3931,6 @@ gdk_window_draw_rectangle (GdkDrawable *drawable,
END_DRAW;
}
static void
gdk_window_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
GdkPoint *points,
gint npoints)
{
GdkPoint *new_points;
if (GDK_WINDOW_DESTROYED (drawable))
return;
BEGIN_DRAW;
if (x_offset != 0 || y_offset != 0)
{
int 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_polygon (impl, gc, filled, new_points, npoints);
if (new_points != points)
g_free (new_points);
END_DRAW;
}
static GdkDrawable *
gdk_window_get_source_drawable (GdkDrawable *drawable)
{

View File

@ -184,46 +184,6 @@ gdk_quartz_draw_rectangle (GdkDrawable *drawable,
gdk_quartz_drawable_release_context (drawable, context);
}
static void
gdk_quartz_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
GdkPoint *points,
gint npoints)
{
CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
int i;
if (!context)
return;
_gdk_quartz_gc_update_cg_context (gc, drawable, context,
filled ?
GDK_QUARTZ_CONTEXT_FILL :
GDK_QUARTZ_CONTEXT_STROKE);
if (filled)
{
CGContextMoveToPoint (context, points[0].x, points[0].y);
for (i = 1; i < npoints; i++)
CGContextAddLineToPoint (context, points[i].x, points[i].y);
CGContextClosePath (context);
CGContextFillPath (context);
}
else
{
CGContextMoveToPoint (context, points[0].x + 0.5, points[0].y + 0.5);
for (i = 1; i < npoints; i++)
CGContextAddLineToPoint (context, points[i].x + 0.5, points[i].y + 0.5);
CGContextClosePath (context);
CGContextStrokePath (context);
}
gdk_quartz_drawable_release_context (drawable, context);
}
static void
gdk_quartz_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,
@ -455,7 +415,6 @@ gdk_drawable_impl_quartz_class_init (GdkDrawableImplQuartzClass *klass)
drawable_class->create_gc = _gdk_quartz_gc_new;
drawable_class->draw_rectangle = gdk_quartz_draw_rectangle;
drawable_class->draw_polygon = gdk_quartz_draw_polygon;
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;

View File

@ -55,11 +55,6 @@ static void gdk_win32_draw_rectangle (GdkDrawable *drawable,
gint y,
gint width,
gint height);
static void gdk_win32_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
GdkPoint *points,
gint npoints);
static void gdk_win32_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,
GdkPixmap *src,
@ -113,7 +108,6 @@ _gdk_drawable_impl_win32_class_init (GdkDrawableImplWin32Class *klass)
drawable_class->create_gc = _gdk_win32_gc_new;
drawable_class->draw_rectangle = gdk_win32_draw_rectangle;
drawable_class->draw_polygon = gdk_win32_draw_polygon;
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;
@ -772,91 +766,6 @@ gdk_win32_draw_rectangle (GdkDrawable *drawable,
cairo_region_destroy (region);
}
static void
draw_polygon (GdkGCWin32 *gcwin32,
HDC hdc,
gint x_offset,
gint y_offset,
va_list args)
{
gboolean filled;
POINT *pts;
HGDIOBJ old_pen_or_brush;
gint npoints;
gint i;
filled = va_arg (args, gboolean);
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 (filled)
old_pen_or_brush = SelectObject (hdc, GetStockObject (NULL_PEN));
else
old_pen_or_brush = SelectObject (hdc, GetStockObject (HOLLOW_BRUSH));
if (old_pen_or_brush == NULL)
WIN32_GDI_FAILED ("SelectObject");
GDI_CALL (Polygon, (hdc, pts, npoints));
if (old_pen_or_brush != NULL)
GDI_CALL (SelectObject, (hdc, old_pen_or_brush));
}
static void
gdk_win32_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
GdkPoint *points,
gint npoints)
{
GdkRectangle bounds;
cairo_region_t *region;
POINT *pts;
int i;
GDK_NOTE (DRAW, g_print ("gdk_win32_draw_polygon: %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 | (filled ? 0 : LINE_ATTRIBUTES),
draw_polygon, region, filled, pts, npoints);
cairo_region_destroy (region);
g_free (pts);
}
static void
gdk_win32_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,

View File

@ -55,11 +55,6 @@ static void gdk_x11_draw_rectangle (GdkDrawable *drawable,
gint y,
gint width,
gint height);
static void gdk_x11_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
GdkPoint *points,
gint npoints);
static void gdk_x11_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,
GdkPixmap *src,
@ -109,7 +104,6 @@ _gdk_drawable_impl_x11_class_init (GdkDrawableImplX11Class *klass)
drawable_class->create_gc = _gdk_x11_gc_new;
drawable_class->draw_rectangle = gdk_x11_draw_rectangle;
drawable_class->draw_polygon = gdk_x11_draw_polygon;
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;
@ -330,50 +324,6 @@ gdk_x11_draw_rectangle (GdkDrawable *drawable,
GDK_GC_GET_XGC (gc), x, y, width, height);
}
static void
gdk_x11_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
GdkPoint *points,
gint npoints)
{
XPoint *tmp_points;
gint tmp_npoints, i;
GdkDrawableImplX11 *impl;
impl = GDK_DRAWABLE_IMPL_X11 (drawable);
if (!filled &&
(points[0].x != points[npoints-1].x || points[0].y != points[npoints-1].y))
{
tmp_npoints = npoints + 1;
tmp_points = g_new (XPoint, tmp_npoints);
tmp_points[npoints].x = points[0].x;
tmp_points[npoints].y = points[0].y;
}
else
{
tmp_npoints = npoints;
tmp_points = g_new (XPoint, tmp_npoints);
}
for (i=0; i<npoints; i++)
{
tmp_points[i].x = points[i].x;
tmp_points[i].y = points[i].y;
}
if (filled)
XFillPolygon (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,
GDK_GC_GET_XGC (gc), tmp_points, tmp_npoints, Complex, CoordModeOrigin);
else
XDrawLines (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,
GDK_GC_GET_XGC (gc), tmp_points, tmp_npoints, CoordModeOrigin);
g_free (tmp_points);
}
static void
gdk_x11_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,