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