Fix the UI scaling factor invalidating the render cache#3818
Fix the UI scaling factor invalidating the render cache#3818TrueDoctor merged 2 commits intomasterfrom
Conversation
Summary of ChangesHello @TrueDoctor, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where UI scaling led to incorrect render caching. The solution involves enhancing the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses an issue with the render cache when UI scaling is active. The fix involves two main changes: including the device scale in the cache key to differentiate renders at different UI scales, and correcting the calculation of viewport bounds which was previously incorrect due to mixing logical and physical scales. The changes appear to correctly solve the problem. I've provided one suggestion to improve the clarity and maintainability of the viewport bounds calculation.
| let viewport_bounds = footprint.viewport_bounds_in_local_space(); | ||
| let viewport_bounds = AxisAlignedBbox { | ||
| start: viewport_bounds.start, | ||
| end: viewport_bounds.start + viewport_bounds.size() / device_scale, | ||
| }; |
There was a problem hiding this comment.
This recalculation of viewport_bounds is a bit indirect. It relies on the implicit knowledge that viewport_bounds_in_local_space returns a bounding box with a correct start position but a size that is too large by a factor of device_scale. This happens because it's called with a physical resolution while the transform only accounts for logical scale.
For better clarity and maintainability, it would be better to calculate the bounds directly using the correct logical resolution.
| let viewport_bounds = footprint.viewport_bounds_in_local_space(); | |
| let viewport_bounds = AxisAlignedBbox { | |
| start: viewport_bounds.start, | |
| end: viewport_bounds.start + viewport_bounds.size() / device_scale, | |
| }; | |
| let inverse_transform = footprint.transform.inverse(); | |
| let logical_resolution = footprint.resolution.as_dvec2() / device_scale; | |
| let viewport_bounds = AxisAlignedBbox { | |
| start: inverse_transform.transform_point2(DVec2::ZERO), | |
| end: inverse_transform.transform_point2(logical_resolution), | |
| }; |
c1a5836 to
5a00eb8
Compare
5a00eb8 to
4fec69a
Compare
Fixes regression from #3722.