WTF !!!!

WTF !!!!

FMX.Forms.Border.Win contains a private global var

var
Rts: array [0..5000] of TRect;

80.016 bytes !

Comments

  1. x, y, w, h are they single or double?

    ReplyDelete
  2. Dorin Duminica 4 * SizeOf(Integer) * 50001 = 80.016 I've discovered that looking at TDS infos

    FMX.Forms.Border.Win data size is exactly 80.016

    github.com - Delphi

    ReplyDelete
  3. That's a very interesting project. Thanks for sharing.

    Note. Typo in the above formula. You have 50,001 instead of 5,001. But I get your point

    ReplyDelete
  4. Paul TOTH interesting that it's using ints rather than floats

    ReplyDelete
  5. Dorin Duminica AFAIK that array is used to create Windows region from bitmap on Windows and API requires integer coordinates.

    ReplyDelete
  6. Dalija Prasnikar right, I missed the Win suffix, makes sense, thanks!

    ReplyDelete
  7. it should be a local dynamic array of TRect not a global var.

    ReplyDelete
  8. Attila Kovacs on the main page you can download everystring as a single ZIP...but you can't download a branch AFAIK
    github.com - tothpaul/Delphi

    ReplyDelete
  9. Paul TOTH There is however question of usage frequency. If called too often that might pose a problem. But I haven't looked at that code closely.

    ReplyDelete
  10. Dalija Prasnikar the variable is used by CreateRegionDataFromBitmap called only by CreateRegionFromBitmap, called only by TWindowBorderWin.RecreateRegion, called only by TWindowBorderWin.Resize...not sure what it is about...
    docwiki.embarcadero.com - FMX.Forms.TForm.Border - RAD Studio API Documentation

    ReplyDelete
  11. Paul TOTH Regions are used to define window shape (form or any other win control). There are several API functions to do that - most simple are rectangle and round rectangle regions.

    For more complex, irregular shapes you have to define it by array of rectangles. And you have to do that every time window changes its size.

    So when you drag to resize above functions will be repeatedly called during that process. So speed counts. If nothing else globally defined fixed size array is allocated only once.

    Again, I haven't looked at that code closely so I don't know how well it is written and I don't know what are possible bottlenecks there.

    ReplyDelete
  12. Attila Kovacs Multithreading is not an issue because this is UI related code.

    ReplyDelete

Post a Comment