Index: trunk/src/draw.c =================================================================== --- trunk/src/draw.c (revision 8421) +++ trunk/src/draw.c (revision 8422) @@ -411,24 +411,31 @@ static void pcb_draw_mask(int side, const pcb_box_t * screen) { - int thin = conf_core.editor.thin_draw || conf_core.editor.thin_draw_poly; unsigned long side_lyt = side ? PCB_LYT_TOP : PCB_LYT_BOTTOM; pcb_layergrp_id_t gid = -1; pcb_layer_group_t *grp; - + comp_ctx_t cctx; + + cctx.pcb = PCB; + cctx.screen = screen; + cctx.thin = conf_core.editor.thin_draw || conf_core.editor.thin_draw_poly; + cctx.invert = pcb_gui->mask_invert; + cctx.poly_before = pcb_gui->poly_before; + cctx.poly_after = pcb_gui->poly_after; + pcb_layergrp_list(PCB, PCB_LYT_MASK | side_lyt, &gid, 1); grp = pcb_get_layergrp(PCB, gid); if ((grp == NULL) || (grp->len == 0)) { /* fallback: no layers -> original code: draw a single auto-sub */ - comp_init(thin, screen, 1); - comp_start_sub(thin, screen); + comp_init(&cctx, 1); + comp_start_sub(&cctx); pcb_draw_mask_auto(side, screen); - comp_start_add(thin, screen); + comp_start_add(&cctx); } else { /* generic multi-layer rendering */ int n, adding = -1; pcb_layer_t *l = pcb_get_layer(grp->lid[0]); - comp_init(thin, screen, (l->comb & PCB_LYC_SUB)); + comp_init(&cctx, (l->comb & PCB_LYC_SUB)); for(n = 0; n < grp->len; n++) { int want_add; @@ -437,9 +444,9 @@ want_add = !(l->comb & PCB_LYC_SUB); if (want_add != adding) { if (want_add) - comp_start_add(thin, screen); + comp_start_add(&cctx); else - comp_start_sub(thin, screen); + comp_start_sub(&cctx); adding = want_add; } @@ -447,7 +454,7 @@ const char *old_color = l->Color; pcb_hid_gc_t old_fg = Output.fgGC; Output.fgGC = Output.pmGC; - if (!thin) + if (!cctx.thin) l->Color = conf_core.appearance.color.mask; if (!want_add) l->Color = "erase"; @@ -456,12 +463,12 @@ Output.fgGC = old_fg; } else - pcb_draw_mask_auto(side, screen); + pcb_draw_mask_auto(cctx.thin, screen); } if (!adding) - comp_start_add(thin, screen); + comp_start_add(&cctx); } - comp_finish(thin, screen); + comp_finish(&cctx); } static void DrawRats(const pcb_box_t * drawn_area) Index: trunk/src/draw_composite.c =================================================================== --- trunk/src/draw_composite.c (revision 8421) +++ trunk/src/draw_composite.c (revision 8422) @@ -27,77 +27,85 @@ /* Local functions to draw a layer group as a composite of logical layers using positive and negative draw operations. Included from draw.c. */ +typedef struct comp_ctx_s { + pcb_board_t *pcb; + const pcb_box_t *screen; + unsigned thin:1; + unsigned invert:1; + unsigned poly_before:1; + unsigned poly_after:1; +} comp_ctx_t; -static void comp_fill_board(int mask_type, const pcb_box_t * drawn_area) +static void comp_fill_board(comp_ctx_t *ctx, int mask_type) { /* Skip the mask drawing if the GUI doesn't want this type */ - if ((mask_type == HID_MASK_BEFORE && !pcb_gui->poly_before) || (mask_type == HID_MASK_AFTER && !pcb_gui->poly_after)) + if ((mask_type == HID_MASK_BEFORE && !ctx->poly_before) || (mask_type == HID_MASK_AFTER && !ctx->poly_after)) return; pcb_gui->use_mask(mask_type); pcb_gui->set_color(Output.fgGC, conf_core.appearance.color.mask); - if (drawn_area == NULL) - pcb_gui->fill_rect(Output.fgGC, 0, 0, PCB->MaxWidth, PCB->MaxHeight); + if (ctx->screen == NULL) + pcb_gui->fill_rect(Output.fgGC, 0, 0, ctx->pcb->MaxWidth, ctx->pcb->MaxHeight); else - pcb_gui->fill_rect(Output.fgGC, drawn_area->X1, drawn_area->Y1, drawn_area->X2, drawn_area->Y2); + pcb_gui->fill_rect(Output.fgGC, ctx->screen->X1, ctx->screen->Y1, ctx->screen->X2, ctx->screen->Y2); } -static void comp_start_sub_(int thin, const pcb_box_t *screen) +static void comp_start_sub_(comp_ctx_t *ctx) { - if (thin) + if (ctx->thin) pcb_gui->set_color(Output.pmGC, conf_core.appearance.color.mask); else pcb_gui->use_mask(HID_MASK_CLEAR); } -static void comp_start_add_(int thin, const pcb_box_t *screen) +static void comp_start_add_(comp_ctx_t *ctx) { - if (thin) + if (ctx->thin) pcb_gui->set_color(Output.pmGC, "erase"); else pcb_gui->use_mask(HID_MASK_SET); } -static void comp_start_sub(int thin, const pcb_box_t *screen) +static void comp_start_sub(comp_ctx_t *ctx) { - if (pcb_gui->mask_invert) - comp_start_add_(thin, screen); + if (ctx->invert) + comp_start_add_(ctx); else - comp_start_sub_(thin, screen); + comp_start_sub_(ctx); } -static void comp_start_add(int thin, const pcb_box_t *screen) +static void comp_start_add(comp_ctx_t *ctx) { - if (pcb_gui->mask_invert) - comp_start_sub_(thin, screen); + if (ctx->invert) + comp_start_sub_(ctx); else - comp_start_add_(thin, screen); + comp_start_add_(ctx); } -static void comp_finish(int thin, const pcb_box_t *screen) +static void comp_finish(comp_ctx_t *ctx) { - if (!thin) { + if (!ctx->thin) { pcb_gui->use_mask(HID_MASK_AFTER); - comp_fill_board(HID_MASK_AFTER, screen); + comp_fill_board(ctx, HID_MASK_AFTER); pcb_gui->use_mask(HID_MASK_OFF); } } -static void comp_init(int thin, const pcb_box_t *screen, int negative) +static void comp_init(comp_ctx_t *ctx, int negative) { pcb_gui->use_mask(HID_MASK_INIT); - if (pcb_gui->mask_invert) + if (ctx->invert) negative = !negative; - if ((!thin) && (negative)) { + if ((!ctx->thin) && (negative)) { /* old way of drawing the big poly for the negative */ - comp_fill_board(HID_MASK_BEFORE, screen); + comp_fill_board(ctx, HID_MASK_BEFORE); if (!pcb_gui->poly_before) { /* new way */ pcb_gui->use_mask(HID_MASK_SET); - comp_fill_board(HID_MASK_SET, screen); + comp_fill_board(ctx, HID_MASK_SET); } } }