3
3
#include " mplutils.h"
4
4
#include " numpy_cpp.h"
5
5
#include " py_converters.h"
6
+ #define AVOID_NUMPY_HEADERS
6
7
#include " py_converters_11.h"
7
8
#include " _backend_agg.h"
8
9
@@ -40,22 +41,13 @@ PyBufferRegion_get_extents(BufferRegion *self)
40
41
41
42
static void
42
43
PyRendererAgg_draw_path (RendererAgg *self,
43
- pybind11::object gc_obj ,
44
- pybind11::object path_obj ,
44
+ GCAgg &gc ,
45
+ py::PathIterator path ,
45
46
agg::trans_affine trans,
46
47
pybind11::object face_obj)
47
48
{
48
- GCAgg gc;
49
- py::PathIterator path;
50
49
agg::rgba face;
51
50
52
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
53
- throw pybind11::error_already_set ();
54
- }
55
- if (!convert_path (path_obj.ptr (), &path)) {
56
- throw pybind11::error_already_set ();
57
- }
58
-
59
51
if (!convert_face (face_obj.ptr (), gc, &face)) {
60
52
throw pybind11::error_already_set ();
61
53
}
@@ -69,45 +61,28 @@ PyRendererAgg_draw_text_image(RendererAgg *self,
69
61
double x,
70
62
double y,
71
63
double angle,
72
- pybind11::object gc_obj )
64
+ GCAgg &gc )
73
65
{
74
66
numpy::array_view<agg::int8u,2 > image;
75
- GCAgg gc;
76
67
77
68
if (!image.converter_contiguous (image_obj.ptr (), &image)) {
78
69
throw pybind11::error_already_set ();
79
70
}
80
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
81
- throw pybind11::error_already_set ();
82
- }
83
71
84
72
self->draw_text_image (gc, image, x, y, angle);
85
73
}
86
74
87
75
static void
88
76
PyRendererAgg_draw_markers (RendererAgg *self,
89
- pybind11::object gc_obj ,
90
- pybind11::object marker_path_obj ,
77
+ GCAgg &gc ,
78
+ py::PathIterator marker_path ,
91
79
agg::trans_affine marker_path_trans,
92
- pybind11::object path_obj ,
80
+ py::PathIterator path ,
93
81
agg::trans_affine trans,
94
82
pybind11::object face_obj)
95
83
{
96
- GCAgg gc;
97
- py::PathIterator marker_path;
98
- py::PathIterator path;
99
84
agg::rgba face;
100
85
101
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
102
- throw pybind11::error_already_set ();
103
- }
104
- if (!convert_path (marker_path_obj.ptr (), &marker_path)) {
105
- throw pybind11::error_already_set ();
106
- }
107
- if (!convert_path (path_obj.ptr (), &path)) {
108
- throw pybind11::error_already_set ();
109
- }
110
-
111
86
if (!convert_face (face_obj.ptr (), gc, &face)) {
112
87
throw pybind11::error_already_set ();
113
88
}
@@ -117,17 +92,13 @@ PyRendererAgg_draw_markers(RendererAgg *self,
117
92
118
93
static void
119
94
PyRendererAgg_draw_image (RendererAgg *self,
120
- pybind11::object gc_obj ,
95
+ GCAgg &gc ,
121
96
double x,
122
97
double y,
123
98
pybind11::array_t <agg::int8u, pybind11::array::c_style> image_obj)
124
99
{
125
- GCAgg gc;
126
100
numpy::array_view<agg::int8u,3 > image;
127
101
128
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
129
- throw pybind11::error_already_set ();
130
- }
131
102
if (!image.set (image_obj.ptr ())) {
132
103
throw pybind11::error_already_set ();
133
104
}
@@ -141,7 +112,7 @@ PyRendererAgg_draw_image(RendererAgg *self,
141
112
142
113
static void
143
114
PyRendererAgg_draw_path_collection (RendererAgg *self,
144
- pybind11::object gc_obj ,
115
+ GCAgg &gc ,
145
116
agg::trans_affine master_transform,
146
117
pybind11::object paths_obj,
147
118
pybind11::object transforms_obj,
@@ -150,25 +121,20 @@ PyRendererAgg_draw_path_collection(RendererAgg *self,
150
121
pybind11::object facecolors_obj,
151
122
pybind11::object edgecolors_obj,
152
123
pybind11::object linewidths_obj,
153
- pybind11::object dashes_obj ,
124
+ DashesVector dashes ,
154
125
pybind11::object antialiaseds_obj,
155
126
pybind11::objectPy_UNUSED (ignored_obj),
156
127
// offset position is no longer used
157
128
pybind11::object Py_UNUSED(offset_position_obj))
158
129
{
159
- GCAgg gc;
160
130
py::PathGenerator paths;
161
131
numpy::array_view<const double ,3 > transforms;
162
132
numpy::array_view<const double ,2 > offsets;
163
133
numpy::array_view<const double ,2 > facecolors;
164
134
numpy::array_view<const double ,2 > edgecolors;
165
135
numpy::array_view<const double ,1 > linewidths;
166
- DashesVector dashes;
167
136
numpy::array_view<const uint8_t ,1 > antialiaseds;
168
137
169
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
170
- throw pybind11::error_already_set ();
171
- }
172
138
if (!convert_pathgen (paths_obj.ptr (), &paths)) {
173
139
throw pybind11::error_already_set ();
174
140
}
@@ -187,9 +153,6 @@ PyRendererAgg_draw_path_collection(RendererAgg *self,
187
153
if (!linewidths.converter (linewidths_obj.ptr (), &linewidths)) {
188
154
throw pybind11::error_already_set ();
189
155
}
190
- if (!convert_dashes_vector (dashes_obj.ptr (), &dashes)) {
191
- throw pybind11::error_already_set ();
192
- }
193
156
if (!antialiaseds.converter (antialiaseds_obj.ptr (), &antialiaseds)) {
194
157
throw pybind11::error_already_set ();
195
158
}
@@ -209,7 +172,7 @@ PyRendererAgg_draw_path_collection(RendererAgg *self,
209
172
210
173
static void
211
174
PyRendererAgg_draw_quad_mesh (RendererAgg *self,
212
- pybind11::object gc_obj ,
175
+ GCAgg &gc ,
213
176
agg::trans_affine master_transform,
214
177
unsigned int mesh_width,
215
178
unsigned int mesh_height,
@@ -220,15 +183,11 @@ PyRendererAgg_draw_quad_mesh(RendererAgg *self,
220
183
bool antialiased,
221
184
pybind11::object edgecolors_obj)
222
185
{
223
- GCAgg gc;
224
186
numpy::array_view<const double ,3 > coordinates;
225
187
numpy::array_view<const double ,2 > offsets;
226
188
numpy::array_view<const double ,2 > facecolors;
227
189
numpy::array_view<const double ,2 > edgecolors;
228
190
229
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
230
- throw pybind11::error_already_set ();
231
- }
232
191
if (!coordinates.converter (coordinates_obj.ptr (), &coordinates)) {
233
192
throw pybind11::error_already_set ();
234
193
}
@@ -256,18 +215,14 @@ PyRendererAgg_draw_quad_mesh(RendererAgg *self,
256
215
257
216
static void
258
217
PyRendererAgg_draw_gouraud_triangles (RendererAgg *self,
259
- pybind11::object gc_obj ,
218
+ GCAgg &gc ,
260
219
pybind11::object points_obj,
261
220
pybind11::object colors_obj,
262
221
agg::trans_affine trans)
263
222
{
264
- GCAgg gc;
265
223
numpy::array_view<const double ,3 > points;
266
224
numpy::array_view<const double ,3 > colors;
267
225
268
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
269
- throw pybind11::error_already_set ();
270
- }
271
226
if (!points.converter (points_obj.ptr (), &points)) {
272
227
throw pybind11::error_already_set ();
273
228
}