Commit graph

606 commits

Author SHA1 Message Date
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
Olivier Goffart
0bb61cc1b3 Fix popup placmement and size with the qt backend 2021-04-26 17:29:06 +02:00
Olivier Goffart
76befb63a3 Fix the dependency tracker not registering a dependency if it was not dirty
Also fix opening/closing the popup should refresh the window
2021-04-26 15:24:48 +02:00
Olivier Goffart
3380383787 Bump version number
(Does not include docs and README yet)
2021-04-26 13:16:48 +02:00
Olivier Goffart
a61935568a Fix text alignment with multiple lines
Broken by d8ebd42712
for issue #207
2021-04-26 10:13:38 +02:00
Olivier Goffart
d8ebd42712 GL backend: fix vertical alignment of text
Fix issue in
https://github.com/sixtyfpsui/sixtyfps/issues/207#issuecomment-825780094

For the purpose of alignment, we need to use the font height, not the actual
text height, because otherwise it does not look visualy centered if the
text does not have letters that goes under the baseline
2021-04-25 14:20:35 +02:00
Olivier Goffart
f4c38f3700 Update dependencies 2021-04-23 16:24:30 +02:00
Olivier Goffart
6fe2c1fa56 Prevent the maximum size to be set to 0,0
Otherwise the window will disapear and will never be seen again

This is a mitigation for #194
2021-04-23 13:10:53 +02:00
Olivier Goffart
f1338c39ef GL backend: fix maximum and minimum size 2021-04-21 18:41:51 +02:00
Olivier Goffart
9adf95c99f Fix native widget with the GL backend and a scale factor
We need to keep everything in logical, but it most likely already it
2021-04-21 18:38:58 +02:00
Olivier Goffart
74e0a98105 Adapt the GL backend to the logical/physical pixel changes 2021-04-21 17:44:53 +02:00
Olivier Goffart
c2745c76ed Use qttypes from crates.io since it has been released 2021-04-21 13:12:55 +02:00
Simon Hausmann
db705c0104 GL backend: Fix image colorization
Commit f50d573120 accidentally changed the
composition mode for the colorization - it should of course be SourceIn.
2021-04-20 22:34:35 +02:00
Simon Hausmann
dbfa5cadde Fix text rendering with path-clipping
When rendering into a layer, we applied the y coordinate system flip
using a transform. That transform is incompatible with
Canvas::fill/stroke_text, which uses transform_point to transform the
glyph quads. That appears to not work, as opposed to the
y-flip in the main vertex shader.

Fortunately we can work around it by doing the flip when rendering the
layer image (as part of the fill).

Closes #199
2021-04-20 22:25:59 +02:00
Simon Hausmann
29425c5138 GL backend: fix texture leak when using path clipping
Make sure to release the layer images after flushing. The shared data remains alive beyond the flush.
2021-04-20 15:07:08 +02:00
Olivier Goffart
2e09a58fd7 Use the qttypes crate 2021-04-20 12:41:44 +02:00
Simon Hausmann
f50d573120 GL backend: Add support for path clipping, used for rounded rects
Render the sub-tree of items into an intermediate image and fill the
clip path with that image.

Fixes #199
2021-04-20 10:26:11 +02:00
Olivier Goffart
ea5e611f41 Properly combine the alpha in the GL backend 2021-04-15 15:55:14 +02:00
Simon Hausmann
6d7f8b6bab Fix handling of border width for clip in the GL backend
Similar to commit 48e6d2f48b, share the rect adjustment
code between the rectangle drawing code and the clipping.
2021-04-15 15:43:49 +02:00
Olivier Goffart
3bf3761450 Implement the Opacity filter.
Notice that the GL implementation currently don't combine the opacity
2021-04-15 10:17:52 +02:00
Simon Hausmann
fad4ef677f Improve colorize effect with the GL backend
As reported in issue #176 , there is a difference between the rendering
with Qt and femtovg. It appears that this is due to incorrect
assumptions about whether the rgb values in the intermediate buffer
image for colorization have the alpha-channel pre-multiplied or not.

When rendering into the image buffer, we would pre-multiply the alpha,
but when rendering the buffer itself, femtovg's fragment shader would
assume texture type 2 and multiply the alpha again. Therefore set the
image flag to avoid that.
2021-04-14 19:17:55 +02:00
Simon Hausmann
48e6d2f48b Fix handling of non-zero border width in clip-enabled Rectangles
The border should be visible (as in the included test case), which this
patch fixes for Qt by subtracting the border width just like when drawing.
2021-04-14 13:34:51 +02:00
Simon Hausmann
87a80023c9 Fix warning when compiling on non-windows 2021-04-13 15:49:32 +02:00
Simon Hausmann
f2c59725fb Fix rendering of chinese text on Windows
Use font-kit's get_fallback_fonts on Windows, since it's actually implemented there.
This allows determining the fonts to fall back to given the reference text.

Fixes #195
2021-04-13 15:47:23 +02:00