Skip to content

Commit

Permalink
Merge pull request #222 from HinTak/m121-public
Browse files Browse the repository at this point in the history
M121 public
  • Loading branch information
HinTak authored Jan 26, 2024
2 parents 8025331 + 4f91ec1 commit 2e41f21
Show file tree
Hide file tree
Showing 20 changed files with 441 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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-m120-minimize-download.patch && python tools/git-sync-deps && patch -p1 -R -i ../patch/skia-m120-minimize-download.patch
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
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Build skia 3rd-Party
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ 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.m120](relnotes/README.m120.md), [README.m121](relnotes/README.m121.md).

## Contributing

Expand Down
236 changes: 236 additions & 0 deletions patch/skia-m121-colrv1-freetype.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
diff --git a/modules/canvaskit/canvaskit_bindings.cpp b/modules/canvaskit/canvaskit_bindings.cpp
index 073f853..17b70e3 100644
--- a/modules/canvaskit/canvaskit_bindings.cpp
+++ b/modules/canvaskit/canvaskit_bindings.cpp
@@ -110,6 +110,8 @@
#include "include/core/SkFontMetrics.h"
#include "include/core/SkFontMgr.h"
#include "include/core/SkFontTypes.h"
+enum class FT_Color_Root_Transform_;
+typedef FT_Color_Root_Transform_ FT_Color_Root_Transform; /* freetype/ftcolor.h */
#include "src/ports/SkFontHost_FreeType_common.h"
#ifdef CK_INCLUDE_PARAGRAPH
#include "modules/skparagraph/include/Paragraph.h"
diff --git a/modules/canvaskit/skottie_bindings.cpp b/modules/canvaskit/skottie_bindings.cpp
index d345fe8..dc8bde8 100644
--- a/modules/canvaskit/skottie_bindings.cpp
+++ b/modules/canvaskit/skottie_bindings.cpp
@@ -19,6 +19,8 @@
#include "modules/sksg/include/SkSGInvalidationController.h"
#include "modules/skunicode/include/SkUnicode.h"
#include "src/base/SkUTF.h"
+enum class FT_Color_Root_Transform_;
+typedef FT_Color_Root_Transform_ FT_Color_Root_Transform; /* freetype/ftcolor.h */
#include "src/ports/SkFontHost_FreeType_common.h"
#include "tools/skui/InputState.h"
#include "tools/skui/ModifierKey.h"
diff --git a/modules/skparagraph/utils/TestFontCollection.cpp b/modules/skparagraph/utils/TestFontCollection.cpp
index 9e5374f..b796d7d 100644
--- a/modules/skparagraph/utils/TestFontCollection.cpp
+++ b/modules/skparagraph/utils/TestFontCollection.cpp
@@ -8,6 +8,8 @@
#include "tools/Resources.h"

#if defined(SK_TYPEFACE_FACTORY_FREETYPE)
+enum class FT_Color_Root_Transform_;
+typedef FT_Color_Root_Transform_ FT_Color_Root_Transform; /* freetype/ftcolor.h */
#include "src/ports/SkFontHost_FreeType_common.h"
#elif defined(SK_TYPEFACE_FACTORY_CORETEXT)
#include "src/ports/SkTypeface_mac_ct.h"
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index f2d0927..bf2666c 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -31,6 +31,8 @@
#include "src/sfnt/SkOTTable_OS_2.h"

#ifdef SK_TYPEFACE_FACTORY_FREETYPE
+enum class FT_Color_Root_Transform_;
+typedef FT_Color_Root_Transform_ FT_Color_Root_Transform; /* freetype/ftcolor.h */
#include "src/ports/SkFontHost_FreeType_common.h"
#endif

diff --git a/src/ports/SkFontConfigTypeface.h b/src/ports/SkFontConfigTypeface.h
index 7955049..8551cf7 100644
--- a/src/ports/SkFontConfigTypeface.h
+++ b/src/ports/SkFontConfigTypeface.h
@@ -12,6 +12,8 @@
#include "include/core/SkStream.h"
#include "include/ports/SkFontConfigInterface.h"
#include "src/core/SkFontDescriptor.h"
+enum class FT_Color_Root_Transform_;
+typedef FT_Color_Root_Transform_ FT_Color_Root_Transform; /* freetype/ftcolor.h */
#include "src/ports/SkFontHost_FreeType_common.h"

class SkFontDescriptor;
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 1122283..9b196ca 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -31,7 +31,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/sfnt/SkOTUtils.h"
#include "src/sfnt/SkSFNTHeader.h"
#include "src/sfnt/SkTTCFHeader.h"
@@ -49,6 +48,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 1505cd0..7873a9e 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>
@@ -1577,6 +1577,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 6cba604..92e56af 100644
--- a/src/ports/SkFontHost_FreeType_common.h
+++ b/src/ports/SkFontHost_FreeType_common.h
@@ -29,6 +29,7 @@ typedef struct FT_FaceRec_* FT_Face;
typedef struct FT_StreamRec_* FT_Stream;
typedef signed long FT_Pos;
typedef struct FT_BBox_ FT_BBox;
+typedef unsigned short FT_UShort; /* freetype/fttypes.h */


#ifdef SK_DEBUG
@@ -41,7 +42,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.
@@ -68,7 +77,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;
diff --git a/src/ports/SkFontMgr_android.cpp b/src/ports/SkFontMgr_android.cpp
index 8a93a2e..d3743ba 100644
--- a/src/ports/SkFontMgr_android.cpp
+++ b/src/ports/SkFontMgr_android.cpp
@@ -23,6 +23,8 @@
#include "src/core/SkFontDescriptor.h"
#include "src/core/SkOSFile.h"
#include "src/core/SkTypefaceCache.h"
+enum class FT_Color_Root_Transform_;
+typedef FT_Color_Root_Transform_ FT_Color_Root_Transform; /* freetype/ftcolor.h */
#include "src/ports/SkFontHost_FreeType_common.h"
#include "src/ports/SkFontMgr_android_parser.h"

diff --git a/src/ports/SkFontMgr_custom.cpp b/src/ports/SkFontMgr_custom.cpp
index a0c6693..536f1c2 100644
--- a/src/ports/SkFontMgr_custom.cpp
+++ b/src/ports/SkFontMgr_custom.cpp
@@ -16,6 +16,8 @@
#include "include/private/base/SkTArray.h"
#include "include/private/base/SkTemplates.h"
#include "src/core/SkFontDescriptor.h"
+enum class FT_Color_Root_Transform_;
+typedef FT_Color_Root_Transform_ FT_Color_Root_Transform; /* freetype/ftcolor.h */
#include "src/ports/SkFontHost_FreeType_common.h"
#include "src/ports/SkFontMgr_custom.h"

diff --git a/src/ports/SkFontMgr_custom.h b/src/ports/SkFontMgr_custom.h
index 0de4d1d..b9298dd 100644
--- a/src/ports/SkFontMgr_custom.h
+++ b/src/ports/SkFontMgr_custom.h
@@ -14,6 +14,8 @@
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkTArray.h"
+enum class FT_Color_Root_Transform_;
+typedef FT_Color_Root_Transform_ FT_Color_Root_Transform; /* freetype/ftcolor.h */
#include "src/ports/SkFontHost_FreeType_common.h"

class SkData;
diff --git a/src/ports/SkFontMgr_fontconfig.cpp b/src/ports/SkFontMgr_fontconfig.cpp
index 12b1e95..6d386d9 100644
--- a/src/ports/SkFontMgr_fontconfig.cpp
+++ b/src/ports/SkFontMgr_fontconfig.cpp
@@ -28,6 +28,8 @@
#include "src/core/SkOSFile.h"
#include "src/core/SkScalerContext.h"
#include "src/core/SkTypefaceCache.h"
+enum class FT_Color_Root_Transform_;
+typedef FT_Color_Root_Transform_ FT_Color_Root_Transform; /* freetype/ftcolor.h */
#include "src/ports/SkFontHost_FreeType_common.h"

#include <fontconfig/fontconfig.h>
70 changes: 70 additions & 0 deletions patch/skia-m121-minimize-download.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
diff --git a/DEPS b/DEPS
index 3556177..e9a5c4a 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@fb6b960c0a737d20e9b6907a8da56343fd1fab08",
- "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@7ce5da31c2af7a4461e185117c8ae4799e37d29e",
- "third_party/externals/jinja2" : "https://chromium.googlesource.com/chromium/src/third_party/jinja2@515dd10de9bf63040045902a4a310d2ba25213a0",
- "third_party/externals/markupsafe" : "https://chromium.googlesource.com/chromium/src/third_party/markupsafe@006709ba3ed87660a17bd4548c45663628f5ed85",
- "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@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@4befa3ada54ce2fbdadb2383712da70811efe85e",
"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@26e8d593e8b8a850722b78ac508cdb4a49a54595",
- "third_party/externals/spirv-cross" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/SPIRV-Cross@a3da0e87fa1a6aacdf32c5e729a653b60afe82af",
- "third_party/externals/spirv-headers" : "https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Headers.git@cca08c63cefa129d082abca0302adcb81610b465",
- "third_party/externals/spirv-tools" : "https://skia.googlesource.com/external/github.com/KhronosGroup/SPIRV-Tools.git@0d87845532579ec3787165cc55635c95180463e0",
- "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@19a863ccce773ff393b186329478b1eb1a519fd3",
- "third_party/externals/vulkan-tools" : "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Tools@8718f7f80506b4377d1a37608b532c7c3c54c685",
- "third_party/externals/vulkan-utility-libraries": "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Utility-Libraries@2feac587338c7e1b631b2ef9bd6e894d7ad7f56d",
- "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 2e41f21

Please sign in to comment.