-
Notifications
You must be signed in to change notification settings - Fork 23
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
beginLayer
vs beginFilter
#32
Comments
Layers are not only useful for filtering operations. They can also be used to apply blending to the result of a group of draw calls, or more generally apply composite operations to such group. The canvas API is procedural, not declarative. It would be wasteful to have the JavaScript build a whole layer, just for it to be marked as hidden later. If a layer is to be hidden, it's better to simply not render it in the first place. Perhaps what you have in mind aligns with the Recorded Picture proposal (also called Display List). Display Lists would allow a group of draw calls to be replayed multiple times. Layers and Display Lists would be very different in terms of implementation, and in terms for their performance characteristics. We think that Layers and Display Lists provide solutions for two different problems and are both complementary. It would be a shame to impose the cost of building optimizing and caching display list if it's to be rasterized only once. We would rather have a high-performance code-path for single-use draw call group rasterizing, and another API focused on making draw calls rasterizable multiple times. Does that make sense? |
Hey @graveljp thanks for taking the time to write that up. That makes total sense on the reasoning for why it's designed the way it is. For actual layering I'd probably use multiple canvases stacked on top of each other. I think my point is mostly about naming. Using the "layer" in the name is likely going to require every explanation of the concept to be prefaced by something like:
(If you search "html canvas layers" you'll see lots of results all trying to solve the familiar problem of layering with canvas.) So I'd suggest using a different naming scheme that avoids that confusion. Something like |
I'm curious about why the naming uses "layers" as a concept with
beginLayer/endLayer
, instead of calling them simplybeginFilter/endFilter
if their sole purpose is to be able to apply filters to groups of commands. Because I excepted "layers" to be something else, more analogous to layers in a graphics editor that can be shown/hidden/reordered/etc.The text was updated successfully, but these errors were encountered: