-
Notifications
You must be signed in to change notification settings - Fork 118
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
Implementation of GC to enable multi zoom level support for win32 #1214
base: master
Are you sure you want to change the base?
Implementation of GC to enable multi zoom level support for win32 #1214
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.
Hi @amartya4256 , thank you for your contribution.
I noticed some problems with the visibility of some fields (the most serious one is allowing to set the deviceZoom
and nativeDeviceZoom
separately.
Could you please look into it?
Thank you.
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.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/win32/org/eclipse/swt/graphics/GCData.java
Outdated
Show resolved
Hide resolved
3a3458a
to
18b420d
Compare
I just wanted to note that (platform dependent) package private or even public fields / methods are quite common, they should just be documented in this case as platform dependent. |
@laeubi Is it really necessary to specify that a package private field/method inside a fragment is platform-dependent? I mean the fragment is already platform-dependent and the field/method can't be seen outside the fragment. Or am I missing something? |
@fedejeanne I have only seen it on public field, so maybe in my sentence it should read as an XOR so:
:-) |
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.
The tests are broken
tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/graphics/GCWin32Tests.java
Show resolved
Hide resolved
tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/graphics/GCWin32Tests.java
Outdated
Show resolved
Hide resolved
tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/graphics/GCWin32Tests.java
Outdated
Show resolved
Hide resolved
Note that new test classes in a test plug-in usually need to be added to the plug-ins test suite. In the win32 SWT tests, this is the If you cannot provide reasonable, sufficient tests via public API only, you need to add the test cases in the win32 fragments, as prepared for the |
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GCData.java
Outdated
Show resolved
Hide resolved
27f3996
to
40f7c63
Compare
40f7c63
to
90e57ec
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.
I have some remarks and questions regarding the current design for which I need some clarification before I can approve this. The essential problem I have here is with respect to responsibilities. My understanding is that in the proposed implementation Controls
are reponsible for updating zoom data used by a GC
indirectly via changing values in GCData
. This leads to visibility problems, duplicated logic for setting these values across package borders etc.. Since these values only seem to be a cache of information provided by the underlying Drawable
of a GC
, I do not understand why (1) this caching is necessary and (2) why GC
cannot simply listen for zoom change events at the Control
and then update the data itself but requires the Control
to take care of it.
And even if the information really have to be provided to GCData
(e.g., because they will be required by other Resources
, as mentioned in the PR description), I would still expect the GC
to be responsible for updating them and not the Controls
. Then you should also get rid of the current visibility problems.
Please also extend the commit description with information about
- why these changes are necessary, and
- what they do,
so that people are able to understand the changes only by the commit, even without the PR.
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GCData.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GCData.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
Outdated
Show resolved
Hide resolved
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 seems that some fields added here will not be necessary in future PRs (see Shell
and Widget
), please remove them.
Also, the method GCData::setNativeZoomForGCData
suffers from a code smell, it would be nice if it's not necessary or if it can be done differently.
Have the tests been addressed yet?
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
Outdated
Show resolved
Hide resolved
90e57ec
to
ffac213
Compare
I updated this PR with respect to the PR #1229. It should look more consistent now. |
6d41ade
to
ddd2019
Compare
tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/graphics/GCWin32Tests.java
Outdated
Show resolved
Hide resolved
@@ -3887,6 +3909,7 @@ long identity() { | |||
|
|||
void init(Drawable drawable, GCData data, long hDC) { | |||
int foreground = data.foreground; | |||
this.data = data; |
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.
Why move it up?
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.
moved back
ddd2019
to
67e2821
Compare
edffc3c
to
6d4785d
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, these changes now look fine to me. With the preparation in #1229, my recent concerns have been addressed.
I have some remaining comments on naming and test methodology, all of them being minor.
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GCData.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
Outdated
Show resolved
Hide resolved
tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/graphics/GCWin32Tests.java
Outdated
Show resolved
Hide resolved
tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/graphics/GCWin32Tests.java
Outdated
Show resolved
Hide resolved
6d4785d
to
4945f06
Compare
af9ada0
to
7adc15f
Compare
a4a2c67
to
34ba421
Compare
This contribution is to provide the nativeDeviceZoom to all the widgets so that it can be used later on for e.g. font scaling and more. Currently, the nativeDeviceZoom is only available via the shell, which is not sufficient later when there is no shell available, e.g. GC. Contributes to eclipse-platform#62 and eclipse-platform#127
This commit contributes to multi zoom level support of GC which can be extended by other resources and widgets. Contributes to eclipse-platform#62 and eclipse-platform#131
34ba421
to
8b87c03
Compare
@@ -3886,6 +3908,7 @@ long identity() { | |||
} | |||
|
|||
void init(Drawable drawable, GCData data, long hDC) { | |||
this.data = data; // Need to set GCData first because it is needed for getDeviceZoom calls |
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 which line(s) will these getDeviceZoom()
calls happen? It feels kind of dangerous to set the field before it's actual values are properly filled, as it's unclear when you can assume which property to have the expected value.
@@ -4582,8 +4618,9 @@ void setLineAttributesInPixels (LineAttributes attributes) { | |||
} | |||
if (changed) { | |||
float[] newDashes = new float[dashes.length]; | |||
int deviceZoom = getDeviceZoom(); |
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.
Why is it necessary/beneficial to store the result of getDeviceZoom()
in a local variable? At many other places this value is used directly.
@@ -5120,4 +5158,12 @@ private static int sin(int angle, int length) { | |||
return (int)(Math.sin(angle * (Math.PI/180)) * length); | |||
} | |||
|
|||
private int getNativeDeviceZoom() { | |||
return data.nativeZoom != 0 ? data.nativeZoom : DPIUtil.getNativeDeviceZoom(); |
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 don't understand the intended invariant for nativeZoom
. In the init()
method, the value is extracted from the handle if nativeZoom
would be zero otherwise, which suggests that the value should never be zero. Here, the assumption is that nativeZoom
might be zero and implements another fallback functionality for a zero nativeZoom
, namely using the general, potentially wrong native zoom from DPIUtil
. I would expect a that only one of them is necessary and implemented, implying a proper invariant for when nativeZoom
is expected to (not) be zero.
Addressed issues
Requires
Note: Only the last commit in this PR is to be reviewed. Previous commit(s) belong to the prerequisite PR(s)
Unlocks
Description
This pull request is a base pull request for several following PRs which implement multi zoom level support for different components (resources, widgets, etc).
In this PR, the focus is on GC to enable it to use the zoom level information which is added to widget. Also, it provides zoom level information in GCData which can later be used by resources like Image, Region, etc which don't have the zoom information since they are not a widget. Also, GC now uses the DPIUtil methods with zoom for getting the size as per the zoom level. This zoom in GC is derived from the GCData where we add the zoom information.