Skip to content
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

Canvas off-screen caching #49

Open
jonathanolson opened this issue May 16, 2013 · 3 comments
Open

Canvas off-screen caching #49

jonathanolson opened this issue May 16, 2013 · 3 comments

Comments

@jonathanolson
Copy link
Contributor

There are two types of caching to be supported:

  • Cache a node (and its subtree) at a specific resolution, draw to the canvas with the node's global transform (blurry if transform isn't an integral translation, may be pixelated on zoom, but doesn't need to update on a node or its ancestors being transformed) - may consider adaptive resolution for zooming? This would help BASE. Also consider snapping to integral translations?
  • Cache an instance (and its subtree) in global coordinates, draw to the canvas with no transform. Always sharp as possible, but needs to be updated any time the node or one of its ancestors is transformed.

This issue is to track progress.

@ghost ghost assigned jonathanolson May 16, 2013
@jonathanolson
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@jonathanolson
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants