Commit graph

302 commits

Author SHA1 Message Date
Simon Hausmann
0bf924cf0d Bump FemtoVG to 0.10.1 release that fixes scissor clip problem 2024-10-24 10:30:12 +02:00
Simon Hausmann
e8127ce6ad Temporarily downgrade FemtoVG version
0.10.0 introduced a regression with clipping, that's visible when
running the printer demo (or previewing anything in the vs code
extension).
2024-10-24 08:55:18 +02: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
2a4024fdcb Bump various dependencies 2024-10-23 10:06:12 +02:00
Tobias Hunger
df4f9b38ee femtovg: Fix warning about deprecated web_sys::set_fill_style
Use set_fill_style_str insterad, it avoids constructing a JSValue
from a str.
2024-10-16 13:25:00 +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
29804f34de Fix WASM version of OpenGL underlay example
Commit 3cb636169506262d96ec2bc53a617714d5ab068d in femtovg switched to
using WeblGL to (needed for tiling). This means the GraphicsAPI::WebGL
context type needs to be updated, too. Also, the canvas_id was always
empty, but needs to be initialized from the id of the element we're
using.
2024-09-24 10:47:15 +02:00
Simon Hausmann
b42840ee85 femtovg: Avoid artifacts of texture sampling with accidental wrap-around on texture boundaries
Set REPEAT_X/Y flags only if tiling is requested. Otherwise we might see artifacts.

See #6268
2024-09-24 09:43:10 +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
Olivier Goffart
827975202c femtovg: Fix mixing tiling and coloring
We need to pass the REPEAT_* flags also when creating colorized tetures
2024-09-13 17:03:58 +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
b5da1f7b09 FemtoVG: Fix input method cursor position in empty TextInput elements with horizontal alignment
`draw_text_input` handled the empty case with alignment correctly, but text_input_cursor_rect_for_byte_offset, as called for the ime update, did not.
This patch moves the logic into layout_text_lines() for sharing.

This replaces #6006 (which also has a manual test case in the comments).
2024-09-02 17:55: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
0be2d4521e API Review: Remove suspend/resume related functions from FemtoVG renderer
This could've been `set_opengl_context` taking an `Option`, but it turns
out that makes for an awkward interface when wanting to pass None,
because that also then requires a dummy type for the OpenGL context even
though none is wanted.
2024-07-08 12:23:56 +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
e497effd73 FemtoVG: Fix rendering notifier invocation when suspending and resuming the renderer 2024-07-03 14:22:30 +02:00
Simon Hausmann
2f4b633807 Simplify FemtoVG new() constructor
Build it on top of the new new_suspended() and resume() functions to reduce code duplication.
2024-07-03 14:22:30 +02:00
Simon Hausmann
38bc37f72a Add missing dispatch of resize event to the window item when the user resizes the window while being hidden 2024-07-03 14:22:30 +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
a4cd0d8113 Upstream FemtoVG
Apply suggestion from https://github.com/slint-ui/slint/issues/5177 to femtovg 0.9.2.

Fixes #4868
Fixes #5177
2024-06-27 18:50:30 +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
Tobias Hunger
0baf382c33 janitor: Fix clippy "usage of bool::then in filter_map" 2024-06-24 14:59:47 +02:00
Tobias Hunger
f8e4072d0c janitor: Fix clippy "unneeded return" 2024-06-24 14:59:47 +02:00
Olivier Goffart
c89ea56abb Update a bunch of dependencies
Bigger change is cause by resvg/usvg which now takes the font database
in a Arc, so we must store it in a Arc ourself to cheaply lend it to usvg
2024-06-23 16:47:13 +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
b579bd577f Remove unused rhw dependency 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