Commit graph

244 commits

Author SHA1 Message Date
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
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
fa956aca2d janitor: Fix nightly doc warnings about unused parentheses 2022-08-05 09:25:31 +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
Simon Hausmann
480da2506c Remove unused import (oops) 2022-08-02 12:00:56 +02:00
Simon Hausmann
c587c3a270 Avoid re-creating the font collection every time we lay out text 2022-08-02 12:00:56 +02:00
Olivier Goffart
2e1044afd7 skia backend: gradients 2022-08-02 12:00:56 +02:00
Simon Hausmann
89a7a4fb30 Render the output of the performance counter 2022-08-02 12:00:56 +02:00
Simon Hausmann
780775a303 Begin work on text rendering 2022-08-02 12:00:56 +02:00
Simon Hausmann
9bfd8c8477 Implement clipping 2022-08-02 12:00:56 +02:00
Simon Hausmann
69fa40ebbf Implement drawing of rounded rects with border 2022-08-02 12:00:56 +02:00
Simon Hausmann
aac89c458a Implement translate, opacity layers and global opacity
The latter requires manually applying the alpha to colors. But on the upside, opacity
layers are a built-in feature.
2022-08-02 12:00:56 +02:00
Simon Hausmann
771b122198 Add skia renderer skeleton
This one can render basically just plain rectangles.
2022-08-02 12:00:56 +02:00
Simon Hausmann
086880f605 Speed up rendering of clipped children
When the renderer does not re-implement visit_clip, we call combine_clip.
Then we're missing out on an optimization the GL renderer does: When the resulting clip region
is empty, we do not need to recurse into children for rendering.

That itself reduces the property dependency chain and avoids unnecessary
updates when invisible (clipped) children change properties.
2022-08-02 11:07:46 +02:00
Simon Hausmann
b782e43226 Make it possible to have multiple renderers in the winit crate
Make GLWindow generic over the renderer and canvas
2022-07-28 19:03:01 +02:00
Simon Hausmann
27bf9348e6 Rename the backend-gl crate into backend-winit 2022-07-26 17:43:51 +02:00