Skia Canvas plugin for hardware-accelerated 2D rendering in SWT#3231
Skia Canvas plugin for hardware-accelerated 2D rendering in SWT#3231DenisUngemach wants to merge 4 commits intoeclipse-platform:masterfrom
Conversation
Integrates an SWT’s canvas extension framework, which replacing the native backend for canvases with the SWT.SKIA style bit and leveraging OpenGL. - Includes core classes for rendering - resource management - a factory for SWT integration. - Implements caching for fonts, images, and text, supports DPI scaling, and manages Skija resources explicitly. - The plugin is modular, minimizes API changes, and is OSGi-activatable. - for more information read the skia.md in bundles/org.eclipse.swt.skia
- for adding the SWT.SKIA field, the version of SWT should be increased - there seams to be a bug on the api tools for sealed classes. Locally on my system, there are no api bugs for handle etc. But on github i get error messages, that handle etc are used. this only happens for sealed classes.
|
Referring to the issue: #2616 |
|
I think we need another PR to add the Skia libraries to the buiild. @HeikoKlare can you guide what needs to be done for that? |
In the current change the source jars will also be loaded to the lib folder. On my builds this was only a warning, it seems here it is an error. |
From my understanding, we need to add the library to the eclipse-sdk-prereqs target, so they become available in our target platform. Just like we did here for the JSVG library used in the SWT SVG fragment: I can provide a PR once I find the time to do so. But feel free to just do it inspired by the linked PR even earlier. |
Only causes warnings and errors. These are not necessary in the org.eclipse.swt.skia plugin. Only convenience.
Is this right: swt-initiative31/eclipse.platform.releng.aggregator#1 Of course i will open then the PR to the original releng repo, if this should do it. |
|
|
||
| @Override | ||
| public Rectangle getClipping() { | ||
| return currentClipBounds; |
There was a problem hiding this comment.
The clip returned by this method should never be null, even if no clipping is set. From the JavaDoc:
If no clipping region is set, the return value will be a rectangle which covers the entire bounds of the object the receiver is drawing on.
| return currentClipBounds; | |
| if (currentClipRegion != null) { | |
| return currentClipBounds; | |
| } | |
| return canvas.getBounds(); |
Here an example that throws an exception with Skia but not with GTK:
public class Test {
public static void main(String[] args) {
Shell shell = new Shell();
shell.setSize(200, 200);
shell.setLayout(new FillLayout());
Canvas canvas = new Canvas(shell, SWT.SKIA);
canvas.addPaintListener(event -> {
GC gc = event.gc;
Objects.requireNonNull(gc.getClipping());
});
shell.open();
Display display = shell.getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
}| private boolean xorModeActive; | ||
| private int lineWidth = 1; | ||
| private int lineCap = SWT.CAP_FLAT; | ||
| private int lineStyle; |
There was a problem hiding this comment.
If the line style is never set, 0 is returned, which is an illegal value.
| private int lineStyle; | |
| private int lineStyle = SWT.LINE_SOLID; |
This will throw an IllegalArgumentException with Skia, but not with GTK.
public class Test {
public static void main(String[] args) {
Shell shell = new Shell();
shell.setSize(200, 200);
shell.setLayout(new FillLayout());
Canvas canvas = new Canvas(shell, SWT.SKIA);
canvas.addPaintListener(event -> {
GC gc = event.gc;
gc.setLineStyle(gc.getLineStyle());
});
shell.open();
Display display = shell.getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
}
|
I'm currently getting a consistent crash with the Draw2D TreeExample when changing the minor/major spacing. I'm not quite sure yet what exactly is going wrong, but it seems like the Skia surface is being disposed. Immediately before the crash, the following returns Perhaps as a first step, the following check needs to be added to every method, similar to the other GC's? Here the crash log: |

Skia Canvas plugin for hardware-accelerated 2D rendering in SWT.
[Experimental Feature]
Integrates an SWT’s canvas extension framework, which replaces the
native backend for canvases with the Skia drawing framework which relies in this implementation on
OpenGL.
adds a new fragment of org.eclipse.swt: bundles/org.eclipse.swt.skia
Includes core classes for rendering
resource management
a factory for SWT integration with the ServiceLoader
Implements caching for fonts, images, and text, supports DPI scaling
The plugin is modular an minimizes API changes
there are some tests in the org.eclipse.swt.skia plugin
for more information read the skia.md file in bundles/org.eclipse.swt.skia
uses the service loader, if there are bugs at the loading, the skia plugin will be ignored.
Since the API was modified the SWT version should be increased (still to do)
there seems to be an api tools bug because of sealed classes. This happens only in the github PR checks.
The second commit contains only the ignores for the api tools. It can be reverted and then the versioning could be fixed properly.