diff --git a/pxl/pxpaint.c b/pxl/pxpaint.c index fcf7ebe..400389a 100644 --- a/pxl/pxpaint.c +++ b/pxl/pxpaint.c @@ -341,13 +341,15 @@ pxl_allow_rop_for_stroke(gs_state *pgs) /* Paint the current path, optionally resetting it afterwards. */ static int paint_path(px_state_t *pxs, bool reset) -{ gs_state *pgs = pxs->pgs; +{ + gs_state *pgs = pxs->pgs; gx_path *ppath = gx_current_path(pgs); px_gstate_t *pxgs = pxs->pxgs; bool will_stroke = pxgs->pen.type != pxpNull; gs_point cursor; int code = 0; gx_path *save_path = 0; + int no_current_point; if ( gx_path_is_void(ppath) ) return 0; /* nothing to draw */ @@ -356,16 +358,18 @@ paint_path(px_state_t *pxs, bool reset) #else # define save_for_stroke (!reset) #endif - if ( pxgs->brush.type != pxpNull ) - { int (*fill_proc)(gs_state *) = + if ( pxgs->brush.type != pxpNull ) { + int (*fill_proc)(gs_state *) = (pxgs->fill_mode == eEvenOdd ? gs_eofill : gs_fill); if ( (code = px_set_paint(&pxgs->brush, pxs)) < 0 ) return code; pxs->have_page = true; if ( !will_stroke && reset ) - { gs_currentpoint(pgs, &cursor); + { + no_current_point = gs_currentpoint(pgs, &cursor); code = (*fill_proc)(pgs); + if (!no_current_point) gs_moveto(pgs, cursor.x, cursor.y); return code; } @@ -374,30 +378,28 @@ paint_path(px_state_t *pxs, bool reset) return_error(errorInsufficientMemory); gx_path_assign_preserve(save_path, ppath); code = (*fill_proc)(pgs); - if ( code < 0 ) - goto rx; - if ( !will_stroke ) + if ( code < 0 || !will_stroke) { + no_current_point = gs_currentpoint(pgs, &cursor); goto rx; + } if ( save_for_stroke ) gx_path_assign_preserve(ppath, save_path); else { gx_path_assign_free(ppath, save_path); gx_setcurrentpoint_from_path((gs_imager_state *)pgs, ppath); - gs_currentpoint(pgs, &cursor); save_path = 0; } - } - else if ( !will_stroke ) + } else if ( !will_stroke ) return 0; - else if ( save_for_stroke ) - { save_path = - gx_path_alloc(pxs->memory, "paint_path(save_path)"); + else { + if ( save_for_stroke ) { + save_path = gx_path_alloc(pxs->memory, "paint_path(save_path)"); if ( save_path == 0 ) return_error(errorInsufficientMemory); gx_path_assign_preserve(save_path, ppath); } - else - gs_currentpoint(pgs, &cursor); + } + no_current_point = gs_currentpoint(pgs, &cursor); /* * The PCL XL documentation from H-P says that dash lengths do not * scale according to the CTM, but according to H-P developer @@ -411,15 +413,15 @@ paint_path(px_state_t *pxs, bool reset) * CTM than the current one, we must pre-expand the dashes. * (Eventually we should expand the library API to handle this.) */ - if ( pxgs->dashed ) - { gs_matrix mat; + if ( pxgs->dashed ) { + gs_matrix mat; gs_currentmatrix(pgs, &mat); if ( mat.xx != pxgs->dash_matrix.xx || mat.xy != pxgs->dash_matrix.xy || mat.yx != pxgs->dash_matrix.yx || mat.yy != pxgs->dash_matrix.yy - ) - { code = gs_flattenpath(pgs); + ) { + code = gs_flattenpath(pgs); if ( code < 0 ) goto rx; gs_setmatrix(pgs, &pxgs->dash_matrix); @@ -458,8 +460,11 @@ paint_path(px_state_t *pxs, bool reset) gx_path_assign_free(ppath, save_path); /* path without a Current point! */ gx_setcurrentpoint_from_path((gs_imager_state *)pgs, ppath); } - else /* Iff save_path is NULL, set currentpoint back to original */ + else if (!no_current_point) + /* Iff save_path is NULL, set currentpoint back to original + * (if there is one). */ gs_moveto(pgs, cursor.x, cursor.y); + return code; }