-
Notifications
You must be signed in to change notification settings - Fork 176
A strict check 200% image data is double the size of 100% image data #2249
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
A strict check 200% image data is double the size of 100% image data #2249
Conversation
a31c3d0
to
9a302a0
Compare
560fc50
to
085c1c6
Compare
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java
Outdated
Show resolved
Hide resolved
085c1c6
to
d78d6ae
Compare
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
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
Outdated
Show resolved
Hide resolved
db68f87
to
1403084
Compare
In CI failing checks I have the below error, Dont think this has anything to do with my changes.
|
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.
Some comments before I move to the testing phase
...e.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Image.java
Outdated
Show resolved
Hide resolved
...t.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_ImageData.java
Outdated
Show resolved
Hide resolved
...sts/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_internal_SVGRasterizer.java
Outdated
Show resolved
Hide resolved
...sts/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_internal_SVGRasterizer.java
Outdated
Show resolved
Hide resolved
...t.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_ImageData.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java
Outdated
Show resolved
Hide resolved
8b2a4c3
to
73e1a6c
Compare
982ab6d
to
a6d4f74
Compare
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
Outdated
Show resolved
Hide resolved
bc5eaca
to
c40fee2
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.
In general, the PR looks good to me. I have only one comment regarding the printed message.
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
Outdated
Show resolved
Hide resolved
9f23866
to
5a064b6
Compare
5a064b6
to
e06a13e
Compare
A strict check to be used only for debugging means, which ensures the imageData returned by an ImageDataProvider is scaled linearly for 100 and 200 zooms.
e06a13e
to
34e4127
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.
Looks fine now. I rebased on master and slightly enhanced the information in the message (including the image data sizes at 100%/200%).
This caused a regression when working with |
ImageDataProvider zoom handling In PR eclipse-platform#2249, a strict check was introduced that ImageData should be linearly scaled for other zoom levels. And imageDataProviders in SWT repo not following this strict checks were modified (eg to return only imageData at 100%). However, this change broke DPIUtil.autoScaleImageData. That function creates an Image using the system zoom level, draws it on a GC at scaled dimensions, and then requests ImageData at 100% zoom from the image. Since the ImageDataProvider was now restricted to 100% zoom only, requesting imageData at other zoom levels while creating an image at system zoom level triggered recursive calls, causing a stack overflow error. The current commit reverts the behavior of the ImageDataProvider used in DPIUtil.autoScaleImageData to return the same ImageData at all zoom levels. We also Disable the strict zoom check in this specific case, because the scaling is done by GC.drawImage() and the ImageData used to create the is expected to be same.
ImageDataProvider zoom handling In PR eclipse-platform#2249, a strict check was introduced that ImageData should be linearly scaled for other zoom levels. And imageDataProviders in SWT repo not following this strict checks were modified (eg to return only imageData at 100%). However, this change broke DPIUtil.autoScaleImageData. That function creates an Image using the system zoom level, draws it on a GC at scaled dimensions, and then requests ImageData at 100% zoom from the image. Since the ImageDataProvider was now restricted to 100% zoom only, requesting imageData at other zoom levels while creating an image at system zoom level triggered recursive calls, causing a stack overflow error. The current commit reverts the behavior of the ImageDataProvider used in DPIUtil.autoScaleImageData to return the same ImageData at all zoom levels. We also Disable the strict zoom check in this specific case, because the scaling is done by GC.drawImage() and the ImageData used to create the is expected to be same.
In PR eclipse-platform#2249, a strict check was introduced that ImageData should be linearly scaled for other zoom levels. And imageDataProviders in SWT repo not following this strict checks were modified (eg to return only imageData at 100%). However, this change broke DPIUtil.autoScaleImageData. That function creates an Image using the system zoom level, draws it on a GC at scaled dimensions, and then requests ImageData at 100% zoom from the image. Since the ImageDataProvider was now restricted to 100% zoom only, requesting imageData at other zoom levels while creating an image at system zoom level triggered recursive calls, causing a stack overflow error. The current commit reverts the behavior of the ImageDataProvider used in DPIUtil.autoScaleImageData to return the same ImageData at all zoom levels. We also Disable the strict zoom check in this specific case, because the scaling is done by GC.drawImage() and the ImageData used to create the is expected to be same.
In PR eclipse-platform#2249, a strict check was introduced that ImageData should be linearly scaled for other zoom levels. And imageDataProviders in SWT repo not following this strict checks were modified (eg to return only imageData at 100%). However, this change broke DPIUtil.autoScaleImageData. That function creates an Image using the system zoom level, draws it on a GC at scaled dimensions, and then requests ImageData at 100% zoom from the image. Since the ImageDataProvider was now restricted to 100% zoom only, requesting imageData at other zoom levels while creating an image at system zoom level triggered recursive calls, causing a stack overflow error. The current commit reverts the behavior of the ImageDataProvider used in DPIUtil.autoScaleImageData to return the same ImageData at all zoom levels. We also Disable the strict zoom check in this specific case, because the scaling is done by GC.drawImage() and the ImageData used to create the is expected to be same.
In PR eclipse-platform#2249, a strict check was introduced that ImageData should be linearly scaled for other zoom levels. And imageDataProviders in SWT repo not following this strict checks were modified (eg to return only imageData at 100%). However, this change broke DPIUtil.autoScaleImageData. That function creates an Image using the system zoom level, draws it on a GC at scaled dimensions, and then requests ImageData at 100% zoom from the image. Since the ImageDataProvider was now restricted to 100% zoom only, requesting imageData at other zoom levels while creating an image at system zoom level triggered recursive calls, causing a stack overflow error. The current commit reverts the behavior of the ImageDataProvider used in DPIUtil.autoScaleImageData to return the same ImageData at all zoom levels. We also Disable the strict zoom check in this specific case, because the scaling is done by GC.drawImage() and the ImageData used to create the is expected to be same.
In PR eclipse-platform#2249, a strict check was introduced that ImageData should be linearly scaled for other zoom levels. And imageDataProviders in SWT repo not following this strict checks were modified (eg to return only imageData at 100%). However, this change broke DPIUtil.autoScaleImageData. That function creates an Image using the system zoom level, draws it on a GC at scaled dimensions, and then requests ImageData at 100% zoom from the image. Since the ImageDataProvider was now restricted to 100% zoom only, requesting imageData at other zoom levels while creating an image at system zoom level triggered recursive calls, causing a stack overflow error. The current commit reverts the behavior of the ImageDataProvider used in DPIUtil.autoScaleImageData to return the same ImageData at all zoom levels. We also Disable the strict zoom check in this specific case, because the scaling is done by GC.drawImage() and the ImageData used to create the is expected to be same.
In PR eclipse-platform#2249, a strict check was introduced that ImageData should be linearly scaled for other zoom levels. And imageDataProviders in SWT repo not following this strict checks were modified (eg to return only imageData at 100%). However, this change broke DPIUtil.autoScaleImageData. That function creates an Image using the system zoom level, draws it on a GC at scaled dimensions, and then requests ImageData at 100% zoom from the image. Since the ImageDataProvider was now restricted to 100% zoom only, requesting imageData at other zoom levels while creating an image at system zoom level triggered recursive calls, causing a stack overflow error. The current commit reverts the behavior of the ImageDataProvider used in DPIUtil.autoScaleImageData to return the same ImageData at all zoom levels. We also Disable the strict zoom check in this specific case, because the scaling is done by GC.drawImage() and the ImageData used to create the is expected to be same.
In PR eclipse-platform#2249, a strict check was introduced that ImageData should be linearly scaled for other zoom levels. And imageDataProviders in SWT repo not following this strict checks were modified (eg to return only imageData at 100%). However, this change broke DPIUtil.autoScaleImageData. That function creates an Image using the system zoom level, draws it on a GC at scaled dimensions, and then requests ImageData at 100% zoom from the image. Since the ImageDataProvider was now restricted to 100% zoom only, requesting imageData at other zoom levels while creating an image at system zoom level triggered recursive calls, causing a stack overflow error. The current commit reverts the behavior of the ImageDataProvider used in DPIUtil.autoScaleImageData to return the same ImageData at all zoom levels. We also Disable the strict zoom check in this specific case, because the scaling is done by GC.drawImage() and the ImageData used to create the is expected to be same.
A strict check to be used only for debugging means, this ensures the imageData is scaled linearly for 100 and 200 zooms.
Steps to reproduce
Out of the blow snippets. Snippet1 which uses an image data provider that always returns the same image, when executed with the VM argument
-Dorg.eclipse.swt.internal.enableStrictChecks=True
, logs the error` "ImageData should be linearly scaled across zooms." to stdout. Whereas snippet 2 which scales ImageData linearly runs without this error log.snippet 1
snippet 2
The below examples demonstrate testing this again with PNG images. In the first snippet, the ImageDataProvider returns the image data from the same file for both 100% and 200% zoom levels without scaling, which causes the error message "ImageData should be linearly scaled across zooms." to be printed to stdout. In the second snippet it provides properly scaled image data at 200% zoom (using a scaled image), so it executes without logging this error.
To run these snippets, download the following PNG files and place them in your working directory:
pause.png
[email protected]
snippet 1
snippet 2