Recent

Author Topic: BGRABitmap: render to N bitmaps in N threads?  (Read 1044 times)

Alextp

  • Hero Member
  • *****
  • Posts: 1275
    • UVviewsoft
BGRABitmap: render to N bitmaps in N threads?
« on: February 23, 2021, 11:11:36 am »
For my app, I need parallel rendering: render N BGRAbitmaps (N=2..4) in N threads. Render is: TextOut, Rect, FillRect, Line, CopyRect etc.
It's possible?

circular

  • Hero Member
  • *****
  • Posts: 3712
    • Personal webpage
Re: BGRABitmap: render to N bitmaps in N threads?
« Reply #1 on: February 23, 2021, 09:46:46 pm »
Many things are thread safe but not text rendering, at least using LCL renderer. A part from that, I am not sure what would prevent from multithreading.
Conscience is the debugger of the mind

Alextp

  • Hero Member
  • *****
  • Posts: 1275
    • UVviewsoft
Re: BGRABitmap: render to N bitmaps in N threads?
« Reply #2 on: February 25, 2021, 10:41:05 pm »
I now tested it and confirm. demo attached. If I uncomment "TextOut", app crashes on button press.
Can you solve it, pls?

Alextp

  • Hero Member
  • *****
  • Posts: 1275
    • UVviewsoft
Re: BGRABitmap: render to N bitmaps in N threads?
« Reply #3 on: February 25, 2021, 10:47:46 pm »
I got that LCL cannot do TextOut such a way; how can I do textout then? some use of FreeType maybe?

circular

  • Hero Member
  • *****
  • Posts: 3712
    • Personal webpage
Re: BGRABitmap: render to N bitmaps in N threads?
« Reply #4 on: February 26, 2021, 08:56:35 pm »
I suppose you could try with FreeType by using a font collection for each thread. You can specify the collection to use by assigning it to the Collection property of the TBGRAFreeTypeFontRenderer. Note that you need to create a renderer for each TBGRABitmap.

I am curious if it will work.

Another approach would be to use TVectorizedFont and to precompute all the glyphs you are going to use. After that, I suppose you can use it within threads. The drawback is that you need to know in advance which font and style you're going to use.
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 2418
Re: BGRABitmap: render to N bitmaps in N threads?
« Reply #5 on: February 26, 2021, 09:15:52 pm »

Another approach would be to use TVectorizedFont and to precompute all the glyphs you are going to use. After that, I suppose you can use it within threads. The drawback is that you need to know in advance which font and style you're going to use.

Hi!

That is the PostScript  way: Collect all needed chars and then build the glyphs.
In the worst case this will force you to a two-path-job:
First collect and build all needed glyphs.
And then copy the glyphs to your BGRAbitmap. 

This seems to be thread save from my experience.

Winni

 

TinyPortal © 2005-2018