Commit graph

339 commits

Author SHA1 Message Date
Simon Hausmann
3146fb7764 internal cleanup: Remove the sixtyfps::testing::HasWindow trait
and replace it with the internal, re-exported WindowHandleAccess
one.

Strictly speaking, this is a breaking change. In practice the
returned type of this trait was in `sixtyfps::re_exports`, so any
public use is questionable :)
2021-07-21 20:33:02 +02:00
Simon Hausmann
eaddbe664e internal cleanup: Rename ComponentWindow to WindowRc
That's all it is nowadays, it's a wrapper around Rc<Window>. It's not an
alias because we need to also "wrap" it to C++ via cbindgen, but that's
about it.
2021-07-21 20:33:02 +02:00
Simon Hausmann
ef184f7f1a internal cleanup: Remove the rest of the ComponentWindow API
Now it just remains a wrapper around the Rc, and it can soon be moved to
the API crate hopefully.
2021-07-21 17:41:12 +02:00
Simon Hausmann
77ea5b7a15 API cleanup: hide the rest of the ComponentWindow "internals" 2021-07-21 17:41:12 +02:00
Simon Hausmann
4c1d9dc03e internal cleanup: Remove the poup functions from ComponentWindow
Use WindowHandleAccess instead. Also the clone()
isn't needed anymore since the function take a self reference instead of an Rc<Self> by value.
2021-07-21 17:41:12 +02:00
Simon Hausmann
e005058285 internal cleanup: remove free_graphics_resource from the public ComponentWindow API
Use the WindowHandleAccess backdoor instead.
2021-07-21 17:41:12 +02:00
Simon Hausmann
3aa959700c Revert "Attempt to fix a stack overflow in debug"
This reverts commit 51836a9457.

This is not needed anymore since PR #322
2021-07-15 12:20:01 +02:00
Simon Hausmann
42110263f6 Simplify field offset access workaround
As suggested by Olivier, we don't need the temporary variable. A ref followed
by immediate deref works just as well.
2021-07-15 12:19:20 +02:00
Simon Hausmann
aaf162d504 rust codegen: clarify comment about stack usage by referencing github issue 2021-07-15 12:19:20 +02:00
Simon Hausmann
30dbcdcaad rust generator: simplify field access code
There's no need for a separate access_self_field_offset function when
we can use format_ident directly.
2021-07-15 12:19:20 +02:00
Simon Hausmann
f7248a4863 Fix stack overflow with Rust generated code in debug builds on Windows
On Windows the default stack size is less than on Linux/macOS and
therefore an issues surfaces that is however operating system agnostic:

Due to inlining we generate quite big inner components with many fields.
Their field offsets are accumulated in the separate FIELD_OFFSETS
struct. The access pattern typically looks like this:

    Self::FIELD_OFFSETS.some_field.apply_pin(...)

This is destructed into at least two smaller operations, fetching
some_field and then calling apply_pin with that field as self parameter.

In Rust debug builds the first operation, unfortunately, ends up making
a full copy of Self::FIELD_OFFSETS into a temporary variable on the
stack. Unfortunately also that stack space isn't reused, so every access
results in a new stack allocation to hold all of the FIELD_OFFSETS
structure (~5kb in the printer demo).

With so many accesses to that in the generated code, we run out of stack
space already in the new() function, in item_tree() as well as in the
Drop impl that also accesses all field offsets.

This patch applies the following workaround that does the trick. The
above expression is replaced with

    {
        let field = &Self::FIELD_OFFSETS.some_field;
        *field
    }.apply_pin(...)

Fixes #133
2021-07-15 12:19:20 +02:00
Olivier Goffart
cc8249212d Fix name conflict when having two global with the same name in different files
Give globals an unique id so two global with the same name imported
from different file don't clash

Fixes #159
2021-07-13 14:36:38 +02:00
Olivier Goffart
6ed5044940 Fix rust compilation when using keywords in struct 2021-07-09 13:33:09 +02:00
Olivier Goffart
5c18e100b0 Fix unary operator + in rust 2021-07-09 12:52:18 +02:00
Olivier Goffart
a987b225b5 Collect all used components before inlining
And do some passes before inlining

We will need the list of components before inlining in order to generate
them if we disable inlining

So we can do some passes on each component before they are inlining

I tried to put the flickable pass in that list, but it did not work
if the Flickable itself is the root of a component
2021-07-07 17:58:43 +02:00
Tobias Hunger
e5bdeaa804 Janitor: Remove unnecessary & 2021-07-07 08:42:28 +02:00
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +02:00
Olivier Goffart
16ba23ae47 Move StateInfo to the private namespace 2021-06-28 11:23:44 +02:00
Tobias Hunger
13d7f5e7bd Janitor: Fix typos in comments and user-facing strings
Also adapt tests for error messages containing the fixed strings.

No behavior change is intended!
2021-06-28 08:32:25 +02:00
Tobias Hunger
87460c4ac8 Janitor: Fix typo in struct field name
No behavior change is intended here!
2021-06-28 08:32:00 +02:00
Olivier Goffart
99c140ae08 Allow accessing the width and height of the image in .60
Closes #208
2021-06-21 11:22:50 +02:00
Olivier Goffart
d758102f26 Make the orientation a static parameter to BuiltinFunction::ImplicitLayoutInfo 2021-06-16 15:14:07 +02:00
Olivier Goffart
7aba0f2a0b Layout split of horizontal/vertical
Rust part
2021-06-16 15:14:07 +02:00
Olivier Goffart
2483425d57 Add abs() 2021-06-11 14:17:47 +02:00
Olivier Goffart
ce34ff87d0 Finish support for callback aliases
cc #111
2021-06-07 20:40:36 +02:00
Olivier Goffart
142a8dc185 Rename ImageReference to ImageInner and make Immage.0 private 2021-05-28 17:05:16 +02:00
Olivier Goffart
0b3fecf300 WIP: API to expose image loading from C++ and Rust 2021-05-28 17:05:16 +02:00
Olivier Goffart
a1880bd943 Report an error when trying to convert from logical to physical coordinate in a global 2021-05-20 18:11:58 +02:00
Olivier Goffart
a79a4351b5 Be smarter at detecting the constant property and at not generating bindings
this implies that we need to make sure the property are initialized in
order so that constant properties that depends on other constant properties
are correctly computed
2021-05-20 13:40:51 +02:00
Olivier Goffart
ba1aff84d0 Layout refactoring: C++ part 2021-05-11 14:59:57 +02:00
Olivier Goffart
539a78e807 Rust: implement enough of PathLayout so that the tests passes
(does not implement the repeater case)
2021-05-11 14:59:57 +02:00
Olivier Goffart
f99d7de5ad Fixup layout in rust 2021-05-11 14:59:57 +02:00
Olivier Goffart
b01884f3b9 Layout refactor: do the rust part 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
51836a9457 Attempt to fix a stack overflow in debug
The function that initialize all the bindings is huge, and its framz size is
too big. Put each binding evaluation in its own function seems to help
to avoid the stack overflow

Hopefully fixes #133
2021-05-05 22:01:06 +02:00
Olivier Goffart
f620351cbf Go to definition of structs
Also add the struct in the outline
2021-04-24 15:06:58 +02:00
Olivier Goffart
91ed04a72c Make length (still the default for all property) be the logical length
And a new `physical_length` is now the physical_length unit

Note: this does not change the runtime part yet
2021-04-21 17:15:19 +02:00
Olivier Goffart
7ae850d564 Rename Type::Length -> Type::PhysicalLength 2021-04-21 17:15:19 +02:00
Olivier Goffart
3f3a4c4ec9 Store the actual property declaration node
so that the goto definition can go to the right location
2021-04-18 14:19:38 +02:00
Simon Hausmann
f995ec44ae Fix build of rust generated font loading setup code
The font registration functions return void, so generate a semicolon at the end of the call, like with SetFocusItem.
2021-04-14 09:44:33 +02:00
Simon Hausmann
f7ce1ba8b4 Generate registration code for custom fonts imported in .60 files
This removes the need to manually register fonts. This is initially
applied to the printer demo, but the other demos and removal of the
public manual registration API will come in follow-up commits.
2021-04-14 09:30:32 +02:00
Olivier Goffart
e67deebc76 Make rgb() and rgba() a macro that can take 3 or 4 arguments
and that accept both percent or integer

Closes #139
2021-04-12 15:19:15 +02:00
Olivier Goffart
ca64a540c4 Continue support for rgb() function
Fixup of previous commit which was part of https://github.com/sixtyfpsui/sixtyfps/pull/139
2021-04-12 15:18:25 +02:00
Seo Sanghyeon
0a76f40093 Add rgb function 2021-04-12 13:24:46 +02:00
Olivier Goffart
a712f515fa Make the viewport element of the flickable a real Element in the object_tree 2021-04-09 19:14:48 +02:00
Olivier Goffart
85986c39bd Layouting: make the materialize fake layout property have an actual value
So that when we query it from the code, it has a value
2021-04-08 14:35:16 +02:00
Olivier Goffart
4a79498761 Rename self_pinned to self_rc, that's a better name since _self is already pinned 2021-03-30 12:56:16 +02:00
Olivier Goffart
1b9ebda204 Rust generated code: Avoid using self_pinned when not needed 2021-03-30 12:55:10 +02:00
Olivier Goffart
5dfa2549c8 Put the named reference in a Rc so it will be easier to compute the use count and suck 2021-03-29 15:16:41 +02:00
Olivier Goffart
3db3400951 Rename the Object type to Struct in the compiler 2021-03-16 12:38:53 +01:00