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,17 +41,11 @@ 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
agg::rgba face)
47
48
{
48
- GCAgg gc;
49
-
50
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
51
- throw pybind11::error_already_set ();
52
- }
53
-
54
49
self->draw_path (gc, path, trans, face);
55
50
}
56
51
@@ -60,52 +55,38 @@ PyRendererAgg_draw_text_image(RendererAgg *self,
60
55
double x,
61
56
double y,
62
57
double angle,
63
- pybind11::object gc_obj )
58
+ GCAgg &gc )
64
59
{
65
60
numpy::array_view<agg::int8u,2 > image;
66
- GCAgg gc;
67
61
68
62
if (!image.converter_contiguous (image_obj.ptr (), &image)) {
69
63
throw pybind11::error_already_set ();
70
64
}
71
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
72
- throw pybind11::error_already_set ();
73
- }
74
65
75
66
self->draw_text_image (gc, image, x, y, angle);
76
67
}
77
68
78
69
static void
79
70
PyRendererAgg_draw_markers (RendererAgg *self,
80
- pybind11::object gc_obj ,
71
+ GCAgg &gc ,
81
72
mpl::PathIterator marker_path,
82
73
agg::trans_affine marker_path_trans,
83
74
mpl::PathIterator path,
84
75
agg::trans_affine trans,
85
76
agg::rgba face)
86
77
{
87
- GCAgg gc;
88
-
89
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
90
- throw pybind11::error_already_set ();
91
- }
92
-
93
78
self->draw_markers (gc, marker_path, marker_path_trans, path, trans, face);
94
79
}
95
80
96
81
static void
97
82
PyRendererAgg_draw_image (RendererAgg *self,
98
- pybind11::object gc_obj ,
83
+ GCAgg &gc ,
99
84
double x,
100
85
double y,
101
86
pybind11::array_t <agg::int8u, pybind11::array::c_style> image_obj)
102
87
{
103
- GCAgg gc;
104
88
numpy::array_view<agg::int8u,3 > image;
105
89
106
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
107
- throw pybind11::error_already_set ();
108
- }
109
90
if (!image.set (image_obj.ptr ())) {
110
91
throw pybind11::error_already_set ();
111
92
}
@@ -119,7 +100,7 @@ PyRendererAgg_draw_image(RendererAgg *self,
119
100
120
101
static void
121
102
PyRendererAgg_draw_path_collection (RendererAgg *self,
122
- pybind11::object gc_obj ,
103
+ GCAgg &gc ,
123
104
agg::trans_affine master_transform,
124
105
pybind11::object paths_obj,
125
106
pybind11::object transforms_obj,
@@ -128,25 +109,20 @@ PyRendererAgg_draw_path_collection(RendererAgg *self,
128
109
pybind11::object facecolors_obj,
129
110
pybind11::object edgecolors_obj,
130
111
pybind11::object linewidths_obj,
131
- pybind11::object dashes_obj ,
112
+ DashesVector dashes ,
132
113
pybind11::object antialiaseds_obj,
133
114
pybind11::objectPy_UNUSED (ignored_obj),
134
115
// offset position is no longer used
135
116
pybind11::object Py_UNUSED(offset_position_obj))
136
117
{
137
- GCAgg gc;
138
118
mpl::PathGenerator paths;
139
119
numpy::array_view<const double ,3 > transforms;
140
120
numpy::array_view<const double ,2 > offsets;
141
121
numpy::array_view<const double ,2 > facecolors;
142
122
numpy::array_view<const double ,2 > edgecolors;
143
123
numpy::array_view<const double ,1 > linewidths;
144
- DashesVector dashes;
145
124
numpy::array_view<const uint8_t ,1 > antialiaseds;
146
125
147
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
148
- throw pybind11::error_already_set ();
149
- }
150
126
if (!convert_pathgen (paths_obj.ptr (), &paths)) {
151
127
throw pybind11::error_already_set ();
152
128
}
@@ -165,9 +141,6 @@ PyRendererAgg_draw_path_collection(RendererAgg *self,
165
141
if (!linewidths.converter (linewidths_obj.ptr (), &linewidths)) {
166
142
throw pybind11::error_already_set ();
167
143
}
168
- if (!convert_dashes_vector (dashes_obj.ptr (), &dashes)) {
169
- throw pybind11::error_already_set ();
170
- }
171
144
if (!antialiaseds.converter (antialiaseds_obj.ptr (), &antialiaseds)) {
172
145
throw pybind11::error_already_set ();
173
146
}
@@ -187,7 +160,7 @@ PyRendererAgg_draw_path_collection(RendererAgg *self,
187
160
188
161
static void
189
162
PyRendererAgg_draw_quad_mesh (RendererAgg *self,
190
- pybind11::object gc_obj ,
163
+ GCAgg &gc ,
191
164
agg::trans_affine master_transform,
192
165
unsigned int mesh_width,
193
166
unsigned int mesh_height,
@@ -198,15 +171,11 @@ PyRendererAgg_draw_quad_mesh(RendererAgg *self,
198
171
bool antialiased,
199
172
pybind11::object edgecolors_obj)
200
173
{
201
- GCAgg gc;
202
174
numpy::array_view<const double ,3 > coordinates;
203
175
numpy::array_view<const double ,2 > offsets;
204
176
numpy::array_view<const double ,2 > facecolors;
205
177
numpy::array_view<const double ,2 > edgecolors;
206
178
207
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
208
- throw pybind11::error_already_set ();
209
- }
210
179
if (!coordinates.converter (coordinates_obj.ptr (), &coordinates)) {
211
180
throw pybind11::error_already_set ();
212
181
}
@@ -234,18 +203,14 @@ PyRendererAgg_draw_quad_mesh(RendererAgg *self,
234
203
235
204
static void
236
205
PyRendererAgg_draw_gouraud_triangles (RendererAgg *self,
237
- pybind11::object gc_obj ,
206
+ GCAgg &gc ,
238
207
pybind11::object points_obj,
239
208
pybind11::object colors_obj,
240
209
agg::trans_affine trans)
241
210
{
242
- GCAgg gc;
243
211
numpy::array_view<const double ,3 > points;
244
212
numpy::array_view<const double ,3 > colors;
245
213
246
- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
247
- throw pybind11::error_already_set ();
248
- }
249
214
if (!points.converter (points_obj.ptr (), &points)) {
250
215
throw pybind11::error_already_set ();
251
216
}