Commit graph

629 commits

Author SHA1 Message Date
Simon Hausmann
d4385280eb Fix disappearing images or panics when hiding and showing a window with wayland
Properly release GL resource when unmapping a window and detect stale
cache indices using a generation count. This fixes the disappearing
images (GL textures would be invalid and need to be re-created) as well
as the panics when an item's cache index ended up being re-used because
some other item was drawn first and allocated that indices. The latter
is fixed by using a generational counter on the cache that's bumped when
clearing, instead of a single "cache_ok" bool.
2021-05-28 09:16:24 +02:00
Simon Hausmann
9503ba69b3 GL backend: Move all font related code into the fonts module 2021-05-27 18:51:32 +02:00
Simon Hausmann
7ddbfbdd64 Clean up font_metrics interface on corelib:🪟:Window
Since the GL backend can't really fail on this anymore we can now
remove the Option from the return value.
2021-05-27 17:04:45 +02:00
Simon Hausmann
9b02f2e4a2 GL backend: provide font metrics even when the window is not mapped
Move the item graphics cache into the GraphicsWindow and then, together
with the new femtovg::TextContext, we can provide the metrics and can
stop using the window_map_pending notifier for this query.
2021-05-27 17:00:44 +02:00
Simon Hausmann
61a5859d70 Further encapsulate also the context creation in OpenGLContext 2021-05-27 15:55:38 +02:00
Simon Hausmann
3723aa6f42 Encapsulate the winit WindowContext and wasm winit::Window handling
With wasm there is no current context (can alwasy render) but we own the
winit::Window. With glutin own the ContextWrapper and have to make it
current (and resize). This patch hides all that behind the OpenGLContext
type.
2021-05-27 15:53:33 +02:00
Simon Hausmann
77a064ecab Simplify glutin GL context resizing slightly
Move the resize call into make_current, in preparation for additional
encapsulation in that type.
2021-05-27 15:52:54 +02:00
Simon Hausmann
4a0a9f8a2c Make the font cache thread local 2021-05-27 15:52:54 +02:00
Simon Hausmann
e3264f02d7 Switch to femtovg's TextContext API
This is primarly search & replace for now, slightly simplifying function
signatures.
However this paves the way to a thread-local font cache that can share
fonts across windows (not glyph atlas) and also measure without a canvas.
2021-05-27 15:52:54 +02:00
Simon Hausmann
6d65236813 GL backend: simplify window factory function signature
We can retrieve the event loop window target from anywhere
2021-05-27 15:49:33 +02:00
Simon Hausmann
8d2554ff3b Remove internal event loop proxy clone in the GL renderer
We don't need it since we can send events through the TLS
2021-05-27 15:45:29 +02:00
Simon Hausmann
4b98e05a8f Fix broken layout in web version of gallery
When we calculate the initial layout without a mapped window early on,
we end up with zero text metrics with the GL backend due to an API
limitation of femtovg.

While working on that, this patch introduces a workaround to mark the callers of
image_size() and font_metrics() as dirty when the window is mapped.
2021-05-25 18:37:53 +02:00
Simon Hausmann
7acbe93bf1 Adjust the pin of femtovg
The blur is now in master, so use that instead until release.
2021-05-25 11:32:46 +02:00
Olivier Goffart
74418db9ad Try to create the window with a proper size already
CC #235
2021-05-21 18:43:41 +02:00
Simon Hausmann
655aff24e4 Fix CI
Remove trailing whitespace to silence cargo fmt
2021-05-21 17:52:29 +02:00
Simon Hausmann
431c433e8b Clean up blur effect C++ code
Use Olivier's advice and use the more modern using declaration to access
the draw function, locally.
2021-05-21 17:33:21 +02:00
Simon Hausmann
1d92ab4d36 Simplify Qt blur effect application slightly
Call draw on the blur effect directly instead of going through QGraphicsScene::render().
2021-05-21 17:33:21 +02:00
Simon Hausmann
27dcfa0f11 Improved rendering of drop shadow for Qt
Use QGraphicsBlurEffect as public API to take the blur into account
2021-05-21 17:33:21 +02:00
Olivier Goffart
1f46fd05ec Allow the qt_viewer to compile if cmake finds qt, but not qttypes
This can happen when setting the SIXTYFPS_NO_QT env variable

cc #232
2021-05-21 07:45:38 +02:00
Olivier Goffart
7f117829f2 Display a warning if Qt is older than 5.15
cc #232
2021-05-20 18:28:52 +02:00
Simon Hausmann
235e102f31 Fix slide puzzle not showing with the Qt backend
The window in .60 in the slide puzzle has no preferred size set. Therefore fall back to QWidget::sizeHint().
2021-05-20 18:19:20 +02:00
Olivier Goffart
6540fd48ae GL backend: set the proper size on the rendering context
Otherwise we draw garbage with wayland
2021-05-20 15:19:33 +02:00
Olivier Goffart
fb690dc815 Fix infinite resize in Gnome (wayland)
The gnome compositor don't like when we resize the window while it
is being resized by the user

Fixes #226
2021-05-20 13:41:26 +02:00
Simon Hausmann
a7ce64657c Restore source compatibility for drop-shadow-blur
Let's keep source compatibility and define `drop-shadow-blur` to be a radius.
The CSS spec says that the standard deviation is half of the radius.

We just need to scale again and increase the shadow rect to make sure that no borders are visible.
2021-05-20 12:14:05 +02:00
Simon Hausmann
2ba883b8e2 Fix WebGL demos
Commit bb7b301b10 pulled in a branch of femtovg, which
had a change to its shader that used a variable in the loop condition.
That is unfortunately not supported in WebGL 1.0 / GLES 2.0.

The pinned femtovg works around that limitation.

Fixes #230
2021-05-20 09:39:28 +02:00
Simon Hausmann
9a4dc4a8dc Clean up femtovg crate dependencies
Let only the GL backend depend on femtovg, by moving the color functions.
This way it's easier to change the femtovg version in one place.
2021-05-20 08:56:11 +02:00
Simon Hausmann
bb7b301b10 GL backend: new box drop shadow implementation
This replaces the box gradient with a new implementation that
behaves like the HTML Canvas element, by applying a gaussian
blur to the alpha of the rectangle to shadow.

The drop-shadow-blur property is changed to be now just a "level", like
the HTML Canvas shadowBlur property, which is defined to be half of the
standard deviation of the gaussian blur to be applied.
2021-05-20 08:50:02 +02:00
Olivier Goffart
3983e47720 Fix initial window size 2021-05-18 16:55:07 +02:00
Olivier Goffart
fbdbe69fe7 Window: make hight and width fixed size, preferred-* property set the initial size
Issue #227
2021-05-18 10:23:06 +02:00
Olivier Goffart
987f4666b8 Fix Qt6 build 2021-05-14 14:02:43 +02:00
Simon Hausmann
5b9d64b26e Fix failing assert in QFont with the printer demo
We use a weight of 900 in the demo, which results in a QFont::Weight of 100.
Unfortunately QFont::setWeight() doesn't cap itself, but brutally asserts
if the value is > 99. So let's cap ourselves.
2021-05-14 09:25:47 +02:00
Simon Hausmann
290759cf16 Fix Qt build
Amends ea358d9b2c
2021-05-12 22:06:39 +02:00
Simon Hausmann
ea358d9b2c Simplify internal image_size API
We don't need a property reference anymore, a plain image reference is fine AFAICS.

Dirtyness of the source is tracked on the caller side of layouting_info()
or in the draw_image_impl anyway.
2021-05-12 19:40:09 +02:00
Olivier Goffart
2482745998 Fix wasm build 2021-05-12 13:35:59 +02:00
Olivier Goffart
7b2653db23 MouseWheel support for the Flickable
cc #222
2021-05-12 13:28:39 +02:00
Olivier Goffart
5f74475224 Refactor the MouseEvent 2021-05-12 12:03:03 +02:00
Olivier Goffart
0034a3e67d Fix restarting the event loop with the GL backend
We must reset the proxy to a queue so one can restart it with pending events
2021-05-11 17:48:56 +02:00
Olivier Goffart
720001a223 Remove the solve_layout from the component vtable
no longer required
2021-05-11 14:59:57 +02:00
Olivier Goffart
11158fa922 Remove implicit_size from the Item vtable
Use the preferred size in the layouting_info instead.
2021-05-11 14:59:57 +02:00
Olivier Goffart
81473c2541 Remove implicit_size from the Item vtable
Use the preferred size in the layouting_info instead.
2021-05-11 14:59:57 +02:00
Olivier Goffart
a0e910abf0 Use the testing backend for rust 2021-05-11 11:40:26 +02:00
Olivier Goffart
662c52abff Introduce a "testing" rendering backend and use it for the interpreter test
This way the tests can pass even if the tests would otherwise need a running
window, like they do with the GL backend
2021-05-11 11:40:26 +02:00
Simon Hausmann
c84e6d2945 Export getter functions for all item vtable implementations 2021-05-10 22:54:06 +02:00
Olivier Goffart
a4b31fbe2e CI: -W was not enough to override the -D, use -A instead
Also fix a warning about the usage of std::any::Any without dyn
2021-05-06 19:03:52 +02:00
Simon Hausmann
4a603aa204 Add comment about ttf parser version pin 2021-04-29 13:49:44 +02:00
Simon Hausmann
42154c5ead Use the same version of the ttf_parser crate as rustybuzz
We're currently using three different versions of ttf_parser, and
this brings it down to 2. The other culprit is femtovg.

Saves ~1kb on release build of sixtyfps-wasm-interpreter
2021-04-29 11:21:30 +02:00
Simon Hausmann
d73e7e48d3 GL backend: Fix GPU memory leak with layers
Delete any FBOs before making the context not current. Ooops!

Fixes #211
2021-04-29 09:23:07 +02:00
Simon Hausmann
e3d031a5a4 Fix wasm build when Qt is found in the host system
Pull in qttypes only on non-wasm builds. This requires resolver = "2" as
well, but we require that anyway for wasm builds.
2021-04-27 15:43:05 +02:00
Simon Hausmann
30ffe731b2 Bump femtovg and remove the patch 2021-04-27 11:01:47 +02:00
Simon Hausmann
1ef1e79b93 GL backend: Fix round corner clip radius
Rendering tests/cases/examples/rectangle_clip.60 shows a border radius
for the clipped area that's not identical with the border radius of the
inner edge of the rectangle stroke.

It appears that the stroke's inner radius is not exactly the difference
of the line (border) width but rather scaled by kappa.
2021-04-26 17:34:00 +02:00