aboutsummaryrefslogtreecommitdiffstats
path: root/testing/agg/0004-Make-rasterizer_outline_aa-ignore-close_polygon-when.patch
blob: 0cecaf794860b74036f9aa694762c304a9e72460 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
From b9c4b1c72b4ad6b24c37f402d3eec39ef393b0eb Mon Sep 17 00:00:00 2001
From: Tom Hughes <tom@compton.nu>
Date: Sun, 19 May 2013 14:17:43 +0100
Subject: [PATCH 04/15] Make rasterizer_outline_aa ignore close_polygon when
 vertex count < 3

---
 include/agg_rasterizer_outline_aa.h | 107 ++++++++++++++++++------------------
 1 file changed, 52 insertions(+), 55 deletions(-)

diff --git a/include/agg_rasterizer_outline_aa.h b/include/agg_rasterizer_outline_aa.h
index 4d6dd57..24301d5 100644
--- a/include/agg_rasterizer_outline_aa.h
+++ b/include/agg_rasterizer_outline_aa.h
@@ -333,68 +333,65 @@ namespace agg
         int y2;
         int lprev;
 
-        if(close_polygon)
+        if(close_polygon && (m_src_vertices.size() >= 3))
         {
-            if(m_src_vertices.size() >= 3)
+            dv.idx = 2;
+
+            v     = &m_src_vertices[m_src_vertices.size() - 1];
+            x1    = v->x;
+            y1    = v->y;
+            lprev = v->len;
+
+            v  = &m_src_vertices[0];
+            x2 = v->x;
+            y2 = v->y;
+            dv.lcurr = v->len;
+            line_parameters prev(x1, y1, x2, y2, lprev);
+
+            v = &m_src_vertices[1];
+            dv.x1    = v->x;
+            dv.y1    = v->y;
+            dv.lnext = v->len;
+            dv.curr = line_parameters(x2, y2, dv.x1, dv.y1, dv.lcurr);
+
+            v = &m_src_vertices[dv.idx];
+            dv.x2 = v->x;
+            dv.y2 = v->y;
+            dv.next = line_parameters(dv.x1, dv.y1, dv.x2, dv.y2, dv.lnext);
+
+            dv.xb1 = 0;
+            dv.yb1 = 0;
+            dv.xb2 = 0;
+            dv.yb2 = 0;
+
+            switch(m_line_join)
             {
-                dv.idx = 2;
-
-                v     = &m_src_vertices[m_src_vertices.size() - 1];
-                x1    = v->x;
-                y1    = v->y;
-                lprev = v->len;
-
-                v  = &m_src_vertices[0];
-                x2 = v->x;
-                y2 = v->y;
-                dv.lcurr = v->len;
-                line_parameters prev(x1, y1, x2, y2, lprev);
-
-                v = &m_src_vertices[1];
-                dv.x1    = v->x;
-                dv.y1    = v->y;
-                dv.lnext = v->len;
-                dv.curr = line_parameters(x2, y2, dv.x1, dv.y1, dv.lcurr);
-
-                v = &m_src_vertices[dv.idx];
-                dv.x2 = v->x;
-                dv.y2 = v->y;
-                dv.next = line_parameters(dv.x1, dv.y1, dv.x2, dv.y2, dv.lnext);
-
-                dv.xb1 = 0;
-                dv.yb1 = 0;
-                dv.xb2 = 0;
-                dv.yb2 = 0;
-
-                switch(m_line_join)
-                {
-                case outline_no_join:
-                    dv.flags = 3;
-                    break;
+            case outline_no_join:
+                dv.flags = 3;
+                break;
 
-                case outline_miter_join:
-                case outline_round_join:
-                    dv.flags = 
-                            (prev.diagonal_quadrant() == dv.curr.diagonal_quadrant()) |
-                        ((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant()) << 1);
-                    break;
+            case outline_miter_join:
+            case outline_round_join:
+                dv.flags = 
+                        (prev.diagonal_quadrant() == dv.curr.diagonal_quadrant()) |
+                    ((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant()) << 1);
+                break;
 
-                case outline_miter_accurate_join:
-                    dv.flags = 0;
-                    break;
-                }
+            case outline_miter_accurate_join:
+                dv.flags = 0;
+                break;
+            }
 
-                if((dv.flags & 1) == 0 && m_line_join != outline_round_join)
-                {
-                    bisectrix(prev, dv.curr, &dv.xb1, &dv.yb1);
-                }
+            if((dv.flags & 1) == 0 && m_line_join != outline_round_join)
+            {
+                bisectrix(prev, dv.curr, &dv.xb1, &dv.yb1);
+            }
 
-                if((dv.flags & 2) == 0 && m_line_join != outline_round_join)
-                {
-                    bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2);
-                }
-                draw(dv, 0, m_src_vertices.size());
+            if((dv.flags & 2) == 0 && m_line_join != outline_round_join)
+            {
+                bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2);
             }
+            draw(dv, 0, m_src_vertices.size());
         }
         else
         {
-- 
1.8.1.4