Commit graph

372 commits

Author SHA1 Message Date
Simon Hausmann
37be696cd6 Bump glow and femtovg versions 2025-01-14 14:24:41 +01:00
Simon Hausmann
53f2d572b1 Remove some uses of once_cell 2025-01-14 14:18:24 +01:00
Tasuku Suzuki
346d1c2df3 Fix typos
Ran `typos .` and fixed all typos that do make sense.
https://crates.io/crates/typos
2025-01-13 08:35:20 +01:00
Simon Hausmann
c764da4aab
Add property to toggle anti-aliasing on Path elements (#7308)
This enables working around bugs in GPU drivers. Especially the GC7000UL
plus its driver on imx8mp has been observed to sometimes horribly degrade in
performance when Skia renders anti-aliased paths (when a function like
`gcoSURF_BlitCPU` shows up at the top of `perf` that's a bad sign).
2025-01-10 10:28:01 +01:00
Simon Hausmann
c271fe2e19 Clean up unicode-segmentation dependency
Use a workspace dependency.
2025-01-09 20:42:56 +01:00
Simon Hausmann
2ec0522151 Fix panic in FemtoVG and Skia renderers with certain drop shadows
If the effectively drop shadow size would be zero, the FemtoVG and Skia item renderers would panic. The following test-case reproduces this:

```slint
export component Test inherits Window {
    Rectangle {
        drop-shadow-color: black;
        drop-shadow-offset-x: 1px;
        drop-shadow-blur: -0.5px;
        width: 0.5px;
        height: 0.5px;
        background: blue;
    }
}
```

ChangeLog: [Renderers] Fix panic with FemtoVG and Skia renderers for certain drop shadows.
2025-01-06 12:40:44 +01:00
wu bobo
a60c3b39b9
Fixed text input on Android, fixed for older Android versions (#7204)
* Fixes for older Android versions (6.0 to 9.0)

* Fix build script for Android (#4920)

* Fix clipboard operations on Android

* Fix TextEdit crashing on Android (#7203)

* Remove unsafe calls added in 'Fixes for older Android versions'

* Update a comment in androidwindowadapter.rs

Fixes #7182
2025-01-03 11:18:33 +01:00
Simon Hausmann
102d83a306 Skia: Don't render with software by default on macOS/Windows
On macOS we should default to the Meta renderer, similar `renderer-skia` defaults to D3D on Windows. Unfortunately commit 0d36f88152 broke this by forgetting
that None with the requested graphics API means: Go for with what we have, nothing special requested.

This also fixes the terminal output "Failed to initialize Skia GPU renderer: Requested non-Metal rendering with Metal renderer . Falling back to software rendering" (and similar on Windows).
2024-12-20 10:48:55 +01:00
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
Simon Hausmann
a537556b77 Bump FemtoVG renderer
Fixes #2314
2024-11-17 15:03:33 +01:00
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