diff options
Diffstat (limited to 'Build/source/texk/dvipdfmx/src/pdfdraw.c')
-rw-r--r-- | Build/source/texk/dvipdfmx/src/pdfdraw.c | 335 |
1 files changed, 159 insertions, 176 deletions
diff --git a/Build/source/texk/dvipdfmx/src/pdfdraw.c b/Build/source/texk/dvipdfmx/src/pdfdraw.c index 444d177d9b0..cb348206c4b 100644 --- a/Build/source/texk/dvipdfmx/src/pdfdraw.c +++ b/Build/source/texk/dvipdfmx/src/pdfdraw.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfdraw.c,v 1.13 2006/12/11 12:46:03 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfdraw.c,v 1.14 2007/11/22 17:10:12 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -267,7 +267,7 @@ static char fmt_buf[1024]; /* FIXME */ #define FORMAT_BUFF_LEN(p) 1024 static void -pdf_path__initpath (pdf_path *p) +init_a_path (pdf_path *p) { ASSERT(p); @@ -301,7 +301,7 @@ pdf_path__growpath (pdf_path *p, int max_pe) } static void -pdf_path__cleanpath (pdf_path *p) +clear_a_path (pdf_path *p) { ASSERT(p); @@ -987,25 +987,18 @@ m_stack_top (m_stack *stack) #define m_stack_depth(s) ((s) ? (s)->size : 0) - -static m_stack _gsstck; /* FIXME */ - +static m_stack gs_stack; static void -pdf_dev__init_gstate (pdf_gstate *gs) +init_a_gstate (pdf_gstate *gs) { - pdf_path *pa = &gs->path; - pdf_color *cf = &gs->fillcolor; - pdf_color *cs = &gs->strokecolor; - pdf_tmatrix *M = &gs->matrix; - gs->cp.x = 0.0; gs->cp.y = 0.0; - pdf_setmatrix(M, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0); + pdf_setmatrix(&gs->matrix, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0); - pdf_color_graycolor(cs, 0.0); - pdf_color_graycolor(cf, 0.0); + pdf_color_graycolor(&gs->strokecolor, 0.0); + pdf_color_graycolor(&gs->fillcolor, 0.0); gs->linedash.num_dash = 0; gs->linedash.offset = 0; @@ -1018,22 +1011,22 @@ pdf_dev__init_gstate (pdf_gstate *gs) /* Internal variables */ gs->flags = 0; - pdf_path__initpath(pa); + init_a_path(&gs->path); return; } static void -pdf_dev__clean_gstate (pdf_gstate *gs) +clear_a_gstate (pdf_gstate *gs) { - pdf_path__cleanpath(&gs->path); + clear_a_path(&gs->path); memset(gs, 0, sizeof(pdf_gstate)); return; } static void -pdf_dev__copy_gstate (pdf_gstate *gs1, pdf_gstate *gs2) +copy_a_gstate (pdf_gstate *gs1, pdf_gstate *gs2) { int i; @@ -1072,156 +1065,89 @@ pdf_dev__copy_gstate (pdf_gstate *gs1, pdf_gstate *gs2) void pdf_dev_init_gstates (void) { - m_stack *gss = &_gsstck; pdf_gstate *gs; - m_stack_init(gss); + m_stack_init(&gs_stack); gs = NEW(1, pdf_gstate); - pdf_dev__init_gstate(gs); + init_a_gstate(gs); - m_stack_push(gss, gs); /* Initial state */ + m_stack_push(&gs_stack, gs); /* Initial state */ return; } void -pdf_dev_clean_gstates (void) +pdf_dev_clear_gstates (void) { - m_stack *gss = &_gsstck; pdf_gstate *gs; - if (m_stack_depth(gss) > 1) /* at least 1 elem. */ - WARN("GS stack depth not 0 at end of document."); + if (m_stack_depth(&gs_stack) > 1) /* at least 1 elem. */ + WARN("GS stack depth is not zero at the end of the document."); - while ((gs = m_stack_pop(gss)) != NULL) { - pdf_dev__clean_gstate(gs); + while ((gs = m_stack_pop(&gs_stack)) != NULL) { + clear_a_gstate(gs); RELEASE(gs); } - return; } - -int -pdf_dev_currentpoint (pdf_coord *p) -{ - m_stack *gss = &_gsstck; - pdf_gstate *gs = m_stack_top(gss); - pdf_coord *cpt = &gs->cp; - - ASSERT(p); - - p->x = cpt->x; p->y = cpt->y; - - return 0; -} - -int -pdf_dev_currentmatrix (pdf_tmatrix *M) -{ - m_stack *gss = &_gsstck; - pdf_gstate *gs = m_stack_top(gss); - pdf_tmatrix *CTM = &gs->matrix; - - ASSERT(M); - - pdf_copymatrix(M, CTM); - - return 0; -} - -#if 0 int -pdf_dev_currentcolor (pdf_color *color, int is_fill) +pdf_dev_gsave (void) { - m_stack *gss = &_gsstck; - pdf_gstate *gs = m_stack_top(gss); - pdf_color *fcl = &gs->fillcolor; - pdf_color *scl = &gs->strokecolor; + pdf_gstate *gs0, *gs1; + pdf_color *sc, *fc; - ASSERT(color); + gs0 = m_stack_top(&gs_stack); + gs1 = NEW(1, pdf_gstate); + init_a_gstate(gs1); + copy_a_gstate(gs1, gs0); + pdf_color_get_current(&sc, &fc); + pdf_color_copycolor(&gs1->strokecolor, sc); + pdf_color_copycolor(&gs1->fillcolor, fc); + m_stack_push(&gs_stack, gs1); - pdf_color_copycolor(color, is_fill ? fcl : scl); + pdf_doc_add_page_content(" q", 2); return 0; } -#endif /* 0 */ int -pdf_dev_concat (const pdf_tmatrix *M) +pdf_dev_grestore (void) { - m_stack *gss = &_gsstck; - pdf_gstate *gs = m_stack_top(gss); - pdf_path *cpa = &gs->path; - pdf_coord *cpt = &gs->cp; - pdf_tmatrix *CTM = &gs->matrix; - pdf_tmatrix W; - char *buf = FORMAT_BUFF_PTR(NULL); - int len = 0; - - ASSERT(M); + pdf_gstate *gs; + pdf_color sc, fc; - /* Adobe Reader erases page content if there are - * non invertible transformation. - */ - if (fabs(detP(M)) < 1.0e-8) { - WARN("Transformation matrix not invertible."); - WARN("--- M = [%g %g %g %g %g %g]", - M->a, M->b, M->c, M->d, M->e, M->f); - return -1; + if (m_stack_depth(&gs_stack) <= 1) { /* Initial state at bottom */ + WARN("Too many grestores."); + return -1; } - buf[len++] = ' '; - len += pdf_sprint_matrix(buf + len, M); - buf[len++] = ' '; - buf[len++] = 'c'; - buf[len++] = 'm'; - pdf_doc_add_page_content(buf, len); - - pdf_concatmatrix(CTM, M); - - inversematrix(&W, M); - - pdf_path__transform (cpa, &W); - pdf_coord__transform(cpt, &W); - - return 0; -} - - -int -pdf_dev_gsave (void) -{ - m_stack *gss = &_gsstck; - pdf_gstate *gs0, *gs1; - - gs0 = m_stack_top(gss); - gs1 = NEW(1, pdf_gstate); - - pdf_dev__init_gstate(gs1); - pdf_dev__copy_gstate(gs1, gs0); - - pdf_dev_currentcolor(&gs1->strokecolor, 0); - pdf_dev_currentcolor(&gs1->fillcolor, 1); + gs = m_stack_pop(&gs_stack); +// pdf_color_copycolor(&sc, &gs->strokecolor); +// pdf_color_copycolor(&fc, &gs->fillcolor); + clear_a_gstate(gs); + RELEASE(gs); - m_stack_push(gss, gs1); + pdf_doc_add_page_content(" Q", 2); - pdf_doc_add_page_content(" q", 2); + pdf_dev_reset_fonts(); +// pdf_dev_set_strokingcolor(&sc); +// pdf_dev_set_nonstrokingcolor(&fc); - return 0; + return 0; } int pdf_dev_push_gstate (void) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs0; gs0 = NEW(1, pdf_gstate); - pdf_dev__init_gstate(gs0); + init_a_gstate(gs0); m_stack_push(gss, gs0); @@ -1232,7 +1158,7 @@ pdf_dev_push_gstate (void) int pdf_dev_pop_gstate (void) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs; if (m_stack_depth(gss) <= 1) { /* Initial state at bottom */ @@ -1241,7 +1167,7 @@ pdf_dev_pop_gstate (void) } gs = m_stack_pop(gss); - pdf_dev__clean_gstate(gs); + clear_a_gstate(gs); RELEASE(gs); return 0; @@ -1251,16 +1177,15 @@ pdf_dev_pop_gstate (void) int pdf_dev_current_depth (void) { - m_stack *gss = &_gsstck; - - return (m_stack_depth(gss) - 1); /* 0 means initial state */ + return (m_stack_depth(&gs_stack) - 1); /* 0 means initial state */ } void pdf_dev_grestore_to (int depth) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs; + pdf_color sc, fc; ASSERT(depth >= 0); @@ -1271,44 +1196,102 @@ pdf_dev_grestore_to (int depth) while (m_stack_depth(gss) > depth + 1) { pdf_doc_add_page_content(" Q", 2); gs = m_stack_pop(gss); - pdf_dev__clean_gstate(gs); +// pdf_color_copycolor(&sc, &gs->strokecolor); +// pdf_color_copycolor(&fc, &gs->fillcolor); + clear_a_gstate(gs); RELEASE(gs); } pdf_dev_reset_fonts(); - pdf_dev_reset_color(); +// pdf_dev_set_strokingcolor(&sc); +// pdf_dev_set_nonstrokingcolor(&fc); return; } int -pdf_dev_grestore (void) +pdf_dev_currentpoint (pdf_coord *p) { - m_stack *gss = &_gsstck; - pdf_gstate *gs; - pdf_color sc, fc; + m_stack *gss = &gs_stack; + pdf_gstate *gs = m_stack_top(gss); + pdf_coord *cpt = &gs->cp; - if (m_stack_depth(gss) <= 1) { /* Initial state at bottom */ - WARN("Too many grestores."); - return -1; - } + ASSERT(p); - gs = m_stack_pop(gss); + p->x = cpt->x; p->y = cpt->y; + + return 0; +} - pdf_color_copycolor(&sc, &gs->strokecolor); - pdf_color_copycolor(&fc, &gs->fillcolor); +int +pdf_dev_currentmatrix (pdf_tmatrix *M) +{ + m_stack *gss = &gs_stack; + pdf_gstate *gs = m_stack_top(gss); + pdf_tmatrix *CTM = &gs->matrix; - pdf_dev__clean_gstate(gs); - RELEASE(gs); + ASSERT(M); - pdf_doc_add_page_content(" Q", 2); + pdf_copymatrix(M, CTM); - pdf_dev_reset_fonts(); - pdf_dev_reset_color(); + return 0; +} - pdf_dev_setcolor(&sc, 0); - pdf_dev_setcolor(&fc, 1); +#if 0 +int +pdf_dev_currentcolor (pdf_color *color, int is_fill) +{ + m_stack *gss = &gs_stack; + pdf_gstate *gs = m_stack_top(gss); + pdf_color *fcl = &gs->fillcolor; + pdf_color *scl = &gs->strokecolor; - return 0; + ASSERT(color); + + pdf_color_copycolor(color, is_fill ? fcl : scl); + + return 0; +} +#endif /* 0 */ + +int +pdf_dev_concat (const pdf_tmatrix *M) +{ + m_stack *gss = &gs_stack; + pdf_gstate *gs = m_stack_top(gss); + pdf_path *cpa = &gs->path; + pdf_coord *cpt = &gs->cp; + pdf_tmatrix *CTM = &gs->matrix; + pdf_tmatrix W; + char *buf = FORMAT_BUFF_PTR(NULL); + int len = 0; + + ASSERT(M); + + /* Adobe Reader erases page content if there are + * non invertible transformation. + */ + if (fabs(detP(M)) < 1.0e-8) { + WARN("Transformation matrix not invertible."); + WARN("--- M = [%g %g %g %g %g %g]", + M->a, M->b, M->c, M->d, M->e, M->f); + return -1; + } + + buf[len++] = ' '; + len += pdf_sprint_matrix(buf + len, M); + buf[len++] = ' '; + buf[len++] = 'c'; + buf[len++] = 'm'; + pdf_doc_add_page_content(buf, len); + + pdf_concatmatrix(CTM, M); + + inversematrix(&W, M); + + pdf_path__transform (cpa, &W); + pdf_coord__transform(cpt, &W); + + return 0; } /* @@ -1324,7 +1307,7 @@ pdf_dev_grestore (void) int pdf_dev_setmiterlimit (double mlimit) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); int len = 0; char *buf = FORMAT_BUFF_PTR(NULL); @@ -1344,7 +1327,7 @@ pdf_dev_setmiterlimit (double mlimit) int pdf_dev_setlinecap (int capstyle) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); int len = 0; char *buf = FORMAT_BUFF_PTR(NULL); @@ -1361,7 +1344,7 @@ pdf_dev_setlinecap (int capstyle) int pdf_dev_setlinejoin (int joinstyle) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); int len = 0; char *buf = FORMAT_BUFF_PTR(NULL); @@ -1378,7 +1361,7 @@ pdf_dev_setlinejoin (int joinstyle) int pdf_dev_setlinewidth (double width) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); int len = 0; char *buf = FORMAT_BUFF_PTR(NULL); @@ -1398,7 +1381,7 @@ pdf_dev_setlinewidth (double width) int pdf_dev_setdash (int count, double *pattern, double offset) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); int len = 0; char *buf = FORMAT_BUFF_PTR(NULL); @@ -1424,7 +1407,7 @@ pdf_dev_setdash (int count, double *pattern, double offset) int pdf_dev_setflat (int flatness) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); int len = 0; char *buf = FORMAT_BUFF_PTR(NULL); @@ -1445,7 +1428,7 @@ pdf_dev_setflat (int flatness) int pdf_dev_clip (void) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_path *cpa = &gs->path; @@ -1455,7 +1438,7 @@ pdf_dev_clip (void) int pdf_dev_eoclip (void) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_path *cpa = &gs->path; @@ -1465,7 +1448,7 @@ pdf_dev_eoclip (void) int pdf_dev_flushpath (char p_op, int fill_rule) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_path *cpa = &gs->path; int error = 0; @@ -1485,7 +1468,7 @@ pdf_dev_flushpath (char p_op, int fill_rule) int pdf_dev_newpath (void) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_path *p = &gs->path; @@ -1501,7 +1484,7 @@ pdf_dev_newpath (void) int pdf_dev_moveto (double x, double y) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_path *cpa = &gs->path; pdf_coord *cpt = &gs->cp; @@ -1514,7 +1497,7 @@ pdf_dev_moveto (double x, double y) int pdf_dev_rmoveto (double x, double y) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_path *cpa = &gs->path; pdf_coord *cpt = &gs->cp; @@ -1528,7 +1511,7 @@ pdf_dev_rmoveto (double x, double y) int pdf_dev_lineto (double x, double y) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_path *cpa = &gs->path; pdf_coord *cpt = &gs->cp; @@ -1542,7 +1525,7 @@ pdf_dev_lineto (double x, double y) int pdf_dev_rlineto (double x, double y) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_path *cpa = &gs->path; pdf_coord *cpt = &gs->cp; @@ -1558,7 +1541,7 @@ pdf_dev_curveto (double x0, double y0, double x1, double y1, double x2, double y2) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_path *cpa = &gs->path; pdf_coord *cpt = &gs->cp; @@ -1576,7 +1559,7 @@ pdf_dev_rcurveto (double x0, double y0, double x1, double y1, double x2, double y2) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_path *cpa = &gs->path; pdf_coord *cpt = &gs->cp; @@ -1593,7 +1576,7 @@ pdf_dev_rcurveto (double x0, double y0, int pdf_dev_closepath (void) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_coord *cpt = &gs->cp; pdf_path *cpa = &gs->path; @@ -1605,7 +1588,7 @@ pdf_dev_closepath (void) void pdf_dev_dtransform (pdf_coord *p, const pdf_tmatrix *M) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_tmatrix *CTM = &gs->matrix; @@ -1619,7 +1602,7 @@ pdf_dev_dtransform (pdf_coord *p, const pdf_tmatrix *M) void pdf_dev_idtransform (pdf_coord *p, const pdf_tmatrix *M) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_tmatrix *CTM = &gs->matrix; @@ -1633,7 +1616,7 @@ pdf_dev_idtransform (pdf_coord *p, const pdf_tmatrix *M) void pdf_dev_transform (pdf_coord *p, const pdf_tmatrix *M) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_tmatrix *CTM = &gs->matrix; @@ -1647,7 +1630,7 @@ pdf_dev_transform (pdf_coord *p, const pdf_tmatrix *M) void pdf_dev_itransform (pdf_coord *p, const pdf_tmatrix *M) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_tmatrix *CTM = &gs->matrix; @@ -1662,7 +1645,7 @@ int pdf_dev_arc (double c_x , double c_y, double r, double a_0 , double a_1) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_path *cpa = &gs->path; pdf_coord *cpt = &gs->cp; @@ -1678,7 +1661,7 @@ int pdf_dev_arcn (double c_x , double c_y, double r, double a_0 , double a_1) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_path *cpa = &gs->path; pdf_coord *cpt = &gs->cp; @@ -1696,7 +1679,7 @@ pdf_dev_arcx (double c_x , double c_y, int a_d , double xar) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_path *cpa = &gs->path; pdf_coord *cpt = &gs->cp; @@ -1712,7 +1695,7 @@ int pdf_dev_bspline (double x0, double y0, double x1, double y1, double x2, double y2) { - m_stack *gss = &_gsstck; + m_stack *gss = &gs_stack; pdf_gstate *gs = m_stack_top(gss); pdf_path *cpa = &gs->path; pdf_coord *cpt = &gs->cp; |