- Use WinitSkiaRenderer for the adapter in the winit backend (similar to WinitSoftwareRenderer)
- Use SkiaItemRenderer for the impl of the ItemRenderer trait
- Use NonZeroU32 in the OpenGLContextWrapper interface (correct API for the future)
- Don't render zero sized windows with the software renderer and FemtoVG
We would pass `physical_size_to_slint(&self.winit_window().inner_size())`, which is
identical to `slint::Window::size()`, which
calls `size()` on the WindowAdapter, which
returns the above.
There's on guarantee that the pointers returned by get_proc_address are
always valid. Our implementation might, but since the trait isn't
sealed, somebody else could implement it badly.
Accept the OpenGL context as trait impl. This means we can also move the rendering notifier
into the femtovg renderer create and get rid of
the proxy Renderer trait impl.
Remove the generic window handle owner part of the API. Instead assume
that the caller provides safety for the given window handles, like we do
for FemtoVG and like softbuffer does it in its public API.
This simplifies the logic for how to apply window related requests as
they can be applied to the winit window immediately.
It also simplifies the state handling in the WinitWindowAdapter, as
there's no more distinction between mapped and unmapped. We always map
now (winit does).
One related change in core is that the window properties are now sent to
the backend before calling show(), instead of after.
Despite the documentation of softbuffer claiming that the high bits
should be 0, it seems to be interpreted as an alpha value when the
window is actually transparent.
And the values are considered as premultiplied alpha
Also use a Premultiplied aplha for the buffer so we can even have
transparent window with the software renderer
The creation of the renderer might fail, for example if we tried to
create an OpenGL renderer on a display that doesn't support OpenGL. We
should catch that in the future and fall back to the software renderer.
In order for GLX support to work, we need to create the X11 window with
the same visual as in the GLX configuration. That requires delaying
the creation of the window.
This is done in four parts:
- The window builder is re-introduced in the winit backend create
internal renderer interface.
- The glcontext helper code for wasm was moved into a separate function
(less indentation).
- The loop over different display preferences was replaced with a
preference to the "window system native GL interface" over EGL,
which should achieve the same as the fix for #2162. Upstream glutin
defaults to this and so do various downstream projects.
- Use glutin-winit for the actual display selection.
This covers the FemtoVG bits of #2269
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.
This is reproducible in the energy monitor when scrolling down in the
settings page.
In the helper function to colorize an image, we did not expect
brush_to_paint() to fail. The condition of a transparent colorize color
was handled earlier, but it turns out that brush_to_paint() also checked
the global state as an optimization.
This optimization is wrong, as the cached colorized image should not
depend on the untracked global transparency.
So this patch adds a graceful handling of brush_to_paint returning None
for defensive measures, but also moves the early return on an global
transparent alpha to the call sites where it makes sense.
The CI build vsix panics on line 84 in glcontext.rs. There's no unwrap()
there but there's one nearby. I wasn't able to reproduce this with a
local build, so this is a prospective attempt, assuming that this is due
to the attempt of glx-over-egl display configuration finding.
Having a const generic for that didn't turn to be a good API.
Also made the C++ side more difficult
(Also renamed buffer_stride to pixel_stride)
Closes#2135
As the surface creation may fail with Egl later, then display preference
EglThenGlx is not sufficient and we need to completely re-do the glutin
initialization and try with GLX.
cc #2162