11#include < pybind11/pybind11.h>
22#include < pybind11/numpy.h>
3+ #include < pybind11/stl.h>
34#include " mplutils.h"
45#include " numpy_cpp.h"
56#include " py_converters.h"
@@ -41,18 +42,13 @@ PyBufferRegion_get_extents(BufferRegion *self)
4142
4243static void
4344PyRendererAgg_draw_path (RendererAgg *self,
44- py::object gc_obj ,
45+ GCAgg &gc ,
4546 mpl::PathIterator path,
4647 agg::trans_affine trans,
4748 py::object face_obj)
4849{
49- GCAgg gc;
5050 agg::rgba face;
5151
52- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
53- throw py::error_already_set ();
54- }
55-
5652 if (!convert_face (face_obj.ptr (), gc, &face)) {
5753 throw py::error_already_set ();
5854 }
@@ -66,37 +62,28 @@ PyRendererAgg_draw_text_image(RendererAgg *self,
6662 double x,
6763 double y,
6864 double angle,
69- py::object gc_obj )
65+ GCAgg &gc )
7066{
7167 numpy::array_view<agg::int8u, 2 > image;
72- GCAgg gc;
7368
7469 if (!image.converter_contiguous (image_obj.ptr (), &image)) {
7570 throw py::error_already_set ();
7671 }
77- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
78- throw py::error_already_set ();
79- }
8072
8173 self->draw_text_image (gc, image, x, y, angle);
8274}
8375
8476static void
8577PyRendererAgg_draw_markers (RendererAgg *self,
86- py::object gc_obj ,
78+ GCAgg &gc ,
8779 mpl::PathIterator marker_path,
8880 agg::trans_affine marker_path_trans,
8981 mpl::PathIterator path,
9082 agg::trans_affine trans,
9183 py::object face_obj)
9284{
93- GCAgg gc;
9485 agg::rgba face;
9586
96- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
97- throw py::error_already_set ();
98- }
99-
10087 if (!convert_face (face_obj.ptr (), gc, &face)) {
10188 throw py::error_already_set ();
10289 }
@@ -106,17 +93,13 @@ PyRendererAgg_draw_markers(RendererAgg *self,
10693
10794static void
10895PyRendererAgg_draw_image (RendererAgg *self,
109- py::object gc_obj ,
96+ GCAgg &gc ,
11097 double x,
11198 double y,
11299 py::array_t <agg::int8u, py::array::c_style> image_obj)
113100{
114- GCAgg gc;
115101 numpy::array_view<agg::int8u, 3 > image;
116102
117- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
118- throw py::error_already_set ();
119- }
120103 if (!image.set (image_obj.ptr ())) {
121104 throw py::error_already_set ();
122105 }
@@ -130,7 +113,7 @@ PyRendererAgg_draw_image(RendererAgg *self,
130113
131114static void
132115PyRendererAgg_draw_path_collection (RendererAgg *self,
133- py::object gc_obj ,
116+ GCAgg &gc ,
134117 agg::trans_affine master_transform,
135118 py::object paths_obj,
136119 py::object transforms_obj,
@@ -139,25 +122,20 @@ PyRendererAgg_draw_path_collection(RendererAgg *self,
139122 py::object facecolors_obj,
140123 py::object edgecolors_obj,
141124 py::object linewidths_obj,
142- py::object dashes_obj ,
125+ DashesVector dashes ,
143126 py::object antialiaseds_obj,
144127 py::object Py_UNUSED (ignored_obj),
145128 // offset position is no longer used
146129 py::object Py_UNUSED(offset_position_obj))
147130{
148- GCAgg gc;
149131 mpl::PathGenerator paths;
150132 numpy::array_view<const double , 3 > transforms;
151133 numpy::array_view<const double , 2 > offsets;
152134 numpy::array_view<const double , 2 > facecolors;
153135 numpy::array_view<const double , 2 > edgecolors;
154136 numpy::array_view<const double , 1 > linewidths;
155- DashesVector dashes;
156137 numpy::array_view<const uint8_t , 1 > antialiaseds;
157138
158- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
159- throw py::error_already_set ();
160- }
161139 if (!convert_pathgen (paths_obj.ptr (), &paths)) {
162140 throw py::error_already_set ();
163141 }
@@ -176,9 +154,6 @@ PyRendererAgg_draw_path_collection(RendererAgg *self,
176154 if (!linewidths.converter (linewidths_obj.ptr (), &linewidths)) {
177155 throw py::error_already_set ();
178156 }
179- if (!convert_dashes_vector (dashes_obj.ptr (), &dashes)) {
180- throw py::error_already_set ();
181- }
182157 if (!antialiaseds.converter (antialiaseds_obj.ptr (), &antialiaseds)) {
183158 throw py::error_already_set ();
184159 }
@@ -198,7 +173,7 @@ PyRendererAgg_draw_path_collection(RendererAgg *self,
198173
199174static void
200175PyRendererAgg_draw_quad_mesh (RendererAgg *self,
201- py::object gc_obj ,
176+ GCAgg &gc ,
202177 agg::trans_affine master_transform,
203178 unsigned int mesh_width,
204179 unsigned int mesh_height,
@@ -209,15 +184,11 @@ PyRendererAgg_draw_quad_mesh(RendererAgg *self,
209184 bool antialiased,
210185 py::object edgecolors_obj)
211186{
212- GCAgg gc;
213187 numpy::array_view<const double , 3 > coordinates;
214188 numpy::array_view<const double , 2 > offsets;
215189 numpy::array_view<const double , 2 > facecolors;
216190 numpy::array_view<const double , 2 > edgecolors;
217191
218- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
219- throw py::error_already_set ();
220- }
221192 if (!coordinates.converter (coordinates_obj.ptr (), &coordinates)) {
222193 throw py::error_already_set ();
223194 }
@@ -245,18 +216,14 @@ PyRendererAgg_draw_quad_mesh(RendererAgg *self,
245216
246217static void
247218PyRendererAgg_draw_gouraud_triangles (RendererAgg *self,
248- py::object gc_obj ,
219+ GCAgg &gc ,
249220 py::object points_obj,
250221 py::object colors_obj,
251222 agg::trans_affine trans)
252223{
253- GCAgg gc;
254224 numpy::array_view<const double , 3 > points;
255225 numpy::array_view<const double , 3 > colors;
256226
257- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
258- throw py::error_already_set ();
259- }
260227 if (!points.converter (points_obj.ptr (), &points)) {
261228 throw py::error_already_set ();
262229 }
0 commit comments