Skip to content

Commit d75430b

Browse files
committed
PathIterator takes PyObject* instead of Py::Object
1 parent cc7e365 commit d75430b

File tree

4 files changed

+24
-26
lines changed

4 files changed

+24
-26
lines changed

src/_backend_agg.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ RendererAgg::render_clippath(const Py::Object& clippath,
640640
trans *= agg::trans_affine_scaling(1.0, -1.0);
641641
trans *= agg::trans_affine_translation(0.0, (double)height);
642642

643-
PathIterator clippath_iter(clippath);
643+
PathIterator clippath_iter(clippath.ptr());
644644
rendererBaseAlphaMask.clear(agg::gray8(0, 0));
645645
transformed_path_t transformed_clippath(clippath_iter, trans);
646646
curve_t curved_clippath(transformed_clippath);
@@ -691,15 +691,15 @@ RendererAgg::draw_markers(const Py::Tuple& args)
691691
trans *= agg::trans_affine_scaling(1.0, -1.0);
692692
trans *= agg::trans_affine_translation(0.5, (double)height + 0.5);
693693

694-
PathIterator marker_path(marker_path_obj);
694+
PathIterator marker_path(marker_path_obj.ptr());
695695
transformed_path_t marker_path_transformed(marker_path, marker_trans);
696696
snap_t marker_path_snapped(marker_path_transformed,
697697
gc.snap_mode,
698698
marker_path.total_vertices(),
699699
gc.linewidth);
700700
curve_t marker_path_curve(marker_path_snapped);
701701

702-
PathIterator path(path_obj);
702+
PathIterator path(path_obj.ptr());
703703
transformed_path_t path_transformed(path, trans);
704704
snap_t path_snapped(path_transformed,
705705
SNAP_FALSE,
@@ -1270,7 +1270,7 @@ void RendererAgg::_draw_path(path_t& path, bool has_clippath,
12701270
typedef agg::conv_curve<hatch_path_trans_t> hatch_path_curve_t;
12711271
typedef agg::conv_stroke<hatch_path_curve_t> hatch_path_stroke_t;
12721272

1273-
PathIterator hatch_path(gc.hatchpath);
1273+
PathIterator hatch_path(gc.hatchpath.ptr());
12741274
agg::trans_affine hatch_trans;
12751275
hatch_trans *= agg::trans_affine_scaling(1.0, -1.0);
12761276
hatch_trans *= agg::trans_affine_translation(0.0, 1.0);
@@ -1430,7 +1430,7 @@ RendererAgg::draw_path(const Py::Tuple& args)
14301430
args.verify_length(3, 4);
14311431

14321432
GCAgg gc(args[0], dpi);
1433-
PathIterator path(args[1]);
1433+
PathIterator path(args[1].ptr());
14341434
agg::trans_affine trans = py_to_agg_transformation_matrix(args[2].ptr());
14351435
Py::Object face_obj;
14361436
if (args.size() == 4)
@@ -1737,7 +1737,7 @@ class PathListGenerator
17371737
inline path_iterator
17381738
operator()(size_t i) const
17391739
{
1740-
return PathIterator(m_paths[i % m_npaths]);
1740+
return PathIterator(m_paths[i % m_npaths].ptr());
17411741
}
17421742
};
17431743

src/_path.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ PyObject *_point_in_path(PyObject *self, PyObject *_args)
352352
if (!PyArg_ParseTuple(_args, "dddOO", &x, &y, &r, &_path, &_trans)) {
353353
return NULL;
354354
}
355-
PathIterator path(Py::Object(_path, false));
355+
PathIterator path(_path);
356356
agg::trans_affine trans = py_to_agg_transformation_matrix(_trans, false);
357357

358358
if (::point_in_path(x, y, r, path, trans)) {
@@ -373,7 +373,7 @@ PyObject *_points_in_path(PyObject *self, PyObject *_args)
373373
return NULL;
374374
}
375375

376-
PathIterator path(Py::Object(_path, false));
376+
PathIterator path(_path);
377377
agg::trans_affine trans = py_to_agg_transformation_matrix(_trans, false);
378378

379379
PyArrayObject* points_array;
@@ -437,7 +437,7 @@ PyObject *_point_on_path(PyObject *self, PyObject *_args)
437437
if (!PyArg_ParseTuple(_args, "dddOO", &x, &y, &r, &_path, &_trans)) {
438438
return NULL;
439439
}
440-
PathIterator path(Py::Object(_path, false));
440+
PathIterator path(_path);
441441
agg::trans_affine trans = py_to_agg_transformation_matrix(_trans, false);
442442

443443
if (::point_on_path(x, y, r, path, trans))
@@ -498,7 +498,7 @@ PyObject *_get_path_extents(PyObject *self, PyObject *_args)
498498
if (!PyArg_ParseTuple(_args, "OO", &_path, &_trans)) {
499499
return NULL;
500500
}
501-
PathIterator path(Py::Object(_path, false));
501+
PathIterator path(_path);
502502
agg::trans_affine trans = py_to_agg_transformation_matrix(_trans, false);
503503
/*
504504
const Py::Tuple args(_args);
@@ -547,7 +547,7 @@ PyObject *_update_path_extents(PyObject *self, PyObject *_args)
547547
&_path, &_trans, &_bbox, &_minpos, &_ignore)) {
548548
return NULL;
549549
}
550-
PathIterator path(Py::Object(_path, false));
550+
PathIterator path(_path);
551551
agg::trans_affine trans = py_to_agg_transformation_matrix(_trans, false);
552552

553553
double x0, y0, x1, y1;
@@ -803,7 +803,7 @@ PyObject *_get_path_collection_extents(PyObject *self, PyObject *_args)
803803

804804
if (transforms.size() <= 1 && Npaths == 1)
805805
{
806-
PathIterator path(Py::Object(paths_arr[0], false));
806+
PathIterator path(paths_arr[0]);
807807
//PathIterator path(paths[0]);
808808
if (Ntransforms)
809809
{
@@ -834,7 +834,7 @@ PyObject *_get_path_collection_extents(PyObject *self, PyObject *_args)
834834
} else {
835835
for (i = 0; i < N; ++i)
836836
{
837-
PathIterator path(Py::Object(paths_arr[i % Npaths], false));
837+
PathIterator path(paths_arr[i % Npaths]);
838838
//PathIterator path(paths[i % Npaths]);
839839
if (Ntransforms)
840840
{
@@ -976,7 +976,7 @@ PyObject *_point_in_path_collection(PyObject *self, PyObject *_args)
976976

977977
for (i = 0; i < N; ++i)
978978
{
979-
PathIterator path(Py::Object(paths_arr[i % Npaths], false));
979+
PathIterator path(paths_arr[i % Npaths]);
980980
//PathIterator path(paths[i % Npaths]);
981981

982982
if (Ntransforms)
@@ -1071,10 +1071,10 @@ PyObject *_path_in_path(PyObject *self, PyObject *_args)
10711071
if (!PyArg_ParseTuple(_args, "OOOO", &_a, &_atrans, &_b, &_btrans)) {
10721072
return NULL;
10731073
}
1074-
PathIterator a(Py::Object(_a, false));
1074+
PathIterator a(_a);
10751075
agg::trans_affine atrans = py_to_agg_transformation_matrix(_atrans, false);
10761076

1077-
PathIterator b(Py::Object(_b, false));
1077+
PathIterator b(_b);
10781078
agg::trans_affine btrans = py_to_agg_transformation_matrix(_btrans, false);
10791079

10801080
/*
@@ -1313,7 +1313,7 @@ PyObject *_clip_path_to_rect(PyObject *self, PyObject *_args)
13131313
if (!PyArg_ParseTuple(_args, "OOO", &_path, &_bbox, &_inside)) {
13141314
return NULL;
13151315
}
1316-
PathIterator path(Py::Object(_path, false));
1316+
PathIterator path(_path);
13171317
bool inside = PyObject_IsTrue(_inside) != 0;
13181318

13191319
double x0, y0, x1, y1;
@@ -1712,8 +1712,8 @@ PyObject *_path_intersects_path(PyObject *self, PyObject *_args)
17121712
return NULL;
17131713
}
17141714

1715-
PathIterator p1(Py::Object(_p1, false));
1716-
PathIterator p2(Py::Object(_p2, false));
1715+
PathIterator p1(_p1);
1716+
PathIterator p2(_p2);
17171717
bool filled = PyObject_IsTrue(_filled) != 0;
17181718
/*
17191719
const Py::Tuple args(_args);
@@ -1787,7 +1787,7 @@ PyObject *_convert_path_to_polygons(PyObject *self, PyObject *_args)
17871787
if (!PyArg_ParseTuple(_args, "OOdd", &_path, &_trans, &width, &height)) {
17881788
return NULL;
17891789
}
1790-
PathIterator path(Py::Object(_path, false));
1790+
PathIterator path(_path);
17911791
agg::trans_affine trans = py_to_agg_transformation_matrix(_trans, false);
17921792

17931793
/*
@@ -1923,7 +1923,7 @@ PyObject *_cleanup_path(PyObject *self, PyObject *_args)
19231923
return NULL;
19241924
}
19251925

1926-
PathIterator path(Py::Object(_path, false));
1926+
PathIterator path(_path);
19271927
agg::trans_affine trans = py_to_agg_transformation_matrix(_trans, false);
19281928
bool remove_nans = PyObject_IsTrue(_nans) != 0;
19291929
bool do_clip = _clip != Py_None;
@@ -2108,7 +2108,7 @@ PyObject *_convert_to_svg(PyObject *self, PyObject *_args)
21082108
return NULL;
21092109
}
21102110

2111-
PathIterator path(Py::Object(_path, false));
2111+
PathIterator path(_path);
21122112
agg::trans_affine trans = py_to_agg_transformation_matrix(_trans, false);
21132113
bool do_clip = PyObject_IsTrue(_clip) != 0;
21142114

src/agg_py_path_iterator.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,10 @@ class PathIterator
3636

3737
public:
3838
/* path_obj is an instance of the class Path as defined in path.py */
39-
inline PathIterator(const Py::Object& path_obj) :
39+
inline PathIterator(PyObject* _path) :
4040
m_iterator(0), m_should_simplify(false),
4141
m_simplify_threshold(1.0 / 9.0)
4242
{
43-
PyObject* _path = path_obj.ptr();
44-
4543
PyObject* _vertices = PyObject_GetAttrString(_path, "vertices");
4644
if (!_vertices)
4745
{

src/path_cleanup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class PathCleanupIterator
3636
bool do_simplify, double sketch_scale,
3737
double sketch_length, double sketch_randomness) :
3838
m_path_obj(path, true),
39-
m_path_iter(m_path_obj),
39+
m_path_iter(path),
4040
m_transform(trans),
4141
m_transformed(m_path_iter, m_transform),
4242
m_nan_removed(m_transformed, remove_nans, m_path_iter.has_curves()),

0 commit comments

Comments
 (0)