Commit graph

44 commits

Author SHA1 Message Date
Olivier Goffart
763065fd0e Disable the std feature from strum
also use its derive feature
2021-11-25 12:02:16 +01:00
Simon Hausmann
13de800ba3 Internal cleanup: Rename layouting_info to layout_info
That's making the call on the Component VTable consistent(ish) with the Item VTable.
2021-11-08 10:24:30 +01:00
Simon Hausmann
dd043fc51b Fix texture caching for images with the same source but different image-rendering properties
As tests/cases/examples/image_rendering.60 itself demonstrates, the png file
should be loaded into the CPU side image cache once, but the two textures
should be cached independently.

cc #465
2021-09-06 13:47:41 +02:00
Ryan Van Gilder
4d1d0e73a4 Rename image-scaling to image-rendering to align with CSS 2021-09-06 10:03:51 +02:00
Ryan Van Gilder
a03a27ae0d Add image-scaling property to Images to control how they are scaled
Like CSS image-rendering it has "smooth" and "pixelated" options.
Only OpenGL has been tested right now, have not tested WASM or Qt.
Right now the first instance of a @image-url() will set the scaling
for that specific image. The same image used from memory on the otherhand
can all have a different scaling property.
2021-09-06 10:03:51 +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
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +02:00
Olivier Goffart
ae114cf79d C++: don't re-export private symbol in the public API
Use the cbindgen_private namespace dirrectly from the generated code
2021-06-28 12:03:49 +02:00
Olivier Goffart
32e59cf040 Fix division by 0 when layouting empty images 2021-06-22 14:27:01 +02:00
Olivier Goffart
d0923bd82f Height for width for Image in layout 2021-06-21 12:24:36 +02:00
Simon Hausmann
0fdb87cc69 Add Image::size()
This requires the image size query to be window independent and go
through the backend instead.

This implies minor changes for the Qt backend and bigger ones for the GL
backend:

* There exists now a thread-local IMAGE_CACHE, which is used by the
  backend's image_size() function as well as by the renderer for
  loading CPU side images.
* The image remain as decoded images in there (including SVG tree)
  and the window now has a texture_cache, which holds CachedImage
  with ImageData::Texture.
* Rendering an image item therefore fetches the CPU side image,
  calls upload_to_gpu() on it, which creates a new Rc<CachedImage>
  and that's stored in the texture_cache.
* The texture cache continues to be pruned when hiding the window.
2021-06-20 11:18:28 +02:00
Olivier Goffart
deaa0fddb0 WIP layout: split vertical and horizontal cache
Split the vertical and horizontal pass into different property cache
This will allow to implement "height for with"

This patch does not port the Rust or C++ binding yet
2021-06-16 15:14:07 +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
4584c40544 Rename items::Image to ImageItem
Because there will be soon a sixtyfps::Image and the names
can't clash
2021-05-28 17:05:16 +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
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
Simon Hausmann
843f52b3c5 Implement preferred size for images in box layouts
This partially implements #168 as well as #182
2021-04-08 12:06:42 +02:00
Olivier Goffart
6f88d78303 Rename Resource to ImageReference in the runtime 2021-03-11 10:06:23 +01:00
Olivier Goffart
a71edafa33 Refactor the way the mouse events are processed
Have a function first called before the children, and then the main function
called after the children if they did not accept the event.  This will allow
processing the Flickable gesture properly
2021-02-12 20:47:59 +01:00
Simon Hausmann
fd5757bc44 Simplify coordinate handling for item rendering
Remove the pos parameter to the render functions and instead let
the item renderer apply the transformation on the rendere (femtovg
canvas or QPainter).

So `draw_*` functions in the backend now always operate in item local
coordinates.
2021-02-12 17:12:58 +01:00
Simon Hausmann
8a66af0746 Clean up image size determination in the rendering backend
Don't use the item's rendering cache to determine the image size, as
that's soley for rendering. The Qt backend doesn't use the item cache
and the GL backend neither after this change. Instead both backends have
a cache for decoded images.
2021-02-10 17:34:29 +01:00
Olivier Goffart
f7a76dc352 Add ImageFit::cover, and fix ImageFit::contain 2021-02-09 10:52:04 +01:00
Olivier Goffart
0e2471f76b Image::colorize support
(Qt only)
2021-02-04 17:44:01 +01:00
Olivier Goffart
fc9374b35b Prepare rtti to be able to handle Callback with argument 2021-01-20 10:00:19 +01:00
Simon Hausmann
003fdb2564 Fix property dependency chain for Image::implicit_size()
The GL backend uses the item graphics cache for the image size function,
which uses a PropertyTracker. That tracker must have the Image's source
included in its dependencies, to avoid that when loading a HTML image
for example, the cache isn't invalidated when the source is changed
before the HTML image was loaded async. That's why the get() call on the
source property must happen from within the PropertyTracker's callback.
2021-01-18 08:50:41 +01:00
Simon Hausmann
77b5a86168 Add an implicit size to text and image items
For all other items the default is the empty size.

This also required three fixes for the HTML image loading:

  * The upload_pending property value was inverted, it needs to start
    out as true (pending yes) and be set to false when it finished
    loading (not pending anymore)
  * Mark the upload_pending property as dirty before scheduling the
    redraw, in case it's sync
  * Pass the item rendering cache to the image_size function to ensure
    that the Rc<CachedImage> is not only weak inside the image_cache
    of the GLRendererData but also strong on the item.
2021-01-15 17:56:49 +01:00
Simon Hausmann
1ed35fb628 Replace uses of FIELD_OFFSETS.foo.apply_pin(bar) with bar.foo() 2021-01-14 08:53:13 +01:00
Simon Hausmann
65dcb2cb33 Merge BuiltinItem and GeneratePropertyAccessors derive macros
... into the new SixtyFPSElement macro. This generates getters for all properties.
2021-01-14 08:53:13 +01:00
Olivier Goffart
9050c29305 Don't use the window through the eventloop module 2021-01-14 08:53:13 +01:00
Olivier Goffart
c7ff67d0fc Move the ItemRenderer to the item_rendering module 2021-01-14 08:52:22 +01:00
Simon Hausmann
de4194c9ba Make ItemRenderer take &mut again
It's cleaner and indeed possible
2021-01-14 08:52:22 +01:00
Simon Hausmann
43127cb059 Implement releasing of textures when items are destroyed
This means going back to an immutable renderer reference and interior
mutability for the canvas and the gpu cache. This is because while
traversing the item tree for rendering we may end up destroying
other items due to the lazyness of the models.
2021-01-14 08:52:22 +01:00
Simon Hausmann
d92fe445d5 Remove the old GL renderer
and try to stub in the hooks to trigger the new one
2021-01-14 08:52:22 +01:00
Simon Hausmann
d4f603246c WIP: Start a femtovg backend 2021-01-14 08:52:22 +01:00
Simon Hausmann
8dea0c88d1 Beginning of a different way of rendering items
This is the start of a different rendering abstraction, the result of a
separate discussion.

The objective is to provide a better backend encapsulation, that will
make it easier to implement other backends and let the backend decide
what to cache and what not. This is done by passing the struct with the
Property<> fields directly to the backend, so that it can decide what
the cache and what to use every time.
2021-01-14 08:52:22 +01:00
Olivier Goffart
16f5a03c14 Run cargo fmt 2020-12-18 10:29:15 +01:00
Olivier Goffart
0d2d48be4f Rename "signal" to "callback" 2020-12-18 09:51:01 +01:00
Olivier Goffart
2b5213c408 Refactor the rendering variables in a enum instead of an array
And finish the ImageFit::contain implementation
2020-12-15 12:16:44 +01:00
Simon Hausmann
625978fe1a WIP: Add an image-fit property to Image/ClippedImage 2020-12-15 10:26:54 +01:00
Simon Hausmann
3ead4813e2 Fix build
Ammend the parent commit by making the `Signal` import conditional to
RTTI.
2020-12-10 09:46:25 +01:00
Simon Hausmann
753ea9eee8 Fix warning about unused import 2020-12-10 09:41:52 +01:00
Simon Hausmann
447bc9aa6d Split the text and image items into text.rs/image.rs 2020-12-08 17:19:31 +01:00