/* We know ppath != ppath_old. */ int gx_path_copy_reversed(const gx_path *ppath_old, gx_path *ppath, int init) { const subpath *psub = ppath_old->first_subpath; #ifdef DEBUG if ( gs_debug['p'] ) gx_dump_path(ppath_old, "before reversepath"); #endif if ( init ) gx_path_init(ppath, &ppath_old->memory_procs); nsp: while ( psub ) { const segment *pseg = psub->last; const segment *prev; int code = gx_path_add_point(ppath, pseg->pt.x, pseg->pt.y); if ( code < 0 ) { gx_path_release(ppath); return code; } for ( ; ; pseg = prev ) { prev = pseg->prev; switch ( pseg->type ) { case s_start: /* Finished subpath */ if ( psub->closed ) code = gx_path_close_subpath(ppath); psub = (const subpath *)psub->last->next; goto nsp; case s_curve: { const curve_segment *pc = (const curve_segment *)pseg; code = gx_path_add_curve(ppath, pc->p2.x, pc->p2.y, pc->p1.x, pc->p1.y, prev->pt.x, prev->pt.y); break; } case s_line: case s_line_close: code = gx_path_add_line(ppath, prev->pt.x, prev->pt.y); break; } if ( code ) { gx_path_release(ppath); return code; } } /* not reached */ } ppath->position = ppath_old->position; /* restore current point */ #ifdef DEBUG if ( gs_debug['p'] ) gx_dump_path(ppath, "after reversepath"); #endif return 0; }
int gs_newpath(gs_state *pgs) { gx_path_release(pgs->path); gx_path_init(pgs->path, &pgs->memory_procs); return 0; }