3
#include "splash/SplashMath.h"
4
#include "OPVPSplashPath.h"
5
#include "OPVPWrapper.h"
8
void OPVPSplashPath::getBBox(int *xMinA, int *yMinA, int *xMaxA,
12
SplashCoord xMin, yMin, xMax, yMax;
15
/* return far away point */
16
*xMinA = *yMinA = *xMaxA = *yMaxA = 0xC0000000;
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) {
24
} else if (pts[i].x < xMin) {
27
if (pts[i].y > yMax) {
29
} else if (pts[i].y < yMin) {
33
*xMinA = splashRound(xMin);
34
*xMaxA = splashRound(xMax);
35
*yMinA = splashRound(yMin);
36
*yMaxA = splashRound(yMax);
39
GBool OPVPSplashPath::isRectanglePath(
40
SplashCoord *xMin, SplashCoord *yMin, SplashCoord *xMax, SplashCoord *yMax)
43
|| pts[0].x != pts[4].x
44
|| pts[0].y != pts[4].y
45
|| flags[0] != (splashPathFirst | splashPathClosed)
49
|| flags[4] != (splashPathLast | splashPathClosed)) {
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)) {
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)) {
72
SplashCoord t = *xMin;
78
SplashCoord t = *yMin;
86
SplashError OPVPSplashPath::makePath(OPVPWrapper *opvp)
91
if (opvp->NewPath() < 0) {
92
OPRS::error("NewPath error\n");
95
for (i = 0;i < length;i = j) {
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;
115
if (i+2 < length && flags[i] == splashPathCurve) {
118
for (j = i;j+2 < length
119
&& flags[j] == splashPathCurve;j += 3);
122
for (j = i;j < length
123
&& (flags[j] & splashPathCurve) == 0
124
&& (flags[j] & splashPathFirst) == 0;j++);
128
points = new opvp_point_t[n];
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));
137
if (opvp->BezierPath(n,points) < 0) {
138
OPRS::error("BezierPath error\n");
139
return splashErrOPVP;
143
GBool closed = (flags[j-1] & splashPathClosed) != 0;
146
if (opvp->LinePath(OPVP_PATHCLOSE,
148
OPRS::error("LinePath error\n");
149
return splashErrOPVP;
152
if (opvp->LinePath(OPVP_PATHOPEN,
154
OPRS::error("LinePath error\n");
155
return splashErrOPVP;
161
if (opvp->EndPath() < 0) {
162
OPRS::error("EndPath error\n");
163
return splashErrOPVP;
168
void OPVPSplashPath::closeAllSubPath()
173
for (i = 0;i < length;i++) {
174
if ((flags[i] & splashPathFirst) != 0) {
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;