Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

amartya4256
Copy link

@amartya4256 amartya4256 commented May 6, 2024

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.

Copy link
Contributor

github-actions bot commented May 7, 2024

Test Results

   418 files  ±0     418 suites  ±0   7m 27s ⏱️ -53s
 4 121 tests ±0   4 113 ✅ ±0   8 💤 ±0  0 ❌ ±0 
16 313 runs  ±0  16 221 ✅ ±0  92 💤 ±0  0 ❌ ±0 

Results for commit ddd2019. ± Comparison against base commit 2ff635c.

♻️ This comment has been updated with latest results.

@iloveeclipse iloveeclipse removed their request for review May 7, 2024 14:02
Copy link
Contributor

@fedejeanne fedejeanne left a 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.

@laeubi
Copy link
Contributor

laeubi commented May 8, 2024

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.

@fedejeanne
Copy link
Contributor

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 fedejeanne dismissed their stale review May 10, 2024 07:25

My requests were addressed.

@laeubi
Copy link
Contributor

laeubi commented May 10, 2024

@fedejeanne I have only seen it on public field, so maybe in my sentence it should read as an XOR so:

Either the field is package private or instead public but clearly documented to be platform dependent.

:-)

Copy link
Contributor

@fedejeanne fedejeanne left a 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

@HeikoKlare
Copy link
Contributor

The tests are broken

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 AllWin32Tests test suite. If you do so for the new GCWin32Tests, the PR build will fail on Windows because of the test failures mentioned by @fedejeanne.

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 DefaultSWTFontRegistry and ScalingSWTFontRegistry in #1203.

Copy link
Contributor

@HeikoKlare HeikoKlare left a 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.

Copy link
Contributor

@fedejeanne fedejeanne left a 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?

@amartya4256
Copy link
Author

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?

I updated this PR with respect to the PR #1229. It should look more consistent now.

@amartya4256 amartya4256 force-pushed the multi_zoom_level_GC branch 2 times, most recently from 6d41ade to ddd2019 Compare May 15, 2024 14:18
@@ -3887,6 +3909,7 @@ long identity() {

void init(Drawable drawable, GCData data, long hDC) {
int foreground = data.foreground;
this.data = data;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why move it up?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved back

Copy link
Contributor

@HeikoKlare HeikoKlare left a 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.

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
@@ -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
Copy link
Contributor

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();
Copy link
Contributor

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();
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants