Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlElement buffer-able #267

Closed
ELePors opened this issue Jun 6, 2023 · 6 comments
Closed

BlElement buffer-able #267

ELePors opened this issue Jun 6, 2023 · 6 comments

Comments

@ELePors
Copy link

ELePors commented Jun 6, 2023

It could be very usefull to have an inner property of BlElement to be able to bufferize it, or a Trait which enable a BlElement to do so...
When you draw a complex BlElement with multiple BlElement transformed as children, and when children are not updating all the time... the developper should be able so specify a "buffered" BlElement to render only the buffer (when not dirty) and not recompute all child when just moving it.

@labordep
Copy link
Contributor

labordep commented Jun 7, 2023

This is particularly used when some complexe BlElements composition are used to decorate an UI as non-interactive elements. For example you can imagine a background generated with BlElement (for example depending screen size) as a mosaic of advanced image :

image

image

@ELePors
Copy link
Author

ELePors commented Jun 8, 2023

Yes and it will be costless to move a texture drawn by the BlElement than drawing each time each child...

@tinchodias
Copy link
Collaborator

There is beInSingleCompositionLayer that flags a BlElement as buffered. I did an experiment with the SDL_Texture, but also would improve with a cache at the level of Cairo. e.g. do cache the cairo_surface_t or group instead of redrawing as now.

@ELePors
Copy link
Author

ELePors commented Jun 9, 2023

Yes it is a good idea, and more : if dirty, the BlElement must have to refresh the buffer (or a mechanism that allows it)... it is not the idea to have a non updatable BlElement...
But yes, for me it is very important to do beautiful and reactive UI things.

@tinchodias
Copy link
Collaborator

Hi, this is a proposal for this request: #268

@tinchodias
Copy link
Collaborator

This is fixed by #268

Basically, when an element has to draw itself on a canvas and responds true to wantsSeparateCompositingLayer, then it's drawn in a new Cairo surface, and then "painted" into the host space canvas. Next pulse with drawing phase needed, if the element wasn't invalidated, the Cairo surface will be painted again into the host space canvas without need to redraw again.

It's quite basic for the moment: if a BlElement answers true to wantsCompositionLayer, then it will be on a separate Cairo surfaces.

There are two strategies for doing it:

  • anElement beInSingleCompositionLayer, that caches itself and all recursive children in a single surface (it doesn't matter if any of the children have one of these options)
  • anElement beInSeparateCompositionLayer, that is similar to previous option but any children can be cached separately.

Note: Element effect's have wantsCompositionLayer on their API, which the element queries to decide if it has a composition layer. For example, BlGaussianShadowEffect answers true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants