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

Support compositingMode in Bloc-Alexandrie (WIP) #268

Merged
merged 13 commits into from Jul 28, 2023

Conversation

tinchodias
Copy link
Collaborator

@tinchodias tinchodias commented Jun 14, 2023

It may be too simplistic support, I should check non-trivial examples.

Basically, when an element has to draw itself on a canvas and responds true to wantsSeparateCompositingLayer, then it's cached in a Cairo surface that, if didn't change, will be reused on next space redraw.

There are three options:

  • 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.
  • The element has an effect that answers true to wantsCompositionLayer. This is the case for BlGaussianShadowEffect.

…es it

It's used when the element responds true to wantsSeparateCompositingLayer.
@tinchodias tinchodias mentioned this pull request Jun 14, 2023
@labordep
Copy link
Contributor

Thanks @tinchodias, I don't understand wantsCompositionLayer option ?

@tinchodias
Copy link
Collaborator Author

hi @labordep that's the testing method that the element uses to check if it will cachecin a surface. Any of the 3 options I enumerated makes the testing method answer true

@labordep
Copy link
Contributor

Ok thanks :-)

@ELePors
Copy link

ELePors commented Jun 15, 2023

Just a comment about that, We noticed also a slow down when using some effects, i think that the buffering is not efficient.
I just tried to build a form using exportAsForm to have a buffer of my BlElements, i hide my blElement composition and i show the buffer in a new blElement... and i dragged it... and it was fluid...

But when i use '''beInSingleCompositionLayer''' it is still slow...

I think there is a lot of computations when moving a BlElement container, even if it is buffered...
not simple :)

@ELePors
Copy link

ELePors commented Jun 15, 2023

And i think that a Form is NOT the solution for buffering, It have to be a primitive element from the Canvas, an efficient buffer manipulated by the native canvas and cached by the BlElement as an external ressource pushed to the canvas at will to avoid redrawing... (like a CairoTexture ? )

@tinchodias
Copy link
Collaborator Author

Hi @ELePors !

I think there is a lot of computations when moving a BlElement container, even if it is buffered...
not simple :)

this can be key

But (assuming you have loaded the PR #268)... Some points that come to my mind, I hope any of them help:

  1. We can see the current state of layers by inspecting:
(space root allChildrenBreadthFirstSelect: [ :each |
	each hasCompositionLayer ]) collect: [ :each |
	each compositionLayer surface ].
  1. The layer both generated and applied in BlElement>>#ensureLayerAndDrawOn:. It's a place to insert "debug code" to watch what happens. Maybe a layer is generated too many times more than needed.

  2. The AeCairoImageSurface generated there is an external resource as I understand it, it leaves outside Pharo in C structs of cairo library... but yes in regular memory, not in videocard memory, I think you refer to this... a SDL_Texture would be cool. I will do a new attempt to implement it fast (before I tried but failed).

  3. Also, as a closer alternative we can try generating a new Cairo group instead of a new Cairo surface. This would be sending AeCairoContext>>#pushGroup and AeCairoContext>>#popGroupAsSurfacePattern.

@ELePors
Copy link

ELePors commented Jun 15, 2023

And if the BlElement is buffered and not dirty, when we change his position, it shoud not alter subElements... or we should have a way to move it without recomputing, and afrer move is finished, force computation... if you see what i mean ?

(i am on dev-1.0 and up to date)

@tinchodias
Copy link
Collaborator Author

(i am on dev-1.0 and up to date)

Ah but this PR is the only that makes layers work

@ELePors
Copy link

ELePors commented Jun 15, 2023

i just checked out the alexandrie_composition_layer branch ? Is it that ?
I have a composite BlElement named "CWMap" what do i have to do ?

@tinchodias
Copy link
Collaborator Author

When an element changes, will BlElement>>#markNeedsPaintFrom: marks it (flags addNeedsPaint) to regenerate the layer. When an element with layer already generated moves, what's marked is the parent of it.
This is what I understand at the moment.

@tinchodias
Copy link
Collaborator Author

@ELePors you can send the beInSingleCompositionLayer to the CWMap

@ELePors
Copy link

ELePors commented Jun 15, 2023

Ok (i am on discord if you prefer)

Previous approach could be useful in certain scenarios, so I might recover it.
It's problem was that a transformed element was being drawn with the
identity matrix and then transformed at paint, resulting in poor quality.
@tinchodias
Copy link
Collaborator Author

Failing tests are not produced by this PR

@tinchodias tinchodias merged commit a792181 into dev-1.0 Jul 28, 2023
0 of 12 checks passed
@tinchodias tinchodias deleted the alexandrie_composition_layer branch July 28, 2023 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants