Replies: 3 comments 6 replies
-
@Zeus64 I am impressed with the work. It seems absolutely amazing. 👏👏👏👏 As for the drawbacks, I would like to make some considerations:
On mobile, it seems that the draws on both GPU / CPU have similar performance, but there are specific scenarios where the GPU will draw considerably faster, like effects / shaders.
Our TBitmap canvas implementation is raster (CPU) but there are some optimizations. The actual approach creates internally a cache of the texture according to the target of the bitmap and draw target. That is, when you have a TBitmap and draw it on a form surface, it will generate one skia texture from that TBitmap and will cache it for that target until that TBitmap changes. IOW, you can create the TBitmap, draw it, and when you use it to draw on the screen, it will generated a texture internally, that is a slow process, but only for the first draw of that bitmap in another target. So, the tips here are:
Finally, I'm curious to know the relationship between this "4 times slower at drawing images onto the form" performance and #331, I mean, was the measurement made with your proposed changes? |
Beta Was this translation helpful? Give feedback.
-
Thank @viniciusfbb!
Yes, that's true. I was measuring the speed of drawing a simple GPU-based
As for my tests, I didn’t use
I don't fully agree. Yes, Skia is incredible for drawing shapes directly onto the form, but for physical images (e.g.,
There is no relationship between the two. The issue mentioned at #331 is primarily about allowing the possibility of continuing to work with Skia using textures created by third-party products via |
Beta Was this translation helpful? Give feedback.
-
@viniciusfbb thanks a lot! Can you share the code of your demo ? every tests i did show that sk4d_canvas_draw_image_rect is 4 times more slower than TCustomCanvasGpu(ACanvas).DrawTexture. I never used Tbitmap or any abstraction like this always work directly with skimage or TextureID |
Beta Was this translation helpful? Give feedback.
-
https://github.com/MagicFoundation/Alcinoe?tab=readme-ov-file#about-skia
I’ve written a brief article about Skia and Delphi. I’d love to hear any feedback or remarks you might have!
Skia is an open-source 2D graphics library that powers the graphics engine used by Flutter and the Android operating system. The implementation of Skia in Delphi marked a significant advancement for the FireMonkey framework, as it greatly surpasses the legacy Delphi TCanvasGPU graphics engine in nearly every aspect.
Key Advantages of Skia:
Drawbacks of Skia:
Performance Challenges with Skia:
The slower image rendering is particularly problematic in scenarios where we paint everything first onto an internal buffer and then render that buffer to the form surface on each paint loop—a technique often used to avoid flickering and improve performance. Unfortunately, Skia can be up to 4 times slower at drawing images onto the form surface compared to the legacy Delphi TCanvasGPU, which uses OpenGL textures.
For example, on a Google Pixel 7, I can render 2000 textures simultaneously at 90 FPS using TCanvasGPU. However, with Skia, I can only render 500 images at the same frame rate. You can verify this using the demo app located at Demos/ALFmxGraphics.
The Chosen Approach:
Given these limitations, I’ve decided to use Skia as the backend graphics engine in Alcinoe while continuing to use the legacy Delphi canvas (TCanvasGPU) for rendering on the main form surface. The exception is on Windows, where we use Skia for both the backend and the main form surface.
Platform-Specific Considerations:
On Android and iOS, the operating systems already provide powerful graphics APIs, and in many cases, these native APIs outperform Skia—often by as much as 2x. While the performance of the OS graphics APIs is superior, Skia still offers the benefit of a unified graphics engine across all platforms, along with additional features like animated images.
Beta Was this translation helpful? Give feedback.
All reactions