@@ -193,8 +193,8 @@ class PathNanRemover : protected EmbeddedQueue<4>
193193 }
194194
195195 if (m_has_codes) {
196- /* This is the slow method for when there might be curves or closed
197- * loops. */
196+ /* This is the slow method for when there might be curves or closed
197+ * loops. */
198198 if (queue_pop (&code, x, y)) {
199199 return code;
200200 }
@@ -365,75 +365,79 @@ class PathClipper : public EmbeddedQueue<3>
365365 unsigned code;
366366 bool emit_moveto = false ;
367367
368- if (m_do_clipping) {
369- /* This is the slow path where we actually do clipping */
370-
371- if (queue_pop (&code, x, y)) {
372- return code;
373- }
368+ if (!m_do_clipping) {
369+ // If not doing any clipping, just pass along the vertices verbatim
370+ return m_source->vertex (x, y);
371+ }
374372
375- while ((code = m_source->vertex (x, y)) != agg::path_cmd_stop) {
376- emit_moveto = false ;
373+ /* This is the slow path where we actually do clipping */
377374
378- switch (code) {
379- case (agg::path_cmd_end_poly | agg::path_flags_close):
380- if (m_has_init) {
381- draw_clipped_line (m_lastX, m_lastY, m_initX, m_initY);
382- }
383- queue_push (
384- agg::path_cmd_end_poly | agg::path_flags_close,
385- m_lastX, m_lastY);
386- goto exit_loop;
375+ if (queue_pop (&code, x, y)) {
376+ return code;
377+ }
387378
388- case agg::path_cmd_move_to:
389-
390- // was the last command a moveto (and we have
391- // seen at least one command ?
392- // if so, shove it in the queue if in clip box
393- if (m_moveto && m_has_init &&
394- m_lastX >= m_cliprect.x1 &&
395- m_lastX <= m_cliprect.x2 &&
396- m_lastY >= m_cliprect.y1 &&
397- m_lastY <= m_cliprect.y2 ) {
398- // push the last moveto onto the queue
399- queue_push (agg::path_cmd_move_to, m_lastX, m_lastY);
400- // flag that we need to emit it
401- emit_moveto = true ;
402- }
403- // update the internal state for this moveto
404- m_initX = m_lastX = *x;
405- m_initY = m_lastY = *y;
406- m_has_init = true ;
407- m_moveto = true ;
408- // if the last command was moveto exit the loop to emit the code
409- if (emit_moveto) {
410- goto exit_loop;
411- }
412- // else, break and get the next point
413- break ;
379+ while ((code = m_source->vertex (x, y)) != agg::path_cmd_stop) {
380+ emit_moveto = false ;
414381
415- case agg::path_cmd_line_to:
416- if (draw_clipped_line (m_lastX, m_lastY, *x, *y)) {
417- m_lastX = *x;
418- m_lastY = *y;
419- goto exit_loop;
420- }
421- m_lastX = *x;
422- m_lastY = *y;
423- break ;
424-
425- default :
426- if (m_moveto) {
427- queue_push (agg::path_cmd_move_to, m_lastX, m_lastY);
428- m_moveto = false ;
429- }
382+ switch (code) {
383+ case (agg::path_cmd_end_poly | agg::path_flags_close):
384+ if (m_has_init) {
385+ draw_clipped_line (m_lastX, m_lastY, m_initX, m_initY);
386+ }
387+ queue_push (
388+ agg::path_cmd_end_poly | agg::path_flags_close,
389+ m_lastX, m_lastY);
390+ goto exit_loop;
391+
392+ case agg::path_cmd_move_to:
393+
394+ // was the last command a moveto (and we have
395+ // seen at least one command ?
396+ // if so, shove it in the queue if in clip box
397+ if (m_moveto && m_has_init &&
398+ m_lastX >= m_cliprect.x1 &&
399+ m_lastX <= m_cliprect.x2 &&
400+ m_lastY >= m_cliprect.y1 &&
401+ m_lastY <= m_cliprect.y2 ) {
402+ // push the last moveto onto the queue
403+ queue_push (agg::path_cmd_move_to, m_lastX, m_lastY);
404+ // flag that we need to emit it
405+ emit_moveto = true ;
406+ }
407+ // update the internal state for this moveto
408+ m_initX = m_lastX = *x;
409+ m_initY = m_lastY = *y;
410+ m_has_init = true ;
411+ m_moveto = true ;
412+ // if the last command was moveto exit the loop to emit the code
413+ if (emit_moveto) {
414+ goto exit_loop;
415+ }
416+ // else, break and get the next point
417+ break ;
430418
431- queue_push (code, *x, *y);
419+ case agg::path_cmd_line_to:
420+ if (draw_clipped_line (m_lastX, m_lastY, *x, *y)) {
432421 m_lastX = *x;
433422 m_lastY = *y;
434423 goto exit_loop;
435424 }
425+ m_lastX = *x;
426+ m_lastY = *y;
427+ break ;
428+
429+ default :
430+ if (m_moveto) {
431+ queue_push (agg::path_cmd_move_to, m_lastX, m_lastY);
432+ m_moveto = false ;
433+ }
434+
435+ queue_push (code, *x, *y);
436+ m_lastX = *x;
437+ m_lastY = *y;
438+ goto exit_loop;
436439 }
440+ }
437441
438442 exit_loop:
439443
@@ -453,11 +457,6 @@ class PathClipper : public EmbeddedQueue<3>
453457 }
454458
455459 return agg::path_cmd_stop;
456- } else {
457- // If not doing any clipping, just pass along the vertices
458- // verbatim
459- return m_source->vertex (x, y);
460- }
461460 }
462461};
463462
0 commit comments