diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89c2e7e4..0724a384 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,7 @@ jobs: CIBW_TEST_SKIP: "*-macosx_arm64" - uses: actions/upload-artifact@v4 + if: always() with: name: wheel-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.cp }} path: ./wheelhouse/*.whl @@ -103,6 +104,7 @@ jobs: CIBW_TEST_SKIP: "*-macosx_arm64" - uses: actions/upload-artifact@v4 + if: always() with: name: wheel-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.cp }} path: ./wheelhouse/*.whl @@ -127,6 +129,7 @@ jobs: - name: Build docs run: | # installing libegl1 will also install libegl-mesa0 + sudo apt-get -y update sudo apt-get -y install libegl1 python -m pip install --pre -f dist skia-python python -m pip install sphinx sphinx-rtd-theme @@ -174,6 +177,10 @@ jobs: submodules: recursive - run: bash scripts/build_Linux.sh - run: python -m build --wheel + - uses: actions/upload-artifact@v4 + with: + name: wheel-fedora-42 + path: ./dist/*.whl - run: python -m pip install dist/*.whl - run: python -m pip install moderngl - run: python -c 'import moderngl; moderngl_context = moderngl.create_standalone_context(backend="egl"); import skia; interface = skia.GrGLInterface.MakeEGL() ; assert isinstance(skia.GrDirectContext.MakeGL(interface), skia.GrContext) ; print("Success3")' diff --git a/patch/0001-gn-Remove-msvc-env-setting.patch b/patch/0001-gn-Remove-msvc-env-setting.patch deleted file mode 100644 index fc47345d..00000000 --- a/patch/0001-gn-Remove-msvc-env-setting.patch +++ /dev/null @@ -1,146 +0,0 @@ -From c6f2286a2795e36ff7b22b2c1030b2196d76e70e Mon Sep 17 00:00:00 2001 -From: Ben Wagner -Date: Tue, 27 May 2025 16:32:19 -0400 -Subject: [PATCH] [gn] Remove msvc env setting - -SetEnv.cmd has long been removed but kept alive by Skia packaging of -MSVC. Older MSVC compilers and Windows SDKs relied on a large number of -environment variables to be set when cross compiling, but this should no -longer be necessary. - -In addition, the MSVC ARM toolchains are now complete and no longer -require the host toolchain to be on the path. - -These improvements mean that it is no longer necessary to use `cmd.exe -/c` as a "compiler wrapper" to set up the environment. Because it is not -generally possible to properly escape such command lines this has caused -issues with any arguments which would require proper escaping such as -paths with spaces and special characters. - -This change drops support for building Skia for x86 or ARM64 with MSVC -from before VS2022, with the benefit of building for x86 or ARM64 -without extemely odd, undocumented, and limiting restrictions. - -Also add support for detecting MSVC 2022 before looking for 2019 or -2017. - -Bug: 420271794, 376381591 -Change-Id: I8591636aec31095b13db6dc1a376abfa23199ebd -Reviewed-on: https://skia-review.googlesource.com/c/skia/+/999356 -Reviewed-by: Kaylee Lubick ---- - gn/find_msvc.py | 17 ++++++++++------- - gn/toolchain/BUILD.gn | 24 ++++++++---------------- - 2 files changed, 18 insertions(+), 23 deletions(-) - -diff --git a/gn/find_msvc.py b/gn/find_msvc.py -index 108d576139..281a738900 100755 ---- a/gn/find_msvc.py -+++ b/gn/find_msvc.py -@@ -10,16 +10,19 @@ import subprocess - ''' - Look for the first match in the format - C:\\Program Files (x86)\\Microsoft Visual Studio\\${RELEASE}\\${VERSION}\\VC -+ C:\\Program Files\\Microsoft Visual Studio\\${RELEASE}\\${VERSION}\\VC -+If not found, use vswhere.exe. - ''' - def find_msvc(): - if sys.platform.startswith('win'): -- default_dir = r'C:\Program Files (x86)\Microsoft Visual Studio' -- for release in ['2019', '2017']: -- for version in ['Enterprise', 'Professional', 'Community', 'BuildTools', 'Preview']: -- path = os.path.join(default_dir, release, version, 'VC') -- if os.path.isdir(path): -- return path -- -+ default_dirs = [r'C:\Program Files\Microsoft Visual Studio', -+ r'C:\Program Files (x86)\Microsoft Visual Studio'] -+ for default_dir in default_dirs: -+ for release in ['2022', '2019', '2017']: -+ for version in ['Enterprise', 'Professional', 'Community', 'BuildTools', 'Preview']: -+ path = os.path.join(default_dir, release, version, 'VC') -+ if os.path.isdir(path): -+ return path - # Fall back to vswhere.exe to determine non-standard installation paths - # Fixed location, https://github.com/Microsoft/vswhere/wiki/Installing - vswhere = os.path.join(os.getenv('ProgramFiles(x86)'), -diff --git a/gn/toolchain/BUILD.gn b/gn/toolchain/BUILD.gn -index 4d4abc952f..85858b5a01 100644 ---- a/gn/toolchain/BUILD.gn -+++ b/gn/toolchain/BUILD.gn -@@ -87,16 +87,6 @@ template("msvc_toolchain") { - - bin = "$win_vc/Tools/MSVC/$win_toolchain_version/bin/HostX64/$toolchain_target_cpu" - -- env_setup = "" -- if (toolchain_target_cpu == "x86") { -- # Toolchain asset includes a script that configures for x86 building. -- # We don't support x86 builds with local MSVC installations. -- env_setup = "$shell $win_sdk/bin/SetEnv.cmd /x86 && " -- } else if (toolchain_target_cpu == "arm64") { -- # ARM64 compiler is incomplete - it relies on DLLs located in the host toolchain directory. -- env_setup = "$shell set \"PATH=%PATH%;$win_vc\\Tools\\MSVC\\$win_toolchain_version\\bin\\HostX64\\x64\" && " -- } -- - cl_m32_flag = "" - - if (clang_win != "") { -@@ -126,7 +116,8 @@ template("msvc_toolchain") { - if (toolchain_target_cpu == "x64") { - _ml += "64" - } -- command = "$env_setup \"$bin/$_ml.exe\" {{asmflags}} /nologo /c /Fo {{output}} {{source}}" -+ command = -+ "\"$bin/$_ml.exe\" {{asmflags}} /nologo /c /Fo {{output}} {{source}}" - outputs = [ - "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", - ] -@@ -138,7 +129,7 @@ template("msvc_toolchain") { - pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb" - - # Label names may have spaces so pdbname must be quoted. -- command = "$env_setup $cc_wrapper $cl /nologo /showIncludes /FC {{defines}} {{include_dirs}} {{cflags}} $cl_m32_flag {{cflags_c}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" -+ command = "$cc_wrapper $cl /nologo /showIncludes /FC {{defines}} {{include_dirs}} {{cflags}} $cl_m32_flag {{cflags_c}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" - depsformat = "msvc" - outputs = [ - "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", -@@ -151,7 +142,7 @@ template("msvc_toolchain") { - pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb" - - # Label names may have spaces so pdbname must be quoted. -- command = "$env_setup $cc_wrapper $cl /nologo /showIncludes /FC {{defines}} {{include_dirs}} {{cflags}} $cl_m32_flag {{cflags_cc}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" -+ command = "$cc_wrapper $cl /nologo /showIncludes /FC {{defines}} {{include_dirs}} {{cflags}} $cl_m32_flag {{cflags_cc}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" - depsformat = "msvc" - outputs = [ - "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", -@@ -162,7 +153,8 @@ template("msvc_toolchain") { - tool("alink") { - rspfile = "{{output}}.rsp" - -- command = "$env_setup $lib /nologo /ignore:4221 {{arflags}} /OUT:{{output}} @$rspfile" -+ command = -+ "$lib /nologo /ignore:4221 {{arflags}} /OUT:{{output}} @$rspfile" - outputs = [ - # Ignore {{output_extension}} and always use .lib, there's no reason to - # allow targets to override this extension on Windows. -@@ -185,7 +177,7 @@ template("msvc_toolchain") { - pdbname = "${dllname}.pdb" - rspfile = "${dllname}.rsp" - -- command = "$env_setup $link /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:$pdbname @$rspfile" -+ command = "$link /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:$pdbname @$rspfile" - outputs = [ - dllname, - libname, -@@ -217,7 +209,7 @@ template("msvc_toolchain") { - pdbname = "$exename.pdb" - rspfile = "$exename.rsp" - -- command = "$env_setup $link /nologo /OUT:$exename /PDB:$pdbname @$rspfile" -+ command = "$link /nologo /OUT:$exename /PDB:$pdbname @$rspfile" - default_output_extension = ".exe" - default_output_dir = "{{root_out_dir}}" - outputs = [ exename ] --- -2.49.0 - diff --git a/patch/fetch-gn-windows-arm64.diff b/patch/fetch-gn-windows-arm64.diff new file mode 100644 index 00000000..bee01d3c --- /dev/null +++ b/patch/fetch-gn-windows-arm64.diff @@ -0,0 +1,11 @@ +--- a/bin/fetch-gn.orig 2025-08-11 19:21:42.666070053 +0100 ++++ b/bin/fetch-gn 2025-08-11 19:23:01.381159842 +0100 +@@ -20,7 +20,7 @@ + gnzip = os.path.join(tempfile.mkdtemp(), 'gn.zip') + with open(gnzip, 'wb') as f: + OS = {'darwin': 'mac', 'linux': 'linux', 'linux2': 'linux', 'win32': 'windows'}[sys.platform] +- cpu = {'aarch64': 'arm64', 'amd64': 'amd64', 'arm64': 'arm64', 'x86_64': 'amd64'}[platform.machine().lower()] ++ cpu = {'aarch64': 'arm64', 'amd64': 'amd64', 'arm64': 'amd64', 'x86_64': 'amd64'}[platform.machine().lower()] + + rev = 'b2afae122eeb6ce09c52d63f67dc53fc517dbdc8' + url = 'https://chrome-infra-packages.appspot.com/dl/gn/gn/{}-{}/+/git_revision:{}'.format( diff --git a/patch/skia-m139-minimize-download.patch b/patch/skia-m139-minimize-download.patch new file mode 100644 index 00000000..0ac82872 --- /dev/null +++ b/patch/skia-m139-minimize-download.patch @@ -0,0 +1,70 @@ +diff --git a/DEPS b/DEPS +index 6b685a0..c2f3e74 100644 +--- a/DEPS ++++ b/DEPS +@@ -31,53 +31,18 @@ vars = { + # ./tools/git-sync-deps + deps = { + "buildtools" : "https://chromium.googlesource.com/chromium/src/buildtools.git@729495f2ffa69080907780591fa2a630b2556e98", +- "third_party/externals/angle2" : "https://chromium.googlesource.com/angle/angle.git@5220e634850ec26f4b4b0f305ba2a69cf0bc55df", +- "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@d03fe7eda12dfce1578bf69da2814f89fd78c1e9", +- "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://chromium.googlesource.com/chromium/src/third_party/abseil-cpp@04dc59d2c83238cb1fcb49083e5e416643a899ce", +- "third_party/externals/delaunator-cpp" : "https://skia.googlesource.com/external/github.com/skia-dev/delaunator-cpp.git@98305ef6c4e862f7d48df9cc647b690d796fec68", + "third_party/externals/dng_sdk" : "https://android.googlesource.com/platform/external/dng_sdk.git@dbe0a676450d9b8c71bf00688bb306409b779e90", +- "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@8e49998f003d693213b538ef765814c7d21abada", + "third_party/externals/freetype" : "https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@1518bc83d26b434031bd12c706ac3c7dab3902fd", + "third_party/externals/harfbuzz" : "https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@08b52ae2e44931eef163dbad71697f911fadc323", +- "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@e14cbfaa85529d47f9f55b0f104a579c1061f9ad", +- "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/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/partition_alloc" : "https://chromium.googlesource.com/chromium/src/base/allocator/partition_allocator.git@ce13777cb731e0a60c606d1741091fd11a0574d7", +- "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@0ce9bc68d3fc995f76dcab4771c26471100ce759", + "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@31127c60fb320a7eedf48289aa5c435bbb020659", +- "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@2a611a970fdbc41ac2e3e328802aed9985352dca", +- "third_party/externals/spirv-tools" : "https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Tools.git@108b19e5c6979f496deffad4acbe354237afa7d3", +- "third_party/externals/vello" : "https://skia.googlesource.com/external/github.com/linebender/vello.git@3ee3bea02164c5a816fe6c16ef4e3a810edb7620", +- "third_party/externals/vulkan-headers" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Headers@10739e8e00a7b6f74d22dd0a547f1406ff1f5eb9", +- "third_party/externals/vulkan-tools" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Tools@e3fc64396755191b3c51e5c57d0454872e7fa487", +- "third_party/externals/vulkan-utility-libraries": "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Utility-Libraries@72665ee1e50db3d949080df8d727dffa8067f5f8", +- "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/patch/skia-m140-minimize-download.patch b/patch/skia-m140-minimize-download.patch new file mode 100644 index 00000000..c691a84f --- /dev/null +++ b/patch/skia-m140-minimize-download.patch @@ -0,0 +1,70 @@ +diff --git a/DEPS b/DEPS +index 93fc170..5bd8752 100644 +--- a/DEPS ++++ b/DEPS +@@ -31,53 +31,18 @@ vars = { + # ./tools/git-sync-deps + deps = { + "buildtools" : "https://chromium.googlesource.com/chromium/src/buildtools.git@729495f2ffa69080907780591fa2a630b2556e98", +- "third_party/externals/angle2" : "https://chromium.googlesource.com/angle/angle.git@b6b2f380814eadf33f215adc2e99f208c800ae47", +- "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@0b095928b31253ffc9684e460e08cc5710c2c21c", +- "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://chromium.googlesource.com/chromium/src/third_party/abseil-cpp@cae4b6a3990e1431caa09c7b2ed1c76d0dfeab17", +- "third_party/externals/delaunator-cpp" : "https://skia.googlesource.com/external/github.com/skia-dev/delaunator-cpp.git@98305ef6c4e862f7d48df9cc647b690d796fec68", + "third_party/externals/dng_sdk" : "https://android.googlesource.com/platform/external/dng_sdk.git@dbe0a676450d9b8c71bf00688bb306409b779e90", +- "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@c69d433d8509c5c64564c2f0d054bf102a5cf67e", + "third_party/externals/expat" : "https://chromium.googlesource.com/external/github.com/libexpat/libexpat.git@8e49998f003d693213b538ef765814c7d21abada", + "third_party/externals/freetype" : "https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@1518bc83d26b434031bd12c706ac3c7dab3902fd", + "third_party/externals/harfbuzz" : "https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@08b52ae2e44931eef163dbad71697f911fadc323", +- "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@e14cbfaa85529d47f9f55b0f104a579c1061f9ad", +- "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/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/partition_alloc" : "https://chromium.googlesource.com/chromium/src/base/allocator/partition_allocator.git@ce13777cb731e0a60c606d1741091fd11a0574d7", +- "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@681d07e76d8e03286b231766447800aab543bd27", + "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@0a496a889c4c1f56d0637afd2bddf4d89d94ebc9", +- "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@97e96f9e9defeb4bba3cfbd034dec516671dd7a3", +- "third_party/externals/spirv-tools" : "https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Tools.git@3aeaaa088d37b86cff036eee1a9bf452abad7d9d", +- "third_party/externals/vello" : "https://skia.googlesource.com/external/github.com/linebender/vello.git@3ee3bea02164c5a816fe6c16ef4e3a810edb7620", +- "third_party/externals/vulkan-headers" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Headers@37057b4756df4009ad85803bd2e06ec8a3bb1bca", +- "third_party/externals/vulkan-tools" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Tools@f766b30b2de3ffe2cf6b656d943720882617ec58", +- "third_party/externals/vulkan-utility-libraries": "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Utility-Libraries@b0a40d2e50310e9f84327061290a390a061125a3", +- "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 b3c529f..81a1c60 100755 +--- a/bin/activate-emsdk ++++ b/bin/activate-emsdk +@@ -18,6 +18,7 @@ EMSDK_PATH = os.path.join(EMSDK_ROOT, 'emsdk.py') + EMSDK_VERSION = '4.0.7' + + 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/patch/skia-m141-minimize-download.patch b/patch/skia-m141-minimize-download.patch new file mode 100644 index 00000000..1fcf7e68 --- /dev/null +++ b/patch/skia-m141-minimize-download.patch @@ -0,0 +1,70 @@ +diff --git a/DEPS b/DEPS +index 01f37c2..4bb88bc 100644 +--- a/DEPS ++++ b/DEPS +@@ -31,53 +31,18 @@ vars = { + # ./tools/git-sync-deps + deps = { + "buildtools" : "https://chromium.googlesource.com/chromium/src/buildtools.git@729495f2ffa69080907780591fa2a630b2556e98", +- "third_party/externals/angle2" : "https://chromium.googlesource.com/angle/angle.git@1e3e4eb7f98c05e92a113524eeffb5357f68f506", +- "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@b03da099c360d8f021e4de2a3dd0cfb63cbc74d9", +- "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://chromium.googlesource.com/chromium/src/third_party/abseil-cpp@cae4b6a3990e1431caa09c7b2ed1c76d0dfeab17", +- "third_party/externals/delaunator-cpp" : "https://skia.googlesource.com/external/github.com/skia-dev/delaunator-cpp.git@98305ef6c4e862f7d48df9cc647b690d796fec68", + "third_party/externals/dng_sdk" : "https://android.googlesource.com/platform/external/dng_sdk.git@dbe0a676450d9b8c71bf00688bb306409b779e90", +- "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@c69d433d8509c5c64564c2f0d054bf102a5cf67e", + "third_party/externals/expat" : "https://chromium.googlesource.com/external/github.com/libexpat/libexpat.git@8e49998f003d693213b538ef765814c7d21abada", + "third_party/externals/freetype" : "https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@1518bc83d26b434031bd12c706ac3c7dab3902fd", + "third_party/externals/harfbuzz" : "https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@08b52ae2e44931eef163dbad71697f911fadc323", +- "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@e14cbfaa85529d47f9f55b0f104a579c1061f9ad", +- "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/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/partition_alloc" : "https://chromium.googlesource.com/chromium/src/base/allocator/partition_allocator.git@ce13777cb731e0a60c606d1741091fd11a0574d7", +- "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@0390a544a9520c11837f7d2da99a7f480622f29c", + "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@f55240464c0e7ad9fa42130618a2e0532a44c3b3", +- "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@3397e1e4fe0a9964e1837c2934b81835093494b8", +- "third_party/externals/spirv-tools" : "https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Tools.git@392b4893c4955125c1873c33a97f2a8ee8363bd3", +- "third_party/externals/vello" : "https://skia.googlesource.com/external/github.com/linebender/vello.git@3ee3bea02164c5a816fe6c16ef4e3a810edb7620", +- "third_party/externals/vulkan-headers" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Headers@d1cd37e925510a167d4abef39340dbdea47d8989", +- "third_party/externals/vulkan-tools" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Tools@8ce6f121d1fcbdf60f0f4264e23fbcd247b9101d", +- "third_party/externals/vulkan-utility-libraries": "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Utility-Libraries@a528f95dc2f92bdd83c0c32efe2d13c806428c9d", +- "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 b3c529f..81a1c60 100755 +--- a/bin/activate-emsdk ++++ b/bin/activate-emsdk +@@ -18,6 +18,7 @@ EMSDK_PATH = os.path.join(EMSDK_ROOT, 'emsdk.py') + EMSDK_VERSION = '4.0.7' + + 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 461724a0..909ff9bc 100644 --- a/scripts/build_Linux.sh +++ b/scripts/build_Linux.sh @@ -19,7 +19,7 @@ fi # Build skia cd skia && \ - patch -p1 < ../patch/skia-m138-minimize-download.patch && \ + patch -p1 < ../patch/skia-m141-minimize-download.patch && \ patch -p1 < ../patch/skia-m132-colrv1-freetype.diff && \ patch -p1 < ../patch/skia-m132-egl-runtime.diff && \ python3 tools/git-sync-deps && \ diff --git a/scripts/build_Windows.sh b/scripts/build_Windows.sh index 85df523e..71687250 100644 --- a/scripts/build_Windows.sh +++ b/scripts/build_Windows.sh @@ -12,10 +12,10 @@ fi # Build skia cd skia && \ - patch -p1 < ../patch/skia-m138-minimize-download.patch && \ + patch -p1 < ../patch/skia-m141-minimize-download.patch && \ patch -p1 < ../patch/skia-m132-colrv1-freetype.diff && \ patch -p1 -R < ../patch/0001-Disable-OpenGL-for-Windows-on-ARM64.patch && \ - patch -p1 < ../patch/0001-gn-Remove-msvc-env-setting.patch && \ + patch -p1 < ../patch/fetch-gn-windows-arm64.diff && \ python tools/git-sync-deps && \ bin/gn gen out/Release --args=" is_official_build=true diff --git a/scripts/build_macOS.sh b/scripts/build_macOS.sh index 25869913..fe666666 100644 --- a/scripts/build_macOS.sh +++ b/scripts/build_macOS.sh @@ -22,7 +22,7 @@ function apply_patch { } cd skia && \ - patch -p1 < ../patch/skia-m138-minimize-download.patch && \ + patch -p1 < ../patch/skia-m141-minimize-download.patch && \ patch -p1 < ../patch/skia-m132-colrv1-freetype.diff && \ python3 tools/git-sync-deps && \ bin/gn gen out/Release --args=" diff --git a/setup.py b/setup.py index f0e2b708..5d81c7f0 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ pass NAME = 'skia-python' -__version__ = '138.0' +__version__ = '141.0' SKIA_PATH = os.getenv('SKIA_PATH', 'skia') SKIA_OUT_PATH = os.getenv( diff --git a/skia b/skia index 114d33c6..5eefbe51 160000 --- a/skia +++ b/skia @@ -1 +1 @@ -Subproject commit 114d33c62998ce5c16f899b9123c22000ca06ddd +Subproject commit 5eefbe51d17d2e379fa2d7353827e0ccb1e1f601 diff --git a/src/skia/Canvas.cpp b/src/skia/Canvas.cpp index a87b4663..8957374d 100644 --- a/src/skia/Canvas.cpp +++ b/src/skia/Canvas.cpp @@ -1346,7 +1346,7 @@ canvas // &SkCanvas::drawPoints, [] (SkCanvas& canvas, SkCanvas::PointMode mode, const std::vector& points, const SkPaint &paint) { - canvas.drawPoints(mode, points.size(), &points[0], paint); + canvas.drawPoints(mode, {&points[0], points.size()}, paint); }, R"docstring( Draws pts using clip, :py:class:`Matrix` and :py:class:`Paint` @@ -2318,9 +2318,9 @@ canvas if (!colors.empty() && colors.size() != xform.size()) throw std::runtime_error( "colors must have the same length with xform."); - canvas.drawAtlas(atlas, &xform[0], &tex[0], - (colors.empty()) ? nullptr : &colors[0], - xform.size(), mode, options, cullRect, paint); + canvas.drawAtlas(atlas, {&xform[0], xform.size()}, {&tex[0], tex.size()}, + {(colors.empty()) ? nullptr : &colors[0], + colors.size()}, mode, options, cullRect, paint); }, R"docstring( Draws a set of sprites from atlas, using clip, :py:class:`Matrix`, and diff --git a/src/skia/Font.cpp b/src/skia/Font.cpp index ea31a519..4c7e5b1f 100644 --- a/src/skia/Font.cpp +++ b/src/skia/Font.cpp @@ -17,6 +17,7 @@ #ifdef __linux__ #include "include/ports/SkFontMgr_fontconfig.h" +#include "include/ports/SkFontScanner_FreeType.h" #endif #ifdef _WIN32 @@ -35,7 +36,7 @@ static sk_sp fontmgr_factory() { #if defined(__APPLE__) return SkFontMgr_New_CoreText(nullptr); #elif defined(__linux__) - return SkFontMgr_New_FontConfig(nullptr); + return SkFontMgr_New_FontConfig(nullptr, SkFontScanner_Make_FreeType()); #elif defined(_WIN32) return SkFontMgr_New_DirectWrite(); #else @@ -454,14 +455,14 @@ typeface )docstring") .def("getVariationDesignParameters", [] (const SkTypeface& typeface) { - auto count = typeface.getVariationDesignParameters(nullptr, 0); + auto count = typeface.getVariationDesignParameters({nullptr, 0}); if (count == -1) throw std::runtime_error("Failed to get; Likely no parameter"); std::vector params(count); if (count == 0) return params; auto actualCount = typeface.getVariationDesignParameters( - params.data(), params.size()); + {params.data(), params.size()}); if (actualCount == -1) throw std::runtime_error("Failed to get"); return params; @@ -474,12 +475,12 @@ typeface )docstring") .def("getVariationDesignPosition", [] (const SkTypeface& typeface) { - auto count = typeface.getVariationDesignPosition(nullptr, 0); + auto count = typeface.getVariationDesignPosition({nullptr, 0}); if (count == -1) throw std::runtime_error("Failed to get; Likely no position"); std::vector coords(count); auto actualCount = typeface.getVariationDesignPosition( - coords.data(), coords.size()); + {coords.data(), coords.size()}); if (actualCount == -1) throw std::runtime_error("Failed to get"); return coords; @@ -523,7 +524,7 @@ typeface .def("unicharsToGlyphs", [] (const SkTypeface& typeface, const std::vector& chars) { std::vector glyphs(chars.size()); - typeface.unicharsToGlyphs(&chars[0], chars.size(), &glyphs[0]); + typeface.unicharsToGlyphs({&chars[0], chars.size()}, {&glyphs[0], glyphs.size()}); return glyphs; }, R"docstring( @@ -555,7 +556,7 @@ typeface .def("getTableTags", [] (const SkTypeface& typeface) { std::vector tags(typeface.countTables()); - size_t size = typeface.getTableTags(&tags[0]); + size_t size = typeface.readTableTags({&tags[0], tags.size()}); if (size < tags.size()) throw std::runtime_error("Failed to get table tags."); return tags; @@ -612,7 +613,7 @@ typeface const std::vector& glyphs) -> py::object { std::vector adjustments(glyphs.size() - 1); auto result = typeface.getKerningPairAdjustments( - &glyphs[0], glyphs.size(), (glyphs.size() > 1) ? &adjustments[0] : nullptr); + {&glyphs[0], glyphs.size()}, {(glyphs.size() > 1) ? &adjustments[0] : nullptr, adjustments.size()}); if (!result) { // Kerning is not supported for this typeface. return py::none(); @@ -1314,7 +1315,7 @@ font int count = font.countText(&text[0], text.size(), encoding); std::vector glyphs(count); font.textToGlyphs( - &text[0], text.size(), encoding, &glyphs[0], glyphs.size()); + &text[0], text.size(), encoding, {&glyphs[0], glyphs.size()}); return glyphs; }, R"docstring( @@ -1354,7 +1355,7 @@ font .def("unicharsToGlyphs", [] (const SkFont& font, const std::vector& uni) { std::vector glyphs(uni.size()); - font.unicharsToGlyphs(&uni[0], uni.size(), &glyphs[0]); + font.unicharsToGlyphs({&uni[0], uni.size()}, {&glyphs[0], glyphs.size()}); return glyphs; }, py::arg("uni")) @@ -1401,7 +1402,7 @@ font .def("getWidths", [] (const SkFont& font, const std::vector& glyphs) { std::vector width(glyphs.size()); - font.getWidths(&glyphs[0], glyphs.size(), &width[0]); + font.getWidths({&glyphs[0], glyphs.size()}, {&width[0], width.size()}); return width; }, R"docstring( @@ -1417,7 +1418,7 @@ font std::vector width(glyphs.size()); std::vector bounds(glyphs.size()); font.getWidthsBounds( - &glyphs[0], glyphs.size(), &width[0], &bounds[0], paint); + {&glyphs[0], glyphs.size()}, {&width[0], width.size()}, {&bounds[0], bounds.size()}, paint); return py::make_tuple(width, bounds); }, R"docstring( @@ -1434,7 +1435,7 @@ font [] (const SkFont& font, const std::vector& glyphs, const SkPaint* paint) { std::vector bounds(glyphs.size()); - font.getBounds(&glyphs[0], glyphs.size(), &bounds[0], paint); + font.getBounds({&glyphs[0], glyphs.size()}, {&bounds[0], bounds.size()}, paint); return bounds; }, R"docstring( @@ -1454,7 +1455,7 @@ font [] (const SkFont& font, const std::vector& glyphs, const SkPoint& origin) { std::vector pos(glyphs.size()); - font.getPos(&glyphs[0], glyphs.size(), &pos[0], origin); + font.getPos({&glyphs[0], glyphs.size()}, {&pos[0], pos.size()}, origin); return pos; }, R"docstring( @@ -1472,7 +1473,7 @@ font [] (const SkFont& font, const std::vector& glyphs, const SkScalar& origin) { std::vector xpos(glyphs.size()); - font.getXPos(&glyphs[0], glyphs.size(), &xpos[0], origin); + font.getXPos({&glyphs[0], glyphs.size()}, {&xpos[0], xpos.size()}, origin); return xpos; }, R"docstring( @@ -1509,8 +1510,8 @@ font std::vector paths; paths.reserve(glyphIDs.size()); font.getPaths( - glyphIDs.data(), - glyphIDs.size(), + {glyphIDs.data(), + glyphIDs.size()}, [] (const SkPath* pathOrNull, const SkMatrix& mx, void* ctx) { auto paths_ = static_cast*>(ctx); if (pathOrNull) { diff --git a/src/skia/Image.cpp b/src/skia/Image.cpp index 59b76f21..a41d6704 100644 --- a/src/skia/Image.cpp +++ b/src/skia/Image.cpp @@ -150,8 +150,8 @@ sk_sp ImageConvert( at = image.alphaType(); if (at == image.alphaType()) { if (ct == image.colorType()) - return image.makeColorSpace(nullptr, CloneColorSpace(cs)); - return image.makeColorTypeAndColorSpace(nullptr, ct, CloneColorSpace(cs)); + return image.makeColorSpace(nullptr, CloneColorSpace(cs), {}); + return image.makeColorTypeAndColorSpace(nullptr, ct, CloneColorSpace(cs), {}); } auto imageInfo = SkImageInfo::Make( @@ -1398,7 +1398,10 @@ image :return: true if :py:class:`Image` is a GPU texture )docstring") - .def("isValid", py::overload_cast(&SkImage::isValid, py::const_), + .def("isValid", + [] (const SkImage& image, GrRecordingContext* ctx) { + return image.isValid(((ctx) ? ctx->asRecorder() : nullptr)); + }, R"docstring( Returns true if :py:class:`Image` can be drawn on either raster surface or GPU surface. @@ -1744,7 +1747,7 @@ image )docstring") .def("makeSubset", [] (SkImage& image, const SkIRect& subset, GrDirectContext* direct) { - return image.makeSubset(direct, subset); + return image.makeSubset(((direct) ? direct->asRecorder() : nullptr), subset, {}); }, R"docstring( Returns subset of :py:class:`Image`. @@ -1943,7 +1946,7 @@ image .def("makeColorSpace", [] (const SkImage& image, const SkColorSpace* target, GrDirectContext* direct) { - return image.makeColorSpace(direct, CloneColorSpace(target)); + return image.makeColorSpace(((direct) ? direct->asRecorder() : nullptr), CloneColorSpace(target), {}); }, R"docstring( Creates :py:class:`Image` in target :py:class:`ColorSpace`. @@ -1965,7 +1968,7 @@ image [] (const SkImage& image, SkColorType ct, const SkColorSpace* cs, GrDirectContext* direct) { return image.makeColorTypeAndColorSpace( - direct, ct, CloneColorSpace(cs)); + ((direct) ? direct->asRecorder() : nullptr), ct, CloneColorSpace(cs), {}); }, R"docstring( Experimental. diff --git a/src/skia/Matrix.cpp b/src/skia/Matrix.cpp index a0eb9128..ecf4f1ae 100644 --- a/src/skia/Matrix.cpp +++ b/src/skia/Matrix.cpp @@ -1197,8 +1197,8 @@ matrix if (src.size() != dst.size()) throw std::runtime_error("src and dst must have the same size"); if (src.empty()) - return matrix.setPolyToPoly(nullptr, nullptr, 0); - return matrix.setPolyToPoly(&src[0], &dst[0], src.size()); + return matrix.setPolyToPoly({nullptr, 0}, {nullptr, 0}); + return matrix.setPolyToPoly({&src[0], src.size()}, {&dst[0], dst.size()}); }, R"docstring( Sets :py:class:`Matrix` to map src to dst. @@ -1217,7 +1217,7 @@ matrix :return: true if :py:class:`Matrix` was constructed successfully )docstring", py::arg("src"), py::arg("dst")) - .def("invert", &SkMatrix::invert, + .def("invert", py::overload_cast(&SkMatrix::invert, py::const_), R"docstring( Sets inverse to reciprocal matrix, returning true if :py:class:`Matrix` can be inverted. @@ -1291,7 +1291,7 @@ matrix [] (const SkMatrix& matrix, std::vector& pts) { if (pts.empty()) return pts; - matrix.mapPoints(&pts[0], &pts[0], pts.size()); + matrix.mapPoints({&pts[0], pts.size()}, {&pts[0], pts.size()}); return pts; }, R"docstring( @@ -1325,7 +1325,7 @@ matrix [] (const SkMatrix& matrix, std::vector& pts) -> py::object { if (pts.empty()) return py::cast(pts); - matrix.mapHomogeneousPoints(&pts[0], &pts[0], pts.size()); + matrix.mapHomogeneousPoints({&pts[0], pts.size()}, {&pts[0], pts.size()}); return py::cast(pts); }, R"docstring( @@ -1354,7 +1354,7 @@ matrix if (pts.empty()) return py::cast(pts); std::vector dst(pts.size()); - matrix.mapHomogeneousPoints(&dst[0], &pts[0], pts.size()); + matrix.mapPointsToHomogeneous({&dst[0], dst.size()}, {&pts[0], pts.size()}); return py::cast(dst); }, R"docstring( @@ -1365,7 +1365,9 @@ matrix )docstring", py::arg("pts")) .def("mapXY", - py::overload_cast(&SkMatrix::mapXY, py::const_), + [] (const SkMatrix& matrix, SkScalar x, SkScalar y) { + return matrix.mapPoint({x, y}); + }, R"docstring( Returns :py:class:`Point` (x, y) multiplied by :py:class:`Matrix`. @@ -1390,7 +1392,7 @@ matrix [] (const SkMatrix& matrix, std::vector& src) { if (src.empty()) return src; - matrix.mapVectors(&src[0], &src[0], src.size()); + matrix.mapVectors({&src[0], src.size()}, {&src[0], src.size()}); return src; }, R"docstring( diff --git a/src/skia/Path.cpp b/src/skia/Path.cpp index 0190f680..750342b6 100644 --- a/src/skia/Path.cpp +++ b/src/skia/Path.cpp @@ -380,8 +380,8 @@ path SkPathFillType fillType, bool isVolatile) { return SkPath::Make( - points.data(), points.size(), verbs.data(), verbs.size(), - conicWeights.data(), conicWeights.size(), fillType, isVolatile); + {points.data(), points.size()}, {verbs.data(), verbs.size()}, + {conicWeights.data(), conicWeights.size()}, fillType, isVolatile); }, R"docstring( Create a new path with the specified segments. @@ -434,7 +434,7 @@ path [] (const std::vector& points, bool isClosed, SkPathFillType fillType, bool isVolatile) { return SkPath::Polygon( - points.data(), points.size(), isClosed, fillType, isVolatile); + {points.data(), points.size()}, isClosed, fillType, isVolatile); }, py::arg("points"), py::arg("isClosed"), py::arg_v("fillType", SkPathFillType::kWinding, "skia.PathFillType.kWinding"), @@ -710,7 +710,7 @@ path if (max == 0) max = path.countVerbs(); std::vector points(max); - auto length = path.getPoints(&points[0], max); + auto length = path.getPoints({&points[0], max}); if (length < max) points.erase(points.begin() + length, points.end()); return points; @@ -741,7 +741,7 @@ path if (max == 0) max = path.countVerbs(); std::vector verbs(max); - auto length = path.getVerbs(&verbs[0], max); + auto length = path.getVerbs({&verbs[0], max}); if (length < max) verbs.erase(verbs.begin() + length, verbs.end()); std::vector verbs_(verbs.size()); @@ -877,7 +877,7 @@ path )docstring", py::arg("x"), py::arg("y")) .def("moveTo", - py::overload_cast(&SkPath::moveTo), + py::overload_cast(&SkPath::moveTo), R"docstring( Adds beginning of contour at :py:class:`Point` p. @@ -1604,7 +1604,7 @@ path << " elements)."; throw py::value_error(stream.str()); } - return path.addRoundRect(rect, &radii_[0], dir); + return path.addRoundRect(rect, {&radii_[0], radii_.size()}, dir); }, R"docstring( Appends :py:class:`RRect` to :py:class:`Path`, creating a new closed @@ -1658,7 +1658,7 @@ path py::arg("rrect"), py::arg("dir"), py::arg("start")) .def("addPoly", [] (SkPath& path, const std::vector& pts, bool close) { - return path.addPoly(&pts[0], pts.size(), close); + return path.addPoly({&pts[0], pts.size()}, close); }, R"docstring( Adds contour created from pts. @@ -2291,7 +2291,7 @@ PathBuilder .def("close", &SkPathBuilder::close) .def("polylineTo", [] (SkPathBuilder& self, const std::vector& points) { - return self.polylineTo(points.data(), points.size()); + return self.polylineTo({points.data(), points.size()}); }, R"docstring( Append a series of lineTo(...) @@ -2457,7 +2457,7 @@ PathBuilder .def("addPolygon", [] (SkPathBuilder& self, const std::vector& points, bool isClosed) { - return self.addPolygon(points.data(), points.size(), isClosed); + return self.addPolygon({points.data(), points.size()}, isClosed); }, py::arg("points"), py::arg("isClosed")) .def("incReserve", diff --git a/src/skia/PathEffect.cpp b/src/skia/PathEffect.cpp index a01f2e7d..affc3ef1 100644 --- a/src/skia/PathEffect.cpp +++ b/src/skia/PathEffect.cpp @@ -1,4 +1,5 @@ #include "common.h" +#include #include #include #include @@ -62,7 +63,11 @@ strokerec :py:meth:`applyToPath` will return true. )docstring") - .def("applyToPath", &SkStrokeRec::applyToPath, + .def("applyToPath", + [] (const SkStrokeRec& strokerec, SkPath* dst, const SkPath& src) { + auto dst2 = SkPathBuilder(*dst); + return strokerec.applyToPath(&dst2, src); + }, R"docstring( Apply these stroke parameters to the src path, returning the result in dst. @@ -330,7 +335,7 @@ py::class_(m, "DashPathEffect") .def_static("Make", [] (const std::vector& intervals, SkScalar phase) { return SkDashPathEffect::Make( - &intervals[0], intervals.size(), phase); + {&intervals[0], intervals.size()}, phase); }, R"docstring( For example: if intervals[] = {10, 20}, count = 2, and phase = 25, this diff --git a/src/skia/PathMeasure.cpp b/src/skia/PathMeasure.cpp index ec4820a8..f0ed7a4e 100644 --- a/src/skia/PathMeasure.cpp +++ b/src/skia/PathMeasure.cpp @@ -83,7 +83,7 @@ path_measure :py:class:`Point` and tangent :py:class:`Vector`. )docstring", py::arg("distance")) - .def("getSegment", &SkPathMeasure::getSegment, + .def("getSegment", py::overload_cast(&SkPathMeasure::getSegment), R"docstring( Given a start and stop distance, return in dst the intervening segment(s). diff --git a/src/skia/Rect.cpp b/src/skia/Rect.cpp index 4585eaf5..39f74402 100644 --- a/src/skia/Rect.cpp +++ b/src/skia/Rect.cpp @@ -868,7 +868,7 @@ py::class_(m, "Rect", R"docstring( py::arg("left"), py::arg("top"), py::arg("right"), py::arg("bottom")) .def("setBounds", [] (SkRect& rect, const std::vector& points) { - rect.setBounds(&points[0], points.size()); + rect.setBounds({&points[0], points.size()}); }, R"docstring( Sets to bounds of :py:class:`Point` array with count entries. @@ -884,7 +884,7 @@ py::class_(m, "Rect", R"docstring( py::arg("points")) .def("setBoundsCheck", [] (SkRect& rect, const std::vector& points) { - return rect.setBoundsCheck(&points[0], points.size()); + return rect.setBoundsCheck({&points[0], points.size()}); }, R"docstring( Sets to bounds of :py:class:`Point` array with count entries. @@ -902,7 +902,7 @@ py::class_(m, "Rect", R"docstring( py::arg("points")) .def("setBoundsNoCheck", [] (SkRect& rect, const std::vector& points) { - rect.setBoundsNoCheck(&points[0], points.size()); + rect.setBoundsNoCheck({&points[0], points.size()}); }, R"docstring( Sets to bounds of :py:class:`Point` pts array with count entries. @@ -1833,7 +1833,7 @@ rrect :return: bytes read, or 0 if length is less than kSizeInMemory )docstring", py::arg("buffer")) - .def("transform", &SkRRect::transform, + .def("transform", py::overload_cast(&SkRRect::transform, py::const_), R"docstring( Transforms by :py:class:`RRect` by matrix, storing result in dst. diff --git a/src/skia/Region.cpp b/src/skia/Region.cpp index 8c75f1f1..d76a4ac8 100644 --- a/src/skia/Region.cpp +++ b/src/skia/Region.cpp @@ -347,7 +347,7 @@ region :return: relative complexity )docstring") - .def("getBoundaryPath", &SkRegion::getBoundaryPath, + .def("getBoundaryPath", py::overload_cast(&SkRegion::getBoundaryPath, py::const_), R"docstring( Appends outline of :py:class:`Region` to path. diff --git a/src/skia/SkTextOnPath.cpp b/src/skia/SkTextOnPath.cpp index fd3cc884..06c15e09 100644 --- a/src/skia/SkTextOnPath.cpp +++ b/src/skia/SkTextOnPath.cpp @@ -17,10 +17,9 @@ static void morphpoints(SkPoint dst[], const SkPoint src[], int count, SkPathMeasure& meas, const SkMatrix& matrix) { for (int i = 0; i < count; i++) { - SkPoint pos; SkVector tangent; - matrix.mapXY(src[i].fX, src[i].fY, &pos); + SkPoint pos = matrix.mapPoint({src[i].fX, src[i].fY}); SkScalar sx = pos.fX; SkScalar sy = pos.fY; @@ -101,9 +100,9 @@ void SkVisitTextOnPath(const void* text, size_t byteLength, const SkPaint& paint int glyphCount = font.countText(text, byteLength, SkTextEncoding::kUTF8); if (glyphCount <= 0) return; std::vector glyphs(glyphCount); - font.textToGlyphs(text, byteLength, SkTextEncoding::kUTF8, glyphs.data(), glyphCount); + font.textToGlyphs(text, byteLength, SkTextEncoding::kUTF8, {glyphs.data(), glyphCount}); std::vector advances(glyphCount); - font.getWidths(glyphs.data(), glyphCount, advances.data()); + font.getWidths({glyphs.data(), glyphCount}, {advances.data(), advances.size()}); // Prepare path measuring SkPathMeasure meas(follow, false); diff --git a/src/skia/TextBlob.cpp b/src/skia/TextBlob.cpp index 8994b642..558b3c6d 100644 --- a/src/skia/TextBlob.cpp +++ b/src/skia/TextBlob.cpp @@ -94,7 +94,7 @@ textblob "len(text) = {} does not match len(pos) = {}").format( count, pos_.size())); return SkTextBlob::MakeFromPosText( - text.c_str(), text.size(), &pos_[0], font, encoding); + text.c_str(), text.size(), {&pos_[0], pos_.size()}, font, encoding); }), R"docstring( Creates :py:class:`TextBlob` with a single run. @@ -286,7 +286,7 @@ textblob throw py::value_error(stream.str()); } return SkTextBlob::MakeFromPosTextH( - text.c_str(), text.size(), &xpos_[0], constY, font, encoding); + text.c_str(), text.size(), {&xpos_[0], xpos_.size()}, constY, font, encoding); }, R"docstring( Returns a textblob built from a single run of text with x-positions and @@ -316,7 +316,7 @@ textblob throw std::runtime_error( "text and pos must have the same number of elements."); return SkTextBlob::MakeFromPosText( - text.c_str(), text.size(), &pos[0], font, encoding); + text.c_str(), text.size(), {&pos[0], pos.size()}, font, encoding); }, R"docstring( Returns a textblob built from a single run of text with x-positions and @@ -344,7 +344,7 @@ textblob throw std::runtime_error( "text and xform must have the same number of elements."); return SkTextBlob::MakeFromRSXform( - text.c_str(), text.size(), &xform[0], font, encoding); + text.c_str(), text.size(), {&xform[0], xform.size()}, font, encoding); }, py::arg("text"), py::arg("xform"), py::arg("font"), py::arg_v("encoding", SkTextEncoding::kUTF8, "skia.TextEncoding.kUTF8")) @@ -399,7 +399,7 @@ textblobbuilder int glyphCount = font.countText(&text[0], text.size(), encoding); auto run = builder.allocRun(font, glyphCount, x, y, bounds); font.textToGlyphs( - &text[0], text.size(), encoding, run.glyphs, glyphCount); + &text[0], text.size(), encoding, {run.glyphs, glyphCount}); }, R"docstring( Sets a new run with glyphs.