Skip to content

Conversation

@akoch-yatta
Copy link
Contributor

This PR refactors Region in the win32 implementation to better support multiple handles for different zoom settings by creating all handles only on demand. It applies the same patterns as #1856 and #1858

@akoch-yatta akoch-yatta force-pushed the win32-refactor-region branch 2 times, most recently from 2c1c7df to f8d4f9e Compare February 25, 2025 16:21
@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2025

Test Results

   506 files  ±0     506 suites  ±0   8m 56s ⏱️ + 1m 0s
 4 341 tests +1   4 327 ✅ +1   14 💤 ±0  0 ❌ ±0 
16 597 runs  +1  16 488 ✅ +1  109 💤 ±0  0 ❌ ±0 

Results for commit 9b63419. ± Comparison against base commit 9c42733.

♻️ This comment has been updated with latest results.

@akoch-yatta akoch-yatta force-pushed the win32-refactor-region branch from f8d4f9e to 95ce29b Compare February 28, 2025 18:15

private <T> T applyOnAnyHandle(Function<RegionHandle, T> function) {
if (zoomToHandle.isEmpty()) {
RegionHandle handle = newRegionHandle(DPIUtil.getDeviceZoom());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe call this temporaryhandle to improve comprehensibility like done for Transform

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adapted that. FYI, I additionally replaced DPIUtil.getDeviceZoom() with device.getDeviceZoom()

* @see #hashCode
*/
@Override
public boolean equals (Object object) {
Copy link
Contributor

Choose a reason for hiding this comment

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

API tools complain about hashcode/equals as public API methods being removed. I am not sure whether this is intended or a corner case that is not properly covered, still consumers may rely on proper implementations of the methods as they have existed before. On the other hand, the existing implementation of equals were effectively the same as the one from Object, as from my understanding the handle (for initial zoom) for two regions can never be the same. And hashCode used a unique memory pointer before and does it now as well (just taken from a different object).
So in my opinion the change is fine, but we should probably do it consistently across the three OS-specific implementations in a preparatory PR. It would probably be cleanest still remove those methods (and not replace them with just calls to the super implementation), but then we need to add API filters such that the API tooling does not complain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adapted it as recommended and added the api filters

@akoch-yatta akoch-yatta force-pushed the win32-refactor-region branch 6 times, most recently from 0bb4be6 to b700433 Compare March 3, 2025 13:22
@akoch-yatta
Copy link
Contributor Author

akoch-yatta commented Mar 3, 2025

@HeikoKlare I needed to adapt the PR a bit more, because tests failed as some operations that take a Region as input param failed because this region was disposed when a temporary handle was creation. As the OS.CombineRgn calls need a proper Region handle, I extracted a applyOnTemporaryHandle method to create and cleanup temporary handles on demand to theoretically encapsulate Region on Region operations as deep as you want.

@akoch-yatta akoch-yatta force-pushed the win32-refactor-region branch 5 times, most recently from e1efc67 to bafdff2 Compare March 7, 2025 07:28
@akoch-yatta akoch-yatta changed the title [win32] Dynamic handle creation for region [win32] Adapt Region to support creation of handles with operations with disposed resources Mar 7, 2025
@akoch-yatta akoch-yatta force-pushed the win32-refactor-region branch 4 times, most recently from d697b9a to fa94196 Compare March 7, 2025 17:35
@HeikoKlare HeikoKlare force-pushed the win32-refactor-region branch from fa94196 to 638f612 Compare March 8, 2025 08:52
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.

Change looks good. I pushed a minor change to also use the introduced newEmptyRegionHandle() method in the constructor.

This commit refactors Region in the win32 implementation to better
support multiple handles for different zoom settings by creating all
handles only on demand.
@HeikoKlare HeikoKlare force-pushed the win32-refactor-region branch from 638f612 to 9b63419 Compare March 8, 2025 08:54
@HeikoKlare HeikoKlare merged commit 7be6e97 into eclipse-platform:master Mar 8, 2025
14 checks passed
@HeikoKlare HeikoKlare deleted the win32-refactor-region branch March 8, 2025 09:09
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.

Refactor Region to support creation handles on demand

2 participants