Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Remove wlr_egl from backends #2602

Merged
merged 2 commits into from
Jan 7, 2021
Merged

Conversation

bl4ckb0ne
Copy link
Contributor

@bl4ckb0ne bl4ckb0ne commented Jan 6, 2021

Removes the wlr_egl member from various backend to keep it into the wlr_renderer. This also removes various includes of the render/egl.h header that were made useless by this patch.

References: #2563


Breaking change: wlr_renderer_autocreate no longer takes a struct wlr_egl * as parameter.

@bl4ckb0ne bl4ckb0ne marked this pull request as ready for review January 6, 2021 03:47
@emersion emersion added the breaking Breaking change in public API label Jan 6, 2021
Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! Here are a few comments.

This needs to be rebased on top of #2593.

render/wlr_renderer.c Outdated Show resolved Hide resolved
@@ -276,6 +275,9 @@ struct wlr_renderer *wlr_renderer_autocreate(struct wlr_egl *egl,
config_attribs = all_config_attribs;
}

struct wlr_egl *egl = calloc(1, sizeof(*egl));
Copy link
Member

Choose a reason for hiding this comment

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

This memory is leaked when the renderer is destroyed.

I think long-term we'll want to either:

  • Allocate the wlr_egl as part of the wlr_gles2_renderer. This means wlr_gles2_renderer_create would need to take all arguments necessary for the call to wlr_egl_init.
  • Make wlr_gles2_renderer_create take over the wlr_egl (kind of like you're doing in this PR), and replace wlr_egl_init/wlr_egl_finish with wlr_egl_create/wlr_egl_destroy so that the GLES2 renderer can cleanly free the wlr_egl (this would ensuring it's not part of a larger structure).

For this PR we can probably just free(renderer->egl) when destroying the GLES2 renderer, and properly document that wlr_gles2_renderer_create takes ownership of the wlr_egl?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Huh, I was sure I added the free in the wlr_renderer_destroy function. Good catch.
I like the idea of wlr_gles2_renderer becoming the owner of wlr_egl, it makes more sense when we will add the pixman backend.

I'll slap a nice comment and a TODO.

Copy link
Member

Choose a reason for hiding this comment

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

OK. I slightly edited the PR to also add a note in the header defining wlr_gles2_renderer_create.

backend/headless/backend.c Outdated Show resolved Hide resolved
@emersion
Copy link
Member

emersion commented Jan 6, 2021

Also, is it possible to get rid of the unnecessary includes in a separate commit?

@bl4ckb0ne
Copy link
Contributor Author

bl4ckb0ne commented Jan 7, 2021

There you we go, I can reword the commit if you want, I put in something generic since it affects two both the backend and the render folder. I also rebased the patch to get the modifications from #2563

Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@emersion emersion merged commit 9192c04 into swaywm:master Jan 7, 2021
@emersion emersion mentioned this pull request Mar 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking Breaking change in public API
Development

Successfully merging this pull request may close these issues.

None yet

2 participants