Fix cursor loading incorrect image size when ImageData is unavailable at requested zoom #2317
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.
Description
Before this change, the cursor used DPIUtil.validateAndGetImageDataAtZoom() to get image data. However, this method could return image data at a different zoom level if the exact match wasn't available from the ImageDataProvider. As a result, the cursor could be scaled incorrectly, since the returned image data was assumed to match the requested zoom.
With this change, a temporary Image is created, and Image.getImageData(zoom) is called to get properly scaled image data for the requested zoom level.
Steps to reproduce:
Run the below snippet at 150% monitor zoom. The ImageDataProvider in the snippet returns image data only for zoom levels 100 and 200.
Without this change
When run without any
swt.autoScale
VM argument, the cursor size was incorrectly scaled to 60×60.When run with
-Dswt.autoScale=quarter
, the cursor is 30x30.With this current fix applied
The cursor is now correctly sized (e.g., 45×45 at 150% zoom).
Note : This snippet is adapted from [issue #2057](#2057 (comment) to get the scales