Continuous zoom and direct rendering #79
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the ability to continuously zoom in and out on the PlotDevice canvas with a trackpad or mouse. It also improves rendering performance by replacing the bitmap-based approach with directly rendering to the graphic context.
Continuous zoom
zoom_demo.mov
Direct render approach
Previously, the GraphicsView would pre-render the entire canvas to a bitmap (NSImage) at the current zoom level, convert it to a CALayer's contents, and display that layer. This has been replaced by directly drawing to the view's graphics context, with viewport clipping to only draw the visible portion of the canvas.
This avoids potentially expensive pre-rendering and caching, which can be significantly faster for large scenes or high zoom levels:

This is particularly helpful when working with animations, since each frame draws faster:
animation_test.mp4
Note: The old bitmap approach was smoother when scrolling at high zoom (just moving a cached bitmap around instead of redrawing), but overall I think the benefits of direct drawing outweigh this.