Move SkiaSharp C API (src/c) out of upstream :core into libSkiaSharp - #251
Open
mattleibow wants to merge 4 commits into
Open
Move SkiaSharp C API (src/c) out of upstream :core into libSkiaSharp#251mattleibow wants to merge 4 commits into
mattleibow wants to merge 4 commits into
Conversation
mattleibow
force-pushed
the
dev/move-capi-to-libskiasharp
branch
from
June 11, 2026 11:17
1eccf44 to
bcd38b1
Compare
There was a problem hiding this comment.
Pull request overview
This PR moves SkiaSharp’s fork-owned C API shim (src/c/*.cpp and include/c/*.h) out of upstream Skia’s :core target and into the skiasharp_build("SkiaSharp") target (libSkiaSharp), so the shim’s build inputs/defines come from SkiaSharp’s own GN dependency graph instead of upstream :core.
Changes:
- Removed SkiaSharp C API sources/headers from
gn/core.gniso upstream:coreno longer compiles or exports the shim. - Updated
BUILD.gnsoskiasharp_build("SkiaSharp")owns the shim sources/headers, adds the needed deps, and adds a strict deprecation-as-error warnings config. - Updated
src/c/sk_path.cppto use the newerstd::optionalpathops APIs and avoid deprecatedSkPathOps::TightBounds.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/c/sk_path.cpp |
Replaces deprecated pathops calls with std::optional-based APIs and computeTightBounds() logic. |
gn/core.gni |
Removes the fork block that injected SkiaSharp C shim headers/sources into upstream :core. |
BUILD.gn |
Moves shim sources/headers into skiasharp_build("SkiaSharp"), adds deps, and enforces deprecation warnings as errors for the shim. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+4042
to
+4046
| "modules/jsonreader", | ||
| "modules/skottie", | ||
| "modules/skresources", | ||
| "modules/sksg", | ||
| ] |
Comment on lines
+4125
to
+4129
| "src/c/gr_context.cpp", | ||
| "src/c/sk_linker.cpp", | ||
| "src/c/skottie_animation.cpp", | ||
| "src/c/skresources_resource_provider.cpp", | ||
| "src/c/sksg_invalidation_controller.cpp", |
Compile the fork-owned C API shim (src/c/*.cpp) and its public headers
(include/c/*.h) in skiasharp_build("SkiaSharp") instead of injecting them
into upstream :core via gn/core.gni. libSkiaSharp deps directly on the
font-manager optional() targets and the modules the shim needs, so the
shim sees its public_defines (e.g. SK_FONTMGR_FONTCONFIG_AVAILABLE) and
GPU backend defines from its own dependency graph rather than riding on
:core's milestone-churning transitive deps.
Now that src/c no longer compiles in :core, remove the two fork
workarounds that only existed to feed it: the manual GPU defines block
(SK_VULKAN/SK_METAL/SK_DIRECT3D + use_skia_vulkan_headers) and the m148
fontconfig dep block (commit 029229d). Upstream :core's own sources
do not need these.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…SkiaSharp sources sk_path.cpp called the [[deprecated]] SkPathOps TightBounds() helper, which m148 marked deprecated. Inline its exact computeTightBounds() body instead so the C API shim no longer consumes a deprecated Skia API. The deprecation only failed Tizen's hand-written -Werror makefile build because the skiasharp_build GN template bypasses Skia's skia_target_default_configs, so //gn/skia:warnings (and thus -Wall/-Wextra) never reached our sources. Add :warnings for parity and a new :skiasharp_strict config (listed last) that forces -Werror=deprecated-declarations over the :warnings suppression, so any future deprecated-API use in src/c fails on every platform, not just Tizen. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
sk_path.cpp also used the // DEPRECATED bool/out-param overloads of Op, Simplify, AsWinding and SkOpBuilder::resolve. Unlike TightBounds these are only comment-deprecated (no [[deprecated]] attribute) so the compiler did not flag them, but upstream wants callers off them. Migrate all four to the std::optional<SkPath> returning forms, preserving the existing write-to-result + return-bool C API semantics. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
sk_linker.h, skottie_animation.h, skresources_resource_provider.h, and sksg_invalidation_controller.h were never in the C API public header list (carried over from the original gn/core.gni fork block). Now that :SkiaSharp owns the C API surface, complete the public header metadata so GN consumers and gn check see the full surface. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mattleibow
force-pushed
the
dev/move-capi-to-libskiasharp
branch
from
June 12, 2026 22:33
4f9d7c6 to
db4f1e9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves SkiaSharp's fork-owned C API shim (
src/c/*.cpp+include/c/*.h) out of upstream Skia's:coreGN target and into theskiasharp_build("SkiaSharp")target (libSkiaSharp). This cleanly separates "Skia stuff" (upstream) from "SkiaSharp stuff" (our shim), shrinks the fork diff in upstream-owned files, and permanently fixes a class of "lostpublic_definewhen upstream reshuffles:coredeps" bugs.Companion parent-repo PR: mono/SkiaSharp#4131 (bumps this submodule + updates the non-GN Apple/Tizen builds).
Motivation
In the m148 update, upstream commit
029229d8be("Simplify gn typeface related deps") moved the:fontmgr_*targets off:coreand onto:skia. Oursrc/c/sk_typeface.cppselects the Linux default font manager behind#elif defined(SK_FONTMGR_FONTCONFIG_AVAILABLE)— apublic_defineemitted by:fontmgr_fontconfig. Becausesrc/cwas injected into:core(viaskia_core_sources += [...]ingn/core.gni) and upstream dropped:fontmgr_fontconfigfrom:core's deps, the define vanished from our compile →sk_fontmgr_create_default()silently returned an empty font manager → 0 fonts on Linux.skiasharp_build("SkiaSharp")already deps on:skia, which lists:fontmgr_fontconfigin itspublic_deps. GN propagates a dependency'spublic_config(carryingpublic_defines) transitively throughpublic_deps. So compilingsrc/cinlibSkiaSharpmakes it automatically seeSK_FONTMGR_FONTCONFIG_AVAILABLE, the fontconfig include path, andSkFontMgr_New_FontConfig— via one existing edge, with no:corepatch.Changes
gn/core.gniskia_core_sources += [ "$_src/c/*.cpp" ... ](all 40src/csources +sk_types_priv.h).skia_core_public_headers += [ "$_include/c/*.h" ]block.:coreno longer compiles or references any of our shim.BUILD.gnskiasharp_build("SkiaSharp")now owns thesrc/c/*.cppsources (alongside the existingsrc/xamarin/*.cpp), theinclude/c/*.hpublic headers, and explicitdeps/public_depsfor everything those files need to compile that previously arrived transitively via:core:optional()(fontconfig/CoreText/DirectWrite/Android/FCI) so the rightSK_FONTMGR_*_AVAILABLEdefines reachsk_typeface.cppper platform,modules/skottie,modules/skresources,modules/sksgforskottie_animation.cpp/skresources_resource_provider.cpp/sksg_invalidation_controller.cpp,gr_context.cpp.gn/core.gnifork block never listedsk_linker.h,skottie_animation.h,skresources_resource_provider.h, orsksg_invalidation_controller.h, even though their.cppare compiled. Now that:SkiaSharpis the GN owner of the C API surface, these four are added topublicso the target metadata (andgn check) sees the full surface.:corefork workarounds that only existed becausesrc/ccompiled in:core: the GPU-defines block and theif (skia_enable_fontmgr_fontconfig) { deps += [ ":fontmgr_fontconfig" ] }block (the029229d8beworkaround). After the move:coreno longer compilessk_typeface.cpp, so it no longer needs the define.skiasharp_buildtemplate bypasses Skia'sskia_target_default_configs, so//gn/skia:warnings(and thus-Wall/-Wextra) never reached our sources — deprecated-API usage compiled silently on every GN platform and only surfaced on Tizen's hand-written-Werrorbuild. Now the target adds//gn/skia:warningsfor parity, plus a new:skiasharp_strictconfig (listed last so it wins over:warnings'-Wno-deprecated-declarations) that forces-Werror=deprecated-declarations(/we4996on MSVC). Any future deprecated-Skia-API use insrc/cnow fails the build on every platform.src/c/sk_path.cpp— deprecation fixessk_pathop_tight_bounds: was calling the[[deprecated]]SkPathOps::TightBounds; now callsSkPath::computeTightBounds()directly (identical semantics).// DEPRECATEDbool/out-param overloads to the newstd::optional<SkPath>API, preserving the C API's write-to-result + return-bool contract:Op,Simplify,AsWinding, andSkOpBuilder::resolve.Validation
sk_*C API symbols, Metal symbols present.Fc*undefined symbols present in the.so(was 0 when broken).TightBoundsfix makes the build fail witherror: 'TightBounds' is deprecated [-Werror,-Wdeprecated-declarations]; restoring it builds clean.SKTypefaceTest.DefaultIsNotEmpty,SKFontManagerTest, text measurement — are the key regression guard).Notes
:coreworkarounds (done here).