-
Notifications
You must be signed in to change notification settings - Fork 152
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
Image type SWT.ICON loses its type during re-scale #1790
Conversation
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 do not completely understand the change. The assumption that an image with type SWT.ICON
loses it's type when rescaling does not seem to be always true. The following snippet succeeds, even without this change:
Image image = Display.getCurrent().getSystemImage(SWT.ICON_ERROR);
assertEquals("Image type should stay to SWT.ICON", SWT.ICON, image.type);
Image.win32_getHandle(image, 200);
assertEquals("Image type should stay to SWT.ICON", SWT.ICON, image.type);
So the issue rather seems to be about specific ways in which images of type Icon are created. Is it safe to apply this new behavior for all of them, even for those that properly worked before with the existing implementation?
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
Outdated
Show resolved
Hide resolved
tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/graphics/ImageWin32Tests.java
Outdated
Show resolved
Hide resolved
tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/graphics/ImageWin32Tests.java
Outdated
Show resolved
Hide resolved
c852174
to
2b9848c
Compare
The test were passing without the new changes because they were running without quarter scaling. I had my configuration done with quarter scaling on. Now I have move my test to different package as other "Resources Test" with correct settings. |
2b9848c
to
06ab00b
Compare
Can you explain why running the test with quarter scaling is necessary and why moving the test to a different bundle is necessary for that? For me, it does not make any difference whether I run the test with quarter scaling or not. I always succeeds, with the change in this PR and without. |
I am not sure why, but when we start working on it the issue was only in quarter. I can still see the test failing without quarter scaling (also updateOnRunTime should not be true) |
Is your primary monitor 200%? we probably should extend the test to explicitly request multiple zoom setting like:
That should definitely fail |
06ab00b
to
5e8700d
Compare
5e8700d
to
eb64cf3
Compare
Image initialized as SWT.ICON in Image(Device, ImageData, ImageData) loses its "Icon" properties, i.e. type, mask etc., when a handle for a different zoom level is requested and "SMOOTH" scaling is used. This change adapts the initialization of the image when the handle is requested for image type SWT.ICON to preserve the properties. Fixes eclipse-platform#1805
eb64cf3
to
2630103
Compare
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.
Change has the expected effect. I tested different documented scenarios and both linked issues are resolved by the change.
We will address an underlying issue (losing properties of the image such as transparency mask when autpscaling image data with "SMOOTH" mode in DPIUtil) as a follow-up
Regarding the test, Shahzahib and I debugged and found the problem: he uses 150% zoom which ends up using the auto scale method So the solution would be to either change the monitor zoom in the test (probably not possible in the CI) or setting |
Indeed, see: vi-eclipse/Eclipse-Platform#228 That will be resolved via: vi-eclipse/Eclipse-Platform#227 And in Tycho runs, smooth scaling seems to be activated anyway, as there are tests previously executed setting the device zoom and thus enabling smooth scaling as a "side effect" (again, see vi-eclipse/Eclipse-Platform#227). |
Set it to "smooth" so the test works as a proper regression test. Contributes to eclipse-platform#1790
How about setting it explicitly? That way we don't need to rely on the environment and one could run the test locally too. See #1807 |
The test either wants to test monitor-specific scaling (like suggested right now), then we need to fix how monitor-specific enables smooth scaling (see vi-eclipse/Eclipse-Platform#227) or it is supposed to test smooth scaling behavior, then the test needs to be rephrased and the existing extension regarding monitor-specific scaling needs to be removed. |
- Rename ImagesWin32Tests to ImageSmoothScalingWin32Tests - Set system property "swt.autoScale.method=smooth" so the test works as a proper regression test. Contributes to eclipse-platform#1790
- Rename ImagesWin32Tests to ImageSmoothScalingWin32Tests - Set system property "swt.autoScale.method=smooth" so the test works as a proper regression test. Contributes to eclipse-platform#1790
Image initialized as SWT.ICON in
org.eclipse.swt.graphics.Image.Image(Device, ImageData, ImageData)
loses its "Icon" properties, i.e. type, mask etc., when handle for different zoom level is requested. This change adapts the initialization of the image when the handle is requested for image type SWT.ICON to preserve the properties. The unit test is added that was failing before the fix. You can also see it in action in the snippet provided below:Fixes #1805