Commit graph

35 commits

Author SHA1 Message Date
Olivier Goffart
a19efc30db
Replace the MAX_BUFFER_AGE const generic with a runtime enum
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
2023-02-08 14:44:01 +01:00
Olivier Goffart
a4eb1ab287 swrenderer support for linear gradient
Only simple rectangle (no borders or radius)
2023-02-02 15:54:07 +01:00
Olivier Goffart
5050e4fea8 swrenderer: move the SceneCommend vector into a separate struct
Simplifies a bit the code as we will add more vectors that need to be
passed from the SceneBuilder to the Scene
2023-02-02 15:54:07 +01:00
Simon Hausmann
8c807cb1da
Remove slint::Image::stride() (#2147)
cc #2138
2023-01-30 13:59:31 +01:00
Olivier Goffart
35c16b9a69 Fix panics in the software renderer system font
Two bugs:
 - There was an extra `* 4` that caused panic when the Text was clipped
 - There was a bug in glyph handling when the text is being split in
   several runs
2023-01-27 12:34:45 +01:00
Olivier Goffart
cd6cfa2521 Software renderer: fix drawing of border rectangle with transparent border
The current implementation of the software renderer doesn't drawn the
background under the border, so if the border is translusent, we don't
see the background color.
This patch blend the color of the border with the coler of the
background.

Software renderer part of #1988  (minus clipping)
2023-01-18 11:39:53 +01:00
Olivier Goffart
5cd38adb14 Move the colorize property to the Image item
Instead of the ClippedImage. Because we use the colorize property more
often than the source property, and these are soon going to be even more
expensive
2022-12-20 08:42:47 -08:00
Simon Hausmann
dee1b11a83 Initial support for truetype fonts in the software renderer
This works, but it's super slow as for every glyph the font is loaded
again and the glyphs are rasterized every time they're drawn.
2022-12-16 18:20:12 +01:00
Simon Hausmann
d69b4b81ba Simplify glyph handling in the software renderer
Remove platform glyph abstraction, just use non-zero u16 as glyph index
like everyone else.  As a bonus, this reduces the memory consumption of
the glyph buffers per glyph from a size of a pointer to the size of the
u16.
2022-12-16 18:20:12 +01:00
Simon Hausmann
8145d10b5b janitor: adaptor -> adapter 2022-12-13 08:35:20 +01:00
Simon Hausmann
b2ebac63c2 Remove component_destroyed from winit's internal renderer interface
The default impl of unregister_component in WindowAdapterSealed would call free_graphics_resources
on the rendere. Any re-implementation would have to do the same,
which the winit backend forwarded through
the winit backend specific internal renderer interface.

Instead, the original call site for unregister_component now calls
free_graphics_resources and unregister_component (for accessibility tree dirty notification).
2022-12-09 09:03:27 +01:00
Simon Hausmann
f5bbca9fce Remove default_font_size() from internal winit renderer interface
Replace register_root_component in the WindowAdapterSealed altogether with
a default font size getter on the renderer.

This is overall simpler and allows removing the doc-hidden getter in the software renderer.
2022-12-09 09:03:27 +01:00
Olivier Goffart
6d0a3f2f9d swrenderer: Fix text hacing the alpha multiplied twice
and do some renaming
2022-11-30 16:49:23 +01:00
Olivier Goffart
830e33876f swrenderer: Fix drawing of images
There was some confusin on the meaning of the alpha and colorize and how
it is computed for AlphaMap images
2022-11-30 16:49:23 +01:00
Tobias Hunger
47300a7495
janitor: Fix clippy errors (#1895)
* janitor: Fix clippy error drop_copy

Clippy says cache_entry is Copy, so calling drop on it is useless since
it will drop a copied value.

* janitor: Fix clippy error

... about cloning a double ref.

Co-authored-by: Olivier Goffart <olivier@woboq.com>
2022-11-23 15:06:07 +01:00
Florian Blasius
00bd4909e1
SoftwareRenderer: render texture with opacity and color alpha channel (#1877)
* swr: add alpha field to texture
2022-11-21 15:26:35 +01:00
Olivier Goffart
9baf6f2bde swrender: Fix drawing of border rectangle with only border
(no radius or background, just a border)

Fixup previous commit that remove the wrong brace
2022-11-16 12:26:33 +01:00
Florian Blasius
c83e04bb52
swr: apply opacity on rect and rect with (#1866) 2022-11-16 12:20:52 +01:00
Florian Blasius
646cbecfa5
Fix background in swr is not drawn (#1830)
There was an error drawing the window background in the software renderer because of a wrong check.
2022-11-09 12:23:22 +01:00
Simon Hausmann
39121994ca Always set Window.default-font-size
Permit the style metrics to provide a `default-font-size` and bind that
to the `Window` if set. If not provided, then the backend can set a
`default-font-size`. By ensuring that the value is non-zero at run-time,
we can later introduce a rem unit that can act as factor relative to
this non-zero font size.
2022-11-03 17:15:44 +01:00
Olivier Goffart
2e08b7dd1e Fix the rendering size of svg
- On the web, to return the image size, we need to use the natural size
   of the image, and not its dom size, as the later get modified since
   commit  b727aba4a0

 - The target size did not take in account the image fit, that's because
   former version of resvg could only render by respecting the aspect
   ratio. But since the web don't have this limitation, we now need to
   take it into account. And new version of resvg can also scale with
   any aspect ratio
2022-10-24 10:05:38 +02:00
Florian Blasius
c58c704f16
Change type of Window background from color to brush (#1755) 2022-10-21 16:17:22 +02:00
Simon Hausmann
c11b4305c1 Change Item::geometry() to return a LogicalRect 2022-10-13 17:02:18 +02:00
Simon Hausmann
299325370d Change generated accessor functions for Property<Coord> getters to return LogicalLength 2022-10-13 17:02:18 +02:00
Simon Hausmann
2da2511f13
Use a vector for ItemRenderer::translate (#1700)
This simplifes call sites and implementations.
2022-10-02 10:06:20 +02:00
Simon Hausmann
37a8c50c12 Simplify FontRequest
It doesn't have to be generic as mostly the frontend code creates it with logical lengths.
2022-09-30 23:31:32 +02:00
Simon Hausmann
57fe1b9c47 Replace manual calls to LogicalLength::new() for item fields with logical_XXX getters 2022-09-30 13:00:37 +02:00
Simon Hausmann
a52d633b59 Change FontRequest to be a generic over the length
The API uses a logical length for pixel sizes and letter spacing,
but the renderer will need the physical length eventually.
2022-09-30 13:00:37 +02:00
Simon Hausmann
1624a66ebc Change the Renderer trait's text related functions to explicitly operate on logical lengths 2022-09-30 13:00:37 +02:00
Simon Hausmann
59368363c9 Change the ItemRenderer trait to use logical lengths 2022-09-30 13:00:37 +02:00
Simon Hausmann
d698af5326 Move physical length definitions into the software renderer
Their choice of i16 is specific to the software renderer. In say the Skia renderer
the physical coordinate space would still use Skia's Scalar (floating points).
2022-09-30 09:03:02 +02:00
Simon Hausmann
8ee88a53c1
MCU Doc fixes (#1615)
Various edits to the introduction of how to use Slint on MCUs.
2022-09-09 08:35:01 +02:00
Olivier Goffart
36845dcbab
Support drawing embedded textures with the non-software renderers 2022-09-07 18:44:14 +02:00
Olivier Goffart
8850959a2c Rename the backend feature flags 2022-09-07 17:11:57 +02:00
Tobias Hunger
639dcaf702 api: Rename module swrenderer to software_renderer
Also rename the `swrenderer` feature to `software-renderer`.
2022-09-07 10:11:11 +02:00
Renamed from internal/core/swrenderer.rs (Browse further)