Skip to content

Commit 339537d

Browse files
committed
Fix curve simplification
1 parent cfbf8d5 commit 339537d

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/path_converters.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class EmbeddedQueue
5959
{
6060
}
6161

62-
inline void set(const unsigned cmd_, const double &x_, const double &y_)
62+
inline void set(const unsigned cmd_, const double x_, const double y_)
6363
{
6464
cmd = cmd_;
6565
x = x_;
@@ -73,7 +73,7 @@ class EmbeddedQueue
7373
int m_queue_write;
7474
item m_queue[QueueSize];
7575

76-
inline void queue_push(const unsigned cmd, const double &x, const double &y)
76+
inline void queue_push(const unsigned cmd, const double x, const double y)
7777
{
7878
m_queue[m_queue_write++].set(cmd, x, y);
7979
}
@@ -107,6 +107,14 @@ class EmbeddedQueue
107107
}
108108
};
109109

110+
/* Defines when path segment types have more than one vertex */
111+
static const size_t num_extra_points_map[] =
112+
{0, 0, 0, 1,
113+
2, 0, 0, 0,
114+
0, 0, 0, 0,
115+
0, 0, 0, 0
116+
};
117+
110118
/*
111119
PathNanRemover is a vertex converter that removes non-finite values
112120
from the vertices list, and inserts MOVETO commands as necessary to
@@ -119,7 +127,6 @@ class PathNanRemover : protected EmbeddedQueue<4>
119127
VertexSource *m_source;
120128
bool m_remove_nans;
121129
bool m_has_curves;
122-
static const unsigned char num_extra_points_map[16];
123130

124131
public:
125132
/* has_curves should be true if the path contains bezier curve
@@ -171,11 +178,12 @@ class PathNanRemover : protected EmbeddedQueue<4>
171178
size_t num_extra_points = num_extra_points_map[code & 0xF];
172179
bool has_nan = (MPL_notisfinite64(*x) || MPL_notisfinite64(*y));
173180
queue_push(code, *x, *y);
181+
174182
/* Note: this test can not be short-circuited, since we need to
175183
advance through the entire curve no matter what */
176184
for (size_t i = 0; i < num_extra_points; ++i) {
177185
m_source->vertex(x, y);
178-
has_nan |= (MPL_notisfinite64(*x) || MPL_notisfinite64(*y));
186+
has_nan = has_nan || (MPL_notisfinite64(*x) || MPL_notisfinite64(*y));
179187
queue_push(code, *x, *y);
180188
}
181189

@@ -227,15 +235,6 @@ class PathNanRemover : protected EmbeddedQueue<4>
227235
}
228236
};
229237

230-
/* Defines when path segment types have more than one vertex */
231-
template<class VertexSource>
232-
const unsigned char PathNanRemover<VertexSource>::num_extra_points_map[] =
233-
{0, 0, 0, 1,
234-
2, 0, 0, 0,
235-
0, 0, 0, 0,
236-
0, 0, 0, 0
237-
};
238-
239238
/************************************************************
240239
PathClipper uses the Liang-Barsky line clipping algorithm (as
241240
implemented in Agg) to clip the path to a given rectangle. Lines

0 commit comments

Comments
 (0)