-
Notifications
You must be signed in to change notification settings - Fork 177
Refactor fillGradientRectangle to avoid DPIUtil.autoScaleDown() #2284
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
base: master
Are you sure you want to change the base?
Refactor fillGradientRectangle to avoid DPIUtil.autoScaleDown() #2284
Conversation
5c3435f
to
3035e8f
Compare
The changes made here are similar to this PR about refactoring the DPIUtil. We might be working on the same thing, could you check and confirm? |
Yes, the changes are mostly similar. The only additional thing I'm doing is replacing Image constructors that take ImageData with ones that use an ImageDataProvider. I think this change can wait until #2281 is merged |
@arunjose696 #2281 is merged. You can resolve the conflicts and mark this one as ready for review. |
3035e8f
to
f497de4
Compare
Have resolved conflicts |
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
Outdated
Show resolved
Hide resolved
@arunjose696 Please adapt the description of the PR in comparison to the new version of the base branch. It's not relevant anymore. |
4513765
to
1cf0759
Compare
done |
@arunjose696 Can you provide a snippet with which I could test it? I didn't understand which condition you meant to set false. Is it |
What I meant is that, by replacing the original condition: I had originally linked to a specific line in the file, but that became outdated after the file changed. I wasn't able to provide a proper snippet because I couldn’t determine under what conditions the original check would actually evaluate to false. |
e429ce4
to
f8a7090
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.
It's not clear to me how to test this change and why is it necessary. Since you mentioned that "There is no visual impact for the changes the behavior should remain as before" in the description, I assume it is about performance?
I don't have GEF to test this change. Is there any other way to test it? Some screenshots/video to showcase the use case would be helpful too.
The reason is simplier than one might think: the Image constructor just taking an I tried to test the change, but unfortunately I was not able to trigger the affected code. The only caller seems to be |
Reaching this function on Windows is difficult , as the check if (OS.GetROP2(handle) != OS.R2_XORPEN && OS.GetDeviceCaps(handle, OS.TECHNOLOGY) != OS.DT_RASPRINTER) in |
f8a7090
to
0cd839a
Compare
806ddb5
to
c374700
Compare
fillGradientRectangle() This PR refactors the image creation logic in fillGradientRectangle() by using an ImageDataProvider instead of directly creating ImageData. There is no visual impact for the changes the behavior should remain as before.
c374700
to
9973218
Compare
9973218
to
ca2838e
Compare
…l(size,zoom) to DPIUtils
ca2838e
to
77cf2b3
Compare
I have added an additional commit that moves the Win32DPIUtils.pointToPixel(size, zoom) method to DPIUtils, so the existing logic in pointToPixels can be reused instead of manually computing the scaling factor. Since DPIUtils already contains pixelToPoint(size, zoom) methods, it makes sense to place the complementary pointToPixel(size, zoom) method there as well. |
Summary:
This PR refactors the image creation logic in fillGradientRectangle() by using an ImageDataProvider instead of directly creating ImageData. There is no visual impact for the changes the behavior should remain as before.
Steps to reproduce
Reaching this function on Windows is difficult, as the check if (OS.GetROP2(handle) != OS.R2_XORPEN && OS.GetDeviceCaps(handle, OS.TECHNOLOGY) != OS.DT_RASPRINTER) usually returns true, causing the method to be bypassed. For testing purposes, this condition can be manually set to false to ensure that fillGradientRectangle is executed.
When the check is disabled, the method is invoked, for example, when using palettes in GEF. After applying this change, the gradient rectangles in the palette render identical as before.