Commit graph

114 commits

Author SHA1 Message Date
Olivier Goffart
a1724602e6 Skia: Cache the Skia image in the core image cache
Because re-generating the Skia image is slow and there is no point
storing both the image buffer and the SkiaImage in the cache as it
is basically the same information.
2022-08-16 11:22:11 +02:00
Olivier Goffart
ff1400ab6b Skia: Fix drawing of images with source clip, but no colorize
Colorize property with transparent value means no coloration is applied

CC #1445
2022-08-15 12:41:36 +02:00
Simon Hausmann
40ab058b5e Fix build with --all-features on Windows
Remove the renderer-skia-opengl "dev" feature again, as on Windows with a
--all-features build in the CI it'll cause
Skia to be built from source. That's not possible in the CI due to long paths as the skia submodule is checked out.
2022-08-12 16:07:42 +02:00
Simon Hausmann
65acadd14a Add support for rendering with Skia and Direct3D on Windows 2022-08-12 16:07:42 +02:00
Simon Hausmann
cc49ee1824 Add support for rendering with Skia and Metal on macOS
Fixes #1470
2022-08-12 08:17:03 +02:00
Simon Hausmann
7b50e38e53 Skia: Implement rotation support 2022-08-11 13:32:40 +02:00
Simon Hausmann
3b9309a0dd Skia: Simplify OpenGL setup
Avoid re-creating a glow context every time we resize the context/window. Instead query
framebuffer info once (it's 0 anyway...) and keep it around.
2022-08-10 17:02:15 +02:00
Simon Hausmann
48b7054254 winit: simplify shutdown logic
Remove release_graphics_resources() as it's always connected to dropping
the entire renderer's canvas. That one in turn is already prepared, i.e.
for femtovg it makes sure that the context is current.
2022-08-10 17:02:15 +02:00
Simon Hausmann
351a1b6448 Move set_rendering_notifier from the (to be public) PlatformWindow to the (private) Renderer trait 2022-08-10 13:07:07 +02:00
Simon Hausmann
6a1bc23321 winit: Clean up rendering notifier handling
Move the rendering notifier into the Renderer. This duplicates a little bit of code, but it

   (1) Allows for avoiding the flush of femtovg/skia if no rendering notifier is
   registered
   (2) Paves the way of gracefully handling the situation where the renderer doesn't support this yet
2022-08-10 13:07:07 +02:00
Simon Hausmann
7314fa0953 Attempt to clarify the reasoning behind windows_with_pending_property_updates 2022-08-10 11:34:30 +02:00
Simon Hausmann
6209af1c9a Remove unnecessary into_iter() call on the Vec's drain 2022-08-10 11:34:30 +02:00
Simon Hausmann
6446a28fd6 winit: fix jitter on macos again when resizing windows
Commit 0ee361d994 regressed on
https://github.com/slint-ui/slint/issues/1269 as the inner_size()
returned at the time during event processing is already the future
value, that will change again when processing the resize event.

Instead of storing the last received value, process the event at the
appropriate MainEventsCleared stage.
2022-08-10 11:34:30 +02:00
Simon Hausmann
9ec6fdc18a winit: fix error messages in console when resizing a window
Make sure the glutin context is current before calling resize.
2022-08-10 09:44:07 +02:00
Simon Hausmann
f4ddfa5ef6 winit: separate rendering from surface resizing
Resize the glutin context when we receive a resize event from winit.
This is the approach recommended by glutin/winit's documentation.

This approach also avoids jitter when rendering with metal (not
implemented yet, but tested locally :)
2022-08-09 16:20:53 +02:00
Simon Hausmann
d02a94eb7c Move the OpenGL specific Skia surface handling into a separate module 2022-08-09 16:20:53 +02:00
Simon Hausmann
50d315437c Skia: encapsulate the OpenGL handling further in a OpenGLSurface type 2022-08-09 16:20:53 +02:00
Simon Hausmann
704985cb7e winit: Move the OpenGL context into the FemtoVGCanvas
This simplifies the "GL" Window type a little, the render() signature
and prepares for supporting rendering with non-GL.
2022-08-09 16:20:53 +02:00
Simon Hausmann
0ee361d994 winit: Remove unused existing_size field
This field duplicates the winit window's inner size. It is set on a
WindowEvent::Resized(), after which
`winit:🪟:Window::inner_size()` returns the same value.
2022-08-09 13:16:52 +02:00
Simon Hausmann
0ddf7e8d56 winit: Make the rgb crate dependency also optional to the femtovg renderer 2022-08-05 10:31:35 +02:00
Simon Hausmann
db867ac18f winit: Bail out with an error message if no renderer is selected 2022-08-05 10:31:35 +02:00
Simon Hausmann
1d04b8665f Make it possible to build without the FemtoVG renderer 2022-08-05 10:31:35 +02:00
Simon Hausmann
fa956aca2d janitor: Fix nightly doc warnings about unused parentheses 2022-08-05 09:25:31 +02:00
Simon Hausmann
8835f856e6 Skia: require the new release
This pulls in the branches for the Yocto build support

Fixes #1454
2022-08-05 09:12:51 +02:00
Simon Hausmann
0805e52cf0 Skia and FemtoVG: Release cached layers when cache-rendering-hint is disabled
There's no good reason to keep the texture around.
2022-08-03 08:33:56 +02:00
Simon Hausmann
4189eebeb4 Skia: Fix caching of colorized image
Commit 0cf432b9a0 placed the colorize_image() call on the result
of the item cache retrieval, not inside the cache update closure.
2022-08-03 08:28:45 +02:00
Simon Hausmann
0cf432b9a0 Skia: Cache the result of colorizing an image
Colorization is typically implemented using an intermediate layer and since
usually it doesn't change so often, it's faster to cache the result in the existing SkImage cache
per Image item.
2022-08-02 13:48:04 +02:00
Simon Hausmann
8f0ddd7ad7 Remove unused variable 2022-08-02 12:00:56 +02:00
Simon Hausmann
c7641a528d Fix use of default font family with Skia
Go through the default font manager in style matching first, so that the empty family is matched against system defaults.
Otherwise the first registered custom font because the overall default.
2022-08-02 12:00:56 +02:00
Simon Hausmann
b0851301d0 Fix rendering of border rects with border-width = 0
Don't stroke such rectangles.
2022-08-02 12:00:56 +02:00
Simon Hausmann
f47a1221fb Implement rendering of the native style with Skia 2022-08-02 12:00:56 +02:00
Simon Hausmann
33d080924c Implement ImageRendering option for Skia 2022-08-02 12:00:56 +02:00
Simon Hausmann
e8c7cf32db Implement release_graphics_resources() for Skia 2022-08-02 12:00:56 +02:00
Simon Hausmann
dacf083162 Silence unused paramter warnings 2022-08-02 12:00:56 +02:00
Simon Hausmann
4d73d50664 Don't use deprecated Skia functions 2022-08-02 12:00:56 +02:00
Simon Hausmann
4da67036ac Add support for custom fonts 2022-08-02 12:00:56 +02:00
Simon Hausmann
59cab28d0d Add support for layer caching 2022-08-02 12:00:56 +02:00
Simon Hausmann
5e670dd511 Add support for caching the box shadow 2022-08-02 12:00:56 +02:00
Olivier Goffart
77db0ea8b7 Skia: fix the text_size() to avoid one letter being chopped off 2022-08-02 12:00:56 +02:00
Olivier Goffart
44f905fc5f skia: implement Path 2022-08-02 12:00:56 +02:00
Olivier Goffart
4ff8daa2ac skia: implement text vertical alignment 2022-08-02 12:00:56 +02:00
Olivier Goffart
881fbcb86d skia: Implement colorized image 2022-08-02 12:00:56 +02:00
Olivier Goffart
159e72f702 skia: Implement drop shadow 2022-08-02 12:00:56 +02:00
Simon Hausmann
01f09599dc Add support for rendering SVGs 2022-08-02 12:00:56 +02:00
Olivier Goffart
183d58b876 Skia: attempt to get text eliding and alignment 2022-08-02 12:00:56 +02:00
Simon Hausmann
793327f5c1 Initial support for image rendering
This lacks support for colorization, image rendering quality and SVG.
2022-08-02 12:00:56 +02:00
Simon Hausmann
eb5edf0ea4 Fix incorrectly reported text metrics
Return the intrinsic maximum width of the text, not the theoretical max :)
2022-08-02 12:00:56 +02:00
Simon Hausmann
38e1a4f9c8 Set font weight and letter spacing 2022-08-02 12:00:56 +02:00
Simon Hausmann
ca30af383b Don't panic when the clip region is empty
It may happen that the clip region becomes empty (for literally invisible items).
For example this happens in the printer demo.
In that case we want to return an empty rect.
2022-08-02 12:00:56 +02:00
Simon Hausmann
60d5ea8929 Fix height for width for text
Scale the max_width to physical pixels
2022-08-02 12:00:56 +02:00