1
1
#include < pybind11/pybind11.h>
2
2
#include < pybind11/numpy.h>
3
+ #include < pybind11/stl.h>
3
4
#include " mplutils.h"
4
5
#include " numpy_cpp.h"
5
6
#include " py_converters.h"
@@ -40,18 +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
+ GCAgg &gc ,
44
45
mpl::PathIterator path,
45
46
agg::trans_affine trans,
46
47
pybind11::object face_obj)
47
48
{
48
- GCAgg gc;
49
49
agg::rgba face;
50
50
51
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
52
- throw pybind11::error_already_set ();
53
- }
54
-
55
51
if (!convert_face (face_obj.ptr (), gc, &face)) {
56
52
throw pybind11::error_already_set ();
57
53
}
@@ -65,37 +61,28 @@ PyRendererAgg_draw_text_image(RendererAgg *self,
65
61
double x,
66
62
double y,
67
63
double angle,
68
- pybind11::object gc_obj )
64
+ GCAgg &gc )
69
65
{
70
66
numpy::array_view<agg::int8u, 2 > image;
71
- GCAgg gc;
72
67
73
68
if (!image.converter_contiguous (image_obj.ptr (), &image)) {
74
69
throw pybind11::error_already_set ();
75
70
}
76
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
77
- throw pybind11::error_already_set ();
78
- }
79
71
80
72
self->draw_text_image (gc, image, x, y, angle);
81
73
}
82
74
83
75
static void
84
76
PyRendererAgg_draw_markers (RendererAgg *self,
85
- pybind11::object gc_obj ,
77
+ GCAgg &gc ,
86
78
mpl::PathIterator marker_path,
87
79
agg::trans_affine marker_path_trans,
88
80
mpl::PathIterator path,
89
81
agg::trans_affine trans,
90
82
pybind11::object face_obj)
91
83
{
92
- GCAgg gc;
93
84
agg::rgba face;
94
85
95
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
96
- throw pybind11::error_already_set ();
97
- }
98
-
99
86
if (!convert_face (face_obj.ptr (), gc, &face)) {
100
87
throw pybind11::error_already_set ();
101
88
}
@@ -105,17 +92,13 @@ PyRendererAgg_draw_markers(RendererAgg *self,
105
92
106
93
static void
107
94
PyRendererAgg_draw_image (RendererAgg *self,
108
- pybind11::object gc_obj ,
95
+ GCAgg &gc ,
109
96
double x,
110
97
double y,
111
98
pybind11::array_t <agg::int8u, pybind11::array::c_style> image_obj)
112
99
{
113
- GCAgg gc;
114
100
numpy::array_view<agg::int8u, 3 > image;
115
101
116
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
117
- throw pybind11::error_already_set ();
118
- }
119
102
if (!image.set (image_obj.ptr ())) {
120
103
throw pybind11::error_already_set ();
121
104
}
@@ -129,7 +112,7 @@ PyRendererAgg_draw_image(RendererAgg *self,
129
112
130
113
static void
131
114
PyRendererAgg_draw_path_collection (RendererAgg *self,
132
- pybind11::object gc_obj ,
115
+ GCAgg &gc ,
133
116
agg::trans_affine master_transform,
134
117
pybind11::object paths_obj,
135
118
pybind11::object transforms_obj,
@@ -138,25 +121,20 @@ PyRendererAgg_draw_path_collection(RendererAgg *self,
138
121
pybind11::object facecolors_obj,
139
122
pybind11::object edgecolors_obj,
140
123
pybind11::object linewidths_obj,
141
- pybind11::object dashes_obj ,
124
+ DashesVector dashes ,
142
125
pybind11::object antialiaseds_obj,
143
126
pybind11::object Py_UNUSED (ignored_obj),
144
127
// offset position is no longer used
145
128
pybind11::object Py_UNUSED(offset_position_obj))
146
129
{
147
- GCAgg gc;
148
130
mpl::PathGenerator paths;
149
131
numpy::array_view<const double , 3 > transforms;
150
132
numpy::array_view<const double , 2 > offsets;
151
133
numpy::array_view<const double , 2 > facecolors;
152
134
numpy::array_view<const double , 2 > edgecolors;
153
135
numpy::array_view<const double , 1 > linewidths;
154
- DashesVector dashes;
155
136
numpy::array_view<const uint8_t , 1 > antialiaseds;
156
137
157
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
158
- throw pybind11::error_already_set ();
159
- }
160
138
if (!convert_pathgen (paths_obj.ptr (), &paths)) {
161
139
throw pybind11::error_already_set ();
162
140
}
@@ -175,9 +153,6 @@ PyRendererAgg_draw_path_collection(RendererAgg *self,
175
153
if (!linewidths.converter (linewidths_obj.ptr (), &linewidths)) {
176
154
throw pybind11::error_already_set ();
177
155
}
178
- if (!convert_dashes_vector (dashes_obj.ptr (), &dashes)) {
179
- throw pybind11::error_already_set ();
180
- }
181
156
if (!antialiaseds.converter (antialiaseds_obj.ptr (), &antialiaseds)) {
182
157
throw pybind11::error_already_set ();
183
158
}
@@ -197,7 +172,7 @@ PyRendererAgg_draw_path_collection(RendererAgg *self,
197
172
198
173
static void
199
174
PyRendererAgg_draw_quad_mesh (RendererAgg *self,
200
- pybind11::object gc_obj ,
175
+ GCAgg &gc ,
201
176
agg::trans_affine master_transform,
202
177
unsigned int mesh_width,
203
178
unsigned int mesh_height,
@@ -208,15 +183,11 @@ PyRendererAgg_draw_quad_mesh(RendererAgg *self,
208
183
bool antialiased,
209
184
pybind11::object edgecolors_obj)
210
185
{
211
- GCAgg gc;
212
186
numpy::array_view<const double , 3 > coordinates;
213
187
numpy::array_view<const double , 2 > offsets;
214
188
numpy::array_view<const double , 2 > facecolors;
215
189
numpy::array_view<const double , 2 > edgecolors;
216
190
217
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
218
- throw pybind11::error_already_set ();
219
- }
220
191
if (!coordinates.converter (coordinates_obj.ptr (), &coordinates)) {
221
192
throw pybind11::error_already_set ();
222
193
}
@@ -244,18 +215,14 @@ PyRendererAgg_draw_quad_mesh(RendererAgg *self,
244
215
245
216
static void
246
217
PyRendererAgg_draw_gouraud_triangles (RendererAgg *self,
247
- pybind11::object gc_obj ,
218
+ GCAgg &gc ,
248
219
pybind11::object points_obj,
249
220
pybind11::object colors_obj,
250
221
agg::trans_affine trans)
251
222
{
252
- GCAgg gc;
253
223
numpy::array_view<const double , 3 > points;
254
224
numpy::array_view<const double , 3 > colors;
255
225
256
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
257
- throw pybind11::error_already_set ();
258
- }
259
226
if (!points.converter (points_obj.ptr (), &points)) {
260
227
throw pybind11::error_already_set ();
261
228
}
0 commit comments