Very slow graphics with Intel N4100 under xubuntu 19.04 lazarus / 39-Graphics ---------------------------------------------------------------------- msavigo1 · 2019-07-13 15:04 I recently changes to a new notebook and facing very slow graphics with a project using TBitmap. The same project is running on my other computer like a charme. I don't have any problems with any ohter programm on that notebook. Scanling a 4896x3264 pixel picture to 580x350 pixel with CopyRect or StretchDraw takes over 20 seconds! Has anybody an idea how to solve this problem? 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.Button1Click(Sender: TObject);var  SourceJpg: TJpegImage;   // Source image  Bitmap1: TBitmap;        // Original bitmap  Bitmap2: TBitmap;        // Target bitmap  Rect1: TRect;            // Original Rect  Rect2: TRect;            // Target Rectbegin  // Load SourceJpg from file  Label1.Caption := 'Load SourceJpg...';  Label1.Refresh;  SourceJpg := TJpegImage.Create;  SourceJpg.LoadFromFile('./Julia.jpg');   // Assign SourceJpg to a bitmap  Label1.Caption := 'Assign SourceJpg...';  Label1.Refresh;  Bitmap1 := TBitmap.Create;  Bitmap1.Assign(SourceJpg);   // Show bitmap without scaling  Label1.Caption := 'Show bitmap without scaling...';  Label1.Refresh;  Image1.Canvas.Draw(0, 0, Bitmap1);   // Size of original bitmap  Rect1.Create(0, 0, Bitmap1.Width, Bitmap1.Height);   // Create the target bitmap  Bitmap2 := TBitmap.Create;  Bitmap2.SetSize(580, 350);   // Size of target bitmap  Rect2.Create(0, 0, Bitmap2.Width, Bitmap2.Height);   // Draw a scaled bitmap to the target bitmap  Label1.Caption := 'Draw a scaled bitmap to the target...';  Label1.Refresh;  Bitmap2.Canvas.CopyRect(Rect2, Bitmap1.Canvas, Rect1);   // Show scaled bitmap  Label1.Caption := 'Show scaled bitmap.';  Label1.Refresh;  Image1.Canvas.Draw(0, 0, Bitmap2);   //Label1.Caption := 'Show as stretched bitmap.';  //Label1.Refresh;  //Image1.Canvas.StretchDraw(Rect2, Bitmap1); end; Some infos about the notebook: Computer Prozessor   Intel(R) Celeron(R) N4100 CPU @ 1.10GHz Hauptspeicher   3856MB (489MB used) Maschinen-Typ   Laptop Betriebssystem   Ubuntu 19.04 Benutzername   maik (maik) Date/Time   Sa 13 Jul 2019 16:38:57 CEST Anzeige Auflösung   1366x768 pixels OpenGL-Renderer   Mesa DRI Intel(R) UHD Graphics 600 (Geminilake 2x6) X11-Hersteller   The X.Org Foundation Audio-Geräte Audio Adapter   HDA-Intel - HDA Intel PCH Audio Adapter   ThinkPad EC - ThinkPad Console Audio Control ---------------------------------------------------------------------- lainz · 2019-07-13 15:24 Try with BGRABitmap, it has fast resample. https://wiki.freepascal.org/BGRABitmap_tutorial_2#Stretch_the_image BTW, is amazing that with these specs it only takes 20 seconds, I remember creating big images on my old PC's and never working, programs stopping and like that ---------------------------------------------------------------------- Handoko · 2019-07-13 15:32 Hello msavigo1, Welcome to the forum. I checked the info of N4100, although it is not a high performance processor but it is as fast as most of the Core2 Duo processors and the UHD 600 is good enough to play most of 3D games. One interesting thing I found is, it has been reported to have poor driver support on Lubuntu 18.04.1 LTS. Maybe the issue still hasn't solved on Ubuntu 19.04. https://ubuntuforums.org/showthread.php?t=2406273 ---------------------------------------------------------------------- msavigo1 · 2019-07-13 15:48 Hello Handoko, the strange thing is, that I don't have problems with any other (graphic) programm on that computer. Loading an scaling that same jpg is just a click of a button with ohter programms. ---------------------------------------------------------------------- Handoko · 2019-07-13 16:12 If I'm correct, TCanvas drawing procedures are depended/provided by the OS. If your hardward doesn't have graphics driver properly installed it may run very slow. Alternatively I recommend you to try LazPaint. It is built using Lazarus and it uses BGRABitmap to handle the drawing functions, which in some cases can be faster than using the system widgetset. If LazPaint runs significant smoothly for the same image on your system compare to TCanvas, I believe it is driver issue. https://bgrabitmap.github.io/lazpaint/ ---------------------------------------------------------------------- msavigo1 · 2019-07-14 12:43 I tried different live distributions to see if it is a driver problem. The programme runs very fast (< 500 ms) on a fresh xubuntu without updates. Here “glxinfo -B” shows this:     Device: Mesa DRI Intel(R) UHD Graphics 600 (Geminilake 2x6)  (0x3185)     Version: 18.0.5  After applying all updates it is extremely slow (> 60 s) and “glxinfo -B” shows this:     Device: Mesa DRI Intel(R) UHD Graphics 600 (Geminilake 2x6)  (0x3185)     Version: 19.0.2  Even with the latest mesa version there is no improvement.     Device: Mesa DRI Intel(R) UHD Graphics 600 (Geminilake 2x6)  (0x3185)     Version: 19.2.0  Every Mesa version 18.x seem to work but Mesa 19.x case problems. All other graphic programmes run very well with any of these mesa versions. So I’m not sure if it is an Mesa or a Lazarus problem. ---------------------------------------------------------------------- Handoko · 2019-07-14 12:49 Thank you for reporting back what you found. Maybe you should also report it on Ubuntu forum. ---------------------------------------------------------------------- msavigo1 · 2019-07-14 15:48 This isn’t just an Ubuntu problem. The same happened with Ferora. Does the problem come from calling some Mesa functionality (out of Lazarus) the wrong way or does it come from executing the code the wrong way? Sorry for this simple explanation but I’m not an expert on what’s going on behind the scene. These are the timings in ms for the fast executing (Mesa 18.x): Load SourceJpg: 1526 Assign SourceJpg: 66 Show bitmap without scaling: 212 Draw a scaled bitmap to the target: 683 Show scaled bitmap: 0 These are the timings in ms for the slow executing (Mesa 19.x): Load SourceJpg: 1830 Assign SourceJpg: 83 Show bitmap without scaling: 218 Draw a scaled bitmap to the target: 62540 Show scaled bitmap: 0 I’m also not sure how an were to report this problem. ---------------------------------------------------------------------- winni · 2019-07-14 15:58 There were a really lot of updates for Mesa at the end of June and early July. Look if there is an update for Mesa on Ubuntu. Winni ---------------------------------------------------------------------- msavigo1 · 2019-07-14 17:25 I've already tried the latest Mesa version (19.2.0). ---------------------------------------------------------------------- msavigo1 · 2019-07-14 20:26 I did a fresh install (no live session) of xubuntu 19.04 with updates during installation. Now everything runs without problems.  Load SourceJpg: 1575 Assign SourceJpg: 87 Show bitmap without scaling: 248 Draw a scaled bitmap to the target: 413 Show scaled bitmap: 0 Don’t know where the problems came from.