Skip to content

Experimental: Cherry pick Skia types instead of excluding the ones we… #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 14 commits into
base: m92
Choose a base branch
from
Draft
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

[![crates.io](https://img.shields.io/crates/v/skia-safe)](https://crates.io/crates/skia-safe) [![license](https://img.shields.io/crates/l/skia-safe)](LICENSE) [![Build Status](https://dev.azure.com/pragmatrix-github/rust-skia/_apis/build/status/rust-skia.rust-skia?branchName=master)](https://dev.azure.com/pragmatrix-github/rust-skia/_build/latest?definitionId=2&branchName=master)

Skia Submodule Status: chrome/m91 ([upstream changes][skia-upstream], [our changes][skia-ours]).
Skia Submodule Status: chrome/m92 ([upstream changes][skia-upstream], [our changes][skia-ours]).

[skia-upstream]: https://github.com/rust-skia/skia/compare/m91-0.39.3...google:chrome/m91
[skia-ours]: https://github.com/google/skia/compare/chrome/m91...rust-skia:m91-0.39.3
[skia-upstream]: https://github.com/rust-skia/skia/compare/m92-0.40.0...google:chrome/m92
[skia-ours]: https://github.com/google/skia/compare/chrome/m92...rust-skia:m92-0.40.0

## Goals

Expand Down
2 changes: 1 addition & 1 deletion skia-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ doctest = false
# Metadata used from inside the packaged crate that defines where to download skia and depot_tools archives from.
# Note: use short hashes here because of filesystem path size restrictions.
[package.metadata]
skia = "m91-0.39.3"
skia = "m92-0.40.0"
depot_tools = "a110bf6"

[features]
Expand Down
283 changes: 247 additions & 36 deletions skia-bindings/build_support/skia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ pub struct FinalBuildConfiguration {
/// the BuildConfiguration).
pub definitions: Definitions,

/// The binding headers that are used.
pub binding_headers: Vec<PathBuf>,

/// The binding source files to compile.
pub binding_sources: Vec<PathBuf>,

Expand Down Expand Up @@ -421,6 +424,8 @@ impl FinalBuildConfiguration {
files
};

let binding_headers = vec!["src/bindings.h".into()];

let binding_sources = {
let mut sources: Vec<PathBuf> = vec!["src/bindings.cpp".into()];
if features.gl {
Expand Down Expand Up @@ -450,6 +455,7 @@ impl FinalBuildConfiguration {
gn_args,
ninja_files,
definitions: build.definitions.clone(),
binding_headers,
binding_sources,
use_system_libraries,
}
Expand Down Expand Up @@ -738,6 +744,7 @@ fn generate_bindings(build: &FinalBuildConfiguration, output_directory: &Path) {
.raw_line("#![allow(clippy::all)]")
// GrVkBackendContext contains u128 fields on macOS
.raw_line("#![allow(improper_ctypes)]")
.allowlist_recursively(false)
.allowlist_function("C_.*")
.constified_enum(".*Mask")
.constified_enum(".*Flags")
Expand All @@ -746,39 +753,39 @@ fn generate_bindings(build: &FinalBuildConfiguration, output_directory: &Path) {
.constified_enum("GrVkAlloc_Flag")
.constified_enum("GrGLBackendState")
// not used:
.blocklist_type("SkPathRef_Editor")
.blocklist_function("SkPathRef_Editor_Editor")
// .blocklist_type("SkPathRef_Editor")
// .blocklist_function("SkPathRef_Editor_Editor")
// private types that pull in inline functions that cannot be linked:
// https://github.com/rust-skia/rust-skia/issues/318
.raw_line("pub enum GrContext_Base {}")
.blocklist_type("GrContext_Base")
.blocklist_function("GrContext_Base_.*")
.raw_line("pub enum GrImageContext {}")
.blocklist_type("GrImageContext")
.raw_line("pub enum GrImageContextPriv {}")
.blocklist_type("GrImageContextPriv")
.raw_line("pub enum GrContextThreadSafeProxy {}")
.blocklist_type("GrContextThreadSafeProxy")
.blocklist_type("GrContextThreadSafeProxyPriv")
.raw_line("pub enum GrContextThreadSafeProxyPriv {}")
.blocklist_type("GrRecordingContextPriv")
.raw_line("pub enum GrRecordingContextPriv {}")
.blocklist_function("GrRecordingContext_priv.*")
.blocklist_function("GrDirectContext_priv.*")
.blocklist_type("GrContextPriv")
.raw_line("pub enum GrContextPriv {}")
.blocklist_function("GrContext_priv.*")
.blocklist_function("SkDeferredDisplayList_priv.*")
.raw_line("pub enum SkVerticesPriv {}")
.blocklist_type("SkVerticesPriv")
.blocklist_function("SkVertices_priv.*")
.blocklist_function("std::bitset_flip.*")
// .raw_line("pub enum GrContext_Base {}")
// .blocklist_type("GrContext_Base")
// .blocklist_function("GrContext_Base_.*")
// .raw_line("pub enum GrImageContext {}")
// .blocklist_type("GrImageContext")
// .raw_line("pub enum GrImageContextPriv {}")
// .blocklist_type("GrImageContextPriv")
// .raw_line("pub enum GrContextThreadSafeProxy {}")
// .blocklist_type("GrContextThreadSafeProxy")
// .blocklist_type("GrContextThreadSafeProxyPriv")
// .raw_line("pub enum GrContextThreadSafeProxyPriv {}")
// .blocklist_type("GrRecordingContextPriv")
// .raw_line("pub enum GrRecordingContextPriv {}")
// .blocklist_function("GrRecordingContext_priv.*")
// .blocklist_function("GrDirectContext_priv.*")
// .blocklist_type("GrContextPriv")
// .raw_line("pub enum GrContextPriv {}")
// .blocklist_function("GrContext_priv.*")
// .blocklist_function("SkDeferredDisplayList_priv.*")
// .raw_line("pub enum SkVerticesPriv {}")
// .blocklist_type("SkVerticesPriv")
// .blocklist_function("SkVertices_priv.*")
// .blocklist_function("std::bitset_flip.*")
// Vulkan reexports that got swallowed by making them opaque.
// (these can not be allowlisted by a extern "C" function)
.allowlist_type("VkPhysicalDeviceFeatures")
.allowlist_type("VkPhysicalDeviceFeatures2").
// .allowlist_type("VkPhysicalDeviceFeatures")
// .allowlist_type("VkPhysicalDeviceFeatures2").
// m91: These functions are not actually implemented.
blocklist_function("SkCustomTypefaceBuilder_setGlyph[123].*")
.blocklist_function("SkCustomTypefaceBuilder_setGlyph[123].*")
// misc
.allowlist_var("SK_Color.*")
.allowlist_var("kAll_GrBackendState")
Expand All @@ -798,20 +805,38 @@ fn generate_bindings(build: &FinalBuildConfiguration, output_directory: &Path) {
builder
};

for ty in ALLOWLISTED_TYPES {
builder = builder.allowlist_type(ty)
}

for ty in ALLOWED_OPAQUE_TYPES {
builder = builder.allowlist_type(ty).opaque_type(ty)
}

for ty in PRIVATE_TYPES {
builder = builder.raw_line(format!("pub enum {} {{}}", ty));
}

for function in ALLOWLISTED_FUNCTIONS {
builder = builder.allowlist_function(function)
}

for opaque_type in OPAQUE_TYPES {
builder = builder.opaque_type(opaque_type)
}
/*
for opaque_type in OPAQUE_TYPES {
builder = builder.opaque_type(opaque_type)
}
*/

for t in BLOCKLISTED_TYPES {
builder = builder.blocklist_type(t);
}

let mut cc_build = Build::new();

for header in &build.binding_headers {
cargo::rerun_if_changed(header.to_str().unwrap());
}

for source in &build.binding_sources {
cc_build.file(source);
let source = source.to_str().unwrap();
Expand Down Expand Up @@ -928,6 +953,193 @@ fn generate_bindings(build: &FinalBuildConfiguration, output_directory: &Path) {
.expect("Couldn't write bindings!");
}

const ALLOWLISTED_TYPES: &[&str] = &[];

const ALLOWED_OPAQUE_TYPES: &[&str] = &[
"DXGI_FORMAT",
"FILE",
"GrBackendFormat",
"GrBackendSurfaceMutableState",
"GrBackendTexture",
"GrColorFormatDesc",
"GrColorType",
"GrContextOptions",
"GrD3DBackendSurfaceInfo",
"GrD3DResourceStateEnum",
"GrDirectContext",
"GrFlushInfo",
"GrGLBackendTextureInfo",
"GrGLEnum",
"GrGLExtensions",
"GrGLFormat",
"GrGLFrameBufferInfo",
"GrGLInterface",
"GrGLTextureInfo",
"GrMipmapped",
"GrMockTextureInfo",
"GrProtected",
"GrRecordingContext",
"GrSemaphoresSubmitted",
"GrSurfaceOrigin",
"GrVkImageInfo",
"GrVkYcbcrConversionInfo",
"sk_sp",
"Sk3DView",
"SkAlphaType",
"SkApplyPerspectiveClip",
"SkBitmap",
"SkBlendMode",
"SkBlendModeCoeff",
"SkBlurStyle",
"SkBudgeted",
"SkCanvas",
"SkClipOp",
"skcms_.*",
"SkCodec_Options",
"SkCodec_Result",
"SkCodec_SkScanlineOrder",
"SkCodec",
"SkCodecAnimation_.*",
"SkCodecAnimation_Blend",
"SkCodecAnimation_DisposalMethod",
"SkColor",
"SkColor4f",
"SkColorChannelFlag",
"SkColorFilter",
"SkColorInfo",
"SkColorMatrix",
"SkColorSpace",
"SkColorType",
"SkCoverageMode",
"SkCubicMap",
"SkCubicResampler",
"SkCustomTypefaceBuilder",
"SkData",
"SkDataTable",
"SkDeferredDisplayList",
"SkDeferredDisplayListRecorder",
"SkDrawable",
"SkDrawShadowRec",
"SkDynamicMemoryWStream",
"SkEncodedImageFormat",
"SkEncodedInfo",
"SkEncodedOrigin",
"SkFilterMode",
"SkFilterQuality",
"SkFlattenable",
"SkFont",
"SkGlyphID",
"SkGradientShader",
"SkGraphics",
"SkHighContrastConfig",
"SkImage",
"SkImageFilter",
"SkImageFilters_CropRect",
"SkImageGenerator",
"SkImageInfo",
"SkIPoint",
"SkIRect",
"SkISize",
"SkM44",
"SkMask",
"SkMaskFilter",
"SkMatrix",
"SkMemoryStream",
"SkOnce",
"SkOpBuilder",
"SkOrderedFontMgr",
"SkPaint",
"SkParsePath",
"SkPath",
"SkPath1DPathEffect_Style",
"SkPathDirection",
"SkPathEffect",
"SkPathFillType",
"SkPathOp",
"SkPDF_Metadata",
"SkPDF_StructureElementNode",
"SkPicture",
"SkPixelGeometry",
"SkPixmap",
"SkPMColor",
"SkPngChunkReader",
"SkPoint",
"SkPoint3",
"SkRasterHandleAllocator_Handle",
"SkRect",
"SkRefCnt",
"SkRegion",
"SkRRect",
"SkRSXform",
"SkRuntimeEffect",
"SkSamplingOptions",
"SkScalar",
"SkShader_GradientInfo",
"SkShader_GradientType",
"SkShader",
"SkShadowFlags",
"SkSize",
"SkStream",
"SkStreamMemory",
"SkString",
"SkStrings",
"SkStrokeRec",
"SkSurface",
"SkSurfaceCharacterization",
"SkSurfaceProps",
"SkTableMaskFilter",
"SkTextBlob",
"SkTextEncoding",
"SkTextUtils",
"SkTileMode",
"SkUnichar",
"SkV3",
"SkV4",
"SkVector",
"SkVertices",
"SkWStream",
"SkYUVAInfo_PlaneConfig",
"SkYUVAInfo_Subsampling",
"SkYUVAInfo",
"SkYUVAPixmapInfo_SupportedDataTypes",
"SkYUVAPixmapInfo",
"SkYUVAPixmaps",
"SkYUVColorSpace",
"std::atomic",
"std::function",
"std::string",
"std::unique_ptr",
"std::vector",
"U8CPU",
"va_list",
"VkBool32",
"VkFormat",
"VkStructureType",
"SkCodecAnimation::DisposalMethod",
"SkCodecAnimation::Blend",
"GrBackendSurfaceMutableState_.*",
"GrYUVABackendTextures",
"GrMipMapped",
"GrYUVABackendTextureInfo",
];

const PRIVATE_TYPES: &[&str] = &[
"GrVkBackendSurfaceInfo",
"SkReadBuffer",
"SkSerialProcs",
"SkDeserialProcs",
"GrImageContext",
];

const BLOCKLISTED_TYPES: &[&str] = &[
"sk_sp_.*",
"std::atomic_.*",
"std::vector_.*",
"std::unique_ptr_.*",
"std::string_.*",
"std::function_.*",
];

const ALLOWLISTED_FUNCTIONS: &[&str] = &[
"SkAnnotateRectWithURL",
"SkAnnotateNamedDestination",
Expand All @@ -951,11 +1163,6 @@ const ALLOWLISTED_FUNCTIONS: &[&str] = &[
"Simplify",
"TightBounds",
"AsWinding",
// utils/
"Sk3LookAt",
"Sk3Perspective",
"Sk3MapPts",
"SkUnitCubicInterp",
];

const OPAQUE_TYPES: &[&str] = &[
Expand Down Expand Up @@ -1071,8 +1278,11 @@ const OPAQUE_TYPES: &[&str] = &[
"GrD3DMemoryAllocator",
// m87, yuva_pixmaps
"std::tuple",
// m92: referred, but yet unused
"SkFontDescriptor",
];

/*
const BLOCKLISTED_TYPES: &[&str] = &[
// modules/skparagraph
// pulls in a std::map<>, which we treat as opaque, but bindgen creates wrong bindings for
Expand All @@ -1092,6 +1302,7 @@ const BLOCKLISTED_TYPES: &[&str] = &[
"std::__cxx.*",
"std::array.*",
];
*/

#[derive(Debug)]
struct ParseCallbacks;
Expand Down
2 changes: 1 addition & 1 deletion skia-bindings/skia
Submodule skia updated 1782 files
Loading