Index: trunk/src_plugins/hid_batch/batch.c =================================================================== --- trunk/src_plugins/hid_batch/batch.c (revision 12272) +++ trunk/src_plugins/hid_batch/batch.c (revision 12273) @@ -206,6 +206,10 @@ { } +static void batch_fill_polygon_offs(pcb_hid_gc_t gc, int n_coords, pcb_coord_t *x, pcb_coord_t *y, pcb_coord_t dx, pcb_coord_t dy) +{ +} + static void batch_fill_rect(pcb_hid_gc_t gc, pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2) { } @@ -355,6 +359,7 @@ batch_hid.draw_rect = batch_draw_rect; batch_hid.fill_circle = batch_fill_circle; batch_hid.fill_polygon = batch_fill_polygon; + batch_hid.fill_polygon_offs = batch_fill_polygon_offs; batch_hid.fill_rect = batch_fill_rect; batch_hid.calibrate = batch_calibrate; batch_hid.shift_is_pressed = batch_shift_is_pressed; Index: trunk/src_plugins/hid_gtk2_gdk/gtkhid-gdk.c =================================================================== --- trunk/src_plugins/hid_gtk2_gdk/gtkhid-gdk.c (revision 12272) +++ trunk/src_plugins/hid_gtk2_gdk/gtkhid-gdk.c (revision 12273) @@ -811,6 +811,7 @@ gdk_draw_arc(priv->out_clip, priv->clip_gc, TRUE, Vx(cx) - vr, Vy(cy) - vr, vr * 2, vr * 2, 0, 360 * 64); } +/* Intentional code duplication for performance */ static void ghid_gdk_fill_polygon(pcb_hid_gc_t gc, int n_coords, pcb_coord_t * x, pcb_coord_t * y) { static GdkPoint *points = 0; @@ -834,6 +835,30 @@ gdk_draw_polygon(priv->out_clip, priv->clip_gc, 1, points, n_coords); } +/* Intentional code duplication for performance */ +static void ghid_gdk_fill_polygon_offs(pcb_hid_gc_t gc, int n_coords, pcb_coord_t *x, pcb_coord_t *y, pcb_coord_t dx, pcb_coord_t dy) +{ + static GdkPoint *points = 0; + static int npoints = 0; + int i; + render_priv_t *priv = gport->render_priv; + USE_GC(gc); + + assert((curr_drawing_mode == PCB_HID_COMP_POSITIVE) || (curr_drawing_mode == PCB_HID_COMP_NEGATIVE)); + + if (npoints < n_coords) { + npoints = n_coords + 1; + points = (GdkPoint *) realloc(points, npoints * sizeof(GdkPoint)); + } + for (i = 0; i < n_coords; i++) { + points[i].x = Vx(x[i]+dx); + points[i].y = Vy(y[i]+dy); + } + gdk_draw_polygon(priv->out_pixel, priv->pixel_gc, 1, points, n_coords); + if (priv->out_clip != NULL) + gdk_draw_polygon(priv->out_clip, priv->clip_gc, 1, points, n_coords); +} + static void ghid_gdk_fill_rect(pcb_hid_gc_t gc, pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2) { gint w, h, lw, xx, yy; @@ -1437,6 +1462,7 @@ hid->draw_rect = ghid_gdk_draw_rect; hid->fill_circle = ghid_gdk_fill_circle; hid->fill_polygon = ghid_gdk_fill_polygon; + hid->fill_polygon_offs = ghid_gdk_fill_polygon_offs; hid->fill_rect = ghid_gdk_fill_rect; hid->request_debug_draw = ghid_gdk_request_debug_draw; Index: trunk/src_plugins/hid_gtk2_gl/gtkhid-gl.c =================================================================== --- trunk/src_plugins/hid_gtk2_gl/gtkhid-gl.c (revision 12272) +++ trunk/src_plugins/hid_gtk2_gl/gtkhid-gl.c (revision 12273) @@ -556,6 +556,13 @@ hidgl_fill_polygon(n_coords, x, y); } +void ghid_gl_fill_polygon_offs(pcb_hid_gc_t gc, int n_coords, pcb_coord_t *x, pcb_coord_t *y, pcb_coord_t dx, pcb_coord_t dy) +{ + USE_GC(gc); + + hidgl_fill_polygon_offs(n_coords, x, y, dx, dy); +} + void ghid_gl_fill_pcb_polygon(pcb_hid_gc_t gc, pcb_poly_t * poly, const pcb_box_t * clip_box) { USE_GC(gc); @@ -1181,6 +1188,7 @@ hid->draw_rect = ghid_gl_draw_rect; hid->fill_circle = ghid_gl_fill_circle; hid->fill_polygon = ghid_gl_fill_polygon; + hid->fill_polygon_offs = ghid_gl_fill_polygon_offs; hid->fill_rect = ghid_gl_fill_rect; hid->set_drawing_mode = hidgl_set_drawing_mode; Index: trunk/src_plugins/hid_gtk2_gl/hidgl.c =================================================================== --- trunk/src_plugins/hid_gtk2_gl/hidgl.c (revision 12272) +++ trunk/src_plugins/hid_gtk2_gl/hidgl.c (revision 12273) @@ -538,7 +538,7 @@ printf("Vertex received with unknown type\n"); } - +/* Intentaional code duplication for performance */ void hidgl_fill_polygon(int n_coords, pcb_coord_t * x, pcb_coord_t * y) { int i; @@ -573,6 +573,41 @@ free(vertices); } +/* Intentaional code duplication for performance */ +void hidgl_fill_polygon_offs(int n_coords, pcb_coord_t *x, pcb_coord_t *y, pcb_coord_t dx, pcb_coord_t dy) +{ + int i; + GLUtesselator *tobj; + GLdouble *vertices; + + assert(n_coords > 0); + + vertices = malloc(sizeof(GLdouble) * n_coords * 3); + + tobj = gluNewTess(); + gluTessCallback(tobj, GLU_TESS_BEGIN, (_GLUfuncptr) myBegin); + gluTessCallback(tobj, GLU_TESS_VERTEX, (_GLUfuncptr) myVertex); + gluTessCallback(tobj, GLU_TESS_COMBINE, (_GLUfuncptr) myCombine); + gluTessCallback(tobj, GLU_TESS_ERROR, (_GLUfuncptr) myError); + + gluTessBeginPolygon(tobj, NULL); + gluTessBeginContour(tobj); + + for (i = 0; i < n_coords; i++) { + vertices[0 + i * 3] = x[i] + dx; + vertices[1 + i * 3] = y[i] + dy; + vertices[2 + i * 3] = 0.; + gluTessVertex(tobj, &vertices[i * 3], &vertices[i * 3]); + } + + gluTessEndContour(tobj); + gluTessEndPolygon(tobj); + gluDeleteTess(tobj); + + myFreeCombined(); + free(vertices); +} + void tesselate_contour(GLUtesselator * tobj, pcb_pline_t * contour, GLdouble * vertices, double scale) { pcb_vnode_t *vn = &contour->head; Index: trunk/src_plugins/hid_gtk2_gl/hidgl.h =================================================================== --- trunk/src_plugins/hid_gtk2_gl/hidgl.h (revision 12272) +++ trunk/src_plugins/hid_gtk2_gl/hidgl.h (revision 12273) @@ -34,6 +34,7 @@ void hidgl_draw_rect(pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2); void hidgl_fill_circle(pcb_coord_t vx, pcb_coord_t vy, pcb_coord_t vr, double scale); void hidgl_fill_polygon(int n_coords, pcb_coord_t * x, pcb_coord_t * y); +void hidgl_fill_polygon_offs(int n_coords, pcb_coord_t *x, pcb_coord_t *y, pcb_coord_t dx, pcb_coord_t dy); void hidgl_fill_pcb_polygon(pcb_poly_t * poly, const pcb_box_t * clip_box, double scale); void hidgl_fill_rect(pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2); void hidgl_init(void); Index: trunk/src_plugins/hid_gtk3_cairo/gtkhid-cairo.c =================================================================== --- trunk/src_plugins/hid_gtk3_cairo/gtkhid-cairo.c (revision 12272) +++ trunk/src_plugins/hid_gtk3_cairo/gtkhid-cairo.c (revision 12273) @@ -996,6 +996,7 @@ //gdk_draw_arc(gport->drawable, priv->u_gc, TRUE, Vx(cx) - vr, Vy(cy) - vr, vr * 2, vr * 2, 0, 360 * 64); } +/* Intentaional code duplication for performance */ static void ghid_cairo_fill_polygon(pcb_hid_gc_t gc, int n_coords, pcb_coord_t * x, pcb_coord_t * y) { int i; @@ -1019,6 +1020,30 @@ cairo_fill(cr); } +/* Intentaional code duplication for performance */ +static void ghid_cairo_fill_polygon_offs(pcb_hid_gc_t gc, int n_coords, pcb_coord_t *x, pcb_coord_t *y, pcb_coord_t dx, pcb_coord_t dy) +{ + int i; + render_priv_t *priv = gport->render_priv; + cairo_t *cr = priv->cr; + int _x, _y; + + if (priv->cr == NULL) + return; + + USE_GC(gc); + + for (i = 0; i < n_coords; i++) { + _x = Vx(x[i]); + _y = Vy(y[i]); + if (i == 0) + cairo_move_to(cr, _x + dx, _y + dy); + else + cairo_line_to(cr, _x + dx, _y + dy); + } + cairo_fill(cr); +} + /** Fills the drawing with only \p bg_color */ static void erase_with_background_color(cairo_t * cr, GdkRGBA * bg_color) { @@ -1628,6 +1653,7 @@ hid->draw_rect = ghid_cairo_draw_rect; hid->fill_circle = ghid_cairo_fill_circle; hid->fill_polygon = ghid_cairo_fill_polygon; + hid->fill_polygon_offs = ghid_cairo_fill_polygon_offs; hid->fill_rect = ghid_cairo_fill_rect; hid->request_debug_draw = ghid_cairo_request_debug_draw; Index: trunk/src_plugins/hid_lesstif/main.c =================================================================== --- trunk/src_plugins/hid_lesstif/main.c (revision 12272) +++ trunk/src_plugins/hid_lesstif/main.c (revision 12273) @@ -3120,6 +3120,7 @@ XFillArc(display, mask_bitmap, mask_gc, cx, cy, radius * 2, radius * 2, 0, 360 * 64); } +/* Intentaional code duplication for performance */ static void lesstif_fill_polygon(pcb_hid_gc_t gc, int n_coords, pcb_coord_t * x, pcb_coord_t * y) { static XPoint *p = 0; @@ -3147,6 +3148,32 @@ XFillPolygon(display, mask_bitmap, mask_gc, p, n_coords, Complex, CoordModeOrigin); } +/* Intentaional code duplication for performance */ +static void lesstif_fill_polygon_offs(pcb_hid_gc_t gc, int n_coords, pcb_coord_t *x, pcb_coord_t *y, pcb_coord_t dx, pcb_coord_t dy) +{ + static XPoint *p = 0; + static int maxp = 0; + int i; + + if (maxp < n_coords) { + maxp = n_coords + 10; + if (p) + p = (XPoint *) realloc(p, maxp * sizeof(XPoint)); + else + p = (XPoint *) malloc(maxp * sizeof(XPoint)); + } + + for (i = 0; i < n_coords; i++) { + p[i].x = Vx(x[i] + dx); + p[i].y = Vy(y[i] + dy); + } + + set_gc(gc); + XFillPolygon(display, pixmap, my_gc, p, n_coords, Complex, CoordModeOrigin); + if (use_mask()) + XFillPolygon(display, mask_bitmap, mask_gc, p, n_coords, Complex, CoordModeOrigin); +} + static void lesstif_fill_rect(pcb_hid_gc_t gc, pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2) { int vw = Vz(gc->width); @@ -3750,6 +3777,7 @@ lesstif_hid.draw_rect = lesstif_draw_rect; lesstif_hid.fill_circle = lesstif_fill_circle; lesstif_hid.fill_polygon = lesstif_fill_polygon; + lesstif_hid.fill_polygon_offs = lesstif_fill_polygon_offs; lesstif_hid.fill_rect = lesstif_fill_rect; lesstif_hid.calibrate = lesstif_calibrate; Index: trunk/src_plugins/hid_remote/proto.c =================================================================== --- trunk/src_plugins/hid_remote/proto.c (revision 12272) +++ trunk/src_plugins/hid_remote/proto.c (revision 12273) @@ -279,7 +279,7 @@ send_end(&pctx); } -void proto_send_draw_poly(int gc, int n_coords, pcb_coord_t * x, pcb_coord_t * y) +void proto_send_draw_poly(int gc, int n_coords, pcb_coord_t *x, pcb_coord_t *y, pcb_coord_t dx, pcb_coord_t dy) { int n; send_begin(&pctx, "poly"); @@ -289,8 +289,8 @@ send_open(&pctx, 0, 1); for(n = 0; n < n_coords; n++) { send_open(&pctx, 0, 1); - sendf(&pctx, cfmt, x[n]); - sendf(&pctx, cfmt, y[n]); + sendf(&pctx, cfmt, x[n] + dx); + sendf(&pctx, cfmt, y[n] + dy); send_close(&pctx); } send_close(&pctx); Index: trunk/src_plugins/hid_remote/proto.h =================================================================== --- trunk/src_plugins/hid_remote/proto.h (revision 12272) +++ trunk/src_plugins/hid_remote/proto.h (revision 12273) @@ -42,7 +42,7 @@ void proto_send_draw_arc(int gc, pcb_coord_t cx, pcb_coord_t cy, pcb_coord_t width, pcb_coord_t height, pcb_angle_t start_angle, pcb_angle_t delta_angle); void proto_send_draw_rect(int gc, pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2, int is_filled); void proto_send_fill_circle(int gc, pcb_coord_t cx, pcb_coord_t cy, pcb_coord_t radius); -void proto_send_draw_poly(int gc, int n_coords, pcb_coord_t * x, pcb_coord_t * y); +void proto_send_draw_poly(int gc, int n_coords, pcb_coord_t *x, pcb_coord_t *y, pcb_coord_t dx, pcb_coord_t dy); int proto_send_set_drawing_mode(const char *name, int direct); int remote_proto_parse_all(); Index: trunk/src_plugins/hid_remote/remote.c =================================================================== --- trunk/src_plugins/hid_remote/remote.c (revision 12272) +++ trunk/src_plugins/hid_remote/remote.c (revision 12273) @@ -291,9 +291,16 @@ { int idx = gc2idx(gc); if (idx >= 0) - proto_send_draw_poly(idx, n_coords, x, y); + proto_send_draw_poly(idx, n_coords, x, y, 0, 0); } +static void remote_fill_polygon_offs(pcb_hid_gc_t gc, int n_coords, pcb_coord_t *x, pcb_coord_t *y, pcb_coord_t dx, pcb_coord_t dy) +{ + int idx = gc2idx(gc); + if (idx >= 0) + proto_send_draw_poly(idx, n_coords, x, y, dx, dy); +} + static void remote_fill_rect(pcb_hid_gc_t gc, pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2) { int idx = gc2idx(gc); @@ -459,6 +466,7 @@ remote_hid.draw_rect = remote_draw_rect; remote_hid.fill_circle = remote_fill_circle; remote_hid.fill_polygon = remote_fill_polygon; + remote_hid.fill_polygon_offs = remote_fill_polygon_offs; remote_hid.fill_rect = remote_fill_rect; remote_hid.calibrate = remote_calibrate; remote_hid.shift_is_pressed = remote_shift_is_pressed;