~ubuntu-branches/ubuntu/gutsy/dvipdfmx/gutsy

« back to all changes in this revision

Viewing changes to src/pdfdraw.c

  • Committer: Bazaar Package Importer
  • Author(s): Yu Guanghui
  • Date: 2007-02-23 20:48:19 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20070223204819-cmq5zsbprwjztzp9
Tags: upstream-20061211
ImportĀ upstreamĀ versionĀ 20061211

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  $Header: /home/cvsroot/dvipdfmx/src/pdfdraw.c,v 1.11 2005/08/31 08:01:05 chofchof Exp $
 
1
/*  $Header: /home/cvsroot/dvipdfmx/src/pdfdraw.c,v 1.13 2006/12/11 12:46:03 chofchof Exp $
2
2
    
3
3
    This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
4
4
 
1148
1148
}
1149
1149
#endif /* 0 */
1150
1150
 
1151
 
/* Implementation of the optimization of adjacent transform
1152
 
 * matrices, for example, "1 0 0 1 a b cm 1 0 0 1 c d cm" results
1153
 
 * "1 0 0 1 a+c b+d cm".
1154
 
 *
1155
 
 * The static variable ptM holds the information of pending
1156
 
 * transform matrices, and it will be flushed before any non
1157
 
 * transform command appears.
1158
 
 */
1159
 
static pdf_tmatrix *ptM = NULL;
1160
 
static char tmatrix_buf[1024]; /* FIXME: To avoid confliction with fmt_buf. */
1161
 
 
1162
 
/* pdf_dev_flushtmatrix() is called from pdf_doc_add_page_content()
1163
 
 * in pdfdoc.c
1164
 
 */
1165
 
int
1166
 
pdf_dev_flushtmatrix (char **buf)
1167
 
{
1168
 
  int len = 0;
1169
 
 
1170
 
  if (ptM) {
1171
 
    *buf = tmatrix_buf;
1172
 
    (*buf)[len++] = ' ';
1173
 
    len += pdf_sprint_matrix((*buf) + len, ptM);
1174
 
    /* Do not flush "1 0 0 1 0 0 cm". Sting check is faster than
1175
 
     * checking six double variables. */
1176
 
    if (!strncmp((*buf) + 1, "1 0 0 1 0 0", 11)) {
1177
 
      return 0;
1178
 
    }
1179
 
    (*buf)[len++] = ' ';
1180
 
    (*buf)[len++] = 'c';
1181
 
    (*buf)[len++] = 'm';
1182
 
    RELEASE(ptM);    
1183
 
    ptM = NULL;
1184
 
  }
1185
 
 
1186
 
  return len;
1187
 
}
1188
 
 
1189
1151
int
1190
1152
pdf_dev_concat (const pdf_tmatrix *M)
1191
1153
{
1195
1157
  pdf_coord   *cpt = &gs->cp;
1196
1158
  pdf_tmatrix *CTM = &gs->matrix;
1197
1159
  pdf_tmatrix  W;
 
1160
  char        *buf = FORMAT_BUFF_PTR(NULL);
 
1161
  int          len = 0;
1198
1162
 
1199
1163
  ASSERT(M);
1200
1164
 
1208
1172
    return -1;
1209
1173
  }
1210
1174
 
1211
 
  if (ptM) {
1212
 
    pdf_concatmatrix(ptM, M);
1213
 
  } else {
1214
 
    ptM = NEW(1, pdf_tmatrix);
1215
 
    pdf_copymatrix(ptM, M);
1216
 
  }
 
1175
  buf[len++] = ' ';
 
1176
  len += pdf_sprint_matrix(buf + len, M);
 
1177
  buf[len++] = ' ';
 
1178
  buf[len++] = 'c';
 
1179
  buf[len++] = 'm';
 
1180
  pdf_doc_add_page_content(buf, len);
1217
1181
 
1218
1182
  pdf_concatmatrix(CTM, M);
1219
1183
 
1310
1274
    pdf_dev__clean_gstate(gs);
1311
1275
    RELEASE(gs);
1312
1276
  }
1313
 
#if  0
1314
1277
  pdf_dev_reset_fonts();
1315
 
#else
1316
 
  pdf_dev_reset();
1317
 
#endif
 
1278
  pdf_dev_reset_color();
1318
1279
 
1319
1280
  return;
1320
1281
}
1341
1302
 
1342
1303
  pdf_doc_add_page_content(" Q", 2);
1343
1304
 
1344
 
#if  0
1345
1305
  pdf_dev_reset_fonts();
1346
 
#else
1347
 
  pdf_dev_reset();
1348
 
#endif
 
1306
  pdf_dev_reset_color();
1349
1307
 
1350
1308
  pdf_dev_setcolor(&sc, 0);
1351
1309
  pdf_dev_setcolor(&fc, 1);
1353
1311
  return  0;
1354
1312
}
1355
1313
 
1356
 
#if  0
1357
 
void
1358
 
pdf_dev_reset_color (void)
1359
 
{
1360
 
  m_stack    *gss = &_gsstck;
1361
 
  pdf_gstate *gs  = m_stack_top(gss);
1362
 
  pdf_color   fill, stroke;
1363
 
 
1364
 
  pdf_color_copycolor(&fill,   &gs->fillcolor);
1365
 
  pdf_color_copycolor(&stroke, &gs->strokecolor);
1366
 
 
1367
 
  /* Clear current color: */
1368
 
  pdf_color_graycolor(&gs->fillcolor,   0.0);
1369
 
  pdf_color_graycolor(&gs->strokecolor, 0.0);
1370
 
 
1371
 
  pdf_dev_setcolor(&stroke, 0);
1372
 
  pdf_dev_setcolor(&fill,   1);
1373
 
 
1374
 
  return;  
1375
 
}
1376
 
 
1377
 
int
1378
 
pdf_dev_setcolor (const pdf_color *color, int is_fill)
1379
 
{
1380
 
  m_stack    *gss = &_gsstck;
1381
 
  pdf_gstate *gs  = m_stack_top(gss);
1382
 
  pdf_color  *fcl = &gs->fillcolor;
1383
 
  pdf_color  *scl = &gs->strokecolor;
1384
 
  int         colormode;
1385
 
  pdf_color  *curcol;
1386
 
 
1387
 
  if (!color) {
1388
 
    WARN("No color specified.");
1389
 
    return -1;
1390
 
  }
1391
 
 
1392
 
  colormode = pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE);
1393
 
  if (!colormode) {
1394
 
    WARN("setcolor ignored. (Ignore color option set)");
1395
 
    return  0;
1396
 
  }
1397
 
 
1398
 
  curcol = is_fill ? fcl : scl;
1399
 
  if (!pdf_color_compare_color(color, curcol)) {
1400
 
    return 0;
1401
 
  }
1402
 
 
1403
 
  graphics_mode();
1404
 
  pdf_color_print_color(color, is_fill);
1405
 
 
1406
 
  pdf_color_copycolor(curcol, color);
1407
 
 
1408
 
  return 0;
1409
 
}
1410
 
#endif
1411
 
 
1412
1314
/*
1413
1315
 * num w        LW  linewidth (g.t. 0)
1414
1316
 * int J        LC  linecap