|
|
Home » Community » U++ community news and announcements » BufferPainter now MT optimized
|
Re: BufferPainter now MT optimized [message #49161 is a reply to message #49144] |
Fri, 29 December 2017 13:07   |
Tom1
Messages: 1301 Registered: March 2007
|
Ultimate Contributor |
|
|
Hi Mirek,
Sorry to inform you, but there is something wrong with ::Co when drawing solid strokes of longer polylines. They come out as narrow center line and then some filled polygon in some part of the edge line.
I'm really busy at the moment, but I'll try to get some pictures of the phenomenon in the coming days, next week likely.
Best regards,
Tom
|
|
|
|
Re: BufferPainter now MT optimized [message #49163 is a reply to message #49162] |
Fri, 29 December 2017 17:39   |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
Any chance for extracting a testcase for this?
Or maybe just a hint how the painting code looks like... Painter Co works by storing multiple paths into buffer, if they are solid color only, then rasterizing these multiple paths in parallel, then rendering resulting lines of resulting raster in parallel. If it is nor a solid color polygon/stroke, it is rasterized ST, then lines rendered in parallel.
What could got wrong is that perhaps the storing multiple paths has some problems. That would be probably caused by some combination of Fill / Stroke that I do not account for correctly...
Mirek
[Updated on: Fri, 29 December 2017 17:59] Report message to a moderator
|
|
|
Re: BufferPainter now MT optimized [message #49180 is a reply to message #49163] |
Tue, 02 January 2018 15:34   |
Tom1
Messages: 1301 Registered: March 2007
|
Ultimate Contributor |
|
|
Hi Mirek,
Sorry for the alarm. This is likely my own fault in one way or another:
While attempting to create a testcase, I discovered that my complex polyline optimization routines might end up skipping the stroking of polylines, e.g. if the lines are too narrow to display at specific zoom levels. This in turn leaves the entered vertices (Move()/Line()) in the Painter unused and probably cause trouble afterwards in the MT optimized code while it is fine with ST code. I was able to fix the MT rendering symptoms by simply enclosing the my polyline code within a Begin()/End() pair in the BufferPainter.
Thanks and have a nice 2018!
Best regards,
Tom
|
|
|
|
Re: BufferPainter now MT optimized [message #49183 is a reply to message #49181] |
Wed, 03 January 2018 09:04   |
Tom1
Messages: 1301 Registered: March 2007
|
Ultimate Contributor |
|
|
Hi Mirek,
I found out that PreClip(true/false); is involved here. (To optimize rendering performance in my code, I enable PreClip only for rendering dashed strokes.)
Please find attached the MTPainterIssue testcase package. It is supposed to draw four sine waves, half of which are solid and the other half dashed. As it turns out, with BufferPainter::Co the solid strokes become fills instead of lines. The package is delivered here in its faulty state with painter.Co(true); please set to false to see the correct rendering.
The way to fix this problem in the MTPainterIssue testcase package is to switch the ordering of PreClip(true)/Begin() and End()/PreClip(false) pairs for dashed lines. This is also the appropriate fix for my actual code.
Best regards,
Tom
Update: Added the missing attachment...
[Updated on: Wed, 03 January 2018 09:29] Report message to a moderator
|
|
|
Re: BufferPainter now MT optimized [message #49195 is a reply to message #49183] |
Sat, 06 January 2018 11:33   |
Tom1
Messages: 1301 Registered: March 2007
|
Ultimate Contributor |
|
|
Hi Mirek,
I have started to think if swithing PreClip() on-the-fly is Co() compatible at all. In some rare occasions it seems to cause the issue even when properly bounded between a Begin/End pair.
I think there might be too little parallelism (content) in my testcase to ever face this issue after reordering the PreClip and Begin/End calls.
Best regards,
Tom
|
|
|
|
|
|
|
Re: BufferPainter now MT optimized [message #49202 is a reply to message #49201] |
Sun, 07 January 2018 00:06   |
Tom1
Messages: 1301 Registered: March 2007
|
Ultimate Contributor |
|
|
Hi,
Thanks Mirek! This sounds excellent. I will try this out as soon as I can, on Monday I hope.
I'm not sure I fully understand the current logic for using Begin/End. I have previously used it like PUSH/POP for the context of rotations or transformations in general. Additionally, I have similarly enveloped the polylines which had dashing enabled. If I get it right, I do not need to use it for polylines, polygons or dashing anymore. Right? (All my vector objects are solid single color, no gradient or image fills there.)
What exactly are you referring to by the possibility to try to remove End boundary? Does it mean you could possibly make it even more parallel than described in your message?
Anyway, I will test this and see how well it works and how much faster it is. I will also try if I can do the dashed polylines/polygons without Begin/End pairs.
Thanks and best regards,
Tom
|
|
|
|
Re: BufferPainter now MT optimized [message #49213 is a reply to message #49203] |
Mon, 08 January 2018 10:37  |
Tom1
Messages: 1301 Registered: March 2007
|
Ultimate Contributor |
|
|
Hi Mirek,
OK, now I've tested with a very long dashed line only partially visible in the view. The performance improvement with PreClip() and PreClipDashed() is (obviously) similar: 2.5x speed compared to running without any PreClip. Using PreClipDashed(), instead of on-the-fly switching of PreClip(), removes any rendering issues thereof. So, I suggest obsoleting the old PreClip() altogether. PreClipDashed() does it all.
Does this even need to be selectable anymore? There does not seem to be any performance penalty for ordinary (solid) strokes.
I still had to use Begin()/End() to enclose dashed strokes. Otherwise, some solid strokes came out as dashed. Then I noticed that the Begin()/End() pair was (an expensive) way to put the stroking back to solid mode after drawing dashed strokes. Calling Dash(""); before every solid stroke removed the need for such usage of Begin()/End(). Is Dash(""); the cheapest way to return to solid stroking?
Please note: Getting rid of extra Begin()/End() pairs nicely improved overall rendering performance by some 5-10 %. 
Thanks and best regards,
Tom
Update: After further consideration, I decided to do all dashed strokes by the sequence of "painter.Dash(x); painter.Stroke(); painter.Dash("");". This keeps the default line style solid. It also lowers the number of calls to Dash(); because most of the strokes are solid anyway.
[Updated on: Mon, 08 January 2018 11:32] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Tue Apr 29 00:28:28 CEST 2025
Total time taken to generate the page: 0.01455 seconds
|
|
|