Skip to content

Commit

Permalink
Merge pull request #236 from HinTak/m124-public
Browse files Browse the repository at this point in the history
M124 public
  • Loading branch information
HinTak committed Apr 30, 2024
2 parents a9ce10f + fe2df88 commit 4faf14d
Show file tree
Hide file tree
Showing 25 changed files with 664 additions and 52 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ jobs:
name: Build skia bundled 3rd-party on linux/aarch64
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/cache@v3
- uses: actions/cache@v4
id: cache-skia
with:
path: |
gn
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-m121-minimize-download.patch && python tools/git-sync-deps && patch -p1 -R -i ../patch/skia-m121-minimize-download.patch
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
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Build skia 3rd-Party
# Taken from https://github.com/pypa/cibuildwheel/blob/v2.16.2/cibuildwheel/resources/pinned_docker_images.cfg
uses: docker://quay.io/pypa/manylinux2014_aarch64:2023-10-03-72cdc42
Expand All @@ -41,24 +41,24 @@ jobs:
needs: prebuild_linux_aarch64_3rd_party
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/cache@v3
- uses: actions/cache@v4
id: cache-skia
with:
path: |
gn
skia
key: linux-aarch64-skia-${{ github.sha }}
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: |
gn
skia
key: linux-aarch64-skia-${{ github.sha }}-3rd-party
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Build Skia Proper
uses: docker://quay.io/pypa/manylinux2014_aarch64:2023-10-03-72cdc42
with:
Expand Down Expand Up @@ -100,11 +100,11 @@ jobs:
cp: cp312

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
if: runner.os == 'Linux' && matrix.arch == 'aarch64'
with:
path: |
Expand All @@ -114,12 +114,12 @@ jobs:

- name: Set up QEMU
if: runner.os == 'Linux' && matrix.arch == 'aarch64'
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ matrix.arch }}

- name: Build wheels
uses: pypa/[email protected].2
uses: pypa/[email protected].5
env:
CIBW_BUILD: "${{ matrix.cp }}-*"
CIBW_SKIP: "*musllinux*"
Expand All @@ -144,7 +144,7 @@ jobs:
needs: [build_wheels]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
name: Install Python
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,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.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).

## Contributing

Expand Down
119 changes: 119 additions & 0 deletions patch/skia-m122-colrv1-freetype.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 7e096a6..46fe7a0 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -33,7 +33,6 @@
#include "src/core/SkMask.h"
#include "src/core/SkMaskGamma.h"
#include "src/core/SkScalerContext.h"
-#include "src/ports/SkFontHost_FreeType_common.h"
#include "src/ports/SkTypeface_FreeType.h"
#include "src/sfnt/SkOTUtils.h"
#include "src/sfnt/SkSFNTHeader.h"
@@ -52,6 +51,7 @@
#ifdef FT_COLOR_H // 2.10.0
# include <freetype/ftcolor.h>
#endif
+#include "src/ports/SkFontHost_FreeType_common.h"
#include <freetype/freetype.h>
#include <freetype/ftlcdfil.h>
#include <freetype/ftmodapi.h>
diff --git a/src/ports/SkFontHost_FreeType_common.cpp b/src/ports/SkFontHost_FreeType_common.cpp
index 14b2adb..f041583 100644
--- a/src/ports/SkFontHost_FreeType_common.cpp
+++ b/src/ports/SkFontHost_FreeType_common.cpp
@@ -6,7 +6,6 @@
* found in the LICENSE file.
*/

-#include "src/ports/SkFontHost_FreeType_common.h"

#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
@@ -32,6 +31,7 @@
#ifdef FT_COLOR_H
# include <freetype/ftcolor.h>
#endif
+#include "src/ports/SkFontHost_FreeType_common.h"
#include <freetype/ftimage.h>
#include <freetype/ftoutln.h>
#include <freetype/ftsizes.h>
@@ -1574,6 +1574,41 @@ bool SkScalerContext_FreeType_Base::drawCOLRv1Glyph(FT_Face face,
SkASSERTF(haveLayers, "Could not get COLRv1 layers from '%s'.", face->family_name);
return haveLayers;
}
+/*
+ * This content is mostly just
+ * SkTypeface_FreeType::FaceRec::setupPalette()
+ + + SkScalerContext_FreeType_Base::drawCOLRv1Glyph()
+ +*/
+bool SkScalerContext_FreeType_Base::skia_colrv1_start_glyph(SkCanvas* canvas,
+ FT_Face face,
+ uint16_t glyphId,
+ FT_UShort palette_index,
+ FT_Color_Root_Transform rootTransform
+ ) {
+ uint32_t fForegroundColor{SK_ColorBLACK};
+ FT_Palette_Data paletteData;
+ FT_Palette_Data_Get(face, &paletteData);
+
+ FT_Color* ftPalette = nullptr;
+ FT_Palette_Select(face, palette_index, &ftPalette);
+ std::unique_ptr<SkColor[]> ptr_palette(new SkColor[paletteData.num_palette_entries]);
+ for (int i = 0; i < paletteData.num_palette_entries; ++i) {
+ ptr_palette[i] = SkColorSetARGB(ftPalette[i].alpha,
+ ftPalette[i].red,
+ ftPalette[i].green,
+ ftPalette[i].blue);
+ }
+ SkSpan<SkColor> palette(ptr_palette.get(), paletteData.num_palette_entries);
+
+ VisitedSet activePaints;
+ bool haveLayers = colrv1_start_glyph(canvas, palette,
+ fForegroundColor, // FT_Palette_Get_Foreground_Color?
+ face, glyphId,
+ FT_COLOR_INCLUDE_ROOT_TRANSFORM,
+ &activePaints);
+ SkASSERTF(haveLayers, "Could not get COLRv1 layers from '%s'.", face->family_name);
+ return haveLayers;
+}
#endif // TT_SUPPORT_COLRV1

#ifdef FT_COLOR_H
diff --git a/src/ports/SkFontHost_FreeType_common.h b/src/ports/SkFontHost_FreeType_common.h
index d649784..1100b0e 100644
--- a/src/ports/SkFontHost_FreeType_common.h
+++ b/src/ports/SkFontHost_FreeType_common.h
@@ -19,6 +19,7 @@
typedef struct FT_FaceRec_* FT_Face;
typedef struct FT_StreamRec_* FT_Stream;
typedef signed long FT_Pos;
+typedef unsigned short FT_UShort; /* freetype/fttypes.h */


#ifdef SK_DEBUG
@@ -31,7 +32,15 @@ const char* SkTraceFtrGetError(int);
#endif


-class SkScalerContext_FreeType_Base : public SkScalerContext {
+class SK_SPI SkScalerContext_FreeType_Base : public SkScalerContext {
+public:
+ static bool computeColrV1GlyphBoundingBox(FT_Face, SkGlyphID, SkRect* bounds);
+ static bool skia_colrv1_start_glyph(SkCanvas* canvas,
+ FT_Face face,
+ uint16_t glyphId,
+ FT_UShort palette_index,
+ FT_Color_Root_Transform rootTransform
+ );
protected:
// See http://freetype.sourceforge.net/freetype2/docs/reference/ft2-bitmap_handling.html#FT_Bitmap_Embolden
// This value was chosen by eyeballing the result in Firefox and trying to match it.
@@ -57,7 +66,6 @@ protected:
* configure size, matrix and load glyphs as needed after using this function to restore the
* state of FT_Face.
*/
- static bool computeColrV1GlyphBoundingBox(FT_Face, SkGlyphID, SkRect* bounds);

struct ScalerContextBits {
static const constexpr uint32_t COLRv0 = 1;
70 changes: 70 additions & 0 deletions patch/skia-m122-minimize-download.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
diff --git a/DEPS b/DEPS
index bd7ed9d..8180821 100644
--- a/DEPS
+++ b/DEPS
@@ -23,53 +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@c6fbf93decbac74cd14c6ca3d600d4ed91d1179d",
- "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@5b45794c2c24c3fa40dc480af92c5284a95423ef",
- "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@45903920b984540bb629bc89f4c010159c23a89a",
"third_party/externals/harfbuzz" : "https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@4cfc6d8e173e800df086d7be078da2e8c5cfca19",
- "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@4f81635489681ecf7707623177123cb78d6a66a0",
- "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@386707c6d19b974ca2e3db7f5c61873813c6fe44",
"third_party/externals/libwebp" : "https://chromium.googlesource.com/webm/libwebp.git@2af26267cdfcb63a88e5c74a85927a12d6ca1d76",
- "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@328e794f0c8bddc81c834ccc89c9652902f643cb",
"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@4307b0183c9e16bc920ef0bceaa9e9d630c352c3",
- "third_party/externals/spirv-cross" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/SPIRV-Cross@b82536766d1b81631b126d1ddbe49baf42929bd3",
- "third_party/externals/spirv-headers" : "https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Headers.git@7b0309708da5126b89e4ce6f19835f36dc912f2f",
- "third_party/externals/spirv-tools" : "https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Tools.git@3e6bdd0f99655b1bc6a54aa73e5bfaaa4252198b",
- "third_party/externals/vello" : "https://skia.googlesource.com/external/github.com/linebender/vello.git@ee3a076b291d206c361431cc841407adf265c692",
"third_party/externals/vulkan-headers" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Headers@217e93c664ec6704ec2d8c36fa116c1a4a1e2d40",
- "third_party/externals/vulkan-tools" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Tools@7c6d640a5ca3ab73c1f42d22312f672b54babfaf",
- "third_party/externals/vulkan-utility-libraries": "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Utility-Libraries@4cfc176e3242b4dbdfd3f6c5680c5d8f2cb7db45",
- "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 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
Loading

0 comments on commit 4faf14d

Please sign in to comment.