@@ -59,17 +59,14 @@ PyRendererAgg_draw_path(RendererAgg *self,
5959
6060static void
6161PyRendererAgg_draw_text_image (RendererAgg *self,
62- py::array_t <agg::int8u, py::array::c_style> image_obj,
62+ py::array_t <agg::int8u, py::array::c_style | py::array::forcecast > image_obj,
6363 double x,
6464 double y,
6565 double angle,
6666 GCAgg &gc)
6767{
68- numpy::array_view<agg::int8u, 2 > image;
69-
70- if (!image.converter_contiguous (image_obj.ptr (), &image)) {
71- throw py::error_already_set ();
72- }
68+ // TODO: This really shouldn't be mutable, but Agg's renderer buffers aren't const.
69+ auto image = image_obj.mutable_unchecked <2 >();
7370
7471 self->draw_text_image (gc, image, x, y, angle);
7572}
@@ -98,13 +95,10 @@ PyRendererAgg_draw_image(RendererAgg *self,
9895 GCAgg &gc,
9996 double x,
10097 double y,
101- py::array_t <agg::int8u, py::array::c_style> image_obj)
98+ py::array_t <agg::int8u, py::array::c_style | py::array::forcecast > image_obj)
10299{
103- numpy::array_view<agg::int8u, 3 > image;
104-
105- if (!image.set (image_obj.ptr ())) {
106- throw py::error_already_set ();
107- }
100+ // TODO: This really shouldn't be mutable, but Agg's renderer buffers aren't const.
101+ auto image = image_obj.mutable_unchecked <3 >();
108102
109103 x = mpl_round (x);
110104 y = mpl_round (y);
@@ -179,21 +173,18 @@ PyRendererAgg_draw_quad_mesh(RendererAgg *self,
179173 agg::trans_affine master_transform,
180174 unsigned int mesh_width,
181175 unsigned int mesh_height,
182- py::object coordinates_obj,
176+ py::array_t < double , py::array::c_style | py::array::forcecast> coordinates_obj,
183177 py::object offsets_obj,
184178 agg::trans_affine offset_trans,
185179 py::object facecolors_obj,
186180 bool antialiased,
187181 py::object edgecolors_obj)
188182{
189- numpy::array_view<const double , 3 > coordinates;
190183 numpy::array_view<const double , 2 > offsets;
191184 numpy::array_view<const double , 2 > facecolors;
192185 numpy::array_view<const double , 2 > edgecolors;
193186
194- if (!coordinates.converter (coordinates_obj.ptr (), &coordinates)) {
195- throw py::error_already_set ();
196- }
187+ auto coordinates = coordinates_obj.mutable_unchecked <3 >();
197188 if (!convert_points (offsets_obj.ptr (), &offsets)) {
198189 throw py::error_already_set ();
199190 }
@@ -219,19 +210,12 @@ PyRendererAgg_draw_quad_mesh(RendererAgg *self,
219210static void
220211PyRendererAgg_draw_gouraud_triangles (RendererAgg *self,
221212 GCAgg &gc,
222- py::object points_obj,
223- py::object colors_obj,
213+ py::array_t < double > points_obj,
214+ py::array_t < double > colors_obj,
224215 agg::trans_affine trans)
225216{
226- numpy::array_view<const double , 3 > points;
227- numpy::array_view<const double , 3 > colors;
228-
229- if (!points.converter (points_obj.ptr (), &points)) {
230- throw py::error_already_set ();
231- }
232- if (!colors.converter (colors_obj.ptr (), &colors)) {
233- throw py::error_already_set ();
234- }
217+ auto points = points_obj.unchecked <3 >();
218+ auto colors = colors_obj.unchecked <3 >();
235219
236220 self->draw_gouraud_triangles (gc, points, colors, trans);
237221}
0 commit comments