Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 148 additions & 34 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1887,26 +1887,6 @@ skia_source_set("core") {
public = skia_core_public
sources = skia_core_sources

# mono/skia: SkiaSharp's C API shims (src/c/gr_context.cpp et al.) are
# compiled into :core via gn/core.gni, but Skia's backend defines live on
# :gpu's all_dependent_configs and therefore don't reach :core. Without
# them, SK_ONLY_DIRECT3D / SK_ONLY_VULKAN / SK_ONLY_METAL collapse to
# stub returns, GPU context factory C entry points never reference
# backend symbols, and the linker strips d3d12/vulkan/metal imports
# from libSkiaSharp. :core's own compile needs the defines; its
# dependents already inherit them from :gpu's chain.
defines = []
if (skia_use_direct3d) {
defines += [ "SK_DIRECT3D" ]
}
if (skia_use_vulkan) {
defines += [ "SK_VULKAN" ]
configs += [ ":use_skia_vulkan_headers" ]
}
if (skia_use_metal) {
defines += [ "SK_METAL" ]
}

# These deps don't belong to :core, but they are currently needed to support (de)serialization.
deps = [
":fontmgr_mac_ct",
Expand All @@ -1917,20 +1897,6 @@ skia_source_set("core") {
":typeface_fontations",
":typeface_freetype",
]

# mono/skia: SkiaSharp compiles its C API (src/c/sk_typeface.cpp) into :core
# via gn/core.gni. That code selects the Linux default SkFontMgr behind
# `#elif defined(SK_FONTMGR_FONTCONFIG_AVAILABLE)`, a public_define carried by
# :fontmgr_fontconfig that also supplies the <fontconfig/fontconfig.h> include
# path and the SkFontMgr_New_FontConfig symbol. Upstream m148
# (commit 029229d8be "Simplify gn typeface related deps") intentionally moved
# the fontmgr targets off :core, keeping them only on :skia — correct upstream,
# but it strips the define from our C API's compile, so sk_fontmgr_create_default
# silently falls back to an empty font manager on Linux. Add it back here only
# for the fork; the list above is left identical to upstream to keep merges clean.
if (skia_enable_fontmgr_fontconfig) {
deps += [ ":fontmgr_fontconfig" ]
}
}

skia_component("skia") {
Expand Down Expand Up @@ -4023,10 +3989,43 @@ if (skia_build_rust_targets) {

# SkiaSharp + HarfBuzzSharp

# mono/skia: strict-warnings config applied to libSkiaSharp's own sources
# (src/c + src/xamarin). It promotes deprecated-declarations to a hard error so
# the C API shim can never silently compile against a deprecated Skia API. It is
# applied AFTER //gn/skia:warnings on the target so this -Werror=… wins over that
# config's -Wno-deprecated-declarations (clang uses last-flag-wins), and it is
# unconditional (not gated on the `werror` arg) so the guard holds on every
# platform and in every build configuration.
config("skiasharp_strict") {
if (is_win) {
# MSVC: C4996 is the deprecation warning; /we4996 promotes it to an error.
cflags = [ "/we4996" ]
} else {
cflags = [ "-Werror=deprecated-declarations" ]
}
}

skiasharp_build("SkiaSharp") {
public_configs = [ ":skia_public" ]
configs += skia_library_configs

# mono/skia: libSkiaSharp is built via the custom skiasharp_build template,
# which (unlike Skia's skia_* templates) does not pull in Skia's
# skia_target_default_configs, so the //gn/skia:warnings config never reached
# our shim — that is why -Wall/-Wextra were absent here and deprecated API
# usage in src/c (e.g. SkPathOps TightBounds) compiled silently on every GN
# platform, surfacing only on Tizen's hand-written -Werror makefile build.
# Add :warnings for -Wall/-Wextra parity with upstream, then force
# deprecated-declarations back to a hard error: :warnings deliberately
# suppresses it (-Wno-deprecated-declarations) for Skia's own sources, but
# OUR shim must never consume deprecated Skia APIs. :skiasharp_strict is listed
# last so its -Werror=deprecated-declarations wins over that suppression, and
# it does so regardless of the global `werror` arg (which our build never sets).
configs += [
"//gn/skia:warnings",
":skiasharp_strict",
]

if (skia_use_vulkan) {
configs += [ ":use_skia_vulkan_headers" ]
}
Expand All @@ -4041,10 +4040,125 @@ skiasharp_build("SkiaSharp") {
# sk_pathop_simplify, sk_pathop_tight_bounds, sk_pathop_as_winding,
# SkOpBuilder) so we need it linked into libSkiaSharp.so directly.
":pathops",

# mono/skia: SkiaSharp's C API shim (src/c/*.cpp) is compiled in THIS
# target (not upstream's :core). The font managers that sk_typeface.cpp
# selects per-platform are depended on directly so its public_defines
# (e.g. SK_FONTMGR_FONTCONFIG_AVAILABLE, emitted via optional()'s
# all_dependent_configs) come from libSkiaSharp's own dependency graph
# instead of riding on :core's churning transitive deps. These are
# optional() targets — empty/harmless on platforms where they're disabled.
":fontmgr_FontConfigInterface",
":fontmgr_android",
":fontmgr_android_ndk",
":fontmgr_custom_directory",
":fontmgr_custom_embedded",
":fontmgr_custom_empty",
":fontmgr_fontations_empty",
":fontmgr_fontconfig",
":fontmgr_mac_ct",
":fontmgr_win",
":fontmgr_win_gdi",

# mono/skia: modules used directly by the C API shim. skottie pulls
# jsonreader/skresources/sksg in transitively, but the shim includes
# their headers/symbols directly (sk_linker.cpp -> jsonreader;
# skresources_resource_provider.cpp -> skresources;
# sksg_invalidation_controller.cpp -> sksg) so depend on them explicitly.
"modules/jsonreader",
"modules/skottie",
"modules/skresources",
"modules/sksg",
]
Comment on lines +4068 to +4072

# mono/skia: C API public headers (moved out of upstream's :core).
public = [
"include/c/sk_bitmap.h",
"include/c/sk_blender.h",
"include/c/sk_canvas.h",
"include/c/sk_codec.h",
"include/c/sk_colorfilter.h",
"include/c/sk_colorspace.h",
"include/c/sk_data.h",
"include/c/sk_document.h",
"include/c/sk_drawable.h",
"include/c/sk_font.h",
"include/c/sk_general.h",
"include/c/sk_graphics.h",
"include/c/sk_image.h",
"include/c/sk_imagefilter.h",
"include/c/sk_maskfilter.h",
"include/c/sk_matrix.h",
"include/c/sk_paint.h",
"include/c/sk_path.h",
"include/c/sk_pathbuilder.h",
"include/c/sk_patheffect.h",
"include/c/sk_picture.h",
"include/c/sk_pixmap.h",
"include/c/sk_region.h",
"include/c/sk_rrect.h",
"include/c/sk_runtimeeffect.h",
"include/c/sk_shader.h",
"include/c/sk_stream.h",
"include/c/sk_string.h",
"include/c/sk_surface.h",
"include/c/sk_svg.h",
"include/c/sk_textblob.h",
"include/c/sk_typeface.h",
"include/c/sk_types.h",
"include/c/sk_vertices.h",
"include/c/gr_context.h",
"include/c/sk_linker.h",
"include/c/skottie_animation.h",
"include/c/skresources_resource_provider.h",
"include/c/sksg_invalidation_controller.h",
]

sources = [
# mono/skia: C API shim implementation (moved out of upstream's :core).
"src/c/sk_bitmap.cpp",
"src/c/sk_blender.cpp",
"src/c/sk_canvas.cpp",
"src/c/sk_codec.cpp",
"src/c/sk_colorfilter.cpp",
"src/c/sk_colorspace.cpp",
"src/c/sk_data.cpp",
"src/c/sk_document.cpp",
"src/c/sk_drawable.cpp",
"src/c/sk_enums.cpp",
"src/c/sk_font.cpp",
"src/c/sk_general.cpp",
"src/c/sk_graphics.cpp",
"src/c/sk_image.cpp",
"src/c/sk_imagefilter.cpp",
"src/c/sk_maskfilter.cpp",
"src/c/sk_matrix.cpp",
"src/c/sk_paint.cpp",
"src/c/sk_path.cpp",
"src/c/sk_pathbuilder.cpp",
"src/c/sk_patheffect.cpp",
"src/c/sk_picture.cpp",
"src/c/sk_pixmap.cpp",
"src/c/sk_region.cpp",
"src/c/sk_rrect.cpp",
"src/c/sk_runtimeeffect.cpp",
"src/c/sk_shader.cpp",
"src/c/sk_stream.cpp",
"src/c/sk_string.cpp",
"src/c/sk_structs.cpp",
"src/c/sk_surface.cpp",
"src/c/sk_svg.cpp",
"src/c/sk_textblob.cpp",
"src/c/sk_typeface.cpp",
"src/c/sk_types_priv.h",
"src/c/sk_vertices.cpp",
"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",
Comment on lines +4155 to +4159

# mono/skia: managed-interop shims.
"src/xamarin/sk_compatpaint.cpp",
"src/xamarin/sk_manageddrawable.cpp",
"src/xamarin/sk_managedstream.cpp",
Expand Down
83 changes: 0 additions & 83 deletions gn/core.gni
Original file line number Diff line number Diff line change
Expand Up @@ -805,86 +805,3 @@ skia_android_core_srcs = [

# Generated by Bazel rule //include/android:animated_image_hdrs
skia_android_core_hdrs = [ "$_include/android/SkAnimatedImage.h" ]

# SkiaSharp C API additions (mono/skia fork)
skia_core_public += [
"$_include/c/sk_bitmap.h",
"$_include/c/sk_blender.h",
"$_include/c/sk_canvas.h",
"$_include/c/sk_codec.h",
"$_include/c/sk_colorfilter.h",
"$_include/c/sk_colorspace.h",
"$_include/c/sk_data.h",
"$_include/c/sk_document.h",
"$_include/c/sk_drawable.h",
"$_include/c/sk_font.h",
"$_include/c/sk_general.h",
"$_include/c/sk_graphics.h",
"$_include/c/sk_image.h",
"$_include/c/sk_imagefilter.h",
"$_include/c/sk_maskfilter.h",
"$_include/c/sk_matrix.h",
"$_include/c/sk_paint.h",
"$_include/c/sk_path.h",
"$_include/c/sk_pathbuilder.h",
"$_include/c/sk_patheffect.h",
"$_include/c/sk_picture.h",
"$_include/c/sk_pixmap.h",
"$_include/c/sk_region.h",
"$_include/c/sk_rrect.h",
"$_include/c/sk_runtimeeffect.h",
"$_include/c/sk_shader.h",
"$_include/c/sk_stream.h",
"$_include/c/sk_string.h",
"$_include/c/sk_surface.h",
"$_include/c/sk_svg.h",
"$_include/c/sk_textblob.h",
"$_include/c/sk_typeface.h",
"$_include/c/sk_types.h",
"$_include/c/sk_vertices.h",
"$_include/c/gr_context.h",
]

skia_core_sources += [
"$_src/c/sk_bitmap.cpp",
"$_src/c/sk_blender.cpp",
"$_src/c/sk_canvas.cpp",
"$_src/c/sk_codec.cpp",
"$_src/c/sk_colorfilter.cpp",
"$_src/c/sk_colorspace.cpp",
"$_src/c/sk_data.cpp",
"$_src/c/sk_document.cpp",
"$_src/c/sk_drawable.cpp",
"$_src/c/sk_enums.cpp",
"$_src/c/sk_font.cpp",
"$_src/c/sk_general.cpp",
"$_src/c/sk_graphics.cpp",
"$_src/c/sk_image.cpp",
"$_src/c/sk_imagefilter.cpp",
"$_src/c/sk_maskfilter.cpp",
"$_src/c/sk_matrix.cpp",
"$_src/c/sk_paint.cpp",
"$_src/c/sk_path.cpp",
"$_src/c/sk_pathbuilder.cpp",
"$_src/c/sk_patheffect.cpp",
"$_src/c/sk_picture.cpp",
"$_src/c/sk_pixmap.cpp",
"$_src/c/sk_region.cpp",
"$_src/c/sk_rrect.cpp",
"$_src/c/sk_runtimeeffect.cpp",
"$_src/c/sk_shader.cpp",
"$_src/c/sk_stream.cpp",
"$_src/c/sk_string.cpp",
"$_src/c/sk_structs.cpp",
"$_src/c/sk_surface.cpp",
"$_src/c/sk_svg.cpp",
"$_src/c/sk_textblob.cpp",
"$_src/c/sk_typeface.cpp",
"$_src/c/sk_types_priv.h",
"$_src/c/sk_vertices.cpp",
"$_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",
]
31 changes: 26 additions & 5 deletions src/c/sk_path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,36 @@ int sk_path_convert_conic_to_quads(const sk_point_t* p0, const sk_point_t* p1, c
// Path Ops

bool sk_pathop_op(const sk_path_t* one, const sk_path_t* two, sk_pathop_t op, sk_path_t* result) {
return Op(*AsPath(one), *AsPath(two), (SkPathOp)op, AsPath(result));
if (auto res = Op(*AsPath(one), *AsPath(two), (SkPathOp)op)) {
*AsPath(result) = *res;
return true;
}
return false;
}

bool sk_pathop_simplify(const sk_path_t* path, sk_path_t* result) {
return Simplify(*AsPath(path), AsPath(result));
if (auto res = Simplify(*AsPath(path))) {
*AsPath(result) = *res;
return true;
}
return false;
}

bool sk_pathop_tight_bounds(const sk_path_t* path, sk_rect_t* result) {
return TightBounds(*AsPath(path), AsRect(result));
auto rect = AsPath(path)->computeTightBounds();
if (rect.isFinite()) {
*AsRect(result) = rect;
return true;
}
return false;
}

bool sk_pathop_as_winding(const sk_path_t* path, sk_path_t* result) {
return AsWinding(*AsPath(path), AsPath(result));
if (auto res = AsWinding(*AsPath(path))) {
*AsPath(result) = *res;
return true;
}
return false;
}

sk_opbuilder_t* sk_opbuilder_new(void) {
Expand All @@ -206,7 +223,11 @@ void sk_opbuilder_add(sk_opbuilder_t* builder, const sk_path_t* path, sk_pathop_
}

bool sk_opbuilder_resolve(sk_opbuilder_t* builder, sk_path_t* result) {
return AsOpBuilder(builder)->resolve(AsPath(result));
if (auto res = AsOpBuilder(builder)->resolve()) {
*AsPath(result) = *res;
return true;
}
return false;
}

// Path Measure
Expand Down