Commit graph

171 commits

Author SHA1 Message Date
Simon Hausmann
48df8d0911 Rework the API between the items and the renderer
Move fields out of the HighLevelRenderingPrimitive that are suitable to
represent as uniform variables. That reduces fields like Image or
Rectangle to their image or dimension, and only if *they* change, then
we re-do the work of building geometry and uploading it to the GPU.

Instead, the typically animated properties such as the position or the
color are passed separately with each draw call. This avoids re-decoding
PNG files and uploading them again when moving an image element around
on the screen.
2020-08-05 09:44:12 +02:00
Simon Hausmann
a9297af00d Update the rendering primitives lazily using a property listener scope
This also allows avoiding the need to store the high-level rendering
primitive item in the low-level primitive struct for comparison later.
2020-08-04 22:48:03 +02:00
Simon Hausmann
685a3fb8ab Rename Text::font_pixel_size to just font_size
Since length are resolution independent, it doesn't make sense anymore
to have the pixel infix.
2020-08-04 16:56:42 +02:00
Simon Hausmann
2b713eb341 Use a default font size that scales with the window scale factor
This is still coded in the backend but eventually we'll have default values
properties of items and then that can go there.
2020-08-04 16:53:48 +02:00
Simon Hausmann
76adda0abd Move ComponentWindow and friends from datastructures into eventloop 2020-08-03 14:26:47 +02:00
Simon Hausmann
1b270f42d0 Move datastructures::Color into graphics 2020-08-03 13:27:35 +02:00
Simon Hausmann
fa87363dc5 Move Point, Rect and Size into graphics
And move the expanded structures for cbindgen into an ffi sub-module.
2020-08-03 13:24:39 +02:00
Simon Hausmann
a2cec9e86f Clean up LyonPathIterator API
* Remove Lyon from the name and instead call it PathDataIterator.
* Remove the fit() function and just provide two factory functions.
2020-08-03 13:18:38 +02:00
Simon Hausmann
ce7f66320b Move datastructures::Resource into graphics
It's only used for graphics at the moment and used
for image resources.
2020-08-03 12:47:05 +02:00
Simon Hausmann
05f3ff10a6 Rename graphics::RenderingPrimitive to HighLevelRenderingPrimitive
That plays better with the existing LowlLevelRenderingPrimitive.
2020-08-03 12:39:57 +02:00
Simon Hausmann
550d0122a5 Move datastructures::RenderingPrimitive to graphics 2020-08-03 12:39:52 +02:00
Simon Hausmann
aa398c6277 Rename Resource::EmbeddedDataOwned -> EmbeddedRgbaImage 2020-08-03 12:20:17 +02:00
Simon Hausmann
6c5d423cd4 Rename sixtyfps_corelib to sixtyfps-corelib 2020-08-03 10:01:58 +02:00
Simon Hausmann
893124d64e Minor cleanup in glyph cache code
Merge string_to_glyphs and layout_glyphs -- they only make sense together here.
2020-07-28 14:22:34 +02:00
Simon Hausmann
cd77171bbc Move all glyph cache related code into one module 2020-07-28 14:22:34 +02:00
Simon Hausmann
c102fca828 Move the glyph rasterization code into the new font module in corelib 2020-07-28 14:22:34 +02:00
Olivier Goffart
d77d7cddc3 The viewer can use the Qt style with --style qt 2020-07-24 18:06:55 +02:00
Olivier Goffart
b8299747c6 WIP: some draft of a Qt style 2020-07-24 17:59:23 +02:00
Simon Hausmann
0c5b0fbabd Don't require a border width to make a rounded rect 2020-07-24 14:54:49 +02:00
Simon Hausmann
016834ad91 Don't fill a rectangle beyond its outline 2020-07-24 14:25:37 +02:00
Simon Hausmann
424f74a506 Minor style tweak
Use collect() instead of the explicit from_iter call. A little neater :-)
2020-07-24 10:49:17 +02:00
Simon Hausmann
9938197b58 Split Rectangle again
Into the previous Rectangle and BorderRectangle that allows (rounded) borders through a stroke in addition to the fill.

Next step is to make the compiler make the choice automatically depending
on the properties used.
2020-07-24 10:15:12 +02:00
Simon Hausmann
0a24fbd56d Reduce some code duplication in the renderer 2020-07-24 09:28:02 +02:00
Simon Hausmann
dd9bd2cf72 Add a rounded border to the button
There's still an open question about how to avoid the border properties
for all rectangles but allocate them only for those who have a border.
Regardless, this border illustrates the issue with the lack of text sizing.
2020-07-24 09:21:30 +02:00
Simon Hausmann
00f2d384b2 Fix formatting 2020-07-24 07:52:18 +02:00
Olivier Goffart
debd2b5839 Smaller workaround for the fact that some function are not exported 2020-07-23 17:11:00 +02:00
Simon Hausmann
992f990fa8 Allow for fitting paths into a given bounding rectangle
... by applying a transformation. This allows designing a path in some
other path design tool and then make it fit using bindings.
2020-07-13 15:41:11 +02:00
Simon Hausmann
6243df1702 Avoid unnecessary path building
When the path was constructed from events (SVG commands), then we don't really need to build an intermediate path,
neither for rendering nor for path layouting.
2020-07-10 13:59:40 +02:00
Simon Hausmann
ad98ae65ae Avoid unnecessary path building 2020-07-10 10:24:36 +02:00
Simon Hausmann
f45ff6ce79 Add support for stroking paths
This will make it easier to visualize the path for layouts.
2020-07-09 09:36:16 +02:00
Simon Hausmann
dfe95a2f6d Allow rendering primitives to break down into multiple GL primitives
This is in preparation for path stroking and filling.
2020-07-09 09:10:55 +02:00
Simon Hausmann
afa23faa94 Move the path building function into corelib
We're going to need it not only in the GL renderer but also in the layout code.
2020-07-08 20:36:40 +02:00
Simon Hausmann
32f9f4117f Upgrade to a new upstream glow version
This includes our fix for the texture creation from canvas, and requires
a little source compatibility fix.
2020-07-08 20:25:40 +02:00
Simon Hausmann
c6c0f1f589 Make path arc rendering more robust
Some arcs may not result in any content, for example if the radius is too small
or start and end pointer overlap. Let Lyon do the
checking for us and handle it accordingly.

Newer versions of Lyon will allow the re-use of the SvgArc created temporarily.
2020-07-08 08:42:01 +02:00
Simon Hausmann
f646809ff4 Added ArcTo element for paths 2020-07-07 16:02:46 +02:00
Simon Hausmann
1ab71b8ca3 Prepare the path element setup in the run-time for extensibility
Make the anonymous struct for the LineTo variant in the PathElement enum
as separate structure, which can be introspected using rtto::FieldInfo.
2020-07-07 14:14:17 +02:00
Simon Hausmann
9cf2d618d2 Use Lyon's path builder
Instead of trying to convert the individual (future) elements, let's use a builder.
This way the markup remains simple and due to
future support for bindings we can't really
pre-compute the path events anyway.
2020-07-07 14:14:17 +02:00
Olivier Goffart
1cbd522a03 Rust: make non-constant model and if expression work 2020-07-03 14:04:23 +02:00
Simon Hausmann
4e22c2839e Add the rendering primitives for rendering a path
Right now the path is limited to polygons (only LineTo elements) and only the fill color can be specified.
2020-07-01 14:58:09 +02:00
Simon Hausmann
98ba6a66be Switch glow version to upstream master revision
My fix for creating textures from html canvas elements was merged into
upstream. Until a new version is on crates.io, let's use a pinned sha1
from upstream instead of my fork.
2020-06-22 08:30:30 +02:00
Simon Hausmann
8f613685ba Expose a ComponentWindow in C++
This paves a way for a more modular API.
2020-06-17 19:15:18 +02:00
Simon Hausmann
9df888578f Expose a ComponentWindow type in Rust
This comes with a factory function that re-directs to the backend and a
run member function to replace
sixtyfps_runtime_run_component_with_gl_renderer. For now it's all still
hidden in the generated run() method.
2020-06-17 19:15:18 +02:00
Simon Hausmann
85bf8a195a Improve EventLoop encapsulation
Hide the winit loop and extract it only in the GL renderer
2020-06-17 15:16:46 +02:00
Simon Hausmann
271f52b9c9 Fix rectangle rendering with alpha
Lyon generates triangles, not a triangle strip. For a triangle strip
we'd end up drawing too many triangles, messing
up the alpha on overdraw.
2020-06-16 13:46:25 +02:00
Olivier Goffart
89968e0722 Add a Slice type which can be used in FFI 2020-06-10 14:23:57 +02:00
Simon Hausmann
1404cb73ae Add support for embedding resources in the rust generator
This is relatively straight-forward via a pass in the compiler to
collect the resources to embed and then use include_bytes! (once per
resource).

What's really annoying is that the rust resource enum can't store a
&'static [u8] because cbindgen doesn't represent that, probably because
the slice representation isn't guaranteed to stay as it is. So instead
this, for now, uses raw pointers.
2020-06-09 22:54:29 +02:00
Simon Hausmann
5bae6e01a5 Prepare for the ability to embed image data
The Image's source property used to be a string. Now it is a Resource
enum, which can either be None or an absolute file path to the image on
disk. This also replaces the internal Image type.

The compiler internally resolves the img bang expression to a resource
reference, which shall remain just an absolute path. For now the target
generator passes that through, but in the future the target generator
may choose a target specific way of embedding the data and thus
generating a different Resource type in the final code (through
compile_expression in the cpp and rust generator).

The C++ binding is a bit messy as cbindgen doesn't really support
exporting enums that can be constructed on the C++ side. So instead we
use cbindgen to merely export the type internally and only use the tag
from it then. The public API is then a custom Resource type that is
meant to be binary compatible.
2020-06-09 22:54:29 +02:00
Simon Hausmann
aa61a9d2b2 Reduce the #[cfg] usage a little in the GL renderer
Collect configuration specific fields in one PlatformData structure.
2020-06-09 14:04:39 +02:00
Simon Hausmann
afd7319ae5 Rename corelib to sixtyfps_corelib
This is consistent with the other packages and since corelib is now also
a cdylib, libsixtyfps_corelib.so looks much better than libcorelib.so
:-)
2020-06-09 13:27:18 +02:00
Simon Hausmann
547a732e33 Fix rebuild issues, part 10523
By setting RUSTFLAGS in the Cargo config we run into the situation that
when doing a host build, all rust files are compiled with the flags,
including build.rs. When cross-compiling, build.rs is not build with the
RUSTFLAGS specified. That makes kind of sense, but it also means that
all the build scripts are always recompiled when switching between a
target and a host build - and that applies to *all* packages, including
dependencies.

So short of a better solution, this patch removes the need to set
RUSTFLAGS. It was used to extract the system library dependencies for
the static library we'd create. Instead we're now building two shared
libraries and are linking against them. They contain the rust library
twice, so that's not really a desirable final state either, but
productivity wins right now :-)

It might make sense to go back to creating *one* shared library through
a dedicated crate and -- since 'pub extern "C"' functions are not
transitively exported, it may require re-exporting them by hand or using
some clever build trick perhaps.
2020-06-09 13:08:59 +02:00