-
Notifications
You must be signed in to change notification settings - Fork 160
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
[win32] Refactor path to support multiple handles #1856
[win32] Refactor path to support multiple handles #1856
Conversation
Test Results 505 files ±0 505 suites ±0 8m 7s ⏱️ -27s For more details on these failures, see this check. Results for commit b0e34fa. ± Comparison against base commit 523a5d4. ♻️ This comment has been updated with latest results. |
67ea63a
to
f49bb0c
Compare
134325e
to
85b12bc
Compare
ce4beae
to
f2e3e81
Compare
Design-wise, looks good to me. I would approve it. @HeikoKlare I would request you to test it out as well. |
f2e3e81
to
f3eb0e3
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.
Most of the changes look fine to me (see my comments for exception).
I am just wondering what the introduced operations are used for in Path
: if I am not mistaken, the stored operations are not used anywhere. Each operation is directly applied to all present handles for all zooms and in case a new handle for a new zoom is created, the existing logic via passing the PathData
is used.
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java
Outdated
Show resolved
Hide resolved
Gdip.GraphicsPath_AddPath(getHandle(initialZoom), path.getHandle(initialZoom), false); | ||
currentPoint.X = path.currentPoint.X; | ||
currentPoint.Y = path.currentPoint.Y; | ||
this.operations.addAll(path.operations); |
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.
Is it correct to remove the original code here?
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.
Almost. I just missed to apply the new operation to add to the existing handles
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 see. We need to be aware that within the overall refactoring this is kind of a behavioral change. Of course the result should be the same, but maybe using Gdip to add a path based on its handle and re-applying its original operations may result in (slightly) different result (for whatever reason). Still, I understand and agree that this is the right thing to do.
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.
We could do something different. More or less:
- Cache the old operations
- Recreate a path on demand
- Use Gdip.GraphicsPath_AddPath(getHandle(initialZoom), newTempHandle, false);
This would be more or less the same as before, but a bit more complex to understand, I would say
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 am not sure whether we should do that since actually the new operation does exactly what you would expect it to do. I just wanted to mentioned that we might oversee something that eventually leads to derivations of behavior, so that we are aware this change. But I don't see why this might be anything else than minor changes in result because of limited precision of float values and different ways of applying the operations.
But I just checked out the tab you added to the GraphicsExample, which shows that the old and new implementation of addPath
behave different. So we may need to revise this.
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.
Oh damn, you are right. There is a connecting path if you have done something before. That could probably be emulated be an additional move operation, but I would probably favor my approach above more
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.
Sorry for that back and forth. So for this PR I just moved the original logic into an Operation, because in this PR all operations are always applied immediately and no handles are created dynamically yet. I will need to adapt this new opearation in the follow-up PR
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.
That's perfectly fine. It's just that we now have the problem of storing a Path that might be disposed when querying the handle for the encapsulating Path at another zoom level. So we probably need to clone the path to be stored?
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.
No, in this PR the new Path is created on its path data and then scaled. The operations are always applied immediately. But I added a test to ensure it doesn't break later
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java
Outdated
Show resolved
Hide resolved
f3eb0e3
to
3fffd59
Compare
They have a use now. The are used in Path::addPath. Without that, we would have needed them only in #1869, because there the handles are completly generated on demand using the operations |
3fffd59
to
9233c3c
Compare
b9ab37f
to
82e393b
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.
See comment :
It's just that we now have the problem of storing a Path that might be disposed when querying the handle for the encapsulating Path at another zoom level. So we probably need to clone the path to be stored?
Just answered above at the same time 😄 It is not an issue in this PR. I will need to address that in the next one |
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 see. I missed that the operations are not stored (anymore) in this PR. Thanks for the clarification!
This commit refactors Path in the win32 implementation to better support multiple handles for different zoom settings of a Path when monitor-specific scaling is enabled. The previous implementation only applied adaptions to the initial handle of the path and relied on the path not to be changed afterwards. This doesn't cover all scenarios and can lead to unexpected behavior when re-using Path objects over different zoom settings.
82e393b
to
b0e34fa
Compare
Failing test is unrelated and documented: #1843 |
This PR refactors Path in the win32 implementation to better support multiple handles for different zoom settings of a Path when monitor-specific scaling is enables. The previous implementation only applied adaptions on the path to the initial handle and relied on the path not to be changed after usage. This doesn't cover all scenarios and can lead to incompletely rendered path when reusing Path object over different zoom settings.
How to test
You can test this adaption with the new "Path Re-usage"-Tab in the GraphicsExample. You need to: