Skip to content

Commit 805b844

Browse files
authored
Merge pull request #83 from fonttools/remove-unspanned-api
Update uses of Skia's old unspanned APIs
2 parents 195a0d2 + 24d6472 commit 805b844

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/python/pathops/_pathops.pxd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ cdef class _SkScalarArray:
266266
@staticmethod
267267
cdef _SkScalarArray create(object values)
268268

269+
cdef SkSpan[SkScalar] as_span(self)
270+
269271

270272
cdef int pts_in_verb(SkPathVerb v) except -1
271273

src/python/pathops/_pathops.pyx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ cdef class Path:
526526
if intervals.count % 2 != 0:
527527
raise ValueError("Expected an even number of dash_array entries")
528528
paint.setPathEffect(
529-
SkDashPathEffect.Make(intervals.data, intervals.count, dash_offset)
529+
SkDashPathEffect.Make(<SkSpan[const SkScalar]>intervals.as_span(), dash_offset)
530530
)
531531

532532
FillPathWithPaint(self.path.detach(), paint, &self.path)
@@ -1104,6 +1104,9 @@ cdef class _SkScalarArray:
11041104
def __dealloc__(self):
11051105
PyMem_Free(self.data) # no-op if data is NULL
11061106

1107+
cdef SkSpan[SkScalar] as_span(self):
1108+
return SkSpan[SkScalar](self.data, self.count)
1109+
11071110

11081111
cdef inline int pts_in_verb(SkPathVerb v) except -1:
11091112
if <uint8_t>v >= NUM_VERBS:

src/python/pathops/_skia/core.pxd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ ctypedef float SkScalar
66

77
cdef extern from "include/core/SkSpan.h":
88
cdef cppclass SkSpan[T]:
9+
SkSpan()
10+
SkSpan(T* data, size_t size)
911
SkSpan[T] subspan(size_t offset) const
1012
T& operator[](size_t) const
1113
bint empty() const
@@ -240,7 +242,7 @@ cdef extern from "include/core/SkPathEffect.h":
240242
cdef extern from "include/effects/SkDashPathEffect.h":
241243
cdef cppclass SkDashPathEffect:
242244
@staticmethod
243-
sk_sp[SkPathEffect] Make(const SkScalar intervals[], int count, SkScalar phase)
245+
sk_sp[SkPathEffect] Make(SkSpan[const SkScalar] intervals, SkScalar phase)
244246

245247

246248
cdef extern from "include/core/SkPaint.h":

0 commit comments

Comments
 (0)