-
Notifications
You must be signed in to change notification settings - Fork 104
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
feature: provide surface access via the Renderable #3355
Conversation
So, I'm torn on this whole enterprise. On one hand, this is the wrong spot to do this. Particularly, there's no guarantee that the compositor is actually going to call your On the other hand, even the On the third hand, the eternal scenegraph discussion. 🤷♀️ ¹: Which, to be fair, it won't be able to at the moment, as that's not properly implemented. |
@@ -69,6 +72,9 @@ class Renderable | |||
virtual glm::mat4 transformation() const = 0; | |||
|
|||
virtual bool shaped() const = 0; // meaning the pixel format has alpha | |||
|
|||
virtual auto surface_if_any() const | |||
-> std::optional<mir::scene::Surface const*> = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::optional<pointer const*>
is not super different to plain pointer const*
; I could go either way on this; we should probably have an actual style guide decision on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So long as we adhere to the Core Guidelines:
R.2: In interfaces, use raw pointers to denote individual objects (only)
R.3: A raw pointer (a T*) is non-owning
I'm also fine with a named Foo cont*
provided that there's a clear indication (like _if_any
) when nullptr
is possible.
For reference, Sophie was keen on std::optional<>
, so there's some of that around the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like std::optional
personally because it shows intent. We don't null
-check every shared_ptr
in the repo, so I would assume that when we're accessing any pointer, we can assume that it is probably set.
To be clear: this seems like a pragmatic solution to get something working; we've not prioritised getting a nice API for this so waiting for that is unreasonable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are not problems in this code, but thinking on the usecase you mention...
Keeping pointer values in any sort of lookup needs care: a pointer is only valid until the memory it references is deallocated (typically part of deleting the referenced object). After that just accessing (not dereferencing) the pointer is undefined behaviour.
(Not merging pending discussion on std::optional<>
)
auto surface_if_any() const | ||
-> std::optional<mir::scene::Surface const*> override | ||
{ | ||
return {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return {}; | |
return std::nullopt; |
I was not aware that we wanted to do this! Would this mean that instead of going through the GL renderer, surfaces (somehow) just get blipped onto a hardware plane?
👍
Yeah this might be the better solution, but I am afraid I would wait around a while for it, huh? |
8eb9382
to
4b3450a
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3355 +/- ##
==========================================
- Coverage 77.36% 77.33% -0.04%
==========================================
Files 1075 1065 -10
Lines 68268 67883 -385
==========================================
- Hits 52813 52494 -319
+ Misses 15455 15389 -66 ☔ View full report in Codecov by Sentry. |
For my use case, I won't be storing these references, but rather using them when they come to me to resolve back to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. As I say, a pragmatic hack!
Alternative to #3349
What's new?
Surface
via theRenderable