-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[DisplayList] bookmarks allow random access dispatching #54299
Conversation
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 the idea!
From my understanding - we'd still need to manage tracking of things like paint state / CTM correct? Since for a drawRect, the paint would be updated before hand?
I think that would be reasonable since for draw ordering we'd likely just need to know opaque / non-opaque, though to actually re-order I guess we'd need to store the paint state too.
FYI @bdero
Yes, I think I demonstrated that in the code sample in the doc comments with little detail on the "other state" data. Unfortunately, I don't think the code sample will compile because I decided to delete the copy/move constructor/operators for safety (the object holds dispatch state so copying it will sever that association). |
For example, here is a code sample that wouldn't work:
To prevent this use case, I disabled the copy/move operations and the above wouldn't compile even though it is a natural sequence of events. This could be worked around by either having the We could rework this design to allow copying of Dispatcher objects if they implemented an internally shared State object between instances using a managed pointer, but that would mean it would be doing allocations even if you stack allocated it. Note that Bookmark objects are shareable since they are roughly immutable, but copying/moving them around will end up doing inc/decref on the internal sk_sp. |
My next thought that I'm going to prototype is simply adding
I need a solution for how to dispatch with a cull_rect, though. Perhaps Internally I will be reworking the storage to keep a sized list of offsets rather than having the records store a size in them. That frees up space in the records at the cost of a This solution would be much simpler from the outside as it doesn't need a series of coordinated objects that not only have to be kept consistent, but which also store expensive shared pointers. |
Alternative implementation using indexing: #54484 |
Closed in favor of the indexing method implemented in #54484 |
Being able to reorder rendering commands leads to optimization opportunities in the graphics package. A graphics package being fed from a DisplayList either has to take the commands in the order given or implement their own storage format for the rendering data.
With this new dispatching mechanism, the graphics package can do analysis on the properties of the rendering operations and then remember bookmarks into the operations so that they can later be dispatched in any order it prefers.