@@ -164,14 +164,16 @@ class PathNanRemover : protected EmbeddedQueue<4>
164164 bool m_remove_nans;
165165 bool m_has_codes;
166166 bool valid_segment_exists;
167+ bool m_last_segment_valid;
167168
168169 public:
169170 /* has_codes should be true if the path contains bezier curve segments, or
170171 * closed loops, as this requires a slower algorithm to remove the NaNs.
171172 * When in doubt, set to true.
172173 */
173174 PathNanRemover (VertexSource &source, bool remove_nans, bool has_codes)
174- : m_source(&source), m_remove_nans(remove_nans), m_has_codes(has_codes)
175+ : m_source(&source), m_remove_nans(remove_nans), m_has_codes(has_codes),
176+ m_last_segment_valid (false )
175177 {
176178 // ignore all close/end_poly commands until after the first valid
177179 // (nan-free) command is encountered
@@ -221,18 +223,19 @@ class PathNanRemover : protected EmbeddedQueue<4>
221223 }
222224
223225 size_t num_extra_points = num_extra_points_map[code & 0xF ];
224- bool has_nan = (!( std::isfinite (*x) && std::isfinite (*y) ));
226+ m_last_segment_valid = (std::isfinite (*x) && std::isfinite (*y));
225227 queue_push (code, *x, *y);
226228
227229 /* Note: this test can not be short-circuited, since we need to
228230 advance through the entire curve no matter what */
229231 for (size_t i = 0 ; i < num_extra_points; ++i) {
230232 m_source->vertex (x, y);
231- has_nan = has_nan || !(std::isfinite (*x) && std::isfinite (*y));
233+ m_last_segment_valid = m_last_segment_valid &&
234+ (std::isfinite (*x) && std::isfinite (*y));
232235 queue_push (code, *x, *y);
233236 }
234237
235- if (!has_nan ) {
238+ if (m_last_segment_valid ) {
236239 valid_segment_exists = true ;
237240 break ;
238241 }
0 commit comments