~ubuntu-branches/ubuntu/raring/cups-filters/raring-proposed

« back to all changes in this revision

Viewing changes to pdftoopvp/oprs/OPVPSplashPath.cxx

  • Committer: Package Import Robot
  • Author(s): Till Kamppeter
  • Date: 2012-07-22 18:57:32 UTC
  • mfrom: (1.1.17)
  • Revision ID: package-import@ubuntu.com-20120722185732-26kkte5p1lth3rt5
Tags: 1.0.20-0bzr1
* New upstream release
   - pdftops: Added another workaround for Kyocera printers: Some
     models get very slow on images which request interpolation,
     so now we remove the image interpolation requests by additional
     PostScript code only inserted for Kyocera printers (LP: #1026974).
   - Made the Poppler-based filters pdftopdf and pdftoopvp build with
     both Poppler 0.18.x and 0.20.x (Upstream bug #1055).
   - Fixes according to Coverity scan results (Upstream bug #1054).
   - Switched build system to autotools. This especially fixes several
     build problems in Gentoo. Also build-tested with CUPS 1.6.0b1.
   - Fixes for compatibility with clang/gcc-4.7.
   - textonly: Filter did not work as a pipe with copies=1 (Upstream bug
     #1032).
   - texttopdf: Avoid trimming the results of FcFontSort(), as this may
     miss some reasonable candidates under certain circumstances. BTW,
     fix passing a non-pointer as a pointer to "result" (Closes: #670055).
   - Corrected documentation. The option for the maximum image rendering
     resolution in pdftops is "pdftops-max-image-resolution", not
     "pdftops-max-image-resolution-default".
* debian/patches/fcfontsort-no-trim.patch: Removed, fixed upstream.
* debian/rules: Updated options for ./configure and make for the new autotools
  build system.
* debian/watch: Switched to bz2 upstream packages.
* debian/rules, debian/copyright, debian/cups-filters.docs: Updated for
  renamed documentation files.
* debian/control, debian/libfontembed1.install,
  debian/libfontembed-dev.install: Added new binary packages for libfontembed.
* debian/copyright: Updated for recent file additions, and rearrangement of
  directories.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <config.h>
2
 
#include <stdio.h>
3
 
#include "splash/SplashMath.h"
4
 
#include "OPVPSplashPath.h"
5
 
#include "OPVPWrapper.h"
6
 
#include "OPRS.h"
7
 
 
8
 
void OPVPSplashPath::getBBox(int *xMinA, int *yMinA, int *xMaxA,
9
 
    int *yMaxA)
10
 
{
11
 
  int i;
12
 
  SplashCoord xMin, yMin, xMax, yMax;
13
 
 
14
 
  if (length <= 0) {
15
 
    /* return far away point */
16
 
    *xMinA = *yMinA = *xMaxA = *yMaxA = 0xC0000000;
17
 
    return;
18
 
  }
19
 
  xMin = xMax = pts[0].x;
20
 
  yMin = yMax = pts[0].y;
21
 
  for (i = 1;i < length;i++) {
22
 
    if (pts[i].x > xMax) {
23
 
      xMax = pts[i].x;
24
 
    } else if (pts[i].x < xMin) {
25
 
      xMin = pts[i].x;
26
 
    }
27
 
    if (pts[i].y > yMax) {
28
 
      yMax = pts[i].y;
29
 
    } else if (pts[i].y < yMin) {
30
 
      yMin = pts[i].y;
31
 
    }
32
 
  }
33
 
  *xMinA = splashRound(xMin);
34
 
  *xMaxA = splashRound(xMax);
35
 
  *yMinA = splashRound(yMin);
36
 
  *yMaxA = splashRound(yMax);
37
 
}
38
 
 
39
 
GBool OPVPSplashPath::isRectanglePath(
40
 
  SplashCoord *xMin, SplashCoord *yMin, SplashCoord *xMax, SplashCoord *yMax)
41
 
{
42
 
  if (length != 5
43
 
      || pts[0].x != pts[4].x
44
 
      || pts[0].y != pts[4].y
45
 
      || flags[0] != (splashPathFirst | splashPathClosed)
46
 
      || flags[1] != 0
47
 
      || flags[2] != 0
48
 
      || flags[3] != 0
49
 
      || flags[4] != (splashPathLast | splashPathClosed)) {
50
 
    return gFalse;
51
 
  }
52
 
  if (splashRound(pts[0].x) == splashRound(pts[1].x)) {
53
 
    if (splashRound(pts[1].y) != splashRound(pts[2].y)
54
 
      || splashRound(pts[2].x) != splashRound(pts[3].x)
55
 
      || splashRound(pts[3].y) != splashRound(pts[4].y)) {
56
 
      return gFalse;
57
 
    }
58
 
  } else if (splashRound(pts[0].y) == splashRound(pts[1].y)) {
59
 
    if (splashRound(pts[1].x) != splashRound(pts[2].x)
60
 
      || splashRound(pts[2].y) != splashRound(pts[3].y)
61
 
      || splashRound(pts[3].x) != splashRound(pts[4].x)) {
62
 
      return gFalse;
63
 
    }
64
 
  } else {
65
 
    return gFalse;
66
 
  }
67
 
  *xMin = pts[0].x;
68
 
  *yMin = pts[0].y;
69
 
  *xMax = pts[2].x;
70
 
  *yMax = pts[2].y;
71
 
  if (*xMin > *xMax) {
72
 
    SplashCoord t = *xMin;
73
 
 
74
 
    *xMin = *xMax;
75
 
    *xMax = t;
76
 
  }
77
 
  if (*yMin > *yMax) {
78
 
    SplashCoord t = *yMin;
79
 
 
80
 
    *yMin = *yMax;
81
 
    *yMax = t;
82
 
  }
83
 
  return gTrue;
84
 
}
85
 
 
86
 
SplashError OPVPSplashPath::makePath(OPVPWrapper *opvp)
87
 
{
88
 
  int i,j;
89
 
  opvp_fix_t x,y;
90
 
 
91
 
  if (opvp->NewPath() < 0) {
92
 
    OPRS::error("NewPath error\n");
93
 
    return splashErrOPVP;
94
 
  }
95
 
  for (i = 0;i < length;i = j) {
96
 
    int curve = 0; 
97
 
    int n;
98
 
    opvp_point_t *points;
99
 
    int k;
100
 
 
101
 
    if ((flags[i] & splashPathFirst) != 0) {
102
 
      /* first point of a subpath */
103
 
      if ((flags[i] & splashPathLast) == 0
104
 
          || (flags[i] & splashPathClosed) != 0) {
105
 
        OPVP_F2FIX((pts[i].x),(x));
106
 
        OPVP_F2FIX((pts[i].y),(y));
107
 
        if (opvp->SetCurrentPoint(x,y) < 0) {
108
 
          OPRS::error("SetCurrentPoint error\n");
109
 
          return splashErrOPVP;
110
 
        }
111
 
      }
112
 
      j = i+1;
113
 
      continue;
114
 
    }
115
 
    if (i+2 < length && flags[i] == splashPathCurve) {
116
 
      /* curve */
117
 
      curve = 1;
118
 
      for (j = i;j+2 < length
119
 
         && flags[j] == splashPathCurve;j += 3);
120
 
    } else {
121
 
      curve = 0;
122
 
      for (j = i;j < length
123
 
         && (flags[j] & splashPathCurve) == 0
124
 
         && (flags[j] & splashPathFirst) == 0;j++);
125
 
    }
126
 
 
127
 
    n = j-i;
128
 
    points = new opvp_point_t[n];
129
 
    /* copy points */
130
 
    for (k = i; k < j;k++) {
131
 
      OPVP_F2FIX((pts[k].x),(points[k-i].x));
132
 
      OPVP_F2FIX((pts[k].y),(points[k-i].y));
133
 
    }
134
 
 
135
 
    if (curve) {
136
 
      /* curve */
137
 
      if (opvp->BezierPath(n,points) < 0) {
138
 
        OPRS::error("BezierPath error\n");
139
 
        return splashErrOPVP;
140
 
      }
141
 
    } else {
142
 
      /* line */
143
 
      GBool closed = (flags[j-1] & splashPathClosed) != 0;
144
 
 
145
 
      if (closed) {
146
 
        if (opvp->LinePath(OPVP_PATHCLOSE,
147
 
              n,points) < 0) {
148
 
          OPRS::error("LinePath error\n");
149
 
          return splashErrOPVP;
150
 
        }
151
 
      } else {
152
 
        if (opvp->LinePath(OPVP_PATHOPEN,
153
 
              n,points) < 0) {
154
 
          OPRS::error("LinePath error\n");
155
 
          return splashErrOPVP;
156
 
        }
157
 
      }
158
 
    }
159
 
    delete[] points;
160
 
  }
161
 
  if (opvp->EndPath() < 0) {
162
 
    OPRS::error("EndPath error\n");
163
 
    return splashErrOPVP;
164
 
  }
165
 
  return splashOk;
166
 
}
167
 
 
168
 
void OPVPSplashPath::closeAllSubPath()
169
 
{
170
 
  int i;
171
 
  int f = 0;
172
 
 
173
 
  for (i = 0;i < length;i++) {
174
 
    if ((flags[i] & splashPathFirst) != 0) {
175
 
      f = i;
176
 
    }
177
 
    if ((flags[i] & splashPathLast) != 0) {
178
 
      if (pts[f].x == pts[i].x
179
 
        && pts[f].y == pts[i].y) {
180
 
        flags[f] |= splashPathClosed;
181
 
        flags[i] |= splashPathClosed;
182
 
      }
183
 
    }
184
 
  }
185
 
}