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"
@@ -40,17 +41,11 @@ PyBufferRegion_get_extents(BufferRegion *self)
4041
4142static void
4243PyRendererAgg_draw_path (RendererAgg *self,
43- pybind11::object gc_obj ,
44+ GCAgg &gc ,
4445 mpl::PathIterator path,
4546 agg::trans_affine trans,
4647 agg::rgba face)
4748{
48- GCAgg gc;
49-
50- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
51- throw pybind11::error_already_set ();
52- }
53-
5449 self->draw_path (gc, path, trans, face);
5550}
5651
@@ -60,52 +55,38 @@ PyRendererAgg_draw_text_image(RendererAgg *self,
6055 double x,
6156 double y,
6257 double angle,
63- pybind11::object gc_obj )
58+ GCAgg &gc )
6459{
6560 numpy::array_view<agg::int8u, 2 > image;
66- GCAgg gc;
6761
6862 if (!image.converter_contiguous (image_obj.ptr (), &image)) {
6963 throw pybind11::error_already_set ();
7064 }
71- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
72- throw pybind11::error_already_set ();
73- }
7465
7566 self->draw_text_image (gc, image, x, y, angle);
7667}
7768
7869static void
7970PyRendererAgg_draw_markers (RendererAgg *self,
80- pybind11::object gc_obj ,
71+ GCAgg &gc ,
8172 mpl::PathIterator marker_path,
8273 agg::trans_affine marker_path_trans,
8374 mpl::PathIterator path,
8475 agg::trans_affine trans,
8576 agg::rgba face)
8677{
87- GCAgg gc;
88-
89- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
90- throw pybind11::error_already_set ();
91- }
92-
9378 self->draw_markers (gc, marker_path, marker_path_trans, path, trans, face);
9479}
9580
9681static void
9782PyRendererAgg_draw_image (RendererAgg *self,
98- pybind11::object gc_obj ,
83+ GCAgg &gc ,
9984 double x,
10085 double y,
10186 pybind11::array_t <agg::int8u, pybind11::array::c_style> image_obj)
10287{
103- GCAgg gc;
10488 numpy::array_view<agg::int8u, 3 > image;
10589
106- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
107- throw pybind11::error_already_set ();
108- }
10990 if (!image.set (image_obj.ptr ())) {
11091 throw pybind11::error_already_set ();
11192 }
@@ -119,7 +100,7 @@ PyRendererAgg_draw_image(RendererAgg *self,
119100
120101static void
121102PyRendererAgg_draw_path_collection (RendererAgg *self,
122- pybind11::object gc_obj ,
103+ GCAgg &gc ,
123104 agg::trans_affine master_transform,
124105 pybind11::object paths_obj,
125106 pybind11::object transforms_obj,
@@ -128,25 +109,20 @@ PyRendererAgg_draw_path_collection(RendererAgg *self,
128109 pybind11::object facecolors_obj,
129110 pybind11::object edgecolors_obj,
130111 pybind11::object linewidths_obj,
131- pybind11::object dashes_obj ,
112+ DashesVector dashes ,
132113 pybind11::object antialiaseds_obj,
133114 pybind11::object Py_UNUSED (ignored_obj),
134115 // offset position is no longer used
135116 pybind11::object Py_UNUSED(offset_position_obj))
136117{
137- GCAgg gc;
138118 mpl::PathGenerator paths;
139119 numpy::array_view<const double , 3 > transforms;
140120 numpy::array_view<const double , 2 > offsets;
141121 numpy::array_view<const double , 2 > facecolors;
142122 numpy::array_view<const double , 2 > edgecolors;
143123 numpy::array_view<const double , 1 > linewidths;
144- DashesVector dashes;
145124 numpy::array_view<const uint8_t , 1 > antialiaseds;
146125
147- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
148- throw pybind11::error_already_set ();
149- }
150126 if (!convert_pathgen (paths_obj.ptr (), &paths)) {
151127 throw pybind11::error_already_set ();
152128 }
@@ -165,9 +141,6 @@ PyRendererAgg_draw_path_collection(RendererAgg *self,
165141 if (!linewidths.converter (linewidths_obj.ptr (), &linewidths)) {
166142 throw pybind11::error_already_set ();
167143 }
168- if (!convert_dashes_vector (dashes_obj.ptr (), &dashes)) {
169- throw pybind11::error_already_set ();
170- }
171144 if (!antialiaseds.converter (antialiaseds_obj.ptr (), &antialiaseds)) {
172145 throw pybind11::error_already_set ();
173146 }
@@ -187,7 +160,7 @@ PyRendererAgg_draw_path_collection(RendererAgg *self,
187160
188161static void
189162PyRendererAgg_draw_quad_mesh (RendererAgg *self,
190- pybind11::object gc_obj ,
163+ GCAgg &gc ,
191164 agg::trans_affine master_transform,
192165 unsigned int mesh_width,
193166 unsigned int mesh_height,
@@ -198,15 +171,11 @@ PyRendererAgg_draw_quad_mesh(RendererAgg *self,
198171 bool antialiased,
199172 pybind11::object edgecolors_obj)
200173{
201- GCAgg gc;
202174 numpy::array_view<const double , 3 > coordinates;
203175 numpy::array_view<const double , 2 > offsets;
204176 numpy::array_view<const double , 2 > facecolors;
205177 numpy::array_view<const double , 2 > edgecolors;
206178
207- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
208- throw pybind11::error_already_set ();
209- }
210179 if (!coordinates.converter (coordinates_obj.ptr (), &coordinates)) {
211180 throw pybind11::error_already_set ();
212181 }
@@ -234,18 +203,14 @@ PyRendererAgg_draw_quad_mesh(RendererAgg *self,
234203
235204static void
236205PyRendererAgg_draw_gouraud_triangles (RendererAgg *self,
237- pybind11::object gc_obj ,
206+ GCAgg &gc ,
238207 pybind11::object points_obj,
239208 pybind11::object colors_obj,
240209 agg::trans_affine trans)
241210{
242- GCAgg gc;
243211 numpy::array_view<const double , 3 > points;
244212 numpy::array_view<const double , 3 > colors;
245213
246- if (!convert_gcagg (gc_obj.ptr (), &gc)) {
247- throw pybind11::error_already_set ();
248- }
249214 if (!points.converter (points_obj.ptr (), &points)) {
250215 throw pybind11::error_already_set ();
251216 }
0 commit comments