From f7dad34e2e49064522401f20b1d949cc5285d0e3 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 29 Apr 2024 19:38:13 +0100 Subject: [PATCH 01/31] bump version to 125.0b7 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d8a37a27..23128f51 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ pass NAME = 'skia-python' -__version__ = '124.0b7' +__version__ = '125.0b7' SKIA_PATH = os.getenv('SKIA_PATH', 'skia') SKIA_OUT_PATH = os.getenv( From 29269ade0110c42562bfbc8ecb748e075a212ece Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 29 Apr 2024 19:40:50 +0100 Subject: [PATCH 02/31] skia m125 (canvaskit/0.38.2-4468-gec3813eabd) from m124 (canvaskit/0.38.2-4059-ge2ea2eb3e0) --- skia | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skia b/skia index e2ea2eb3..ec3813ea 160000 --- a/skia +++ b/skia @@ -1 +1 @@ -Subproject commit e2ea2eb3e0d37fff47968dfaaa337debb3b75b1e +Subproject commit ec3813eabd24854a1b82457064e9e3031ccc06d7 From 611358b61092a6689f435f5b850b2f5a80604930 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 29 Apr 2024 21:24:09 +0100 Subject: [PATCH 03/31] m125 patches plus adjustments --- .github/workflows/ci.yml | 2 +- patch/skia-m125-minimize-download.patch | 69 +++++++++++++++++++++++++ scripts/build_Linux.sh | 2 +- scripts/build_Windows.sh | 2 +- scripts/build_macOS.sh | 2 +- 5 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 patch/skia-m125-minimize-download.patch diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d472d8bb..6e93b6a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: skia key: linux-aarch64-skia-${{ github.sha }}-3rd-party - name: Pre-fetch skia deps - run: git config --global core.compression 0 && cd skia && patch -p1 -i ../patch/skia-m124-minimize-download.patch && python tools/git-sync-deps && patch -p1 -R -i ../patch/skia-m124-minimize-download.patch + run: git config --global core.compression 0 && cd skia && patch -p1 -i ../patch/skia-m125-minimize-download.patch && python tools/git-sync-deps && patch -p1 -R -i ../patch/skia-m125-minimize-download.patch - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Build skia 3rd-Party diff --git a/patch/skia-m125-minimize-download.patch b/patch/skia-m125-minimize-download.patch new file mode 100644 index 00000000..8d52f977 --- /dev/null +++ b/patch/skia-m125-minimize-download.patch @@ -0,0 +1,69 @@ +diff --git a/DEPS b/DEPS +index 34462a7..0664739 100644 +--- a/DEPS ++++ b/DEPS +@@ -23,52 +23,18 @@ vars = { + # ./tools/git-sync-deps + deps = { + "buildtools" : "https://chromium.googlesource.com/chromium/src/buildtools.git@b138e6ce86ae843c42a1a08f37903207bebcca75", +- "third_party/externals/angle2" : "https://chromium.googlesource.com/angle/angle.git@66bc9cfa00143312cc7545556041622a92745a91", +- "third_party/externals/brotli" : "https://skia.googlesource.com/external/github.com/google/brotli.git@6d03dfbedda1615c4cba1211f8d81735575209c8", +- "third_party/externals/d3d12allocator" : "https://skia.googlesource.com/external/github.com/GPUOpen-LibrariesAndSDKs/D3D12MemoryAllocator.git@169895d529dfce00390a20e69c2f516066fe7a3b", +- # Dawn requires jinja2 and markupsafe for the code generator, tint for SPIRV compilation, and abseil for string formatting. +- # When the Dawn revision is updated these should be updated from the Dawn DEPS as well. +- "third_party/externals/dawn" : "https://dawn.googlesource.com/dawn.git@f20a53466bc2cd5c86f0f903a9eea322cadf8b77", +- "third_party/externals/jinja2" : "https://chromium.googlesource.com/chromium/src/third_party/jinja2@e2d024354e11cc6b041b0cff032d73f0c7e43a07", +- "third_party/externals/markupsafe" : "https://chromium.googlesource.com/chromium/src/third_party/markupsafe@0bad08bb207bbfc1d6f3bbc82b9242b0c50e5794", +- "third_party/externals/abseil-cpp" : "https://skia.googlesource.com/external/github.com/abseil/abseil-cpp.git@334aca32051ef6ede2711487acf45d959e9bdffc", + "third_party/externals/dng_sdk" : "https://android.googlesource.com/platform/external/dng_sdk.git@c8d0c9b1d16bfda56f15165d39e0ffa360a11123", +- "third_party/externals/egl-registry" : "https://skia.googlesource.com/external/github.com/KhronosGroup/EGL-Registry@b055c9b483e70ecd57b3cf7204db21f5a06f9ffe", +- "third_party/externals/emsdk" : "https://skia.googlesource.com/external/github.com/emscripten-core/emsdk.git@a896e3d066448b3530dbcaa48869fafefd738f57", + "third_party/externals/expat" : "https://chromium.googlesource.com/external/github.com/libexpat/libexpat.git@441f98d02deafd9b090aea568282b28f66a50e36", + "third_party/externals/freetype" : "https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@f42ce25563b73fed0123d18a2556b9ba01d2c76b", + "third_party/externals/harfbuzz" : "https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@c053e8f29257814e11ad61493dbbe29f27656de4", +- "third_party/externals/highway" : "https://chromium.googlesource.com/external/github.com/google/highway.git@424360251cdcfc314cfc528f53c872ecd63af0f0", + "third_party/externals/icu" : "https://chromium.googlesource.com/chromium/deps/icu.git@a0718d4f121727e30b8d52c7a189ebf5ab52421f", +- "third_party/externals/icu4x" : "https://chromium.googlesource.com/external/github.com/unicode-org/icu4x.git@bcf4f7198d4dc5f3127e84a6ca657c88e7d07a13", +- "third_party/externals/imgui" : "https://skia.googlesource.com/external/github.com/ocornut/imgui.git@55d35d8387c15bf0cfd71861df67af8cfbda7456", +- "third_party/externals/libavif" : "https://skia.googlesource.com/external/github.com/AOMediaCodec/libavif.git@55aab4ac0607ab651055d354d64c4615cf3d8000", +- "third_party/externals/libgav1" : "https://chromium.googlesource.com/codecs/libgav1.git@5cf722e659014ebaf2f573a6dd935116d36eadf1", +- "third_party/externals/libgrapheme" : "https://skia.googlesource.com/external/github.com/FRIGN/libgrapheme/@c0cab63c5300fa12284194fbef57aa2ed62a94c0", + "third_party/externals/libjpeg-turbo" : "https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@ed683925e4897a84b3bffc5c1414c85b97a129a3", +- "third_party/externals/libjxl" : "https://chromium.googlesource.com/external/gitlab.com/wg1/jpeg-xl.git@a205468bc5d3a353fb15dae2398a101dff52f2d3", + "third_party/externals/libpng" : "https://skia.googlesource.com/third_party/libpng.git@144b348e072a78e8130ed0acc452c9f039a67bf2", + "third_party/externals/libwebp" : "https://chromium.googlesource.com/webm/libwebp.git@ca332209cb5567c9b249c86788cb2dbf8847e760", +- "third_party/externals/libyuv" : "https://chromium.googlesource.com/libyuv/libyuv.git@d248929c059ff7629a85333699717d7a677d8d96", +- "third_party/externals/microhttpd" : "https://android.googlesource.com/platform/external/libmicrohttpd@748945ec6f1c67b7efc934ab0808e1d32f2fb98d", +- "third_party/externals/oboe" : "https://chromium.googlesource.com/external/github.com/google/oboe.git@b02a12d1dd821118763debec6b83d00a8a0ee419", +- "third_party/externals/opengl-registry" : "https://skia.googlesource.com/external/github.com/KhronosGroup/OpenGL-Registry@14b80ebeab022b2c78f84a573f01028c96075553", +- "third_party/externals/perfetto" : "https://android.googlesource.com/platform/external/perfetto@93885509be1c9240bc55fa515ceb34811e54a394", + "third_party/externals/piex" : "https://android.googlesource.com/platform/external/piex.git@bb217acdca1cc0c16b704669dd6f91a1b509c406", +- "third_party/externals/swiftshader" : "https://swiftshader.googlesource.com/SwiftShader@62c59c41e194c288c06739788bb0aad3c86b19bf", + "third_party/externals/vulkanmemoryallocator" : "https://chromium.googlesource.com/external/github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator@a6bfc237255a6bac1513f7c1ebde6d8aed6b5191", +- # vulkan-deps is a meta-repo containing several interdependent Khronos Vulkan repositories. +- # When the vulkan-deps revision is updated, those repos (spirv-*, vulkan-*) should be updated as well. + "third_party/externals/vulkan-deps" : "https://chromium.googlesource.com/vulkan-deps@ec0c320a8ca186363f609b697c037597398a43e6", +- "third_party/externals/spirv-cross" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/SPIRV-Cross@b8fcf307f1f347089e3c46eb4451d27f32ebc8d3", + "third_party/externals/spirv-headers" : "https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Headers.git@4f7b471f1a66b6d06462cd4ba57628cc0cd087d7", +- "third_party/externals/spirv-tools" : "https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Tools.git@2904985aee4de2fd67d697242a267f5ec31814ce", +- "third_party/externals/vello" : "https://skia.googlesource.com/external/github.com/linebender/vello.git@74715ee4650ec3f4483ccc86540b32d15d5bfaa3", +- "third_party/externals/vulkan-headers" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Headers@1e7b8a6d03d30c9254b5f533b561d62bba8c3199", +- "third_party/externals/vulkan-tools" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Tools@d14404b26e17086a707ea6ff5f7342ed5b9938ca", +- "third_party/externals/vulkan-utility-libraries": "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Utility-Libraries@72696f278218d39171678e41d8f43cff9905c513", +- "third_party/externals/unicodetools" : "https://chromium.googlesource.com/external/github.com/unicode-org/unicodetools@66a3fa9dbdca3b67053a483d130564eabc5fe095", +- #"third_party/externals/v8" : "https://chromium.googlesource.com/v8/v8.git@5f1ae66d5634e43563b2d25ea652dfb94c31a3b4", + "third_party/externals/wuffs" : "https://skia.googlesource.com/external/github.com/google/wuffs-mirror-release-c.git@e3f919ccfe3ef542cfc983a82146070258fb57f8", + "third_party/externals/zlib" : "https://chromium.googlesource.com/chromium/src/third_party/zlib@646b7f569718921d7d4b5b8e22572ff6c76f2596", + +diff --git a/bin/activate-emsdk b/bin/activate-emsdk +index 687ca9f..7167d8d 100755 +--- a/bin/activate-emsdk ++++ b/bin/activate-emsdk +@@ -17,6 +17,7 @@ EMSDK_PATH = os.path.join(EMSDK_ROOT, 'emsdk.py') + EMSDK_VERSION = '3.1.44' + + def main(): ++ return + if sysconfig.get_platform() in ['linux-aarch64', 'linux-arm64']: + # This platform cannot install emsdk at the provided version. See + # https://github.com/emscripten-core/emsdk/blob/main/emscripten-releases-tags.json#L5 diff --git a/scripts/build_Linux.sh b/scripts/build_Linux.sh index 2d328c3b..0b621a4b 100644 --- a/scripts/build_Linux.sh +++ b/scripts/build_Linux.sh @@ -60,7 +60,7 @@ git clone https://gn.googlesource.com/gn && \ # Build skia cd skia && \ - patch -p1 < ../patch/skia-m124-minimize-download.patch && \ + patch -p1 < ../patch/skia-m125-minimize-download.patch && \ patch -p1 < ../patch/skia-m123-colrv1-freetype.diff && \ python3 tools/git-sync-deps && \ cp -f ../gn/out/gn bin/gn && \ diff --git a/scripts/build_Windows.sh b/scripts/build_Windows.sh index e4d06a0e..a8ac5281 100644 --- a/scripts/build_Windows.sh +++ b/scripts/build_Windows.sh @@ -4,7 +4,7 @@ export PATH="${PWD}/depot_tools:$PATH" # Build skia cd skia && \ - patch -p1 < ../patch/skia-m124-minimize-download.patch && \ + patch -p1 < ../patch/skia-m125-minimize-download.patch && \ patch -p1 < ../patch/skia-m123-colrv1-freetype.diff && \ python tools/git-sync-deps && \ bin/gn gen out/Release --args=' diff --git a/scripts/build_macOS.sh b/scripts/build_macOS.sh index 7071daa5..48b98dae 100644 --- a/scripts/build_macOS.sh +++ b/scripts/build_macOS.sh @@ -22,7 +22,7 @@ function apply_patch { } cd skia && \ - patch -p1 < ../patch/skia-m124-minimize-download.patch && \ + patch -p1 < ../patch/skia-m125-minimize-download.patch && \ patch -p1 < ../patch/skia-m123-colrv1-freetype.diff && \ python3 tools/git-sync-deps && \ bin/gn gen out/Release --args=" From e04470b42944718c7e5c74adc45725de124eb04a Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 29 Apr 2024 18:19:18 +0100 Subject: [PATCH 04/31] m125: libskunicode split into libskunicode_core and libskunicode_icu --- setup.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 23128f51..5d5fbde4 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,8 @@ ] EXTRA_OBJECTS = list( ) + [os.path.join(SKIA_OUT_PATH, 'svg.lib'), os.path.join(SKIA_OUT_PATH, 'skresources.lib'), os.path.join(SKIA_OUT_PATH, 'skia.lib'), - os.path.join(SKIA_OUT_PATH, 'skshaper.lib'), os.path.join(SKIA_OUT_PATH, 'skunicode.lib')] + os.path.join(SKIA_OUT_PATH, 'skshaper.lib'), + os.path.join(SKIA_OUT_PATH, 'unicode_core.lib'), os.path.join(SKIA_OUT_PATH, 'unicode_icu.lib')] EXTRA_COMPILE_ARGS = [ '/std:c++17', # c++20 fails. '/DVERSION_INFO=%s' % __version__, @@ -64,7 +65,8 @@ ] EXTRA_OBJECTS = list( ) + [os.path.join(SKIA_OUT_PATH, 'libsvg.a'), os.path.join(SKIA_OUT_PATH, 'libskia.a'), - os.path.join(SKIA_OUT_PATH, 'libskshaper.a'), os.path.join(SKIA_OUT_PATH, 'libskunicode.a')] + os.path.join(SKIA_OUT_PATH, 'libskshaper.a'), + os.path.join(SKIA_OUT_PATH, 'libskunicode_core.a'), os.path.join(SKIA_OUT_PATH, 'libskunicode_icu.a')] EXTRA_COMPILE_ARGS = [ '-std=c++17', '-stdlib=libc++', @@ -97,7 +99,8 @@ ] EXTRA_OBJECTS = list( ) + [os.path.join(SKIA_OUT_PATH, 'libsvg.a'), os.path.join(SKIA_OUT_PATH, 'libskresources.a'), os.path.join(SKIA_OUT_PATH, 'libskia.a'), - os.path.join(SKIA_OUT_PATH, 'libskshaper.a'), os.path.join(SKIA_OUT_PATH, 'libskunicode.a')] + os.path.join(SKIA_OUT_PATH, 'libskshaper.a'), + os.path.join(SKIA_OUT_PATH, 'libskunicode_core.a'), os.path.join(SKIA_OUT_PATH, 'libskunicode_icu.a')] EXTRA_COMPILE_ARGS = [ '-std=c++17', '-fvisibility=hidden', From 0bc107adc8d146f351ed98f51f6773c0818d48b4 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 29 Apr 2024 18:05:34 +0100 Subject: [PATCH 05/31] m125: New optional arguments to SkPath::incReserve --- src/skia/Path.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/skia/Path.cpp b/src/skia/Path.cpp index d094b9fd..f095ce8f 100644 --- a/src/skia/Path.cpp +++ b/src/skia/Path.cpp @@ -841,7 +841,7 @@ path py::arg("rect")) .def("incReserve", &SkPath::incReserve, R"docstring( - Grows :py:class:`Path` verb array and :py:class:`Point` array to contain + Grows :py:class:`Path` verb array, :py:class:`Point` array and comics to contain extraPtCount additional :py:class:`Point`. May improve performance and use less memory by reducing the number and @@ -849,8 +849,10 @@ path :param int extraPtCount: number of additional :py:class:`Point` to allocate + :param int extraVerbCount: number of additional verbs + :param int extraConicCount: number of additional conics )docstring", - py::arg("extraPtCount")) + py::arg("extraPtCount"), py::arg("extraVerbCount") = 0, py::arg("extraConicCount") = 0) /* TODO: This was removed in m88 .def("shrinkToFit", &SkPath::shrinkToFit, R"docstring( From b1cf308eaeb448db1ae72eb30ef7f0e3075baaee Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 29 Apr 2024 18:08:38 +0100 Subject: [PATCH 06/31] m125: SK_REMOVE_LEGACY_STREAM_AS_DATA --- skia-m124/include/core/SkStream.h 2024-03-26 00:09:01.000000000 +0000 +++ skia-m125/include/core/SkStream.h 2024-04-29 01:34:47.000000000 +0100 @@ -392,13 +392,9 @@ */ void setMemoryOwned(const void* data, size_t length); -#if !defined(SK_REMOVE_LEGACY_STREAM_AS_DATA) - sk_sp asData() const { return fData; } -#endif sk_sp getData() const override { return fData; } void setData(sk_sp data); - void skipToAlign4(); const void* getAtPos(); size_t read(void* buffer, size_t size) override; --- src/skia/Stream.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/skia/Stream.cpp b/src/skia/Stream.cpp index 6f8ebcdc..687fbb59 100644 --- a/src/skia/Stream.cpp +++ b/src/skia/Stream.cpp @@ -676,9 +676,13 @@ py::class_, SkStreamMemory>(m, "MemoryStream") stream.setMemory(info.ptr, size, copyData); }, py::arg("data"), py::arg("copyData") = false) +/* .def("asData", &SkMemoryStream::asData) +*/ .def("setData", &SkMemoryStream::setData, py::arg("data")) +/* .def("skipToAlign4", &SkMemoryStream::skipToAlign4) +*/ .def("getAtPos", &SkMemoryStream::getAtPos) ; From d49d72753f72c32be90c4320419953a73e9f4da0 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 29 Apr 2024 19:14:52 +0100 Subject: [PATCH 07/31] m125: emulate withdrawn SkMemoryStream::asData with SkMemoryStream::getData --- src/skia/Stream.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/skia/Stream.cpp b/src/skia/Stream.cpp index 687fbb59..d9a4e62a 100644 --- a/src/skia/Stream.cpp +++ b/src/skia/Stream.cpp @@ -676,9 +676,7 @@ py::class_, SkStreamMemory>(m, "MemoryStream") stream.setMemory(info.ptr, size, copyData); }, py::arg("data"), py::arg("copyData") = false) -/* - .def("asData", &SkMemoryStream::asData) -*/ + .def("asData", &SkMemoryStream::getData) .def("setData", &SkMemoryStream::setData, py::arg("data")) /* .def("skipToAlign4", &SkMemoryStream::skipToAlign4) From 96cdc65fd2a2c92663d7cd8ffeea659d0ede1d0e Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 29 Apr 2024 21:26:46 +0100 Subject: [PATCH 08/31] Skip test known to not work in m125 See: https://github.com/google/skia/commit/3844fc48802d20886e628b1d3111f7a31d3fba72 "Remove SkMemoryStream::skipToAlign4" This has been replaced with SkRBuffer::skipToAlign4 and doesn't appear to be used. It also violates the invariant that `fOffset` is always an offset into `fData`. --- tests/test_stream.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_stream.py b/tests/test_stream.py index 8f2f3b94..cf54dad8 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -273,6 +273,7 @@ def test_MemoryStream_setData(memory_stream): memory_stream.setData(data) +@pytest.mark.skip(reason='m125:REVISIT; Apparently replaced by SkRBuffer::skipToAlign4') def test_MemoryStream_skipToAlign4(memory_stream): memory_stream.skipToAlign4() From 543a6fc05aadceda5dc6d92c5fa9a0285b2b68c1 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Tue, 30 Apr 2024 01:09:08 +0100 Subject: [PATCH 09/31] Re-order dependency: libskunicode_icu depends on libskunicode_core --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 5d5fbde4..d1cacb18 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ EXTRA_OBJECTS = list( ) + [os.path.join(SKIA_OUT_PATH, 'svg.lib'), os.path.join(SKIA_OUT_PATH, 'skresources.lib'), os.path.join(SKIA_OUT_PATH, 'skia.lib'), os.path.join(SKIA_OUT_PATH, 'skshaper.lib'), - os.path.join(SKIA_OUT_PATH, 'unicode_core.lib'), os.path.join(SKIA_OUT_PATH, 'unicode_icu.lib')] + os.path.join(SKIA_OUT_PATH, 'skunicode_icu.lib'), os.path.join(SKIA_OUT_PATH, 'skunicode_core.lib')] EXTRA_COMPILE_ARGS = [ '/std:c++17', # c++20 fails. '/DVERSION_INFO=%s' % __version__, @@ -66,7 +66,7 @@ EXTRA_OBJECTS = list( ) + [os.path.join(SKIA_OUT_PATH, 'libsvg.a'), os.path.join(SKIA_OUT_PATH, 'libskia.a'), os.path.join(SKIA_OUT_PATH, 'libskshaper.a'), - os.path.join(SKIA_OUT_PATH, 'libskunicode_core.a'), os.path.join(SKIA_OUT_PATH, 'libskunicode_icu.a')] + os.path.join(SKIA_OUT_PATH, 'libskunicode_icu.a'), os.path.join(SKIA_OUT_PATH, 'libskunicode_core.a')] EXTRA_COMPILE_ARGS = [ '-std=c++17', '-stdlib=libc++', @@ -100,7 +100,7 @@ EXTRA_OBJECTS = list( ) + [os.path.join(SKIA_OUT_PATH, 'libsvg.a'), os.path.join(SKIA_OUT_PATH, 'libskresources.a'), os.path.join(SKIA_OUT_PATH, 'libskia.a'), os.path.join(SKIA_OUT_PATH, 'libskshaper.a'), - os.path.join(SKIA_OUT_PATH, 'libskunicode_core.a'), os.path.join(SKIA_OUT_PATH, 'libskunicode_icu.a')] + os.path.join(SKIA_OUT_PATH, 'libskunicode_icu.a'), os.path.join(SKIA_OUT_PATH, 'libskunicode_core.a')] EXTRA_COMPILE_ARGS = [ '-std=c++17', '-fvisibility=hidden', From c2b19f7f759ffc96f3cebafa70d054cb18d535c0 Mon Sep 17 00:00:00 2001 From: Pavel Panchekha Date: Mon, 29 Apr 2024 20:50:21 -0600 Subject: [PATCH 10/31] Fix fonts on macOS by using the right macro The macOS detector macro is called `__APPLE__`, not `__apple__` --- src/skia/Font.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/skia/Font.cpp b/src/skia/Font.cpp index 9b2b26cc..dcbb9a50 100644 --- a/src/skia/Font.cpp +++ b/src/skia/Font.cpp @@ -10,7 +10,7 @@ #include #endif -#ifdef __apple__ +#ifdef __APPLE__ #include "include/ports/SkFontMgr_mac_ct.h" #endif @@ -31,7 +31,7 @@ bool g_factory_called = false; } // namespace static sk_sp fontmgr_factory() { -#if defined(__apple__) +#if defined(__APPLE__) return SkFontMgr_New_CoreText(nullptr); #elif defined(__linux__) return SkFontMgr_New_FontConfig(nullptr); From fc534b60183a710ee2e98d0cf4fafadd3952b81c Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Tue, 30 Apr 2024 22:21:19 +0100 Subject: [PATCH 11/31] Remove one more stray "Sk" --- relnotes/README.m124.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relnotes/README.m124.md b/relnotes/README.m124.md index 419b6502..4d677e8b 100644 --- a/relnotes/README.m124.md +++ b/relnotes/README.m124.md @@ -2,7 +2,7 @@ New to m124: * The skia.SamplingOptions class has been fleshed out. - To migrate from m87 SkFilterQuality-based code: + To migrate from m87 FilterQuality-based code: FilterQuality.kHigh_FilterQuality -> SamplingOptions(CubicResampler.Mitchell()) FilterQuality.kMedium_FilterQuality -> SamplingOptions(FilterMode.kLinear, MipmapMode.kNearest) // cpu From f47749af0674b96d34d4d3b42acf4c6916740328 Mon Sep 17 00:00:00 2001 From: Pavel Panchekha Date: Mon, 29 Apr 2024 17:17:53 -0600 Subject: [PATCH 12/31] `git-sync-deps` seems to no longer require or support Python 2 --- docs/install.rst | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/install.rst b/docs/install.rst index 5cfd89b8..77059da6 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -116,22 +116,20 @@ macOS Prerequisites: -- Python 2.7 (build time only) - Xcode Command Line Tools -Set up ``PATH`` to the ``depot_tools``, and build skia library. At this point, -``python`` executable should be python 2. +Set up ``PATH`` to the ``depot_tools``, and build skia library. .. code-block:: bash export PATH="$PWD/depot_tools:$PATH" cd skia - python2 tools/git-sync-deps + python tools/git-sync-deps bin/gn gen out/Release --args='is_official_build=true skia_enable_tools=true skia_use_system_libjpeg_turbo=false skia_use_system_libwebp=false skia_use_system_libpng=false skia_use_system_icu=false skia_use_system_harfbuzz=false extra_cflags_cc=["-frtti"]' ninja -C out/Release skia skia.h cd .. -Then, build the skia python binding. At this point, ``python`` should be set to +Then, build the skia-python binding. Here, ``python`` should be set to the desired version. .. code-block:: bash From 714815b05d2e3a5a2424f6981fd4f189b498cd0f Mon Sep 17 00:00:00 2001 From: HinTak Date: Tue, 30 Apr 2024 11:01:19 +0100 Subject: [PATCH 13/31] Update install.rst Use python 3 for Windows and Linux, and requires c++17. --- docs/install.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/install.rst b/docs/install.rst index 77059da6..19c9ce26 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -69,7 +69,7 @@ Linux Prerequisites: -- Python 2.7 (build time only) +- Python 3 (build time only) - GLIBC >= 2.17 - fontconfig >= 2.10.93 - OpenGL @@ -89,14 +89,14 @@ or: Set up ``PATH`` to the ``depot_tools``. build skia library. At this point, -``python`` executable should be python 2. Note the build tools require -relatively new glibc and python 2.7. +``python`` executable should be python 3. Note the build tools require +relatively new glibc and python 3. .. code-block:: bash export PATH="$PWD/depot_tools:$PATH" cd skia - python2 tools/git-sync-deps + python tools/git-sync-deps bin/gn gen out/Release --args='is_official_build=true skia_enable_tools=true skia_use_system_libjpeg_turbo=false skia_use_system_libwebp=false skia_use_system_libpng=false skia_use_system_icu=false skia_use_system_harfbuzz=false extra_cflags_cc=["-frtti"] extra_ldflags=["-lrt"]' ninja -C out/Release skia skia.h cd .. @@ -124,7 +124,7 @@ Set up ``PATH`` to the ``depot_tools``, and build skia library. export PATH="$PWD/depot_tools:$PATH" cd skia - python tools/git-sync-deps + python3 tools/git-sync-deps bin/gn gen out/Release --args='is_official_build=true skia_enable_tools=true skia_use_system_libjpeg_turbo=false skia_use_system_libwebp=false skia_use_system_libpng=false skia_use_system_icu=false skia_use_system_harfbuzz=false extra_cflags_cc=["-frtti"]' ninja -C out/Release skia skia.h cd .. @@ -144,8 +144,8 @@ Windows Prerequisites: -- Python 2.7 (build time only) -- Visual C++ version that supports C++14 +- Python 3 (build time only) +- Visual C++ version that supports C++17 Windows binary can be built using the generic steps above. @@ -154,7 +154,7 @@ Windows binary can be built using the generic steps above. $env:Path += ";$pwd\depot_tools" cd skia - python2 tools\git-sync-deps + python tools\git-sync-deps bin\gn gen out\Release --args="is_official_build=true skia_enable_tools=true skia_use_system_libjpeg_turbo=false skia_use_system_libwebp=false skia_use_system_libpng=false skia_use_system_icu=false skia_use_system_harfbuzz=false skia_use_system_expat=false skia_use_system_zlib=false extra_cflags_cc=[\"/GR\", \"/EHsc\", \"/MD\"] target_cpu=\"x86_64\"" ninja -C out\Release skia skia.h cd .. From 2388f4bf79117cb04c6035642373281071961988 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Tue, 7 May 2024 15:54:24 +0100 Subject: [PATCH 14/31] Fixes CI warning about deprecated Node.js 16 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e93b6a6..b6c498d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -146,7 +146,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 name: Install Python with: python-version: '3.8' From 67e7d611a85606761d574878c254c13041957e48 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 13 May 2024 23:44:23 +0100 Subject: [PATCH 15/31] Enable METAL on Mac OS X build --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index d1cacb18..48684ecb 100644 --- a/setup.py +++ b/setup.py @@ -59,6 +59,7 @@ ('VERSION_INFO', __version__), ('SK_GL', ''), ('SK_GANESH', '1'), + ('SK_METAL', ''), ] LIBRARIES = [ 'dl', From 10a3b62b683fa9e18eaba89a2da5f3d7d58c2023 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Tue, 14 May 2024 01:15:20 +0100 Subject: [PATCH 16/31] Adding 9 blocks of SK_METAL, after their SK_VULKAN equivalents. Skipping 1: GrBackendSurfaceMutableState (support removed in m118) Fix previous mistakes in vulkan argument names Fix Linux/Windows build --- src/skia/GrContext.cpp | 74 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/src/skia/GrContext.cpp b/src/skia/GrContext.cpp index e56de43b..742fe580 100644 --- a/src/skia/GrContext.cpp +++ b/src/skia/GrContext.cpp @@ -11,6 +11,12 @@ #include #include #include +#ifdef SK_METAL +#include +#include +#include +#include +#endif #include #include #include @@ -257,7 +263,14 @@ py::class_(m, "GrBackendSemaphore") py::arg("semaphore")) */ #endif +#ifdef SK_METAL + .def_static("MakeMtl", + [] (GrMTLHandle event, uint64_t value) { + return GrBackendSemaphores::MakeMtl(event, value); + }, + py::arg("event"), py::arg("value")) // .def("initMetal", &GrBackendSemaphore::initMetal) +#endif .def("isInitialized", &GrBackendSemaphore::isInitialized) /* .def("glSync", @@ -271,8 +284,18 @@ py::class_(m, "GrBackendSemaphore") return reinterpret_cast(GrBackendSemaphores::GetVkSemaphore(semaphore)); }) #endif +#ifdef SK_METAL + .def("mtlSemaphore", + [] (GrBackendSemaphore& semaphore) { + return GrBackendSemaphores::GetMtlHandle(semaphore); + }) + .def("mtlValue", + [] (GrBackendSemaphore& semaphore) { + return GrBackendSemaphores::GetMtlValue(semaphore); + }) // .def("mtlSemaphore", &GrBackendSemaphore::mtlSemaphore) // .def("mtlValue", &GrBackendSemaphore::mtlValue) +#endif ; py::class_(m, "GrBackendFormat") @@ -287,6 +310,10 @@ py::class_(m, "GrBackendFormat") py::overload_cast( &GrBackendFormats::MakeVk), py::arg("ycbcrInfo"), py::arg("willUseDRMFormatModifiers") = false) +#endif +#ifdef SK_METAL + .def_static("MakeMtl", &GrBackendFormats::MakeMtl, + py::arg("format")) #endif .def_static("MakeMock", &GrBackendFormat::MakeMock, py::arg("colorType"), py::arg("compression"), py::arg("isStencilFormat") = false) @@ -302,6 +329,9 @@ py::class_(m, "GrBackendFormat") .def("asVkFormat", &GrBackendFormats::AsVkFormat, py::arg("format")) .def("getVkYcbcrConversionInfo", &GrBackendFormats::GetVkYcbcrConversionInfo) +#endif +#ifdef SK_METAL + .def("asMtlFormat", &GrBackendFormats::AsMtlFormat) #endif .def("asMockColorType", &GrBackendFormat::asMockColorType) .def("asMockCompressionType", &GrBackendFormat::asMockCompressionType) @@ -324,6 +354,13 @@ py::class_(m, "GrBackendTexture") return GrBackendTextures::MakeVk(width, height, vkInfo); }), py::arg("width"), py::arg("height"), py::arg("vkInfo")) +#endif +#ifdef SK_METAL + .def(py::init( + [] (int width, int height, skgpu::Mipmapped mipmapped, const GrMtlTextureInfo& mtlInfo, std::string_view label) { + return GrBackendTextures::MakeMtl(width, height, mipmapped, mtlInfo, label); + }), + py::arg("width"), py::arg("height"), py::arg("mipmapped"), py::arg("mtlInfo"), py::arg("label") = std::string_view{}) #endif .def(py::init(), py::arg("width"), py::arg("height"), py::arg("mipMapped"), @@ -343,6 +380,10 @@ py::class_(m, "GrBackendTexture") py::arg("info")) .def("setVkImageLayout", &GrBackendTextures::SetVkImageLayout, py::arg("layout")) +#endif +#ifdef SK_METAL + .def("getMtlTextureInfo", &GrBackendTextures::GetMtlTextureInfo, + py::arg("info")) #endif .def("getBackendFormat", &GrBackendTexture::getBackendFormat) .def("getMockTextureInfo", &GrBackendTexture::getMockTextureInfo, @@ -426,6 +467,13 @@ py::class_(m, "GrBackendRenderTarget") }), py::arg("width"), py::arg("height"), py::arg("sampleCnt"), py::arg("vkInfo")) +#endif +#ifdef SK_METAL + .def(py::init( + [] (int width, int height, const GrMtlTextureInfo& mtlInfo) { + return GrBackendRenderTargets::MakeMtl(width, height, mtlInfo); + }), + py::arg("width"), py::arg("height"), py::arg("mtlInfo")) #endif .def(py::init(), py::arg("width"), py::arg("height"), py::arg("sampleCnt"), @@ -460,6 +508,10 @@ py::class_(m, "GrBackendRenderTarget") of the changed layout. )docstring", py::arg("layout")) +#endif +#ifdef SK_METAL + .def("getMtlTextureInfo", &GrBackendRenderTargets::GetMtlTextureInfo, + py::arg("info")) #endif .def("getBackendFormat", &GrBackendRenderTarget::getBackendFormat, R"docstring( @@ -905,7 +957,7 @@ py::class_, GrRecordingContext>(m, "GrDi )docstring", py::arg("width"), py::arg("height"), py::arg("backendFormat"), py::arg("mipMapped"), py::arg("renderable"), - py::arg("isProtected") = GrProtected::kNo, py::arg("view") = std::string_view{}) + py::arg("isProtected") = GrProtected::kNo, py::arg("label") = std::string_view{}) .def("createBackendTexture", py::overload_cast(&GrDirectContext::createBackendTexture), @@ -919,7 +971,7 @@ py::class_, GrRecordingContext>(m, "GrDi )docstring", py::arg("width"), py::arg("height"), py::arg("colorType"), py::arg("mipMapped"), py::arg("renderable"), - py::arg("isProtected") = GrProtected::kNo, py::arg("view") = std::string_view{}) + py::arg("isProtected") = GrProtected::kNo, py::arg("label") = std::string_view{}) .def("createBackendTexture", [] (GrDirectContext& context, int width, int height, const GrBackendFormat& backendFormat, const SkColor4f& color, @@ -1199,6 +1251,24 @@ py::class_, GrRecordingContext>(m, "GrDi py::arg("backendContext")) #endif +#ifdef SK_METAL + .def_static("MakeMetal", + py::overload_cast( + &GrDirectContexts::MakeMetal), + R"docstring( + Makes a GrDirectContext which uses Metal as the backend. The GrMtlBackendContext contains a + MTLDevice and MTLCommandQueue which should be used by the backend. These objects must + have their own ref which will be released when the GrMtlBackendContext is destroyed. + Ganesh will take its own ref on the objects which will be released when the GrDirectContext + is destroyed. + )docstring", + py::arg("backendContext"), py::arg("options")) + .def_static("MakeMetal", + py::overload_cast( + &GrDirectContexts::MakeMetal), + py::arg("backendContext")) +#endif + .def_static("MakeMock", py::overload_cast( &GrDirectContext::MakeMock), From 2c96aee597536b0949203739668084dee5caddbf Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Tue, 14 May 2024 02:06:20 +0100 Subject: [PATCH 17/31] Re-enable GrContext_Base::defaultBackendFormat and GrContext_Base::compressedBackendFormat Between m87 and m116, the header for these two has moved from include/private/GrContext_Base.h to include/private/gpu/ganesh/GrContext_Base.h but otherwise more or less identical, so it should have just worked (baring missing header at some point in the past). --- src/skia/GrContext.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/skia/GrContext.cpp b/src/skia/GrContext.cpp index 742fe580..4f116518 100644 --- a/src/skia/GrContext.cpp +++ b/src/skia/GrContext.cpp @@ -540,7 +540,6 @@ py::class_, SkRefCnt>(m, "GrContext_Base") R"docstring( The 3D API backing this context. )docstring") -/* .def("defaultBackendFormat", &GrContext_Base::defaultBackendFormat, R"docstring( Retrieve the default :py:class:`GrBackendFormat` for a given @@ -552,7 +551,6 @@ py::class_, SkRefCnt>(m, "GrContext_Base") The caller should check that the returned format is valid. )docstring") .def("compressedBackendFormat", &GrContext_Base::compressedBackendFormat) -*/ .def("threadSafeProxy", &GrContext_Base::threadSafeProxy) // .def("priv", py::overload_cast<>(&GrContext_Base::priv)) // .def("priv", py::overload_cast<>(&GrContext_Base::priv, py::const_)) From 95ad3061279e447bafefa7c802c80de36f9dc12f Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Tue, 14 May 2024 08:56:02 +0100 Subject: [PATCH 18/31] Header not needed --- src/skia/GrContext.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/skia/GrContext.cpp b/src/skia/GrContext.cpp index 4f116518..b032d775 100644 --- a/src/skia/GrContext.cpp +++ b/src/skia/GrContext.cpp @@ -17,7 +17,6 @@ #include #include #endif -#include #include #include #include From 1cf1c10a943d952dd93689dab379f3b89c3fc912 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Tue, 14 May 2024 23:31:23 +0100 Subject: [PATCH 19/31] Interestingly, skia_use_metal=true is only in some IOS usage, not the default --- scripts/build_macOS.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build_macOS.sh b/scripts/build_macOS.sh index 48b98dae..a5b9af75 100644 --- a/scripts/build_macOS.sh +++ b/scripts/build_macOS.sh @@ -35,6 +35,7 @@ skia_use_system_libjpeg_turbo=false skia_use_system_libwebp=false skia_use_system_libpng=false skia_use_system_icu=false +skia_use_metal=true skia_use_system_harfbuzz=false skia_use_system_expat=false extra_cflags_cc=[\"-frtti\"] From b8e92207b532aabce3460ae09b182fe1c181ec5f Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Thu, 16 May 2024 01:57:45 +0100 Subject: [PATCH 20/31] Remove python 3.7 builds from CI --- .github/workflows/ci.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6c498d3..09b58054 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,15 +74,12 @@ jobs: matrix: os: [ubuntu-22.04, windows-2022, macos-12] arch: [auto64] - cp: ["cp3{7,8,9,10,11,12}"] + cp: ["cp3{8,9,10,11,12}"] include: - os: macos-12 arch: arm64 - cp: "cp3{7,8,9,10,11,12}" + cp: "cp3{8,9,10,11,12}" # aarch64 is emulated and takes longer, build one wheel per job - - os: ubuntu-22.04 - arch: aarch64 - cp: cp37 - os: ubuntu-22.04 arch: aarch64 cp: cp38 From 107b9836a3430ae6f086c2e1de52059da4d902d6 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Thu, 16 May 2024 16:02:02 +0100 Subject: [PATCH 21/31] Update Readme on supported python versions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7f240309..92b40ac0 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Binary package is available on PyPI: pip install skia-python ``` -Supported platforms: Python 3.7-3.12 (CPython) on +Supported platforms: Python 3.8-3.12 (CPython) on - Linux x86_64, aarch64 - macOS x86_64, arm64 From 8f340da588350f4ba831ef79874dcd05462bab8f Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sat, 18 May 2024 23:27:09 +0100 Subject: [PATCH 22/31] m126: SkCanvas::drawArc now needs py::overload_cast due to new overloaded alternative Signed-off-by: Hin-Tak Leung --- src/skia/Canvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/skia/Canvas.cpp b/src/skia/Canvas.cpp index ec17cb3e..be6256b1 100644 --- a/src/skia/Canvas.cpp +++ b/src/skia/Canvas.cpp @@ -1586,7 +1586,7 @@ canvas to draw )docstring", py::arg("center"), py::arg("radius"), py::arg("paint")) - .def("drawArc", &SkCanvas::drawArc, + .def("drawArc", py::overload_cast(&SkCanvas::drawArc), R"docstring( Draws arc using clip, :py:class:`Matrix`, and :py:class:`Paint` paint. From 1f9fa306196e02b7ea9c5de39edf2e3326e1ee43 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 20 May 2024 00:07:17 +0100 Subject: [PATCH 23/31] Roll skia forward to m126 (canvaskit/0.38.2-4873-g9097d768e8) from m125 (canvaskit/0.38.2-4468-gec3813eabd) --- skia | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skia b/skia index ec3813ea..9097d768 160000 --- a/skia +++ b/skia @@ -1 +1 @@ -Subproject commit ec3813eabd24854a1b82457064e9e3031ccc06d7 +Subproject commit 9097d768e80c83cd38697be2f194aff4d1f7e488 From e9f30c825df62d7b1e92a8030dd1d5f5ce8a6c67 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 20 May 2024 00:28:49 +0100 Subject: [PATCH 24/31] m125: Emulate the removed SkMemoryStream::skipToAlign4 Copied and adapted from: https://github.com/google/skia/commit/3844fc48802d20886e628b1d3111f7a31d3fba72 --- src/skia/Stream.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/skia/Stream.cpp b/src/skia/Stream.cpp index d9a4e62a..3d398e2f 100644 --- a/src/skia/Stream.cpp +++ b/src/skia/Stream.cpp @@ -678,9 +678,12 @@ py::class_, SkStreamMemory>(m, "MemoryStream") py::arg("data"), py::arg("copyData") = false) .def("asData", &SkMemoryStream::getData) .def("setData", &SkMemoryStream::setData, py::arg("data")) -/* - .def("skipToAlign4", &SkMemoryStream::skipToAlign4) -*/ + .def("skipToAlign4", + [] (SkMemoryStream& stream) { + // cast to remove unary-minus warning + stream.fOffset += -(int)stream.fOffset & 0x03; + } + ) .def("getAtPos", &SkMemoryStream::getAtPos) ; From 6bc7b6bc5f400411826615e63981be630c755c22 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 20 May 2024 00:53:14 +0100 Subject: [PATCH 25/31] stream.fOffset is private; use stream.getPosition() and stream.seek() to get and set. --- src/skia/Stream.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/skia/Stream.cpp b/src/skia/Stream.cpp index 3d398e2f..065113c6 100644 --- a/src/skia/Stream.cpp +++ b/src/skia/Stream.cpp @@ -680,8 +680,10 @@ py::class_, SkStreamMemory>(m, "MemoryStream") .def("setData", &SkMemoryStream::setData, py::arg("data")) .def("skipToAlign4", [] (SkMemoryStream& stream) { + size_t fOffset = stream.getPosition(); // cast to remove unary-minus warning - stream.fOffset += -(int)stream.fOffset & 0x03; + fOffset += -(int)fOffset & 0x03; + stream.seek(fOffset); } ) .def("getAtPos", &SkMemoryStream::getAtPos) From 332029d9e12cdf19bc9ff35aeaf77f87a9f4a433 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 20 May 2024 00:54:30 +0100 Subject: [PATCH 26/31] Re-enable test for memory_stream.skipToAlign4(), now emulated --- tests/test_stream.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_stream.py b/tests/test_stream.py index cf54dad8..8f2f3b94 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -273,7 +273,6 @@ def test_MemoryStream_setData(memory_stream): memory_stream.setData(data) -@pytest.mark.skip(reason='m125:REVISIT; Apparently replaced by SkRBuffer::skipToAlign4') def test_MemoryStream_skipToAlign4(memory_stream): memory_stream.skipToAlign4() From aa6a700d9b0a543a30bba259476494b8f43b5e6e Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 20 May 2024 01:51:56 +0100 Subject: [PATCH 27/31] m126 patches plus adjustments --- .github/workflows/ci.yml | 2 +- patch/skia-m126-minimize-download.patch | 69 +++++++++++++++++++++++++ scripts/build_Linux.sh | 2 +- scripts/build_Windows.sh | 2 +- scripts/build_macOS.sh | 2 +- 5 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 patch/skia-m126-minimize-download.patch diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09b58054..8e284f9d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: skia key: linux-aarch64-skia-${{ github.sha }}-3rd-party - name: Pre-fetch skia deps - run: git config --global core.compression 0 && cd skia && patch -p1 -i ../patch/skia-m125-minimize-download.patch && python tools/git-sync-deps && patch -p1 -R -i ../patch/skia-m125-minimize-download.patch + run: git config --global core.compression 0 && cd skia && patch -p1 -i ../patch/skia-m126-minimize-download.patch && python tools/git-sync-deps && patch -p1 -R -i ../patch/skia-m126-minimize-download.patch - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Build skia 3rd-Party diff --git a/patch/skia-m126-minimize-download.patch b/patch/skia-m126-minimize-download.patch new file mode 100644 index 00000000..bbf62917 --- /dev/null +++ b/patch/skia-m126-minimize-download.patch @@ -0,0 +1,69 @@ +diff --git a/DEPS b/DEPS +index 928cdfc..a4ffe00 100644 +--- a/DEPS ++++ b/DEPS +@@ -23,52 +23,18 @@ vars = { + # ./tools/git-sync-deps + deps = { + "buildtools" : "https://chromium.googlesource.com/chromium/src/buildtools.git@b138e6ce86ae843c42a1a08f37903207bebcca75", +- "third_party/externals/angle2" : "https://chromium.googlesource.com/angle/angle.git@66bc9cfa00143312cc7545556041622a92745a91", +- "third_party/externals/brotli" : "https://skia.googlesource.com/external/github.com/google/brotli.git@6d03dfbedda1615c4cba1211f8d81735575209c8", +- "third_party/externals/d3d12allocator" : "https://skia.googlesource.com/external/github.com/GPUOpen-LibrariesAndSDKs/D3D12MemoryAllocator.git@169895d529dfce00390a20e69c2f516066fe7a3b", +- # Dawn requires jinja2 and markupsafe for the code generator, tint for SPIRV compilation, and abseil for string formatting. +- # When the Dawn revision is updated these should be updated from the Dawn DEPS as well. +- "third_party/externals/dawn" : "https://dawn.googlesource.com/dawn.git@1b2d3eb175fdf83e21e21b6167a34225a03d2bc2", +- "third_party/externals/jinja2" : "https://chromium.googlesource.com/chromium/src/third_party/jinja2@e2d024354e11cc6b041b0cff032d73f0c7e43a07", +- "third_party/externals/markupsafe" : "https://chromium.googlesource.com/chromium/src/third_party/markupsafe@0bad08bb207bbfc1d6f3bbc82b9242b0c50e5794", +- "third_party/externals/abseil-cpp" : "https://skia.googlesource.com/external/github.com/abseil/abseil-cpp.git@334aca32051ef6ede2711487acf45d959e9bdffc", + "third_party/externals/dng_sdk" : "https://android.googlesource.com/platform/external/dng_sdk.git@c8d0c9b1d16bfda56f15165d39e0ffa360a11123", +- "third_party/externals/egl-registry" : "https://skia.googlesource.com/external/github.com/KhronosGroup/EGL-Registry@b055c9b483e70ecd57b3cf7204db21f5a06f9ffe", +- "third_party/externals/emsdk" : "https://skia.googlesource.com/external/github.com/emscripten-core/emsdk.git@a896e3d066448b3530dbcaa48869fafefd738f57", + "third_party/externals/expat" : "https://chromium.googlesource.com/external/github.com/libexpat/libexpat.git@441f98d02deafd9b090aea568282b28f66a50e36", + "third_party/externals/freetype" : "https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@a46424228f0998a72c715f32e18dca8a7a764c1f", + "third_party/externals/harfbuzz" : "https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@b74a7ecc93e283d059df51ee4f46961a782bcdb8", +- "third_party/externals/highway" : "https://chromium.googlesource.com/external/github.com/google/highway.git@424360251cdcfc314cfc528f53c872ecd63af0f0", + "third_party/externals/icu" : "https://chromium.googlesource.com/chromium/deps/icu.git@364118a1d9da24bb5b770ac3d762ac144d6da5a4", +- "third_party/externals/icu4x" : "https://chromium.googlesource.com/external/github.com/unicode-org/icu4x.git@bcf4f7198d4dc5f3127e84a6ca657c88e7d07a13", +- "third_party/externals/imgui" : "https://skia.googlesource.com/external/github.com/ocornut/imgui.git@55d35d8387c15bf0cfd71861df67af8cfbda7456", +- "third_party/externals/libavif" : "https://skia.googlesource.com/external/github.com/AOMediaCodec/libavif.git@55aab4ac0607ab651055d354d64c4615cf3d8000", +- "third_party/externals/libgav1" : "https://chromium.googlesource.com/codecs/libgav1.git@5cf722e659014ebaf2f573a6dd935116d36eadf1", +- "third_party/externals/libgrapheme" : "https://skia.googlesource.com/external/github.com/FRIGN/libgrapheme/@c0cab63c5300fa12284194fbef57aa2ed62a94c0", + "third_party/externals/libjpeg-turbo" : "https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@ed683925e4897a84b3bffc5c1414c85b97a129a3", +- "third_party/externals/libjxl" : "https://chromium.googlesource.com/external/gitlab.com/wg1/jpeg-xl.git@a205468bc5d3a353fb15dae2398a101dff52f2d3", + "third_party/externals/libpng" : "https://skia.googlesource.com/third_party/libpng.git@ed217e3e601d8e462f7fd1e04bed43ac42212429", + "third_party/externals/libwebp" : "https://chromium.googlesource.com/webm/libwebp.git@845d5476a866141ba35ac133f856fa62f0b7445f", +- "third_party/externals/libyuv" : "https://chromium.googlesource.com/libyuv/libyuv.git@d248929c059ff7629a85333699717d7a677d8d96", +- "third_party/externals/microhttpd" : "https://android.googlesource.com/platform/external/libmicrohttpd@748945ec6f1c67b7efc934ab0808e1d32f2fb98d", +- "third_party/externals/oboe" : "https://chromium.googlesource.com/external/github.com/google/oboe.git@b02a12d1dd821118763debec6b83d00a8a0ee419", +- "third_party/externals/opengl-registry" : "https://skia.googlesource.com/external/github.com/KhronosGroup/OpenGL-Registry@14b80ebeab022b2c78f84a573f01028c96075553", +- "third_party/externals/perfetto" : "https://android.googlesource.com/platform/external/perfetto@93885509be1c9240bc55fa515ceb34811e54a394", + "third_party/externals/piex" : "https://android.googlesource.com/platform/external/piex.git@bb217acdca1cc0c16b704669dd6f91a1b509c406", +- "third_party/externals/swiftshader" : "https://swiftshader.googlesource.com/SwiftShader@da334852e70510d259bfa8cbaa7c5412966b2f41", + "third_party/externals/vulkanmemoryallocator" : "https://chromium.googlesource.com/external/github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator@a6bfc237255a6bac1513f7c1ebde6d8aed6b5191", +- # vulkan-deps is a meta-repo containing several interdependent Khronos Vulkan repositories. +- # When the vulkan-deps revision is updated, those repos (spirv-*, vulkan-*) should be updated as well. + "third_party/externals/vulkan-deps" : "https://chromium.googlesource.com/vulkan-deps@f1dcf238ad742f936794809f28b0ad0511b6585b", +- "third_party/externals/spirv-cross" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/SPIRV-Cross@b8fcf307f1f347089e3c46eb4451d27f32ebc8d3", + "third_party/externals/spirv-headers" : "https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Headers.git@49a1fceb9b1d087f3c25ad5ec077bb0e46231297", +- "third_party/externals/spirv-tools" : "https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Tools.git@199038f10cbe56bf7cbfeb5472eb0a25af2f09f5", +- "third_party/externals/vello" : "https://skia.googlesource.com/external/github.com/linebender/vello.git@6938a2893d6a2ba658709d1d04720f6c6033700f", +- "third_party/externals/vulkan-headers" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Headers@5677bafb820e476441e9e1f745371b72133407d3", +- "third_party/externals/vulkan-tools" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Tools@df8e710224f563a04b7db2680f72d31619c4b259", +- "third_party/externals/vulkan-utility-libraries": "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Utility-Libraries@358a107a6ff284906dcccbabe5b0183c03fd85b6", +- "third_party/externals/unicodetools" : "https://chromium.googlesource.com/external/github.com/unicode-org/unicodetools@66a3fa9dbdca3b67053a483d130564eabc5fe095", +- #"third_party/externals/v8" : "https://chromium.googlesource.com/v8/v8.git@5f1ae66d5634e43563b2d25ea652dfb94c31a3b4", + "third_party/externals/wuffs" : "https://skia.googlesource.com/external/github.com/google/wuffs-mirror-release-c.git@e3f919ccfe3ef542cfc983a82146070258fb57f8", + "third_party/externals/zlib" : "https://chromium.googlesource.com/chromium/src/third_party/zlib@646b7f569718921d7d4b5b8e22572ff6c76f2596", + +diff --git a/bin/activate-emsdk b/bin/activate-emsdk +index 687ca9f..7167d8d 100755 +--- a/bin/activate-emsdk ++++ b/bin/activate-emsdk +@@ -17,6 +17,7 @@ EMSDK_PATH = os.path.join(EMSDK_ROOT, 'emsdk.py') + EMSDK_VERSION = '3.1.44' + + def main(): ++ return + if sysconfig.get_platform() in ['linux-aarch64', 'linux-arm64']: + # This platform cannot install emsdk at the provided version. See + # https://github.com/emscripten-core/emsdk/blob/main/emscripten-releases-tags.json#L5 diff --git a/scripts/build_Linux.sh b/scripts/build_Linux.sh index 0b621a4b..96b406a3 100644 --- a/scripts/build_Linux.sh +++ b/scripts/build_Linux.sh @@ -60,7 +60,7 @@ git clone https://gn.googlesource.com/gn && \ # Build skia cd skia && \ - patch -p1 < ../patch/skia-m125-minimize-download.patch && \ + patch -p1 < ../patch/skia-m126-minimize-download.patch && \ patch -p1 < ../patch/skia-m123-colrv1-freetype.diff && \ python3 tools/git-sync-deps && \ cp -f ../gn/out/gn bin/gn && \ diff --git a/scripts/build_Windows.sh b/scripts/build_Windows.sh index a8ac5281..7531b997 100644 --- a/scripts/build_Windows.sh +++ b/scripts/build_Windows.sh @@ -4,7 +4,7 @@ export PATH="${PWD}/depot_tools:$PATH" # Build skia cd skia && \ - patch -p1 < ../patch/skia-m125-minimize-download.patch && \ + patch -p1 < ../patch/skia-m126-minimize-download.patch && \ patch -p1 < ../patch/skia-m123-colrv1-freetype.diff && \ python tools/git-sync-deps && \ bin/gn gen out/Release --args=' diff --git a/scripts/build_macOS.sh b/scripts/build_macOS.sh index a5b9af75..8ac6077a 100644 --- a/scripts/build_macOS.sh +++ b/scripts/build_macOS.sh @@ -22,7 +22,7 @@ function apply_patch { } cd skia && \ - patch -p1 < ../patch/skia-m125-minimize-download.patch && \ + patch -p1 < ../patch/skia-m126-minimize-download.patch && \ patch -p1 < ../patch/skia-m123-colrv1-freetype.diff && \ python3 tools/git-sync-deps && \ bin/gn gen out/Release --args=" From 28b5b8b8ae332f373d8cc9c481bd6b70a0d00956 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 20 May 2024 02:28:45 +0100 Subject: [PATCH 28/31] Comment about overloaded SkCanvas::drawArc --- src/skia/Canvas.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/skia/Canvas.cpp b/src/skia/Canvas.cpp index be6256b1..7c1c2f16 100644 --- a/src/skia/Canvas.cpp +++ b/src/skia/Canvas.cpp @@ -1613,6 +1613,7 @@ canvas )docstring", py::arg("oval"), py::arg("startAngle"), py::arg("sweepAngle"), py::arg("useCenter"), py::arg("paint")) + // New in m126: drawArc(const SkArc& arc, const SkPaint& paint) .def("drawRoundRect", &SkCanvas::drawRoundRect, R"docstring( Draws :py:class:`RRect` bounded by :py:class:`Rect` rect, with corner From 3324bb7cc182a02d6e4cab7e0b3f8ddb0d6a85a6 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 20 May 2024 02:30:18 +0100 Subject: [PATCH 29/31] README.m125 and README.m126 --- relnotes/README.m125.md | 16 ++++++++++++++++ relnotes/README.m126.md | 2 ++ 2 files changed, 18 insertions(+) create mode 100644 relnotes/README.m125.md create mode 100644 relnotes/README.m126.md diff --git a/relnotes/README.m125.md b/relnotes/README.m125.md new file mode 100644 index 00000000..9b139db2 --- /dev/null +++ b/relnotes/README.m125.md @@ -0,0 +1,16 @@ +New to m125: + +* Metal-enabled on Mac OS, and added Metal APIs equivalents to Vulkan's. + + +Changes since m124: + +* Dropping Python 3.7 support + +* GrContext_Base.defaultBackendFormat and GrContext_Base.compressedBackendFormat + re-enabled (disabled between m87 and m116) + +* Corrected two typos in Vulkan code + +* MemoryStream.asData and MemoryStream.skipToAlign4 now emulated + (changed/removed upstream) \ No newline at end of file diff --git a/relnotes/README.m126.md b/relnotes/README.m126.md new file mode 100644 index 00000000..b89b13ef --- /dev/null +++ b/relnotes/README.m126.md @@ -0,0 +1,2 @@ +No user-visible change between m125 and m126 +(SkCanvas::drawArc overloaded; Not adding SkArc class yet) \ No newline at end of file From f60cf1772c4ce476ec4c90d8ac3b6d52dd917b6a Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 20 May 2024 02:31:36 +0100 Subject: [PATCH 30/31] Bump version up to 126.0b8 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 48684ecb..d6c6eff9 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ pass NAME = 'skia-python' -__version__ = '125.0b7' +__version__ = '126.0b8' SKIA_PATH = os.getenv('SKIA_PATH', 'skia') SKIA_OUT_PATH = os.getenv( From 1e4d2c137c85091007b0ca777d42cb3519ebd3b6 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 20 May 2024 02:37:51 +0100 Subject: [PATCH 31/31] Reference README.m125 and README.m126 in top-level README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 92b40ac0..e2a9a918 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,8 @@ https://kyamagu.github.io/skia-python - For information about changes after `m116`, and tips on migration from `m87`: [README.m116](relnotes/README.m116.md), [README.m117](relnotes/README.m117.md), [README.m118](relnotes/README.m118.md), [README.m119](relnotes/README.m119.md), [README.m120](relnotes/README.m120.md), [README.m121](relnotes/README.m121.md), [README.m122](relnotes/README.m122.md), - [README.m123](relnotes/README.m123.md), [README.m124](relnotes/README.m124.md). + [README.m123](relnotes/README.m123.md), [README.m124](relnotes/README.m124.md), [README.m125](relnotes/README.m125.md), + [README.m126](relnotes/README.m126.md). ## Contributing