summaryrefslogtreecommitdiff
path: root/src/cairo-path-stroke.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-10-04 12:39:21 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2008-10-06 12:02:29 +0100
commit6eead4a5f746e182eabfcda9959cd9cc53d95a89 (patch)
treef11bb6ff63c580872c7267867f92b76490c8e1d5 /src/cairo-path-stroke.c
parent4aa0991a11f03a47735dcfafe43d9505b939554e (diff)
[stroke] Simplify dash-off logic.
Remove a redundant level of if-else branching (and remove a duplicate code) block by testing dash_on first.
Diffstat (limited to 'src/cairo-path-stroke.c')
-rw-r--r--src/cairo-path-stroke.c65
1 files changed, 28 insertions, 37 deletions
diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c
index 419412a1..627c71e7 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -872,48 +872,39 @@ _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point)
segment.p2.x = _cairo_fixed_from_double (dx2) + p1->x;
segment.p2.y = _cairo_fixed_from_double (dy2) + p1->y;
- if (fully_in_bounds ||
- _cairo_box_intersects_line_segment (&stroker->bounds, &segment))
+ if (stroker->dash_on &&
+ (fully_in_bounds ||
+ _cairo_box_intersects_line_segment (&stroker->bounds, &segment)))
{
- if (stroker->dash_on) {
- status = _cairo_stroker_add_sub_edge (stroker, &segment.p1, &segment.p2, &dev_slope, slope_dx, slope_dy, &sub_start, &sub_end);
+ status = _cairo_stroker_add_sub_edge (stroker, &segment.p1, &segment.p2, &dev_slope, slope_dx, slope_dy, &sub_start, &sub_end);
+ if (status)
+ return status;
+
+ if (stroker->has_current_face) {
+ /* Join with final face from previous segment */
+ status = _cairo_stroker_join (stroker, &stroker->current_face, &sub_start);
+ stroker->has_current_face = FALSE;
if (status)
return status;
+ } else if (!stroker->has_first_face && stroker->dash_starts_on) {
+ /* Save sub path's first face in case needed for closing join */
+ stroker->first_face = sub_start;
+ stroker->has_first_face = TRUE;
+ } else {
+ /* Cap dash start if not connecting to a previous segment */
+ status = _cairo_stroker_add_leading_cap (stroker, &sub_start);
+ if (status)
+ return status;
+ }
- if (stroker->has_current_face) {
- /* Join with final face from previous segment */
- status = _cairo_stroker_join (stroker, &stroker->current_face, &sub_start);
- stroker->has_current_face = FALSE;
- if (status)
- return status;
- } else if (!stroker->has_first_face && stroker->dash_starts_on) {
- /* Save sub path's first face in case needed for closing join */
- stroker->first_face = sub_start;
- stroker->has_first_face = TRUE;
- } else {
- /* Cap dash start if not connecting to a previous segment */
- status = _cairo_stroker_add_leading_cap (stroker, &sub_start);
- if (status)
- return status;
- }
-
- if (remain) {
- /* Cap dash end if not at end of segment */
- status = _cairo_stroker_add_trailing_cap (stroker, &sub_end);
- if (status)
- return status;
- } else {
- stroker->current_face = sub_end;
- stroker->has_current_face = TRUE;
- }
+ if (remain) {
+ /* Cap dash end if not at end of segment */
+ status = _cairo_stroker_add_trailing_cap (stroker, &sub_end);
+ if (status)
+ return status;
} else {
- if (stroker->has_current_face) {
- /* Cap final face from previous segment */
- status = _cairo_stroker_add_trailing_cap (stroker, &stroker->current_face);
- if (status)
- return status;
- stroker->has_current_face = FALSE;
- }
+ stroker->current_face = sub_end;
+ stroker->has_current_face = TRUE;
}
} else {
if (stroker->has_current_face) {