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

core, wl, headless: New virtual functions in CogPlatform to track live viewport instances #683

Merged
merged 3 commits into from
Dec 20, 2023

Conversation

aperezdc
Copy link
Member

Platform implementations may need (or want) to track all the CogViewport instances in use. Until now this was done by fetching the list of viewports from CogShell, but that assumed that a.) there is always a shell instantiated, and b.) there will ever be only one viewport. It is already possible today to use multiple viewports (see examples/viewports.c) so the latter does not hold true. We want to also avoid using the shell from platform implementations so what this PR does is:

  • Add two vfuncs CogPlatform.viewport_created and CogPlatform.viewport_disposed, and corresponding signals CogPlatform::viewport-created and CogPlatform::viewport-disposed. These are triggered from CogViewport during creation and disposal using private functions.
  • Add multiple view support to the headless platform plug-in, using the above to track all views in all viewports.
  • Change the Wayland platform plug-in to use the above to track viewports, instead of picking the viewport list from CogShell.

After this, the uses that remain of the shell in platform implementations are related to their configuration. Those uses will be addressed in a separa patch set.

This is part of the work towards decoupling CogShell from CogPlatform, as per #634.

@aperezdc aperezdc added the enhancement New feature or request label Dec 18, 2023
@aperezdc aperezdc self-assigned this Dec 18, 2023
Add a pair of new CogPlatform::viewport-{created,disposed} signals,
available also as virtual functions. The main intended usage is
tracking live CogViewport instances inside platform plug-in
implementations.
Support more than one view. This is achieved by opting-in to use the new
CogView.create_backend vfunc, which makes each web view responsible for
creating its own WPE view backend. The platform keeps track of viewports
using CogPlatform.viewport_{created,disposed}, and on each frame timer
tick all views in from all viewports are checked for dispatching frame
acknowledgements.
Use the new CogPlatform.viewport_{created,disposed} vfuncs to track live
CogViewport instances, instead of relying on CogShell. This removes all
the usage of the shell instance in the Wayland platform, paving the way
to uncouple CogShell from CogPlatform.
wpe_fdo_initialize_for_egl_display(display->egl_display);

/* get a reference to the hashmap with viewports added to the shell */
self->viewports = cog_shell_get_viewports(shell);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The platform will use the new signals to track the Viewports by its own in the Platform::viewports. That is good.

What happens with the CogShell? it is still having its own list of Viewports accesible through cog_shell_get_viewports()?. Isn't redundant?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is redundant to have cog_shell_get_viewports() and I plan to revamp CogShell in follow-up PRs. I focused in this one to only avoid using the shell to track viewports inside platform plug-ins.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, scratch that, I will be adding one more commit here removing all the viewport handling from CogShell.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. good. Go ahead. Nice if we have all this done in the same PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spent a bit of time removing from CogShell all the code related to view and viewport handling, and it's bigger than expected. For my current WIP patch I have:

 5 files changed, 129 insertions(+), 413 deletions(-)

Now that is a nice amount of code removed, and there are opportunities to clean up things even more. Therefore I have changed my opinion again: let's merge this PR as-is, and leave the cleanups for follow-up PRs, to make them easier to review. WDYT @psaavedra?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. My feeling was the change was not so big so it makes sense to do it in 2 steps.

platform/wayland/cog-platform-wl.c Show resolved Hide resolved
Copy link
Member

@psaavedra psaavedra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R+

@aperezdc aperezdc merged commit 9e940ce into master Dec 20, 2023
5 checks passed
@aperezdc aperezdc deleted the aperezdc/multiple-views branch December 20, 2023 09:48
aperezdc added a commit that referenced this pull request Dec 20, 2023
Remove handling of viewports and vies from CogShell. Tracking live
viewports can be done using CogPlatform since #683 and platform
plug-ins no longer depend on CogShell for that. The following are
no longer needed in CogShell:

- The :web-view and :viewport properties, and their accessors.
- The ::create-view and ::create-viewport signals.
- The .create_view() virtual function and its default implementation.
- The cog_shell_add_viewport(), cog_shell_remove_viewport(),
  cog_shell_get_n_viewports(), and cog_shell_get_nth_viewport()
  methods.

As a side effect of the above removals, the examples have been changed
to have them create their views using cog_view_new() instead of relying
on the default implementation of the CogShell.create_view() virtual
function.

The launcher also needed a number of changes, which now manages itself
a viewport as it cannot rely on the shell for that. Some code was moved
around to accommodate creation of the view in cog_launcher_startup()
without relying on the CogShell::create-view signal, and similarly for
web view creation when running in automation mode.

There are more opportunities for further simplifications that would be
better done in separate patches: this one focuses on the minimum amount
of changes needed to get view and viewport handling out of CogShell.
aperezdc added a commit that referenced this pull request Dec 20, 2023
Remove handling of viewports and views from CogShell. Tracking live
viewports can be done using CogPlatform since #683 and platform
plug-ins no longer depend on CogShell for that. The following are
no longer needed in CogShell:

- The :web-view and :viewport properties, and their accessors.
- The ::create-view and ::create-viewport signals.
- The .create_view() virtual function and its default implementation.
- The cog_shell_add_viewport(), cog_shell_remove_viewport(),
  cog_shell_get_n_viewports(), and cog_shell_get_nth_viewport()
  methods.

As a side effect of the above removals, the examples have been changed
to have them create their views using cog_view_new() instead of relying
on the default implementation of the CogShell.create_view() virtual
function.

The launcher also needed a number of changes, which now manages itself
a viewport as it cannot rely on the shell for that. Some code was moved
around to accommodate creation of the view in cog_launcher_startup()
without relying on the CogShell::create-view signal, and similarly for
web view creation when running in automation mode.

There are more opportunities for further simplifications that would be
better done in separate patches: this one focuses on the minimum amount
of changes needed to get view and viewport handling out of CogShell.
aperezdc added a commit that referenced this pull request Dec 20, 2023
Remove handling of viewports and views from CogShell. Tracking live
viewports can be done using CogPlatform since #683 and platform
plug-ins no longer depend on CogShell for that. The following are
no longer needed in CogShell:

- The :web-view and :viewport properties, and their accessors.
- The ::create-view and ::create-viewport signals.
- The .create_view() virtual function and its default implementation.
- The cog_shell_add_viewport(), cog_shell_remove_viewport(),
  cog_shell_get_n_viewports(), and cog_shell_get_nth_viewport()
  methods.

As a side effect of the above removals, the examples have been changed
to have them create their views using cog_view_new() instead of relying
on the default implementation of the CogShell.create_view() virtual
function.

The launcher also needed a number of changes, which now manages itself
a viewport as it cannot rely on the shell for that. Some code was moved
around to accommodate creation of the view in cog_launcher_startup()
without relying on the CogShell::create-view signal, and similarly for
web view creation when running in automation mode.

There are more opportunities for further simplifications that would be
better done in separate patches: this one focuses on the minimum amount
of changes needed to get view and viewport handling out of CogShell.
aperezdc added a commit that referenced this pull request Dec 26, 2023
Remove handling of viewports and views from CogShell. Tracking live
viewports can be done using CogPlatform since #683 and platform
plug-ins no longer depend on CogShell for that. The following are
no longer needed in CogShell:

- The :web-view and :viewport properties, and their accessors.
- The ::create-view and ::create-viewport signals.
- The .create_view() virtual function and its default implementation.
- The cog_shell_add_viewport(), cog_shell_remove_viewport(),
  cog_shell_get_n_viewports(), and cog_shell_get_nth_viewport()
  methods.

As a side effect of the above removals, the examples have been changed
to have them create their views using cog_view_new() instead of relying
on the default implementation of the CogShell.create_view() virtual
function.

The launcher also needed a number of changes, which now manages itself
a viewport as it cannot rely on the shell for that. Some code was moved
around to accommodate creation of the view in cog_launcher_startup()
without relying on the CogShell::create-view signal, and similarly for
web view creation when running in automation mode.

There are more opportunities for further simplifications that would be
better done in separate patches: this one focuses on the minimum amount
of changes needed to get view and viewport handling out of CogShell.
aperezdc added a commit that referenced this pull request Jan 3, 2024
Remove handling of viewports and views from CogShell. Tracking live
viewports can be done using CogPlatform since #683 and platform
plug-ins no longer depend on CogShell for that. The following are
no longer needed in CogShell:

- The :web-view and :viewport properties, and their accessors.
- The ::create-view and ::create-viewport signals.
- The .create_view() virtual function and its default implementation.
- The cog_shell_add_viewport(), cog_shell_remove_viewport(),
  cog_shell_get_n_viewports(), and cog_shell_get_nth_viewport()
  methods.

As a side effect of the above removals, the examples have been changed
to have them create their views using cog_view_new() instead of relying
on the default implementation of the CogShell.create_view() virtual
function.

The launcher also needed a number of changes, which now manages itself
a viewport as it cannot rely on the shell for that. Some code was moved
around to accommodate creation of the view in cog_launcher_startup()
without relying on the CogShell::create-view signal, and similarly for
web view creation when running in automation mode.

There are more opportunities for further simplifications that would be
better done in separate patches: this one focuses on the minimum amount
of changes needed to get view and viewport handling out of CogShell.
bykov34 pushed a commit to bykov34/cog that referenced this pull request Mar 14, 2024
Remove handling of viewports and views from CogShell. Tracking live
viewports can be done using CogPlatform since Igalia#683 and platform
plug-ins no longer depend on CogShell for that. The following are
no longer needed in CogShell:

- The :web-view and :viewport properties, and their accessors.
- The ::create-view and ::create-viewport signals.
- The .create_view() virtual function and its default implementation.
- The cog_shell_add_viewport(), cog_shell_remove_viewport(),
  cog_shell_get_n_viewports(), and cog_shell_get_nth_viewport()
  methods.

As a side effect of the above removals, the examples have been changed
to have them create their views using cog_view_new() instead of relying
on the default implementation of the CogShell.create_view() virtual
function.

The launcher also needed a number of changes, which now manages itself
a viewport as it cannot rely on the shell for that. Some code was moved
around to accommodate creation of the view in cog_launcher_startup()
without relying on the CogShell::create-view signal, and similarly for
web view creation when running in automation mode.

There are more opportunities for further simplifications that would be
better done in separate patches: this one focuses on the minimum amount
of changes needed to get view and viewport handling out of CogShell.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants