Skip to content
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

Extract the FemtoVG renderer into a separate crate #2142

Merged
merged 1 commit into from
Mar 6, 2023

Conversation

tronical
Copy link
Member

This will be needed for a future experiment. Unlike the Skia renderer, which operates on raw window handles, the FemtoVG renderer exposes a different interface where it assumes that the caller takes care of the OpenGL context state. This means more boilerplate remains in the winit backend, including the glutin dependency. The upside is that it will allow using the FemtoVG renderer in environments without glutin.

@tronical tronical force-pushed the simon/femtovg-renderer-crate branch 3 times, most recently from dcd32a0 to 0b1d1e2 Compare January 27, 2023 16:21
@tronical
Copy link
Member Author

This is deliberately still a draft and work in progress. One of the things missing is internal documentation.

@tronical tronical force-pushed the simon/femtovg-renderer-crate branch from 0b1d1e2 to 5f8e9a9 Compare January 31, 2023 15:44
@tronical tronical force-pushed the simon/femtovg-renderer-crate branch from 5f8e9a9 to 212ddee Compare February 21, 2023 10:52
@ogoffart
Copy link
Member

(don't forget to add the entry in the publish.sh)

@tronical tronical force-pushed the simon/femtovg-renderer-crate branch 6 times, most recently from 0a7009a to fb20256 Compare February 22, 2023 13:34
@tronical tronical marked this pull request as ready for review February 22, 2023 13:34
internal/renderers/femtovg/lib.rs Show resolved Hide resolved

fn main() {
// Setup cfg aliases
cfg_aliases! {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an objection to the patch, but while i think cfg_alias is great, having a build.rs just for that might have a significant impact on compile time. I haven't measured it though. So I don't know if it is worth it or not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 7 uses of #[cfg(use_fontconfig)]. I could replace those with the full expression, although I think that makes the code less readable. I'll post a patch on top and then we can see.

@@ -21,7 +21,7 @@ path = "lib.rs"
[features]
wayland = ["winit/wayland", "glutin/wayland", "copypasta/wayland", "i-slint-renderer-skia?/wayland"]
x11 = ["winit/x11", "glutin/x11", "glutin/glx", "copypasta/x11", "i-slint-renderer-skia?/x11"]
renderer-winit-femtovg = ["femtovg", "fontdb", "libc", "yeslogic-fontconfig-sys", "winapi", "dwrote", "imgref", "unicode-script", "ttf-parser", "rgb", "i-slint-core/box-shadow-cache"]
renderer-winit-femtovg = ["i-slint-renderer-femtovg"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
renderer-winit-femtovg = ["i-slint-renderer-femtovg"]
renderer-winit-femtovg = ["dep:i-slint-renderer-femtovg"]

But if we do that, we should make it consistent with other features

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel very strong about this, but it sounds like something that should be applied to all crates. That said, I don't mind if we don't use dep: everywhere - at least so far I haven't been confused by the mix :)

This will be needed for a future experiment. Unlike the Skia renderer,
which operates on raw window handles, the FemtoVG renderer exposes a
different interface where it assumes that the caller takes care of the
OpenGL context state. This means more boilerplate remains in the winit
backend, including the glutin dependency. The upside is that it will
allow using the FemtoVG renderer in environments without glutin.

In order to work in an environment without fontconfig or memmap, the
crate has two features:

  - fontconfig (set when we anticipate fontconfig to be available at
    run-time and libloading being available at compile time).
  - diskfonts (set when we want to be able to load fonts from disk)

The winit crate enables fontconfig on "Linux" and diskfonts on !wasm.
@tronical tronical force-pushed the simon/femtovg-renderer-crate branch from 3ff2e61 to 603d619 Compare March 6, 2023 10:16
@tronical tronical merged commit 6d968aa into master Mar 6, 2023
@ogoffart ogoffart deleted the simon/femtovg-renderer-crate branch April 19, 2023 09:05
@tronical tronical restored the simon/femtovg-renderer-crate branch May 15, 2023 16:31
@ogoffart ogoffart deleted the simon/femtovg-renderer-crate branch June 12, 2023 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants