dormky 5 Posted 10 hours ago I'm drawing custom graphs, for now using GDI. Here's an example from a test project : It's a mess but that's because I'm testing as many possibilities as I can with the management of the axis. One problem that I'm running into is performance : 50ms to draw. This is annoying because it makes the graph jittery when dragging elements (lines and rectangles must be able to be moved by the user). I've made modifications so that it can be rendered by OpenGL, which is obviously MUCH faster (<8ms without looking very much at other performance improvements). Unfortunately initializing OpenGL takes multiple seconds. This is fine when you're running a game, but I have forms with 12 of these graphs on screen at the same time, all showing different stuff... So yeah. Is there any rendering engine on Windows that's got equivalent functionnality to GDI, but is just faster by vertue of using the GPU ? Any alternatives to consider ? Share this post Link to post
dormky 5 Posted 8 hours ago 9 minutes ago, Alexander Sviridenkov said: Use Direct2D I did, but performance wasn't that much better, only 50 % 😕 And that's discounting a bunch of issues I've had making it work (it's still not a one-to-one of what I get with GDI, while OpenGL is and didn't cause me implementation issues) Share this post Link to post
David Heffernan 2485 Posted 8 hours ago This can easily be drawn quickly with gdi. You don't need another library. 3 Share this post Link to post
Lars Fosdal 1929 Posted 7 hours ago @dormky Did you take a look at TeeChart? 1 Share this post Link to post
Cristian Peța 122 Posted 6 hours ago 4 hours ago, dormky said: One problem that I'm running into is performance : 50ms to draw Use a profiler and see what takes so much. I doubt that GDI drawing takes 50 ms for this on a modern CPU. Share this post Link to post
dormky 5 Posted 5 hours ago 2 hours ago, David Heffernan said: This can easily be drawn quickly with gdi. You don't need another library. Quickly yes, quickly enough no. And I'm already using things like Polyline and caching to reduce syscalls. Share this post Link to post
dormky 5 Posted 5 hours ago 1 hour ago, Lars Fosdal said: @dormky Did you take a look at TeeChart? Would TeeChart allow me to draw arbitrary shapes onto the graph ? From what I've this doesn't seem to be the case but I might have missed something. I need complete control over how the axis are laid out etc. Although if you know what exactly TeeChart uses under the hood that might point me in the right direction. 1 Share this post Link to post
dormky 5 Posted 5 hours ago (edited) 17 minutes ago, Cristian Peța said: Use a profiler and see what takes so much. I doubt that GDI drawing takes 50 ms for this on a modern CPU. Main bottleneck is the repeated calls to the gdi canvas to draw lines. I have code that prevents drawing unnecessarily (ie check if 2 points are far enough apart that they won't get resolved to the same coordinates) and this reduces the time proportionally to the size of the canvas used. Edited 5 hours ago by dormky Share this post Link to post
Javier Tarí 39 Posted 5 hours ago Did you tried with Skia and see what happens? Share this post Link to post
Cristian Peța 122 Posted 5 hours ago (edited) 23 minutes ago, dormky said: Main bottleneck is the repeated calls to the gdi canvas to draw lines. How many lines? GDI+ is slow but I suppose you are using GDI here. I have 174 ms for 46000 lines. EDIT: That means 13300 lines per 50 ms Edited 5 hours ago by Cristian Peța Share this post Link to post
Cristian Peța 122 Posted 5 hours ago 20 minutes ago, dormky said: Main bottleneck is the repeated calls to the gdi canvas to draw lines. If you profiled this then how much from that 50 ms take the calls to draw lines. Share this post Link to post
David Heffernan 2485 Posted 2 hours ago (edited) 3 hours ago, dormky said: Quickly yes, quickly enough no. And I'm already using things like Polyline and caching to reduce syscalls. Definitely quickly enough. So I use graphics 32 to draw off screen bitmap and blit that. Which is still gdi. But you aren't using gdi to draw lines to a DC. That's how you make it fast. It might even be fast enough to draw to off screen TBitmap and blit that. Edited 2 hours ago by David Heffernan Share this post Link to post
david berneda 64 Posted 46 minutes ago 4 hours ago, dormky said: Would TeeChart allow me to draw arbitrary shapes onto the graph ? From what I've this doesn't seem to be the case but I might have missed something. I need complete control over how the axis are laid out etc. Although if you know what exactly TeeChart uses under the hood that might point me in the right direction. Yes you can use the Chart1.Canvas methods that wrap around a real canvas (gdi, gdi+, opengl, skia etc) to draw anything. Axis have many property settings to position and configure them (and extra TChartAxis can be created). The "TeeNew" folder demo here, has aprox 700 forms, each showing different features of many categories: https://github.com/Steema/TeeChart-VCL-FMX-Samples/tree/main/VCL Share this post Link to post