Skip to content

Conversation

@ShahzaibIbrahim
Copy link
Contributor

@ShahzaibIbrahim ShahzaibIbrahim commented Nov 19, 2025

Enabling a consistent pattern to apply disablement or graying of an Image. They are applied whenever a handle is being created from init method. Ensuring streamline usage and avoid double calls to this method.


How to test

  • Run the Snippet382 with following VM Argument: swt.autoScale.updateOnRuntime=true
  • Move the shell between different zoom levels (100,125,150,175,200,250)
  • The snippet tests different kind of image providers to create an Image.
  • Expected result would be that we don't lose disabled or grayed image attributes.
image

This adaption is made on the basis of this comment: #2737 (comment)

Instead of calling the adaptImageDataIfDisabledOrGray method from init method (which could be executed even when temporary handle is created) we will now call it only when data is loaded for the first time. So instead of calling loadImageData, all providers must call loadImageDataWithGrayOrDisablement and also provide loadImageData implementation of its own. In this way we can achieve one common place to call adaptImageDataIfDisabledOrGray from.

@ShahzaibIbrahim ShahzaibIbrahim marked this pull request as draft November 19, 2025 13:27
Enabling a consistent pattern to apply disablement or graying of an
Image. They are applied whenever a handle is being created from init
method. Ensuring streamline usage and avoid double calls to this method.
Comment on lines +334 to 338
case SWT.IMAGE_DISABLE:
case SWT.IMAGE_GRAY: {
for (ImageHandle imageHandle : srcImage.zoomLevelToImageHandle.values()) {
Rectangle rect = imageHandle.getBounds();
ImageData data = srcImage.getImageData(imageHandle.zoom);
ImageData newData = applyGrayImageData(data, rect.height, rect.width);
init (newData, imageHandle.zoom);
srcImage.getImageData(imageHandle.zoom);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now we only need to reload the data for other handle if exist in order to apply gray or disable image data.

ImageData imageData = image.getImageData(targetZoom);
drawer.postProcess(imageData);
ImageData newData = adaptImageDataIfDisabledOrGray(imageData);
ImageData newData = adaptImageDataIfDisabledOrGray(imageData, styleFlag);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I still have to keep it because a new image is created here with plainImageDataProvider which loads the data directly from handle. I am open to suggestions here.

@ShahzaibIbrahim
Copy link
Contributor Author

@akoch-yatta @HeikoKlare Please review the PR and comments, It might not be in final shape but here I could use some suggestions.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 19, 2025

Test Results

  111 files  ±0    111 suites  ±0   17m 48s ⏱️ +7s
4 597 tests ±0  4 582 ✅ +1  14 💤  - 1  1 ❌ ±0 
  282 runs  ±0    281 ✅ ±0   1 💤 ±0  0 ❌ ±0 

For more details on these failures, see this check.

Results for commit eb0405c. ± Comparison against base commit 63d5582.

♻️ This comment has been updated with latest results.

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.

1 participant