Skip to content

Commit 076057a

Browse files
authored
Merge pull request #81 from fonttools/update-skia-m143
Migrate Skia to m143 and SkPathBuilder
2 parents ed0b67f + 023ed7f commit 076057a

File tree

9 files changed

+437
-437
lines changed

9 files changed

+437
-437
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ on:
88
branches: [main]
99

1010
env:
11-
# skip 3.7 on all platforms; only build pypy3 for linux
12-
CIBW_SKIP: cp37-* pp*-macosx_x86_64 pp*-win_amd64
11+
# skip 3.8, 3.9 (EOL); skip free-threaded 3.14 (untested yet)
12+
CIBW_SKIP: cp38-* cp39-* cp314t-*
13+
# enable PyPy builds on all platforms
14+
CIBW_ENABLE: pypy
1315
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
1416
CIBW_MANYLINUX_I686_IMAGE: manylinux2014
1517
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: manylinux2014
@@ -24,19 +26,28 @@ jobs:
2426
runs-on: ${{ matrix.os }}
2527
env:
2628
CIBW_ARCHS: ${{ matrix.arch }}
29+
CIBW_BUILD: ${{ matrix.cibw_build_filter || '' }}
2730
defaults:
2831
run:
2932
shell: bash
3033
strategy:
3134
fail-fast: false
3235
matrix:
33-
# macos-13 runners are still x86_64, macos-14 (latest) are arm64; we want to build
34-
# the x86_64 wheel on/for x86_64 macs
35-
os: [macos-13, ubuntu-latest, windows-latest]
36+
os: [ubuntu-latest, windows-latest]
3637
arch: [auto64]
3738
include:
39+
# CPython universal2 wheels (x86_64 + arm64) for macOS
3840
- os: macos-latest
3941
arch: universal2
42+
cibw_build_filter: "cp*"
43+
# PyPy x86_64 wheels for macOS (PyPy doesn't support universal2)
44+
- os: macos-13
45+
arch: x86_64
46+
cibw_build_filter: "pp*"
47+
# PyPy arm64 wheels for macOS (PyPy doesn't support universal2)
48+
- os: macos-latest
49+
arch: arm64
50+
cibw_build_filter: "pp*"
4051
- os: windows-latest
4152
arch: x86
4253
steps:
@@ -54,7 +65,11 @@ jobs:
5465
if [ "$BUILD_SKIA_FROM_SOURCE" == "0" ]; then
5566
pip install setuptools githubrelease
5667
if ! [[ $CIBW_ARCHS =~ ^auto ]]; then
57-
cpu_arch="--cpu-arch=$CIBW_ARCHS"
68+
# translate cibuildwheel arch names to download_libskia.py names
69+
case "$CIBW_ARCHS" in
70+
x86_64) cpu_arch="--cpu-arch=x64" ;;
71+
*) cpu_arch="--cpu-arch=$CIBW_ARCHS" ;;
72+
esac
5873
fi
5974
python ci/download_libskia.py -d "${SKIA_LIBRARY_DIR}" $cpu_arch
6075
fi
@@ -72,7 +87,7 @@ jobs:
7287
strategy:
7388
matrix:
7489
# aarch64 uses qemu so it's slow, build each py version in parallel jobs
75-
python: [38, 39, 310, 311, 312, 313]
90+
python: [310, 311, 312, 313, 314]
7691
arch: [aarch64]
7792
env:
7893
# Skip building aarch64 wheels for musllinux until I figure out why I get

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
[build-system]
22
requires = [
3-
# pin setuptools on pypy to workaround this bug: https://github.com/pypa/distutils/issues/283
4-
"setuptools<72.2.0; platform_python_implementation == 'PyPy'",
5-
"setuptools; platform_python_implementation != 'PyPy'",
3+
"setuptools",
64
"wheel",
75
"setuptools_scm",
86
"cython >= 0.28.4",

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def get_skia_using_pkgconfig():
329329
[
330330
# extra flags needed on macOS for C++11
331331
"-stdlib=libc++",
332-
"-mmacosx-version-min=10.9",
332+
"-mmacosx-version-min=11.0",
333333
]
334334
if platform.system() == "Darwin"
335335
else []
@@ -352,6 +352,7 @@ def get_skia_using_pkgconfig():
352352
],
353353
include_dirs=include_dirs,
354354
extra_compile_args=extra_compile_args,
355+
define_macros=[("SK_SUPPORT_UNSPANNED_APIS", "1")],
355356
libraries=["skia", *pkg_config_op.libraries],
356357
library_dirs=library_dirs,
357358
language="c++",
@@ -391,7 +392,7 @@ def get_skia_using_pkgconfig():
391392
# "pytest-cython",
392393
],
393394
},
394-
python_requires=">=3.8",
395+
python_requires=">=3.10",
395396
zip_safe=False,
396397
classifiers=[
397398
"Development Status :: 4 - Beta",

src/python/pathops/_pathops.pxd

Lines changed: 29 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
from ._skia.core cimport (
2+
SkArcSize,
23
SkLineCap,
34
SkLineJoin,
45
SkPath,
6+
SkPathBuilder,
57
SkPathFillType,
8+
SkPathIter,
9+
SkPathVerb,
610
SkPoint,
711
SkScalar,
8-
kMove_Verb,
9-
kLine_Verb,
10-
kQuad_Verb,
11-
kConic_Verb,
12-
kCubic_Verb,
13-
kClose_Verb,
14-
kDone_Verb,
15-
kSmall_ArcSize,
16-
kLarge_ArcSize,
12+
SkSpan,
1713
SkPathDirection,
1814
SkMatrix,
1915
)
@@ -27,6 +23,7 @@ from ._skia.pathops cimport (
2723
kReverseDifference_SkPathOp,
2824
)
2925
from libc.stdint cimport uint8_t, int32_t, uint32_t
26+
from libcpp.optional cimport optional
3027

3128

3229
cpdef enum PathOp:
@@ -56,8 +53,8 @@ cpdef enum LineJoin:
5653

5754

5855
cpdef enum ArcSize:
59-
SMALL = kSmall_ArcSize
60-
LARGE = kLarge_ArcSize
56+
SMALL = <uint32_t>SkArcSize.kSmall_ArcSize
57+
LARGE = <uint32_t>SkArcSize.kLarge_ArcSize
6158

6259

6360
cpdef enum Direction:
@@ -97,10 +94,10 @@ cdef bint collinear(
9794

9895
cdef class Path:
9996

100-
cdef SkPath path
97+
cdef SkPathBuilder path
10198

10299
@staticmethod
103-
cdef Path create(const SkPath& path)
100+
cdef Path create(const SkPathBuilder& path)
104101

105102
cpdef PathPen getPen(self, object glyphSet=*, bint allow_open_paths=*)
106103

@@ -200,13 +197,12 @@ cdef class Path:
200197

201198

202199
cpdef enum PathVerb:
203-
MOVE = kMove_Verb
204-
LINE = kLine_Verb
205-
QUAD = kQuad_Verb
206-
CONIC = kConic_Verb # unsupported
207-
CUBIC = kCubic_Verb
208-
CLOSE = kClose_Verb
209-
DONE = kDone_Verb # unused; we raise StopIteration instead
200+
MOVE = <uint8_t>SkPathVerb.kMove
201+
LINE = <uint8_t>SkPathVerb.kLine
202+
QUAD = <uint8_t>SkPathVerb.kQuad
203+
CONIC = <uint8_t>SkPathVerb.kConic # unsupported
204+
CUBIC = <uint8_t>SkPathVerb.kCubic
205+
CLOSE = <uint8_t>SkPathVerb.kClose
210206

211207

212208
cdef uint8_t *POINTS_IN_VERB
@@ -219,20 +215,19 @@ cdef dict PEN_METHODS
219215
cdef class RawPathIterator:
220216

221217
cdef Path path
222-
cdef SkPath.RawIter iterator
218+
cdef optional[SkPathIter] iterator
223219

224220

225221
cdef class SegmentPenIterator:
226222

227-
cdef _SkPointArray pa
228-
cdef SkPoint *pts
229-
cdef _VerbArray va
230-
cdef uint8_t *verbs
231-
cdef uint8_t *verb_stop
223+
cdef Path path
224+
cdef const SkPoint *pts
225+
cdef const SkPathVerb *verbs
226+
cdef const SkPathVerb *verb_stop
232227
cdef SkPoint move_pt
233228
cdef bint closed
234229

235-
cdef uint8_t peek(self)
230+
cdef bint nextIsClose(self)
236231

237232
cdef tuple _join_quadratic_segments(self)
238233

@@ -260,25 +255,7 @@ cdef class PathPen:
260255
cpdef addComponent(self, glyphName, transformation)
261256

262257

263-
cdef double get_path_area(const SkPath& path) except? -1234567
264-
265-
266-
cdef class _VerbArray:
267-
268-
cdef uint8_t *data
269-
cdef int count
270-
271-
@staticmethod
272-
cdef _VerbArray create(const SkPath& path)
273-
274-
275-
cdef class _SkPointArray:
276-
277-
cdef SkPoint *data
278-
cdef int count
279-
280-
@staticmethod
281-
cdef _SkPointArray create(const SkPath& path)
258+
cdef double get_path_area(const SkPathBuilder& path) except? -1234567
282259

283260

284261
cdef class _SkScalarArray:
@@ -290,13 +267,13 @@ cdef class _SkScalarArray:
290267
cdef _SkScalarArray create(object values)
291268

292269

293-
cdef int pts_in_verb(unsigned v) except -1
270+
cdef int pts_in_verb(SkPathVerb v) except -1
294271

295272

296-
cdef bint reverse_contour(SkPath& path) except False
273+
cdef bint reverse_contour(SkPathBuilder& path) except False
297274

298275

299-
cdef int path_is_inside(const SkPath& self, const SkPath& other) except -1
276+
cdef int path_is_inside(const SkPathBuilder& self, const SkPathBuilder& other) except -1
300277

301278

302279
cpdef int restore_starting_points(Path path, list points) except -1
@@ -313,17 +290,17 @@ cdef int find_oncurve_point(
313290
SkScalar y,
314291
const SkPoint *pts,
315292
int pt_count,
316-
const uint8_t *verbs,
293+
const SkPathVerb *verbs,
317294
int verb_count,
318295
int *pt_index,
319296
int *verb_index,
320297
) except -1
321298

322299

323-
cdef int contour_is_closed(const uint8_t *verbs, int verb_count) except -1
300+
cdef int contour_is_closed(SkSpan[const SkPathVerb] verbs) except -1
324301

325302

326-
cdef int set_contour_start_point(SkPath& path, SkScalar x, SkScalar y) except -1
303+
cdef int set_contour_start_point(SkPathBuilder& path, SkScalar x, SkScalar y) except -1
327304

328305

329306
cdef int compute_conic_to_quad_pow2(

0 commit comments

Comments
 (0)