Skip to content

Follow-Up Feature: Icon-Enablement with Rasterization of SVGs #1647

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

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

Conversation

Michael5601
Copy link
Contributor

@Michael5601 Michael5601 commented Dec 11, 2024

This draft outlines the follow-up functionality for the PR (Feature Proposal: Rasterization of SVGs at Runtime for Eclipse Icons).

The commit 4e6abc7 contains the new functionality that extends the base functionality of the mentioned PR. All future changes to the PR will be performed to this draft.

The new functionality extends the current automatic customization of icons in the Image(Device device, Image srcImage, int flag) constructor. While all of the core functionality is implemented within SWT, some changes are required in Platform UI, which can be found in the following Draft.

When the Image constructor is invoked, the new functionality attempts to create a graphically customized icon by passing a specific flag (e.g., SWT.IMAGE_DISABLE) to the rasterization functionality introduced in the base PR. This functionality is enhanced by a preprocessing step that automatically adds a filter to the SVG before rasterization. These filters are designed to ensure that the resulting icons resemble the current pre-created disabled/gray icons loaded at runtime.

It is important to note that the automatic icon customization differs between GTK and Cocoa/Win32. As such, the icons generated with the new functionality may not align perfectly with the automatically customized GTK icons. However, this discrepancy is also present with the current pre-created icons, so the impact is minimal. Additionally, most icons are pre-created and not automatically customized at runtime.

Below is a comparison between the current pre-created icons and the icons customized automatically at runtime using the new functionality. The color/saturation/brightness can be changed by adjusting the filter:

Pre-created and scaled down to 125% device zoom:
image

Automatically customized at runtime with the new functionality:
image

The following tasks need to be completed for this draft:

  1. Decide whether the unification of the behavior across different operating systems should occur before merging the new functionality.
  2. Merge the main feature upon which this draft is based.
  3. Remove disabled icon paths from the plugin.xml files to ensure the automatic customization is triggered.
  4. Write documentation (JavaDocs) for the new API.
  5. Provide regression tests and a performance comparison between automatic customization and FileIO for pre-created icons. The possibility exists that the rasterization with pre-processing is faster than the additional FileIO to load the pre-created icons.

Fixes #1438.

@BeckerWdf
Copy link
Contributor

Below is a comparison between the current pre-created icons and the icons customized automatically at runtime using the new functionality. The color/saturation/brightness can be changed by adjusting the filter:

Pre-created and scaled down to 125% device zoom: image

Automatically customized at runtime with the new functionality: image

To be honest I almost cannot see a difference. So I think this should not be a problem.

@Michael5601
Copy link
Contributor Author

To be honest I almost cannot see a difference. So I think this should not be a problem.

This is a good thing for me. :) We could utilize the new behaviour from this draft, which means the pre-created PNGs can be removed and we have a little improvement in the look of the icons without changing their appearance (gray tone) too much.

@Michael5601 Michael5601 force-pushed the IconScalingWithDisabledLogic branch 9 times, most recently from e0a66ba to 67d7433 Compare December 18, 2024 11:38
@Michael5601 Michael5601 force-pushed the IconScalingWithDisabledLogic branch 3 times, most recently from 81714d1 to b85ad40 Compare January 7, 2025 08:34
@Michael5601 Michael5601 force-pushed the IconScalingWithDisabledLogic branch 10 times, most recently from b632c14 to c8f72f4 Compare February 6, 2025 13:52
@Michael5601 Michael5601 force-pushed the IconScalingWithDisabledLogic branch from c8f72f4 to c9d6397 Compare February 24, 2025 08:28
Copy link
Contributor

github-actions bot commented Feb 24, 2025

Test Results

  218 files   -    321    218 suites   - 321   10m 47s ⏱️ - 19m 12s
4 330 tests ±     0  4 273 ✅  -     47  57 💤 +48  0 ❌  - 1 
4 477 runs   - 12 102  4 420 ✅  - 12 057  57 💤  - 44  0 ❌  - 1 

Results for commit 4afe499. ± Comparison against base commit 22e8829.

This pull request removes 37 and adds 37 tests. Note that renamed tests count towards both.
AllGTKTests org.eclipse.swt.tests.gtk.Test_GtkConverter ‑ test_HeuristicASCII_dollarSign
AllGTKTests org.eclipse.swt.tests.gtk.Test_GtkConverter ‑ test_HeuristicASCII_emptyString
AllGTKTests org.eclipse.swt.tests.gtk.Test_GtkConverter ‑ test_HeuristicASCII_letterA
AllGTKTests org.eclipse.swt.tests.gtk.Test_GtkConverter ‑ test_HeuristicASCII_letters
AllGTKTests org.eclipse.swt.tests.gtk.Test_GtkConverter ‑ test_HeuristicUTF16LE_null
AllGTKTests org.eclipse.swt.tests.gtk.Test_GtkConverter ‑ test_HeuristicUTF16_AsciiLetters
AllGTKTests org.eclipse.swt.tests.gtk.Test_GtkConverter ‑ test_HeuristicUTF16_Asciiletter
AllGTKTests org.eclipse.swt.tests.gtk.Test_GtkConverter ‑ test_HeuristicUTF16_LotsOfLetters
AllGTKTests org.eclipse.swt.tests.gtk.Test_GtkConverter ‑ test_HeuristicUTF16_letter
AllGTKTests org.eclipse.swt.tests.gtk.Test_GtkConverter ‑ test_HeuristicUTF16_letters
…
AllWin32Tests org.eclipse.swt.graphics.ImageWin32Tests ‑ testImageDataForDifferentFractionalZoomsShouldBeDifferent
AllWin32Tests org.eclipse.swt.graphics.ImageWin32Tests ‑ testImageShouldHaveDimesionAsPerZoomLevel
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testByteArrayTransfer
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testFileTransfer
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testHtmlTransfer
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testImageTransfer_fromCopiedImage
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testImageTransfer_fromImage
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testImageTransfer_fromImageData
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testImageTransfer_fromImageDataFromImage
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testRtfTransfer
…
This pull request removes 2 skipped tests and adds 3 skipped tests. Note that renamed tests count towards both.
AllGTKTests org.eclipse.swt.tests.gtk.Test_GtkConverter ‑ test_Heuristic_specialSingleCases
org.eclipse.swt.tests.gtk.Test_GtkConverter ‑ test_Heuristic_specialSingleCases
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_events_KeyEvent ‑ testEnglishUs_multipleLetters
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_events_KeyEvent ‑ testEnglishUs_unorderedCtrlC
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_events_KeyEvent ‑ testEnglishUs_unpairedKeyUp
This pull request skips 47 tests.
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback[browser flags: 0]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_LocationListener_LocationListener_ordered_changing[browser flags: 0]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_LocationListener_evaluateInCallback[browser flags: 0]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_OpenWindowListener_evaluateInCallback[browser flags: 0]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_StatusTextListener_hoverMouseOverLink[browser flags: 0]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_setForegroundAlphaLorg_eclipse_swt_graphics_Color[browser flags: 0]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_custom_CCombo ‑ test_setForegroundAlphaLorg_eclipse_swt_graphics_Color
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_custom_CLabel ‑ test_setForegroundAlphaLorg_eclipse_swt_graphics_Color
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_custom_CTabFolder ‑ test_setForegroundAlphaLorg_eclipse_swt_graphics_Color
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_custom_StyledText ‑ test_setForegroundAlphaLorg_eclipse_swt_graphics_Color
…

♻️ This comment has been updated with latest results.

@Michael5601 Michael5601 force-pushed the IconScalingWithDisabledLogic branch 2 times, most recently from 3bbb308 to ad19a22 Compare March 17, 2025 10:27
@Michael5601 Michael5601 force-pushed the IconScalingWithDisabledLogic branch 21 times, most recently from 927252f to 173577f Compare March 24, 2025 09:04
@Michael5601 Michael5601 force-pushed the IconScalingWithDisabledLogic branch 2 times, most recently from f667bc7 to e23f321 Compare March 27, 2025 16:04
SWT currently loads icons exclusively as raster graphics (e.g., PNGs)
without support for vector formats like SVG (except for Linux). A major
drawback of raster graphics is their inability to scale without
degrading image quality. Additionally, generating icons of different
sizes requires manually rasterization of SVGs as a preparatory step,
leading to unnecessary effort and many icon files.

This change introduces support for vector graphics in images, enabling
SVGs to be used for images. An SVG rasterizer can be provided via an SWT
fragment. This change adds an according fragment based on the JSVG
library. An according FileFormat implementation is added, which utilized
a present SVG rasterization fragment to rasterize images for the desired
zoom factor.

Fixes eclipse-platform#1438

Revert "Add support for SVG images"

This reverts commit e03b214dc664848d0e1723a1ec80b4a419d2bd59.

Introduce functionality for icon disablement with SVGs

merge new API (flag parameter) into existing API

ImageDataProvider functionality is ignored for now.
@Michael5601 Michael5601 force-pushed the IconScalingWithDisabledLogic branch from e23f321 to 4afe499 Compare March 27, 2025 16:04
@akurtakov
Copy link
Member

What is the status of this one?

@Michael5601
Copy link
Contributor Author

What is the status of this one?

We are currently working on this PR in Platform UI, so that SVGs can be also used by external consumers like URLImageDescriptor or FileImageDescriptor in Jface. With this also Composite Icons can be loaded by using SVGs.

The icon disablement as proposed in this Draft needs further adjustments as it does not work in Cocoa yet and also new API needs to be added so that icons can be created with arbitrary Hue, Saturation and Brightness at runtime. Additionally we should first merge this PR to unify the disablement algorithms for all OS.

Apart from that the functionality in this draft is working and allows the disablement for all icons by perprocessing SVGs before rasterization. Please note that due to the different implementation for cocoa it could happen that the changes proposed in this draft will be dismissed completely.

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.

Improving Eclipse Icon Scaling by Supporting Vectorized Icons
3 participants