-
Notifications
You must be signed in to change notification settings - Fork 168
Use Float Aware Geometry for Scaling #62 #2200
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?
Use Float Aware Geometry for Scaling #62 #2200
Conversation
This commit introduces FloatAwareRectangle and FloatAwarePoint as an extension of Rectangle and Point respectively to improve scaling precision in the DPIUtil by using residuals obtained from rounding. Contributes to eclipse-platform#62 and eclipse-platform#128
Test Results104 files - 441 104 suites - 441 8s ⏱️ - 32m 36s For more details on these failures, see this check. Results for commit ff5192d. ± Comparison against base commit e40ad29. This pull request removes 4333 tests.
|
I must confess that this Is there any reason to not have proper getter/setter instead of public modifiable fields? The e.g. a setX(double) can always update the integer fields as well. Also one might look at how AWT is doing it here: https://docs.oracle.com/javase/8/docs/api/java/awt/geom/Rectangle2D.html So the have
|
I don't see a good reason to not have proper getter/setters for the newly added fields. One issue from OO perspective is that we have the public fields in the existing Rectangle/Points classes which are accessed directly everywhere and makes it difficult to properly extend the classes. But for the additional classes with higher precision, which are only supposed to be used inside SWT at least for now anyway, it definitely makes sense to apply proper encapsulation. I also agree that that names sound strange, at least the float version (for MonitorAware* it makes more sense to me). |
for (int zoom1 : zooms) { | ||
for (int zoom2 : zooms) { | ||
for (int i = 1; i <= 10000; i++) { | ||
Rectangle rect = new Rectangle(0, 0, i, i); |
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.
shouldnt the tests be testing FloatAwareRectangle too?
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.
DPIUtil is responsible for creating the FloatAwareRectangle from Rectangle internally. Hence, this test is already testing FloatAwareRectangle internally.
I'm not sure if we should design such "supposed to be internal" API here. Actually one big drawback of SWT compared to eg. |
I think this is a misunderstanding. I did not want to propose to design an API that is supposed to only be internal. I just wanted to say that these classes are only supposed to be used internally for now, so still having the chance for redesign before they are eventually made public API. We should first adapt the code inside SWT to properly handle higher-precision coordinates (for the reasons you also mentioned) and see where/whether we run into problems there and what needs to be done to adapt all consumers of Point/Rectangle to properly handle the higher-precision versions of them. Afterwards, once we know how to properly do it and once everything is implemented, we can make it API public. If we would do it now, strange things would happen as a consumer could pass a point with floating-point precision to consumers inside SWT without them being adapted to properly consider the higher-precision value. So there is quite some need to adaptation before we might do that. |
This PR introduces FloatAwareRectangle and FloatAwarePoint as an extension of Rectangle and Point respectively to improve scaling precision in the DPIUtil by using residuals obtained from rounding.
Contributes to
#62 and #128