Commit graph

296 commits

Author SHA1 Message Date
Simon Hausmann
0d36f88152 Revamp BackendSelector API
Based on API review, PlatformBuilder becomes BackendSelector with
a slightly smaller API surface but more options, such as selecting
Metal or Vulkan rendering.
2024-12-16 13:06:05 +01:00
Simon Hausmann
bfdf0e275f Clean up Apple cfg's
Use target_vendor = "apple" where to cover all Apple OS, and exclude ios for event pumping.
2024-12-13 11:03:44 +01:00
Simon Hausmann
37f66789c5 macOS: Replace use of old apple creates with modern objc2 replacements 2024-11-28 10:00:24 +01:00
Simon Hausmann
6bd043aede Skia: Remove unnecessary RefCell 2024-11-20 07:25:51 +01:00
Simon Hausmann
3f8084cdc0 When using Skia with softbuffer and partial rendering, report damages to softbuffer
Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-11-19 21:31:04 +01:00
Simon Hausmann
a7e04b7d59 Move the partial rendering state into core
... and use from skia as well as the software renderer.
2024-11-19 21:31:04 +01:00
Simon Hausmann
d706f81773 Add support for partial rendering with Skia behind an environment variable 2024-11-19 21:31:04 +01:00
Simon Hausmann
bdb0be64dd Skia: Reduce indentation and fix rustfmt application
Move the closure passed to `WindowInner::draw_contents()` into a
separate function, so that rustfmt works again.
2024-11-19 21:31:04 +01:00
Simon Hausmann
9fdb420d96 Skia: clean up background drawing
Do gradient and solid color fills in one place, instead of two.
2024-11-19 21:31:04 +01:00
Simon Hausmann
e8f319bd77 Implement translation() 2024-11-19 21:31:04 +01:00
Simon Hausmann
9b7de3f806 Pass the buffer age to the Skia software renderer 2024-11-19 21:31:04 +01:00
Ian Hattendorf
3cc44dc670 Add version to OpenGLAPI 2024-10-23 11:13:49 +02:00
Ian Hattendorf
ac9b85049a Add PlatformBuilder API to allow selecting OpenGL API
Right now this just allows selecting between OpenGL and OpenGL ES.
2024-10-23 11:13:49 +02:00
Simon Hausmann
0b028bfb6f
Add support for a font-metrics property to Text/TextInput. (#6452)
The struct held provides access to the design metrics of the font scaled
to the font pixel size used by the element.

ChangeLog: Slint Language: Added font-metrics property to `Text` and `TextInput`.

Closes #6047
2024-10-05 17:00:46 +02:00
Simon Hausmann
34fc24e4e0 Skia: Fix opacity not being applied to box shadows correctly
When a box shadow is the only child of an opacity item, we don't create an intermediate opacity layer (good). Without the opacity layer, it's mandatory to apply the current opacity though, which commit b5c61fb2f5 did, except
it missed this one draw_image call for the box shadow itself.

Fixes #6359
2024-10-02 07:03:02 +02:00
Simon Hausmann
4c5b7c353a Prospective fix for division by zero in Skia renderer when rendering images
Closes #6280
2024-09-25 14:01:21 +02:00
Simon Hausmann
76388260f6 Simplify oddly complex expression 2024-09-25 12:27:03 +02:00
Simon Hausmann
bc2e97fcef Skia: Improve rendering quality of layers and qt style with fractional translations
Layers and cached pixmaps should be "invisible" in terms of quality,
and they're "designed" to be pixel aligned.
2024-09-18 07:44:29 +02:00
Olivier Goffart
67b82230f7 Skia: fix mixing tiling and colorize
A colorized image is baked by a texture, which needs the context so that
the make_subset don't return None
2024-09-13 17:35:57 +02:00
Simon Hausmann
388b504683 Update Skia to 0.78
This updates Skia to Milestone 129. See
https://github.com/rust-skia/rust-skia/releases/tag/0.78.0 for
additional details.
2024-09-11 08:25:24 +02:00
Simon Hausmann
d74e49e71f Skia renderer: Remove unnecessary scale factor argument / function 2024-09-10 10:24:07 +02:00
Mads Marquart
945e65f6a4 Use raw-window-metal to do layer creation in skia 2024-09-10 10:19:25 +02:00
Simon Hausmann
3d1e57008e
Revert accidental dependency bump 2024-09-09 22:09:02 +02:00
Simon Hausmann
68cd635aec
Bump windows dependency 2024-09-09 22:06:50 +02:00
Simon Hausmann
d6b3e69a7e Fix SLINT_DEBUG_PERFORMANCE="overlay" with Skia
After the FontMgr changes in the previous Skia update we can't default
construct Font anymore. Let's use the same default font we also use for
regular text then.

Fixes #5764
2024-08-06 16:12:15 +02:00
W Etheredge
80ae11cd80 Use associated constants on number types 2024-08-01 07:53:48 +02:00
Simon Hausmann
9bef3e47f4 Fix GBM rendering on mali EGL drivers
Combining an EGL config with EGL_ALPHA_SIZE == 8 with an Xrgb8888 surface yields a bad match on eglCreateWindowSurface.
That's fair, and we should accomodate for that by avoiding such EGL configs.
2024-07-30 13:04:48 +02:00
Simon Hausmann
b5c61fb2f5 Skia: Make sure to consistently apply the global alpha
Replace uses of skia_safe::Paint::default() with calls to self.default_paint(), to apply the current global alpha.

Fixes #5706
2024-07-29 13:21:21 +02:00
Simon Hausmann
e35d05f6b9 API Review: Remove SharedImageBuffer from public API and rename Window::grab_window() to take_snapshot()
Use SharedPixelBuffer as return value for take_snapshot() and provide counter-parts to from_rgb* in Image as to_rgb*
2024-07-05 20:46:55 +02:00
Olivier Goffart
8b5df70dd0 Make a trait for the Text rendering
So we can Split Text
2024-07-05 12:51:25 +02:00
Simon Hausmann
49df131625 Fix slint::Window::hide() on Wayland with winit
On Wayland hiding a window requires destroying the surface, which
means destroying the winit window as well as the underlying graphics
surface. The latter is tricky as we have to keep the renderer around,
as our WindowAdapter trait's `renderer()` function returns a `&dyn
Renderer` and that also has to work without a window (to obtain text
metrics).

Fixes #4225

Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2024-07-03 14:22:30 +02:00
Olivier Goffart
60569673b5 Remove some cargo:rustc-check-cfg output:
- The cfg_aliases crate does it out of the box already
 - Don't create a build.rs for this only purpose when it can be added in
   Cargo.toml lints group. (This wasn't possible when the warning was
   first introduced in nightly)
2024-07-02 13:33:48 +02:00
Simon Hausmann
98a4325f3f Skia: Fix missing BeforeRendering rendering notifier state invocations
Commit 977b827df2 regressed this by passing `None` as surface, so we'd never try to retrieve the graphics api enum to pass to the notifier.
2024-06-26 15:05:47 +02:00
Simon Hausmann
e932aa1381 Skia: Fix broken rendering notifier invocations, part 1
With the new winit, we end up calling resumed() and thus set_window_handle() multiple times - the first time right in the WinitWindowAdapter constructor. This may lead to the following sequence:

1. resumed() calls set_window_handle() the first time.
2. A frame gets rendered (odd, but yeah), we invoke the rendering notifier with RenderingState::RenderingSetup.
3. winit calls resumed(), we call set_window_handle() once more. We reset the surface.
4. The next time a frame gets rendered, we invoke the rendering notifier with RenderingSetup again.

There are a few things wrong, but first and foremost, in step 3 we should call RenderingTeardown if we've called RenderingSetup before.
2024-06-26 15:04:31 +02:00
Walter Kalata
56e6d7b08e Option<(Paint, Option<Shader>)> -> Option<(Paint, Shader)> 2024-06-26 13:16:24 +02:00
Walter Kalata
c04caac5ed Addresses feedback re: tuple return values over closure args 2024-06-26 13:16:24 +02:00
Walter Kalata
aa5e9b99d5 Support dithering gradients in the skia renderer 2024-06-26 13:16:24 +02:00
Simon Hausmann
977b827df2
Add Rust API to grab the contents of a slint::Window into a slint::SharedImageBuffer (#5445) 2024-06-22 09:33:18 +02:00
Olivier Goffart
5d9682b2ad Remove PhantomData 2024-06-18 17:48:17 +02:00
Simon Hausmann
9377d8ea75 Fix Skia Vulkan build on macOS 2024-06-18 17:48:17 +02:00
Simon Hausmann
1c54cce021 Skia: Fix windows build 2024-06-18 17:48:17 +02:00
Simon Hausmann
760e04a411 Fix build
- Upgrade linuxkms backend to rwh06
- Adapt vulkan_surface to internal Skia surface trait changes made in earlier commit
2024-06-18 17:48:17 +02:00
Simon Hausmann
4c888bf1ae Port the Skia renderer to rwh06 and the new softbuffer
... by accepting an Rc<dyn Has*Handle> in the interface. This is required for softbuffer use.
2024-06-18 17:48:17 +02:00
Olivier Goffart
865e3e940d WIP: update winit, glutin, raw-window-handle 2024-06-18 17:48:17 +02:00
Daniel Stuart
436efaceea renderer: Use TextWrap enum for text_size function 2024-06-17 23:52:04 -07:00
Daniel Stuart
9f63d157d1 Add character wrapping for Qt Backend
This adds a new wrapping mode called `char-wrap`, which allows for wrapping at any character.
Currently, it only supports the Qt backend, with the other backends falling back to `word-wrap` when this option is selected.
2024-06-17 23:52:04 -07:00
Simon Hausmann
72e35ea5f9 Work around Skia OpenGL renderer not working with Wayland on certain vivante EGL drivers
Some versions use the zwp_linux_explicit_synchronization_v1 protocol
and end up re-allocating a synchronization object when initialzing an
EGL context on a surface a second time, causing the process to abort.

As a counter-measure, destroy the entire EGL context/surface/etc. before
creating a new one when on startup we call resume() after commit 518681cc02
2024-06-12 10:47:59 +02:00
Simon Hausmann
0e67654431 Fix jitter when resizing a window on macOS
Commit 1e450abc9c originally fixed this. Meanwhile, after many refactorings, this doesn't work anymore for the FemtoVG renderer. That's because the contents placement (or layer's contents gravity) is set before the hidden layer NSOpenGLContext creates is associated with the view.

For the Skia GL surface that already works, but for clarify the code is moved into the same location.

For Skia Metal rendering, apply the same on the metal layer (through the view). For this to work the contents scale also needs to be applied. To avoid further visual effects, the scale needs to be applied as early as possible, so apply it right after creating the
surface and latest at rendering time.

Fixes #5258
2024-06-06 08:34:58 -07:00
Tobias Hunger
d9224cd58f janitor: Use more workspace dependencies 2024-06-04 14:58:29 +02:00
Simon Hausmann
439b11edf3 Remove workaround for Skia bug on macOS
While https://github.com/google/skia/pull/162 has not been merged yet,
it's included in skia-safe:

https://github.com/rust-skia/rust-skia/pull/986
2024-06-03 08:35:26 -07:00