phetsims / scenery

Scenery is an HTML5 scene graph.
MIT License
54 stars 12 forks source link

Canvas off-screen caching #49

Open jonathanolson opened 11 years ago

jonathanolson commented 11 years ago

There are two types of caching to be supported:

This issue is to track progress.

jonathanolson commented 11 years ago

Also, it should be able to use whatever renderer is currently active (Canvas as a canvas, SVG with a data URL, or DOM with an actual HTMLImageElement). It would still use Canvas drawing to write to the off-screen canvas.

It should also be nestable, since that has beneficial performance payoffs in a number of cases.

Implementing it as a CanvasCachingNode that has children breaks the ability to quickly experiment with different performance settings, so I would strongly prefer to have flags set on Nodes.

For local caching, we would need a way to control resolution (probably as a scale relative to the node's transform, so something like cacheScale = 2 might draw the node into a canvas twice as large as its bounding box).

For global caching, we need to know how to handle sub-pixel translation (rotation or scaling will cause cache invalidation). We could either invalidate (ensures smooth animation, but slow), snap to whole-pixel offsets of whatever offset it is initially cached at (with the ability to invalidate and have it be precise), or just translate smoothly (and deal with any blur and loss of performance)

jonathanolson commented 11 years ago

Removing this milestone, planned to work in after sims are published.

jonathanolson commented 9 years ago

Note that sync and pruning will need to be checked for this implementation.