summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvipdfm-x/xsrc/pdfdraw.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/dvipdfm-x/xsrc/pdfdraw.c')
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/pdfdraw.c114
1 files changed, 89 insertions, 25 deletions
diff --git a/Build/source/texk/dvipdfm-x/xsrc/pdfdraw.c b/Build/source/texk/dvipdfm-x/xsrc/pdfdraw.c
index 2d1ab02c29c..334649b3bec 100644
--- a/Build/source/texk/dvipdfm-x/xsrc/pdfdraw.c
+++ b/Build/source/texk/dvipdfm-x/xsrc/pdfdraw.c
@@ -156,7 +156,7 @@ pdf_coord__itransform (pdf_coord *p, const pdf_tmatrix *M)
return 0;
}
-#endif /* 0 */
+#endif
static /* __inline__ */ int
pdf_coord__dtransform (pdf_coord *p, const pdf_tmatrix *M)
@@ -802,7 +802,7 @@ pdf_dev__rectshape (pdf_dev *P,
buf[len++] = isclip ? 'n' : 'Q';
}
- pdf_doc_add_page_content(buf, len); len = 0;
+ pdf_doc_add_page_content(buf, len); /* op: q cm n re Q */
return 0;
}
@@ -851,7 +851,8 @@ pdf_dev__flushpath (pdf_dev *P,
b[len++] = ' ';
b[len++] = 'r';
b[len++] = 'e';
- pdf_doc_add_page_content(b, len); len = 0;
+ pdf_doc_add_page_content(b, len); /* op: re */
+ len = 0;
} else {
n_seg = PA_LENGTH(pa);
for (i = 0, len = 0, pe = &pa->path[0];
@@ -865,11 +866,13 @@ pdf_dev__flushpath (pdf_dev *P,
b[len++] = ' ';
b[len++] = PE_OPCHR(pe);
if (len + 128 > b_len) {
- pdf_doc_add_page_content(b, len); len = 0;
+ pdf_doc_add_page_content(b, len); /* op: m l c v y h */
+ len = 0;
}
}
if (len > 0) {
- pdf_doc_add_page_content(b, len); len = 0;
+ pdf_doc_add_page_content(b, len); /* op: m l c v y h */
+ len = 0;
}
}
@@ -881,7 +884,7 @@ pdf_dev__flushpath (pdf_dev *P,
b[len++] = ' '; b[len++] = 'n';
}
- pdf_doc_add_page_content(b, len);
+ pdf_doc_add_page_content(b, len); /* op: f F s S b B W f* F* s* S* b* B* W* */
return 0;
}
@@ -1129,7 +1132,7 @@ pdf_dev_gsave (void)
pdf_color_copycolor(&gs1->fillcolor, fc);
m_stack_push(&gs_stack, gs1);
- pdf_doc_add_page_content(" q", 2);
+ pdf_doc_add_page_content(" q", 2); /* op: q */
return 0;
}
@@ -1148,7 +1151,7 @@ pdf_dev_grestore (void)
clear_a_gstate(gs);
RELEASE(gs);
- pdf_doc_add_page_content(" Q", 2);
+ pdf_doc_add_page_content(" Q", 2); /* op: Q */
pdf_dev_reset_fonts();
@@ -1210,7 +1213,7 @@ pdf_dev_grestore_to (int depth)
}
while (m_stack_depth(gss) > depth + 1) {
- pdf_doc_add_page_content(" Q", 2);
+ pdf_doc_add_page_content(" Q", 2); /* op: Q */
gs = m_stack_pop(gss);
clear_a_gstate(gs);
RELEASE(gs);
@@ -1265,6 +1268,63 @@ pdf_dev_currentcolor (pdf_color *color, int is_fill)
}
#endif /* 0 */
+#ifndef XETEX
+/*
+ * mask == 0 means stroking color, mask == 0x20 nonstroking color
+ *
+ * force == 1 means that operators will be generated even if
+ * the color is the same as the current graphics state color
+ */
+void
+pdf_dev_set_color (const pdf_color *color, char mask, int force)
+{
+ int len;
+
+ pdf_gstate *gs = m_stack_top(&gs_stack);
+ pdf_color *current = mask ? &gs->fillcolor : &gs->strokecolor;
+
+ ASSERT(pdf_color_is_valid(color));
+
+ if (!(pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE) &&
+ (force || pdf_color_compare(color, current))))
+ /* If "color" is already the current color, then do nothing
+ * unless a color operator is forced
+ */
+ return;
+
+ graphics_mode();
+ len = pdf_color_to_string(color, fmt_buf);
+ fmt_buf[len++] = ' ';
+ switch (pdf_color_type(color)) {
+ case PDF_COLORSPACE_TYPE_RGB:
+ fmt_buf[len++] = 'R' | mask;
+ fmt_buf[len++] = 'G' | mask;
+ break;
+ case PDF_COLORSPACE_TYPE_CMYK:
+ fmt_buf[len++] = 'K' | mask;
+ break;
+ case PDF_COLORSPACE_TYPE_GRAY:
+ fmt_buf[len++] = 'G' | mask;
+ break;
+ default: /* already verified the given color */
+ break;
+ }
+ pdf_doc_add_page_content(fmt_buf, len); /* op: RG K G rg k g */
+
+ pdf_color_copycolor(current, color);
+}
+
+void
+pdf_dev_reset_color (int force)
+{
+ pdf_color *sc, *fc;
+
+ pdf_color_get_current(&sc, &fc);
+ pdf_dev_set_color(sc, 0, force);
+ pdf_dev_set_color(fc, 0x20, force);
+}
+#endif
+
int
pdf_dev_concat (const pdf_tmatrix *M)
{
@@ -1297,7 +1357,7 @@ pdf_dev_concat (const pdf_tmatrix *M)
buf[len++] = ' ';
buf[len++] = 'c';
buf[len++] = 'm';
- pdf_doc_add_page_content(buf, len);
+ pdf_doc_add_page_content(buf, len); /* op: cm */
pdf_concatmatrix(CTM, M);
}
@@ -1332,7 +1392,7 @@ pdf_dev_setmiterlimit (double mlimit)
len += pdf_sprint_length(buf + len, mlimit);
buf[len++] = ' ';
buf[len++] = 'M';
- pdf_doc_add_page_content(buf, len);
+ pdf_doc_add_page_content(buf, len); /* op: M */
gs->miterlimit = mlimit;
}
@@ -1349,7 +1409,7 @@ pdf_dev_setlinecap (int capstyle)
if (gs->linecap != capstyle) {
len = sprintf(buf, " %d J", capstyle);
- pdf_doc_add_page_content(buf, len);
+ pdf_doc_add_page_content(buf, len); /* op: J */
gs->linecap = capstyle;
}
@@ -1366,7 +1426,7 @@ pdf_dev_setlinejoin (int joinstyle)
if (gs->linejoin != joinstyle) {
len = sprintf(buf, " %d j", joinstyle);
- pdf_doc_add_page_content(buf, len);
+ pdf_doc_add_page_content(buf, len); /* op: j */
gs->linejoin = joinstyle;
}
@@ -1386,7 +1446,7 @@ pdf_dev_setlinewidth (double width)
len += pdf_sprint_length(buf + len, width);
buf[len++] = ' ';
buf[len++] = 'w';
- pdf_doc_add_page_content(buf, len);
+ pdf_doc_add_page_content(buf, len); /* op: w */
gs->linewidth = width;
}
@@ -1404,17 +1464,17 @@ pdf_dev_setdash (int count, double *pattern, double offset)
gs->linedash.num_dash = count;
gs->linedash.offset = offset;
- pdf_doc_add_page_content(" [", 2);
+ pdf_doc_add_page_content(" [", 2); /* op: */
for (i = 0; i < count; i++) {
buf[0] = ' ';
len = pdf_sprint_length (buf + 1, pattern[i]);
- pdf_doc_add_page_content(buf, len + 1);
+ pdf_doc_add_page_content(buf, len + 1); /* op: */
gs->linedash.pattern[i] = pattern[i];
}
- pdf_doc_add_page_content("] ", 2);
+ pdf_doc_add_page_content("] ", 2); /* op: */
len = pdf_sprint_length (buf, offset);
- pdf_doc_add_page_content(buf, len);
- pdf_doc_add_page_content(" d", 2);
+ pdf_doc_add_page_content(buf, len); /* op: */
+ pdf_doc_add_page_content(" d", 2); /* op: d */
return 0;
}
@@ -1434,13 +1494,13 @@ pdf_dev_setflat (int flatness)
if (gs->flatness != flatness) {
gs->flatness = flatness;
len = sprintf(buf, " %d i", flatness);
- pdf_doc_add_page_content(buf, len);
+ pdf_doc_add_page_content(buf, len); /* op: i */
}
return 0;
}
-#endif /* 0 */
-
+#endif
+
/* ZSYUEDVEDEOF */
int
pdf_dev_clip (void)
@@ -1493,7 +1553,7 @@ pdf_dev_newpath (void)
pdf_path__clearpath (p);
}
/* The following is required for "newpath" operator in mpost.c. */
- pdf_doc_add_page_content(" n", 2);
+ pdf_doc_add_page_content(" n", 2); /* op: n */
return 0;
}
@@ -1571,6 +1631,7 @@ pdf_dev_curveto (double x0, double y0,
return pdf_path__curveto(cpa, cpt, &p0, &p1, &p2);
}
+#ifdef XETEX
int
pdf_dev_vcurveto (double x0, double y0,
double x1, double y1)
@@ -1602,6 +1663,7 @@ pdf_dev_ycurveto (double x0, double y0,
return pdf_path__curveto(cpa, cpt, &p0, &p1, &p1);
}
+#endif
int
pdf_dev_rcurveto (double x0, double y0,
@@ -1690,7 +1752,7 @@ pdf_dev_itransform (pdf_coord *p, const pdf_tmatrix *M)
return;
}
-#endif /* 0 */
+#endif
int
pdf_dev_arc (double c_x , double c_y, double r,
@@ -1778,7 +1840,7 @@ pdf_dev_rectstroke (double x, double y,
return pdf_dev__rectshape(NULL, &r, M, 'S');
}
-#endif /* 0 */
+#endif
int
pdf_dev_rectfill (double x, double y,
@@ -1808,6 +1870,7 @@ pdf_dev_rectclip (double x, double y,
return pdf_dev__rectshape(NULL, &r, NULL, 'W');
}
+#ifdef XETEX
int
pdf_dev_rectadd (double x, double y,
double w, double h)
@@ -1840,3 +1903,4 @@ pdf_dev_get_fixed_point (pdf_coord *p)
p->x = gs->pt_fixee.x;
p->y = gs->pt_fixee.y;
}
+#endif