ThorVG - test (lightweight vector graphics engine) lazarus / 39-Graphics ---------------------------------------------------------------------- ALLIGATOR · 2026-02-08 10:35 https://www.thorvg.org/ I tried this library on Windows x64 - it looks pretty good I loaded a Lottie animation, rendering (in this case) on the CPU It doesn't seem to slow down, but it can be significantly accelerated (on Windows), IMHO, since most of the load is currently due to Lazarus abstraction layers, IMHO I didn't test it on Linux (although I really wanted to), because the library needs to be compiled. I just took the ready-made one from GitHub, where there was a compiled binary for Windows x64, but not for Linux As for compiling it myself, I don't feel like messing with C++ and its compilation systems at the moment ---------------------------------------------------------------------- ALLIGATOR · 2026-02-08 10:35 animation ---------------------------------------------------------------------- LeP · 2026-02-08 13:43 I try it with little modifications to view SVG files. The colours are not aligned (try with different viewer that give the same results, except in thorvg) ... look at attached image. In many case, where the SVG is more complex it throw an math exception (divide by zero). To resolve this you have to add: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SetExceptionMask(GetExceptionMask + [exOverflow,exZeroDivide,exInvalidOp]); this is normally when you have to do with C Microsoft Dll. But, except for colours, seems to be good with very complex svg images too ... better then Skia. P.S.: Colours not aligned, I meant the colours are not right, some kind is right others not (it's like the typical inversion of the plane R,G,B that affects also PNG sometimes). ---------------------------------------------------------------------- ALLIGATOR · 2026-02-08 14:05 Quote from: LeP on February 08, 2026, 02:43:17 pmI meant the colours are not right, some kind is right others notIt looks like some kind of alpha channel mix-up You need to make the background the same for the shape and the tool you used to get the second image And you can also play around with the modes, where you can choose different RGB8888 settings ---------------------------------------------------------------------- ALLIGATOR · 2026-02-08 14:07 But in general, I tested very limitedly, as soon as I made sure that Lottie animations worked, and slightly removed Lazarus overhead for working with image data - I immediately loaded the result ---------------------------------------------------------------------- LeP · 2026-02-08 14:10 Quote from: ALLIGATOR on February 08, 2026, 03:05:34 pmQuote from: LeP on February 08, 2026, 02:43:17 pmI meant the colours are not right, some kind is right others notIt looks like some kind of alpha channel mix-up You need to make the background the same for the shape and the tool you used to get the second image What background ? The "orginal" image is viewer with Firefox (the "original" image attached), Edge or others tools without setting nothing. ---------------------------------------------------------------------- ALLIGATOR · 2026-02-08 14:12 Quote from: LeP on February 08, 2026, 03:10:14 pmWhat background ? The "orginal" image is viewer with Firefox (the "original" image attached), Edge or others tools without setting nothing.I corrected the message But you'd better send the svg file then ---------------------------------------------------------------------- LeP · 2026-02-08 14:16 Quote from: ALLIGATOR on February 08, 2026, 03:12:19 pmQuote from: LeP on February 08, 2026, 03:10:14 pmWhat background ? The "orginal" image is viewer with Firefox (the "original" image attached), Edge or others tools without setting nothing.I corrected the message But you'd better send the svg file then  Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i                                                     ---------------------------------------------------------------------- ALLIGATOR · 2026-02-08 14:34 Quote from: LeP on February 08, 2026, 03:16:13 pmCode: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Code: Diff  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i -   tvg_swcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data), PaintBox1.Width, PaintBox1.Width, PaintBox1.Height, TVG_COLORSPACE_ABGR8888S);+   tvg_swcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data), PaintBox1.Width, PaintBox1.Width, PaintBox1.Height, TVG_COLORSPACE_ARGB8888S); And everything will be OK ---------------------------------------------------------------------- ALLIGATOR · 2026-02-08 14:36 Quote from: LeP on February 08, 2026, 02:43:17 pmseems to be good with very complex svg images too ... better then SkiaEspecially the size of the library! Just look how tiny it is, and if you link it statically, it will be even smaller! ---------------------------------------------------------------------- LeP · 2026-02-08 15:00 Quote from: ALLIGATOR on February 08, 2026, 03:34:30 pmCode: Diff  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i -   tvg_swcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data), PaintBox1.Width, PaintBox1.Width, PaintBox1.Height, TVG_COLORSPACE_ABGR8888S);+   tvg_swcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data), PaintBox1.Width, PaintBox1.Width, PaintBox1.Height, TVG_COLORSPACE_ARGB8888S);And everything will be OK OK Quote from: ALLIGATOR on February 08, 2026, 03:36:29 pmEspecially the size of the library! Just look how tiny it is, and if you link it statically, it will be even smaller! Yes, but I use Delphi and SKIA or Image32 are integrated in pure Pascal without any external DLL. Other thing is that I need the DLL signed or I should compile the DLL myself (in simple way without python, perl, php, etc ...). All my software are signed. ---------------------------------------------------------------------- hermet · 2026-02-09 04:47 Quote from: hermet on February 09, 2026, 05:46:12 amYes, but I use Delphi and SKIA or Image32 are integrated in pure Pascal without any external DLL. Other thing is that I need the DLL signed or I should compile the DLL myself (in simple way without python, perl, php, etc ...). All my software are signed. Why not use the static library of ThorVG? 🙂 ---------------------------------------------------------------------- ALLIGATOR · 2026-02-09 05:15 Quote from: hermet on February 09, 2026, 05:47:10 amWhy not use the static library of ThorVG? 🙂What???? The author of the library is here? On the FreePascal forum? No way! ---------------------------------------------------------------------- Roland57 · 2026-02-09 07:26 Quote from: ALLIGATOR on February 08, 2026, 11:35:27 amI didn't test it on Linux (although I really wanted to), because the library needs to be compiled. I just took the ready-made one from GitHub, where there was a compiled binary for Windows x64, but not for Linux Hello! Thank you for sharing. I could compile easily the library under Linux: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i meson setup builddirninja -C builddir install I could also compile the Lazarus project, but when I start the program, I get a violation access, then a blank window, and then the window of the application, with the word "Cat". ---------------------------------------------------------------------- ALLIGATOR · 2026-02-09 07:44 Quote from: Roland57 on February 09, 2026, 08:26:51 amI could compile easily the library under LinuxShare the *.so file (I may not be able to use it due to some incompatibility with system libraries, but I'll give it a try) Also, maybe this advice can help you? Quote from: LeP on February 08, 2026, 02:43:17 pmIn many case, where the SVG is more complex it throw an math exception (divide by zero). To resolve this you have to add: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SetExceptionMask(GetExceptionMask + [exOverflow,exZeroDivide,exInvalidOp]);this is normally when you have to do with C Microsoft Dll ---------------------------------------------------------------------- Boleeman · 2026-02-09 08:05 I also get an Access violation on a Win10 A4 AMD Laptop, yet on an Intel Win11 laptop all compiles and runs well. AMD access error at:  r := tvg_engine_init(4); unit1.pas(36,3) Note: Local variable "r" is assigned but never used and at: tvg_animation_set_frame(tvgAnimation, frame_count * progress/duration); I even tried running the working Intel compiled exe on the AMD laptop and get Invalid floating point operation. Access violation could possibly be how AMD CPU treats floats? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1;{$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,thorvg_capi, Math; type   { TForm1 }   TForm1 = class(TForm)    Label1: TLabel;    PaintBox1: TPaintBox;    Timer1: TTimer;    procedure FormCreate(Sender: TObject);    procedure FormDestroy(Sender: TObject);    procedure PaintBox1Paint(Sender: TObject);    procedure Timer1Timer(Sender: TObject);  private    tvgCanvas: Tvg_Canvas;    tvgPaint: Tvg_Paint;    tvgAnimation: Tvg_Animation;    progress: Single;    duration: Single;    frame_count: Single;    b: TBitmap;  end; var  Form1: TForm1; implementation {$R *.lfm} procedure TForm1.FormCreate(Sender: TObject);var  r: Tvg_Result;  Mask1: TFPUExceptionMask;begin  b:=TBitmap.Create;  b.PixelFormat := pf32bit;  //b.SetSize(PaintBox1.Width, PaintBox1.Height);  b.Width:= PaintBox1.Width;  b.Height:= PaintBox1.Height;     Mask1 := SetExceptionMask(GetExceptionMask + [exOverflow,exZeroDivide,exInvalidOp]);    try       r := tvg_engine_init(4);    finally        SetExceptionMask(Mask1);    end;    tvgCanvas := tvg_swcanvas_create(TVG_ENGINE_OPTION_DEFAULT);  tvg_swcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data), PaintBox1.Width, PaintBox1.Width, PaintBox1.Height, TVG_COLORSPACE_ABGR8888S);   tvgAnimation:=tvg_lottie_animation_new();  tvgPaint:=tvg_animation_get_picture(tvgAnimation);  tvg_picture_load(tvgPaint, 'cat.json');  tvg_animation_get_duration(tvgAnimation, @duration);  tvg_animation_get_total_frame(tvgAnimation, @frame_count);  tvg_picture_set_size(tvgPaint, PaintBox1.Width, PaintBox1.Height);   tvg_canvas_add(tvgCanvas, tvgPaint);   Timer1.Enabled:=True;end; procedure TForm1.FormDestroy(Sender: TObject);begin b.Free;end; procedure TForm1.PaintBox1Paint(Sender: TObject);var    Mask2: TFPUExceptionMask;begin  b.BeginUpdate;     Mask2 := SetExceptionMask(GetExceptionMask + [exOverflow,exZeroDivide,exInvalidOp]);    try       tvg_animation_set_frame(tvgAnimation, frame_count * progress/duration);    finally       SetExceptionMask(Mask2);    end;     tvg_canvas_update(tvgCanvas);    tvg_canvas_draw(tvgCanvas, True);    tvg_canvas_sync(tvgCanvas);   b.EndUpdate(True);   PaintBox1.Canvas.Draw(0,0,b);end; procedure TForm1.Timer1Timer(Sender: TObject);begin  progress:=progress + Timer1.Interval*(1.0/1000.0);   if progress>duration then progress:=0.0;   PaintBox1.Invalidate;end; end. ---------------------------------------------------------------------- ALLIGATOR · 2026-02-09 09:14 Quote from: Boleeman on February 09, 2026, 09:05:07 amI also get an Access violationIs it AccessViolation? Or is it “Invalid floating point operation” as shown in your screenshot? At the very beginning of Form.Create, try simply masking all these exceptions for verification purposes: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); As for AMD or Intel, all processors have their own bugs, although I'm not sure if this is a manifestation of a hardware or microcode bug ---------------------------------------------------------------------- Boleeman · 2026-02-09 09:36 OK I did a test to see if the DLL is loading and found that thorvg.dll is not loading on my AMD laptop. Not sure if someone can recompile the thorvg.dll DLL on an AMD laptop and upload? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);var  r: Tvg_Result;  hThorVG: TLibHandle = 0;begin  b:=TBitmap.Create;  b.PixelFormat := pf32bit;  //b.SetSize(PaintBox1.Width, PaintBox1.Height);  b.Width:= PaintBox1.Width;  b.Height:= PaintBox1.Height;       // r := tvg_engine_init(4);       hThorVG := LoadLibrary('thorvg.dll');      if hThorVG = 0 then        raise Exception.Create('thorvg.dll not found');  if not Assigned(tvg_engine_init) then  raise Exception.Create('tvg_engine_init is NIL'); if not Assigned(tvg_swcanvas_create) then  raise Exception.Create('tvg_swcanvas_create is NIL'); if not Assigned(tvg_swcanvas_set_target) then  raise Exception.Create('tvg_swcanvas_set_target is NIL');   tvgCanvas := tvg_swcanvas_create(TVG_ENGINE_OPTION_DEFAULT);  tvg_swcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data),  PaintBox1.Width * 4, PaintBox1.Width, PaintBox1.Height, TVG_COLORSPACE_ABGR8888S);   tvgAnimation:=tvg_lottie_animation_new();  tvgPaint:=tvg_animation_get_picture(tvgAnimation);  tvg_picture_load(tvgPaint, 'cat.json');  tvg_animation_get_duration(tvgAnimation, @duration);  tvg_animation_get_total_frame(tvgAnimation, @frame_count);  tvg_picture_set_size(tvgPaint, PaintBox1.Width, PaintBox1.Height);   tvg_canvas_add(tvgCanvas, tvgPaint);   Timer1.Enabled:=True;end; ---------------------------------------------------------------------- ALLIGATOR · 2026-02-09 09:58 Quote from: Boleeman on February 09, 2026, 10:36:10 amthorvg.dll is not loading on my AMD laptopYou are probably compiling a 32-bit application, but the library is 64-bit, so it won't work You need to compile a 64-bit application, then the library will load I don't plan to deploy a C++ build system myself for now, but I understand that the author of the library is also involved in this thread. Perhaps if he sees this message, we can ask him to create more different versions of the library on GitHub releases: Win_x86, Win_x86_64, Linux_x86_64 (maybe even Arm)? I still don't think it's an AMD CPU issue ---------------------------------------------------------------------- ALLIGATOR · 2026-02-09 10:06 @Booleman I also see that you haven't changed the constant TVG_COLORSPACE_ABGR8888S to TVG_COLORSPACE_ARGB8888S (BGR -> RGB) With the constant from my first post in this thread, the colors come out “flipped” ---------------------------------------------------------------------- BildatBoffin · 2026-02-09 10:22 About linux, is there an API for X11, e.g something in the vein of https://www.cairographics.org/manual/cairo-XLib-Surfaces.html ? ---------------------------------------------------------------------- Boleeman · 2026-02-09 10:37 OK I changed to TVG_COLORSPACE_ARGB8888S I installed Visual Studio 2026 Community Edition and compiled on my AMD computer. I think it was missing DLL dependencies, such as outdated (or, conversely, missing old versions) of the VCRedist runtime, as I used your thorvg.dll ( also compiled the c code using meson and cmake, it compiled OK but I could not locate the thorvg-1.dll in the build directory/folder In the meson log.txt it said: Command line for building ['src\\thorvg-1.dll'] is long, using a response file ) Anyhow, The code now compiles without error using Lazarus 64Bit compiler on my AMD laptop and the exe runs successfully. Hooray. ---------------------------------------------------------------------- ALLIGATOR · 2026-02-09 10:40 Quote from: BildatBoffin on February 09, 2026, 11:22:01 amAbout linux, is there an API for X11, e.g something in the vein of https://www.cairographics.org/manual/cairo-XLib-Surfaces.html ? There must be a way This library only prepares the image data in the form of an RGBA pixel array; what to do with it next is up to the programmer I don't have a compiled *.so for Linux on hand, so I could try to check it out. Maybe there are examples of working with Cairo somewhere in LCL Lazarus, or in the examples that come with the distribution, or here on the forum. I think someone has already discussed it. I also saw Cairo being used in FPC/Lazarus on a German-language forum This is one of its modes of operation, by the way. It can also use output to OpenGL and WebGPU ---------------------------------------------------------------------- ALLIGATOR · 2026-02-09 10:46 Quote from: Boleeman on February 09, 2026, 11:37:40 amI might install Visual Studio and compile the dll on my AMD computer? Unfortunately, in this case, I don't know what the problem could be... If the problem could at least be reproduced on my end, I might be able to do something, but without local reproduction, I have no more ideas about what it could be. Could @Roland57 help you? But I don't know ---------------------------------------------------------------------- ALLIGATOR · 2026-02-09 10:51 @Boleeman Another idea - perhaps you simply don't have certain DLL dependencies, such as outdated (or, conversely, missing old versions) of the VCRedist runtime ---------------------------------------------------------------------- BildatBoffin · 2026-02-09 10:55 QuoteThis is one of its modes of operation, by the way. It can also use output to OpenGL and WebGPU Yes, this is what is interesting compared to Cairo, Thor seems to have a faster backend. ---------------------------------------------------------------------- Roland57 · 2026-02-09 17:31 Quote from: ALLIGATOR on February 09, 2026, 08:44:10 amShare the *.so file (I may not be able to use it due to some incompatibility with system libraries, but I'll give it a try) Also, maybe this advice can help you? I said how I compiled the library in my message. It is very easy. After that, I renamed it this way (in Lazarus demo directory): Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i cp ~/Documents/pascal/thorvg/builddir/src/libthorvg-1.so.1.0.0 libthorvg.so Quote from: ALLIGATOR on February 09, 2026, 08:44:10 amAlso, maybe this advice can help you? I tried. It doesn't change the behaviour of the program. ---------------------------------------------------------------------- ALLIGATOR · 2026-02-09 18:30 Quote from: Boleeman on February 09, 2026, 11:37:40 amThe code now compiles without error using Lazarus 64Bit compiler on my AMD laptop and the exe runs successfully. Hooray.If I hadn't happened to flip through the pages, I wouldn't have noticed that you succeeded Congratulations! (If you had written a new message, I would have seen it in the RSS feed) ---------------------------------------------------------------------- Boleeman · 2026-02-10 08:34 Here is the static linked thorvg-1.dll compiled by myself with all these loaders hopefully enabled: 'svg', 'png', 'jpg', 'lottie', 'ttf', 'webp' with ALLIGATOR's slightly modified source and a driving lottie example. (Hooray I finally worked out how to compile some c++ code to a dll). Many thanks to ALLIGATOR for his advice and Hermet Park (and The ThorVG Team). *** Sorry about the previous mis-spelling Hermet  *** Now Lazarus users will be able to add nice svg graphics and animations to their GUI's. Fantastic. Roland57: Did you get it working on Linux? Not sure if before you made the build you set the options? I was getting those access errors in Windows for a while until I worked out the compile switches. Also I am using Visual Studio 2026 to compile. Not sure what you used (MingW?)? ---------------------------------------------------------------------- hermet · 2026-02-11 08:05 Quote from: Boleeman on February 10, 2026, 09:34:56 amHere is the static linked thorvg-1.dll compiled by myself with all these loaders hopefully enabled: 'svg', 'png', 'jpg', 'lottie', 'ttf', 'webp' with ALLIGATOR's slightly modified source and a driving lottie example. (Hooray I finally worked out how to compile some c++ code to a dll). Many thanks to ALLIGATOR for his advice and Hermit Park (and The ThorVG Team). (Not sure but Samsung looks like it is involved as well or maybe just end user, probably for their Android Apps?). Now Lazarus users will be able to add nice svg graphics and animations to their GUI's. Fantastic. PS: ALLIGATOR: I tried not to spam the thread, that's why I did not reply later on. Roland57: Did you get it working on Linux? Not sure if before you made the build you set the options? I was getting those access errors in Windows for a while until I worked out the compile switches. Also I am using Visual Studio 2026 to compile. Not sure what you used (MingW?)? Cool! PS. My name is Hermet, not Hermit. ---------------------------------------------------------------------- Boleeman · 2026-02-11 10:28 Many Apologies Hermet. Just love the way ThorVG renders and animates. ---------------------------------------------------------------------- elkhalafy · 2026-02-12 06:11 I looking for this library ported to Lazarus, but it's C++ or you already fully ported to FPC Thank you ---------------------------------------------------------------------- Antek · 2026-02-12 11:52 I tested the project provided by @Boleeman. It just worked on win11 64bit. But the cpu usage is (very) high. One core is running with nearly 100%, with given "driving.json" and 25fps. I think this is because of sofware(cpu) rendering: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i tvgCanvas := tvg_swcanvas_create(TVG_ENGINE_OPTION_SMART_RENDER); tvg_swcanvas_s et_target(tvgCanvas, PUInt32(b.RawImage.Data), PaintBox1.Width, PaintBox1.Width, PaintBox1.Height, TVG_COLORSPACE_ARGB8888S); I don't know how to use opengl rendering backend. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i tvgCanvas := tvg_glcanvas_create( TVG_ENGINE_OPTION_DEFAULT); Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i tvg_glcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data), ...... But I think hw rendering is crucial for apps when using animations (heavily). Great work! ---------------------------------------------------------------------- Zvoni · 2026-02-12 12:29 Quote from: Antek on February 12, 2026, 12:52:35 pm*snip* But the cpu usage is (very) high. One core is running with nearly 100%, with given "driving.json" and 25fps. I think this is because of sofware(cpu) rendering: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i tvgCanvas := tvg_swcanvas_create(TVG_ENGINE_OPTION_SMART_RENDER); tvg_swcanvas_s et_target(tvgCanvas, PUInt32(b.RawImage.Data), PaintBox1.Width, PaintBox1.Width, PaintBox1.Height, TVG_COLORSPACE_ARGB8888S); tvg_swcanvas_create --> have a guess, what the "sw" is standing for QuoteI don't know how to use opengl rendering backend. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i tvgCanvas := tvg_glcanvas_create( TVG_ENGINE_OPTION_DEFAULT); Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i tvg_glcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data), ...... But I think hw rendering is crucial for apps when using animations (heavily). Great work! https://www.thorvg.org/post/thorvg-v1-0-a-new-generation-released Scroll down to D. Performance I see a "Renderer" with the following Entries CPU (SW) GPU (GL) And don't you know it: there is a "tvg_glcanvas_create" (as you found out) ---------------------------------------------------------------------- ALLIGATOR · 2026-02-12 15:53 @Antek For OpenGL, you probably need to create a context. I haven't worked with OpenGL before. You either need to study examples of working with OpenGL from Lazarus and ThorVG yourself, or wait until someone adapts the examples SW animation can be accelerated; at least 50% is lost in the depths of LCL when rendering Bitmap (I'm talking about Windows; in other widget sets, everything may be different; in general, you need to adapt the rendering everywhere for minimal overhead) ---------------------------------------------------------------------- ALLIGATOR · 2026-02-12 15:58 @Antek Also, change this to this Code: Diff  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i - ...tvg_engine_init(whatever);+ ...tvg_engine_init(1);It took a lot of load off my CPU Looks like a ThorVG bug? ---------------------------------------------------------------------- Boleeman · 2026-02-13 07:37 My previous compiled DLL just had only sw enabled and not GL. I went back and recompiled the dll with GL enabled. Attached is a slightly larger new GL enabled thorvg-1.dll DLL. I also tried to enable the wg mode rasterizer (which uses GPU) but that option was rejected (my Acer A4 laptop has a GPU, saw this by Ctrl + Shift + Esc and went to the Performance tab). Not sure why it was rejected when compiling the dll? Perhaps someone can try the GL mode to see if it now works with the newly compiled DLL? ---------------------------------------------------------------------- Zvoni · 2026-02-13 08:43 Quote from: Boleeman on February 13, 2026, 08:37:20 amMy previous compiled DLL just had only sw enabled and not GL. I went back and recompiled the dll with GL enabled. Attached is a slightly larger new GL enabled thorvg-1.dll DLL. I also tried to enable the wg mode rasterizer (which uses GPU) but that option was rejected (my Acer A4 laptop has a GPU, saw this by Ctrl + Shift + Esc and went to the Performance tab). Not sure why it was rejected when compiling the dll? Perhaps someone can try the GL mode to see if it now works with the newly compiled DLL? Acc. to their website, wg is not fully supported (experimental?) https://www.thorvg.org/native-apis Go to Classes - Class List - tvg - wgcanvas QuoteDetailed Description A class for the rendering graphic elements with a WebGPU raster engine. Warning     Please do not use it. This class is not fully supported yet.at least as of v 0.15 ---------------------------------------------------------------------- Boleeman · 2026-02-13 09:04 Thanks Zvoni for explaining why that wg mode did not work. I also enabled Enable CPU Vectorization(SIMD) in the GL enabled thorvg-1.dll so hopefully thorvg should render more efficiently. ALLIGATOR's suggestion of using tvg_engine_init(1); reduced the load of my AMD CPU to 18 to 21% rather than the high 90% that I was seeing before. ---------------------------------------------------------------------- Zvoni · 2026-02-13 09:11 Quote from: Boleeman on February 13, 2026, 10:04:51 amThanks Zvoni for explaining why that wg mode did not work. I also enabled Enable CPU Vectorization(SIMD) in the GL enabled thorvg-1.dll so hopefully thorvg should render more efficiently. ALLIGATOR's suggestion of using tvg_engine_init(1); reduced the load of my AMD CPU to 18 to 21% rather than the high 90% that I was seeing before. As far as i understood the docs: https://www.thorvg.org/native- tutorial tvg_engine_init(x); the "x" is for "Count of WorkerThreads", soooooo...... ? IIRC, there are some Pascal-Routines to determine Number of CPU's the Program runs on, so maybe your Computer just doesn't like you spawning 4 additional threads on its AMD ---------------------------------------------------------------------- ALLIGATOR · 2026-02-13 10:42 Quote from: Zvoni on February 13, 2026, 10:11:52 amAs far as i understood the docs: https://www.thorvg.org/native-tutorial tvg_engine_init(x); the "x" is for "Count of WorkerThreads", soooooo...... ? Yes, but it didn't seem to affect the FPS at all. I have 1 - 2.5% load on 12 cores for Lottie car animation With a different value, it was 90% of 12 cores, which is unthinkable for car animation Therefore, I still lean towards the idea that this is some kind of bug in ThorVG (or I misunderstood something) ---------------------------------------------------------------------- Boleeman · 2026-02-13 12:47 Was anyone able to make a GL animation sample? ---------------------------------------------------------------------- LeP · 2026-02-13 14:07 Quote from: ALLIGATOR on February 13, 2026, 11:42:18 amYes, but it didn't seem to affect the FPS at all. I have 1 - 2.5% load on 12 cores for Lottie car animation With a different value, it was 90% of 12 cores, which is unthinkable for car animation Therefore, I still lean towards the idea that this is some kind of bug in ThorVG (or I misunderstood something) I tried some values form 0 to max core count of my PC (INTEL family 14) and with 0 I have a 99% of load, with values more than 1 (so 2,3,4, ....) the load increases progressively up to approximately 25%, while with a value of 1 the load remains between 1% and 2% I will try with OpenGL ... ---------------------------------------------------------------------- ALLIGATOR · 2026-02-14 03:55 Quote from: Boleeman on February 13, 2026, 01:47:56 pmWas anyone able to make a GL animation sample? I just want to mention again that with one core in tvg_engine_init, there is a heavy load (under Windows) also from the internal logic of LCL. If we switch to WinAPI, I expect the load to be reduced by half ---------------------------------------------------------------------- Antek · 2026-02-14 11:35 @alligator , @boleeman I tested : tvg_engine_init(x) case (1) : 0-1% cpu usage case >1: ~ x* 5% cpu usage amd cpu. I don't know how to use opengl. So I can't test. Best. ---------------------------------------------------------------------- valdir.marcos · 2026-02-16 10:19 Quote from: ALLIGATOR on February 12, 2026, 04:53:12 pm@Antek For OpenGL, you probably need to create a context. I haven't worked with OpenGL before. You either need to study examples of working with OpenGL from Lazarus and ThorVG yourself, or wait until someone adapts the examples SW animation can be accelerated; at least 50% is lost in the depths of LCL when rendering Bitmap (I'm talking about Windows; in other widget sets, everything may be different; in general, you need to adapt the rendering everywhere for minimal overhead)Good information. ---------------------------------------------------------------------- hermet · 2026-02-23 15:25 Quote from: Antek on February 12, 2026, 12:52:35 pmI tested the project provided by @Boleeman. It just worked on win11 64bit. But the cpu usage is (very) high. One core is running with nearly 100%, with given "driving.json" and 25fps. I think this is because of sofware(cpu) rendering: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i tvgCanvas := tvg_swcanvas_create(TVG_ENGINE_OPTION_SMART_RENDER); tvg_swcanvas_s et_target(tvgCanvas, PUInt32(b.RawImage.Data), PaintBox1.Width, PaintBox1.Width, PaintBox1.Height, TVG_COLORSPACE_ARGB8888S); Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i tvg_glcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data), ...... But I think hw rendering is crucial for apps when using animations (heavily). Great work! I don't know how to use opengl rendering backend. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i tvgCanvas := tvg_glcanvas_create( TVG_ENGINE_OPTION_DEFAULT); Hi, somehow it seems a bit late but leave a comment for your information. basically, software engine is very fast but the driving animation includes post-effects such as blur. It may require more CPU processing than typical animations. The recommended number of threads is 4 in normal scenario, it's enough. Using more threads may consume additional resources, which could block your app’s main loop cycle. Regarding OpenGL, I’m not sure which framework or window system Lazarus uses. OpenGL initialization and context creation must be handled on the user side with thorvg. If you are using a specific framework such as SDL, you can pass the created OpenGL context to ThorVG. The best practice is described here: https://github.com/thorvg/thorvg.example And WebGPU is designed for web browser running. I guess it's not a case you're concern.