-
Notifications
You must be signed in to change notification settings - Fork 186
[Win32] Reuse zoom handle for drawing image at size if appropriate #2634
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
[Win32] Reuse zoom handle for drawing image at size if appropriate #2634
Conversation
Test Results 118 files 118 suites 14m 14s ⏱️ Results for commit 3d1c6f4. ♻️ This comment has been updated with latest results. |
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
Outdated
Show resolved
Hide resolved
4ea8b2b to
c096306
Compare
c096306 to
3830985
Compare
|
Overall this PR looks good and seem to work properly due to my testing. But I was wondering, why don't we do a similar check in |
akoch-yatta
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks solid. I did not really run into the scenario to resuse a handle from the zoomLevelToImageHandle map in HandleAtSize#getOrCreateImageHandleAtClosestSize without making sure to create a fitting handle first in the runtime. But doing that it worked as expected.
3830985 to
12d5fc5
Compare
That definitely makes sense. I added the simple required logic with 12d5fc5. |
|
|
||
| private Optional<ImageHandle> getHandleAtExactSize(int width, int height) { | ||
| for (ImageHandle handle : zoomLevelToImageHandle.values()) { | ||
| if (handle.width == width && handle.height == height) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would cause a slight issue as if the image was requested at for eg 2X the height elsewhere, they would not be loaded with imageDataAtSizeProvider, we would then end up using this image while doing the drawing even though it is possible to load the image at the given target size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! That was exactly the reason for not doing it. I just adapted the PR again. Maybe we can still integrate something like this as a follow up in case we maybe revise the ImageDataAtSizeProvider.
12d5fc5 to
005dc7f
Compare
When drawing an image at a specified size, currently a new image handle is always created based on on-demand loaded image data. In case the fallback to loading image data for the best fitting zoom is used, a handle for that zoom may already exist and could be reused but is currently not considered. With this change, an existing handle is used if appropriate instead of unnecessarily creating a temporary handle.
005dc7f to
3d1c6f4
Compare
When drawing an image at a specified size, currently a new image handle is always created based on on-demand loaded image data. In case the fallback to loading image data for the best fitting zoom is used, a handle for that zoom may already exist and could be reused but is currently not considered.
With this change, an existing handle is used if appropriate instead of unnecessarily creating a temporary handle.