Skip to content

Commit 719dda5

Browse files
committed
add missing pybind11 include
There are arguments of type `std::vector` in `Point.Offset` (located in the file `src/skia/Point.cpp`) and `BBoxHierarchy.search` (located in the file `src/skia/Picture.cpp`), but the corresponding files do not include `#include <pybind11/stl.h>`. Add the include statement and supplement with related tests.
1 parent 832cb4e commit 719dda5

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

src/skia/Picture.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <include/core/SkBBHFactory.h>
44
#include <include/core/SkPictureRecorder.h>
55
#include <pybind11/operators.h>
6+
#include <pybind11/stl.h>
67

78
namespace {
89

src/skia/Point.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "common.h"
22
#include <include/core/SkPoint3.h>
33
#include <pybind11/operators.h>
4+
#include <pybind11/stl.h>
45

56
void initPoint(py::module &m) {
67
// IPoint

tests/test_picture.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,30 @@ def test_Picture_MakePlaceholder():
6262
skia.Picture.MakePlaceholder(skia.Rect(100, 100)), skia.Picture)
6363

6464

65-
def test_PictureRecorder_init():
66-
assert isinstance(skia.PictureRecorder(), skia.PictureRecorder)
65+
def test_RTreeFactory_init():
66+
assert isinstance(skia.RTreeFactory(), skia.RTreeFactory)
67+
68+
69+
def test_RTreeFactory_call():
70+
rtree = skia.RTreeFactory()()
71+
assert isinstance(rtree, skia.BBoxHierarchy)
72+
73+
74+
@pytest.fixture
75+
def rtree():
76+
return skia.RTreeFactory()()
77+
78+
79+
def test_BBoxHierarchy_init():
80+
assert isinstance(skia.BBoxHierarchy(), skia.BBoxHierarchy)
81+
82+
83+
def test_BBoxHierarchy_insert(rtree):
84+
rtree.insert(skia.Rect(100, 100), 1)
85+
86+
87+
def test_BBoxHierarchy_search(rtree):
88+
rtree.search(skia.Rect(100, 100), [])
6789

6890

6991
@pytest.mark.parametrize('args', [

tests/test_point.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ def test_Point_init(args):
105105
assert isinstance(skia.Point(*args), skia.Point)
106106

107107

108+
def test_Point_Offset():
109+
points = [skia.Point(1, 2), skia.Point(3, 4)]
110+
points = skia.Point.Offset(points, 1, 1)
111+
assert points[0].equals(2, 3)
112+
assert points[1].equals(4, 5)
113+
114+
108115
def test_Point_x(point):
109116
assert point.x() == 4
110117

0 commit comments

Comments
 (0)