-
Notifications
You must be signed in to change notification settings - Fork 184
Description
We develop a "Skia Canvas for SWT" that utilizes the Skia 2D graphics library for drawing on the canvas in SWT. As Java binding we use Skija.
The code currently under development can be found here: https://github.com/swt-initiative31/skija-canvas
This feature has several advantages:
- Skia is an established 2D graphics library that can be used across multiple operating systems.
- Hardware acceleration is supported for various backends, including OpenGL, Vulkan, Metal, and DirectX12.
- A raster implementation is also available.
- There are two Java bindings: Skija and Skiko. If one binding is deprecated, we can switch to the other.
- big parts of this feature can be developed OS independent
To achieve this, a new fragment, org.eclipse.swt.skia, will be created next to the org.eclipse.swt plugin in the SWT repository: https://github.com/eclipse-platform/eclipse.platform.swt.
All jar dependencies for Skija (these include Skia) will reside in this new plugin.
However, some code modifications to the SWT plugin and its fragments are necessary.
We have discussed the API with application developers, who prefer making minimal modifications to their code to use the Skia canvas.
They favor an API resembling the following:
SkiaConfiguration.applyRasterCanvas(); // Configures to Skia Raster Canvas.
Canvas c = new Canvas(parent, SWT.NONE); // This canvas will use a Skia delegate, directing specific drawing calls to Skia.
SkiaConfiguration.resetCanvasConfiguration(); // Subsequent canvases will revert to the classical canvas.
This approach removes the necessity for modifications to class hierarchies. However, if the canvas configuration isn't reset, all future canvases will be Skia canvases.
Conversely, application developers can opt to switch entirely to Skia canvases.
This configuration method offers flexibility for multiple scenarios.
For the drawing events, the class GC will be refactored from a final class to a sealed class, which is extended by the final class GCExtension.
This GCExtension delegates all drawing commands with an interface to SkiaGC, which interprets them for Skia.
Thus, application developers might not even notice a difference between drawing events with the classical GC and an embedded "SkiaGC."
Please let us know whether this concept is feasible for you.
This project requires much resources, so we would like to know whether this development offers advantages for you and whether it can be integrated into the SWT master branch.
And of course nothing in this design is final, it is a way to integrate Skia in SWT in order to enhance the canvas performance for application developers.
So let us know whether this design can be improved.