Skip to content

Commit 608a5db

Browse files
committed
Remove redundant path code definitions in extensions.
1 parent 8dd2838 commit 608a5db

File tree

5 files changed

+9
-17
lines changed

5 files changed

+9
-17
lines changed

src/_contour.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
#include <algorithm>
1212

1313

14-
// 'kind' codes.
15-
#define MOVETO 1
16-
#define LINETO 2
17-
#define CLOSEPOLY 79
18-
1914
// Point indices from current quad index.
2015
#define POINT_SW (quad)
2116
#define POINT_SE (quad+1)

src/_path.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -1138,15 +1138,14 @@ bool __convert_to_string(PathIterator &path,
11381138
double last_x = 0.0;
11391139
double last_y = 0.0;
11401140

1141-
const int sizes[] = { 1, 1, 2, 3 };
11421141
int size = 0;
11431142
unsigned code;
11441143

11451144
while ((code = path.vertex(&x[0], &y[0])) != agg::path_cmd_stop) {
1146-
if (code == 0x4f) {
1145+
if (code == CLOSEPOLY) {
11471146
buffer += codes[4];
11481147
} else if (code < 5) {
1149-
size = sizes[code - 1];
1148+
size = NUM_VERTICES[code];
11501149

11511150
for (int i = 1; i < size; ++i) {
11521151
unsigned subcode = path.vertex(&x[i], &y[i]);

src/ft2font.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,10 @@ ft_outline_move_to(FT_Vector const* to, void* user)
203203
ft_outline_decomposer* d = reinterpret_cast<ft_outline_decomposer*>(user);
204204
if (d->codes) {
205205
if (d->index) {
206-
// Appending ENDPOLY is important to make patheffects work.
206+
// Appending CLOSEPOLY is important to make patheffects work.
207207
*(d->vertices++) = 0;
208208
*(d->vertices++) = 0;
209-
*(d->codes++) = ENDPOLY;
209+
*(d->codes++) = CLOSEPOLY;
210210
}
211211
*(d->vertices++) = to->x / 64.;
212212
*(d->vertices++) = to->y / 64.;
@@ -286,7 +286,7 @@ FT2Font::get_path()
286286
"FT_Outline_Decompose failed with error 0x%x", error);
287287
return NULL;
288288
}
289-
if (!decomposer.index) { // Don't append ENDPOLY to null glyphs.
289+
if (!decomposer.index) { // Don't append CLOSEPOLY to null glyphs.
290290
npy_intp vertices_dims[2] = { 0, 2 };
291291
numpy::array_view<double, 2> vertices(vertices_dims);
292292
npy_intp codes_dims[1] = { 0 };
@@ -309,7 +309,7 @@ FT2Font::get_path()
309309
}
310310
*(decomposer.vertices++) = 0;
311311
*(decomposer.vertices++) = 0;
312-
*(decomposer.codes++) = ENDPOLY;
312+
*(decomposer.codes++) = CLOSEPOLY;
313313
return Py_BuildValue("NN", vertices.pyobj(), codes.pyobj());
314314
}
315315

src/mplutils.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ inline double mpl_round(double v)
4040
return (double)(int)(v + ((v >= 0.0) ? 0.5 : -0.5));
4141
}
4242

43+
// 'kind' codes for paths.
4344
enum {
4445
STOP = 0,
4546
MOVETO = 1,
4647
LINETO = 2,
4748
CURVE3 = 3,
4849
CURVE4 = 4,
49-
ENDPOLY = 0x4f
50+
CLOSEPOLY = 0x4f
5051
};
5152

5253
const size_t NUM_VERTICES[] = { 1, 1, 1, 2, 3, 1 };

src/tri/_tri.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@
77
*/
88
#define NO_IMPORT_ARRAY
99

10+
#include "../mplutils.h"
1011
#include "_tri.h"
1112

1213
#include <algorithm>
1314
#include <set>
1415

15-
#define MOVETO 1
16-
#define LINETO 2
17-
#define CLOSEPOLY 79
18-
1916

2017
TriEdge::TriEdge()
2118
: tri(-1), edge(-1)

0 commit comments

Comments
 (0)