Skip to content

Commit

Permalink
Merge pull request #197 from HinTak/m117-public
Browse files Browse the repository at this point in the history
M117 public
  • Loading branch information
HinTak authored Sep 22, 2023
2 parents f71fdee + 97834ef commit d13a801
Show file tree
Hide file tree
Showing 21 changed files with 326 additions and 121 deletions.
44 changes: 36 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
types: [published]

jobs:
prebuild_linux_aarch64:
name: Build skia on linux/aarch64
prebuild_linux_aarch64_3rd_party:
name: Build skia bundled 3rd-party on linux/aarch64
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
Expand All @@ -22,12 +22,12 @@ jobs:
path: |
gn
skia
key: linux-aarch64-skia-${{ github.sha }}
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-m116-minimize-download.patch && python tools/git-sync-deps && patch -p1 -R -i ../patch/skia-m116-minimize-download.patch
run: git config --global core.compression 0 && cd skia && patch -p1 -i ../patch/skia-m117-minimize-download.patch && python tools/git-sync-deps && patch -p1 -R -i ../patch/skia-m117-minimize-download.patch
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Build skia
- name: Build skia 3rd-Party
# Taken from https://github.com/pypa/cibuildwheel/blob/v2.12.1/cibuildwheel/resources/pinned_docker_images.cfg
uses: docker://quay.io/pypa/manylinux2014_aarch64:2023-03-05-271004f
if: ${{ steps.cache-skia.outputs.cache-hit != 'true' }}
Expand All @@ -36,6 +36,35 @@ jobs:
bash scripts/build_Linux.sh &&
chmod a+rwx -R skia"

prebuild_linux_aarch64:
name: Build skia on linux/aarch64
needs: prebuild_linux_aarch64_3rd_party
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/cache@v3
id: cache-skia
with:
path: |
gn
skia
key: linux-aarch64-skia-${{ github.sha }}
- uses: actions/cache/restore@v3
with:
path: |
gn
skia
key: linux-aarch64-skia-${{ github.sha }}-3rd-party
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Build Skia Proper
uses: docker://quay.io/pypa/manylinux2014_aarch64:2023-03-05-271004f
with:
args: bash -c "git config --global --add safe.directory '*' &&
bash scripts/build_Linux.sh

build_wheels:
name: Build wheels on ${{ matrix.os }} (${{ matrix.arch }}) for ${{ matrix.cp }}
needs: prebuild_linux_aarch64
Expand Down Expand Up @@ -93,7 +122,6 @@ jobs:
CIBW_SKIP: "*musllinux*"
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_ENVIRONMENT_MACOS: TARGET_ARCH=${{ matrix.arch }}
CIBW_ENVIRONMENT_LINUX: CI_SKIP_BUILD=true
CIBW_BEFORE_ALL: bash scripts/build_${{ runner.os }}.sh
CIBW_BEFORE_BUILD: pip install pybind11 numpy
CIBW_TEST_REQUIRES: pytest pillow glfw
Expand Down Expand Up @@ -126,8 +154,8 @@ jobs:

- name: Build docs
run: |
python -m pip install -f dist skia-python
python -m pip install sphinx sphinx-rtd-theme
python -m pip install --pre -f dist skia-python
python -m pip install sphinx==6.2.1 sphinx-rtd-theme
python setup.py build_sphinx
- name: Deploy docs
Expand Down
25 changes: 25 additions & 0 deletions README.m117.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Since m116:

* Surface::flushAndSubmit() and Surface::flush() now emulated
("Remove legacy SkImage and SkSurface methods")
* Canvas::flush() emulated
* GrDirectContext/GrContext reorganized (#198)
* Image::getBackendTexture() / Image::flush()/Image::flushAndSubmit() emulated
* Image::encodeToData() from GPU backend now works (was broken between m87 and m116)
* new RTreeFactory class added
* PictureRecorder.FinishFlags removed
* more PictureRecorder.beginRecording() overloads
* new ScalarInfinity/ScalarNegativeInfinity defines
* bug fix in TextBlob textcount (#200)

* CI aarch64 build further split into 3rd-party and main to lower job time
* documentation: locking to sphinx==6.2.1 as an interrim measure for splinx 7 breakage.
uses "--pre" to build v11x.0by version of doc

Since m87 (disabled in m116):
* GrDirectContext::ComputeImageSize() now emulated
* Image::MakeFromTexture() re-enabled (#198)
* Image::makeSubset()/Image::flush() re-enabled
* Image::makeTextureImage() / Image::MakeBackendTextureFromImage() emulated
* Shader::Lerp() emulated (#198)
* Surface::MakeFromBackendTexture()/Surface::MakeFromBackendRenderTarget() re-enabled (#198)
68 changes: 68 additions & 0 deletions patch/skia-m117-minimize-download.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
diff --git a/DEPS b/DEPS
index 7e743774c3..d32fab606f 100644
--- a/DEPS
+++ b/DEPS
@@ -19,51 +19,15 @@ 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@f7d7be8d2ff0bbee438b6030419a0b13082de198",
- "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@beaf20f90f1bf21d235c99d5b49b8bb507b722b2",
- "third_party/externals/jinja2" : "https://chromium.googlesource.com/chromium/src/third_party/jinja2@ee69aa00ee8536f61db6a451f3858745cf587de6",
- "third_party/externals/markupsafe" : "https://chromium.googlesource.com/chromium/src/third_party/markupsafe@0944e71f4b2cb9a871bcbe353f95e889b64a611a",
- "third_party/externals/abseil-cpp" : "https://skia.googlesource.com/external/github.com/abseil/abseil-cpp.git@cb436cf0142b4cbe47aae94223443df7f82e2920",
"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@a0bca08de07c7d7651047bedc0b653cfaaa4f2ae",
- "third_party/externals/emsdk" : "https://skia.googlesource.com/external/github.com/emscripten-core/emsdk.git@4a48a752e6a8bef6f222622f2b4926d5eb3bdeb3",
"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@5769f13a6b9fafa3840726f06dde07e755501a16",
"third_party/externals/harfbuzz" : "https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@f94508edd60e26a015586c37c29104d6bdc26462",
- "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/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@f49462dc93784bf34148715eee36ab6697ca0b35",
- "third_party/externals/libgav1" : "https://chromium.googlesource.com/codecs/libgav1.git@0fb779c1e169fe6c229cd1fa9cc6ea6feeb441da",
- "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@386707c6d19b974ca2e3db7f5c61873813c6fe44",
"third_party/externals/libwebp" : "https://chromium.googlesource.com/webm/libwebp.git@fd7bb21c0cb56e8a82e9bfa376164b842f433f3b",
- "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/sfntly" : "https://chromium.googlesource.com/external/github.com/googlei18n/sfntly.git@b55ff303ea2f9e26702b514cf6a3196a2e3e2974",
- "third_party/externals/swiftshader" : "https://swiftshader.googlesource.com/SwiftShader@729e92f8ae07d7b695bdcf346318dec4d11d899e",
- "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@c46d48f777b73fa492cdc6424e54e4004bd9ee01",
- "third_party/externals/spirv-cross" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/SPIRV-Cross@bccaa94db814af33d8ef05c153e7c34d8bd4d685",
- "third_party/externals/spirv-headers" : "https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Headers.git@124a9665e464ef98b8b718d572d5f329311061eb",
- "third_party/externals/spirv-tools" : "https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Tools.git@4a9881fe9b32086d4ceac89a498b0dd34084b574",
- "third_party/externals/vello" : "https://skia.googlesource.com/external/github.com/linebender/vello.git@443539891c4c1eb3ca4ed891d251cbf4097c9a9c",
- "third_party/externals/vulkan-headers" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Headers@450ead13e1064584da027d91192bd7bfb724640f",
- "third_party/externals/vulkan-tools" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Tools@1d8188a974ccd08caffb5bd7fec58751e0c7d786",
- "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@c876c8f87101c5a75f6014b0f832499afeb65b73",

diff --git a/bin/activate-emsdk b/bin/activate-emsdk
index 85badfdf0f..6537cd45f0 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.15'

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
56 changes: 39 additions & 17 deletions scripts/build_Linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ export PATH=${PWD}/depot_tools:$PATH

EXTRA_CFLAGS=""

if [[ $(uname -m) == "aarch64" ]]; then
# Install ninja for aarch64
yum -y install epel-release && \
yum repolist && \
yum install -y ninja-build && \
ln -s ninja-build /usr/bin/ninja &&
mv depot_tools/ninja depot_tools/ninja.bak
fi
export CC=gcc
export CXX=g++
export AR=ar
export CFLAGS="-Wno-deprecated-copy"
export LDFLAGS="-lrt"

# Install system dependencies
if [[ $EUID -eq 0 ]]; then
Expand All @@ -25,17 +22,35 @@ if [[ $EUID -eq 0 ]]; then
rm -rf /var/cache/yum
fi

if [[ $(uname -m) == "aarch64" ]] && [[ $CI_SKIP_BUILD == "true" ]]; then
# gn and skia already built in a previous job
# Wheel-building needs fontconfig-devel from above.
# Simply quit, if it looks like a previous run was successful:
if [[ -f "skia/out/Release/libskia.a" ]] ; then
exit 0
fi

if [[ $(uname -m) == "aarch64" ]]; then
# Install ninja for aarch64
yum -y install epel-release && \
yum repolist && \
yum install -y ninja-build && \
ln -s ninja-build /usr/bin/ninja &&
mv depot_tools/ninja depot_tools/ninja.bak
fi

# libicu.a is the largest 3rd-party; if it already exists, we run ninja
# a 2nd time and exit.
# Running ninja a 2nd-time is safe - it is no-ops if skia is already built too.
# The 3rd-party libraries below are built in size-order; we built libicu last to signal
# having built most of them.
if [[ -f "skia/out/Release/libicu.a" ]] ; then
cd skia && \
ninja -C out/Release && \
cd ..
exit $?
fi
### 2nd round<->1st round ###

# Build gn
export CC=gcc
export CXX=g++
export AR=ar
export CFLAGS="-Wno-deprecated-copy"
export LDFLAGS="-lrt"
git clone https://gn.googlesource.com/gn && \
cd gn && \
git checkout fe330c0ae1ec29db30b6f830e50771a335e071fb && \
Expand All @@ -45,7 +60,7 @@ git clone https://gn.googlesource.com/gn && \

# Build skia
cd skia && \
patch -p1 < ../patch/skia-m116-minimize-download.patch && \
patch -p1 < ../patch/skia-m117-minimize-download.patch && \
patch -p1 < ../patch/skia-m116-colrv1-freetype.diff && \
python3 tools/git-sync-deps && \
cp -f ../gn/out/gn bin/gn && \
Expand All @@ -61,5 +76,12 @@ skia_use_system_freetype2=false
extra_cflags_cc=[\"-frtti\"]
extra_ldflags=[\"-lrt\"]
" && \
ninja -C out/Release && \
ninja -C out/Release \
third_party/freetype2 \
third_party/libwebp \
third_party/dng_sdk \
third_party/harfbuzz \
third_party/icu && \
( ( [[ $(uname -m) == "aarch64" ]] && echo "On aarch64 - Please run me again!" ) || \
ninja -C out/Release ) && \
cd ..
1 change: 1 addition & 0 deletions scripts/build_Windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export PATH="${PWD}/depot_tools:$PATH"

# Build skia
cd skia && \
patch -p1 < ../patch/skia-m117-minimize-download.patch && \
patch -p1 < ../patch/skia-m116-colrv1-freetype.diff && \
python tools/git-sync-deps && \
bin/gn gen out/Release --args='
Expand Down
1 change: 1 addition & 0 deletions scripts/build_macOS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function apply_patch {
}

cd skia && \
patch -p1 < ../patch/skia-m117-minimize-download.patch && \
patch -p1 < ../patch/skia-m116-colrv1-freetype.diff && \
python3 tools/git-sync-deps && \
bin/gn gen out/Release --args="
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
pass

NAME = 'skia-python'
__version__ = '116.0b2'
__version__ = '117.0b3'

SKIA_PATH = os.getenv('SKIA_PATH', 'skia')
SKIA_OUT_PATH = os.getenv(
Expand Down Expand Up @@ -90,7 +90,6 @@
LIBRARIES = [
'dl',
'fontconfig',
'freetype',
'GL',
'expat',
]
Expand Down
2 changes: 1 addition & 1 deletion skia
Submodule skia updated from f44dbc to beb4d7
7 changes: 6 additions & 1 deletion src/skia/Canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,12 @@ canvas
:return: true if :py:class:`SurfaceProps` was copied
)docstring",
py::arg("props"))
.def("flush", &SkCanvas::flush,
.def("flush",
[] (const SkCanvas& canvas) {
if (auto dContext = GrAsDirectContext(canvas.recordingContext())) {
dContext->flushAndSubmit();
}
},
R"docstring(
Triggers the immediate execution of all pending draw operations.
Expand Down
12 changes: 7 additions & 5 deletions src/skia/GrContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ py::class_<GrRecordingContext, sk_sp<GrRecordingContext>, GrImageContext>(
// py::overload_cast<>(&GrRecordingContext::priv, py::const_))
;

py::class_<GrDirectContext, sk_sp<GrDirectContext>, GrRecordingContext>(m, "GrContext")
py::class_<GrDirectContext, sk_sp<GrDirectContext>, GrRecordingContext>(m, "GrDirectContext")
.def("resetContext", &GrDirectContext::resetContext,
R"docstring(
The :py:class:`GrContext` normally assumes that no outsider is setting
Expand Down Expand Up @@ -820,10 +820,12 @@ py::class_<GrDirectContext, sk_sp<GrDirectContext>, GrRecordingContext>(m, "GrCo
// "traceMemoryDump.")
.def("supportsDistanceFieldText", &GrDirectContext::supportsDistanceFieldText)
.def("storeVkPipelineCacheData", &GrDirectContext::storeVkPipelineCacheData)
/*
.def_static("ComputeImageSize", &GrDirectContext::ComputeImageSize,
.def_static("ComputeImageSize",
[] (sk_sp<SkImage> image, GrMipmapped mapped, bool useNextPow2) {
// REVISIT: process GrMipmapped and useNextPow2 = true
return image->textureSize();
},
py::arg("image"), py::arg("mipMapped"), py::arg("useNextPow2") = false)
*/
.def("defaultBackendFormat", &GrDirectContext::defaultBackendFormat,
R"docstring(
Retrieve the default :py:class:`GrBackendFormat` for a given
Expand Down Expand Up @@ -1195,7 +1197,7 @@ py::class_<GrDirectContext, sk_sp<GrDirectContext>, GrRecordingContext>(m, "GrCo
)docstring")
;

m.attr("GrDirectContext") = m.attr("GrContext");
m.attr("GrContext") = m.attr("GrDirectContext");

initGrContext_gl(m);
initGrContext_vk(m);
Expand Down
Loading

0 comments on commit d13a801

Please sign in to comment.