Forum > LCL

[SOLVED] Improvement of lcl/include/canvas.inc TCanvas.BrushCopy

(1/1)

lagprogramming:
The original code doesn't read and write data in a lean way, making the CPU use it's cache poorly. A similar situation has been described in the forum at:
Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » Improvement of packages/fcl-image/src/fpcanvas.inc TFPCustomCanvas.Erase
https://forum.lazarus.freepascal.org/index.php/topic,62788.0.html
I've replaced "for x := 0 to lSrcWidth-1 do for y := 0 to lSrcHeight-1 do" with "for y := 0 to lSrcHeight-1 do for x := 0 to lSrcWidth-1 do". Basically, I've switched the "for" loops.

Here is a patch:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---diff --git a/lcl/include/canvas.inc b/lcl/include/canvas.incindex 97665929b9..4c5300288f 100644--- a/lcl/include/canvas.inc+++ b/lcl/include/canvas.inc@@ -754,8 +754,8 @@ begin      // Next copy the bitmap to a intfimage to be able to make the color change     lIntfImage.LoadFromBitmap(lPaintedBitmap.Handle, 0);-    for x := 0 to lSrcWidth-1 do-      for y := 0 to lSrcHeight-1 do+    for y := 0 to lSrcHeight-1 do+      for x := 0 to lSrcWidth-1 do       begin         lPixelColor := lIntfImage.Colors[x, y];         if (lPixelColor.red = lTransparentColor.red) and

wp:
Since this is relatively clear, I committed it to the main branch without a proper bug report. But since I don't have commit rights in the FPC project I cannot help you with the related FPCustomCanvas issue.

Once again, you are wasting your time when you publish fixes here in the forum. They will be forgotten after a few days since most developers do not read the forum, and if they do they usually insist on a proper bug report for better documentation.

I really do not understand why you have such an aversion against the bug tracker?

lagprogramming:
Your interventions are valuable, wp.  ;)

AlexTP:
I posted the bugreport to https://gitlab.com/freepascal.org/fpc/source/-/issues/40236

Navigation

[0] Message Index

Go to full version