B4J Question .drawpath auto invalidates?

sorex

Expert
Licensed User
Longtime User
Regarding the posted slowdown...

This was extremely slow

The culprit seems to be drawpath that updates the canvas/image at every usage.

@Erel, can you confirm (by looking at your sources) that drawpath auto invalidates?

is this a feature or a bug? :)
 
Regarding the posted slowdown...



The culprit seems to be drawpath that updates the canvas/image at every usage.

@Erel, can you confirm (by looking at your sources) that drawpath auto invalidates?

is this a feature or a bug? :)
Anyway BitmapCreator on B4J is much faster then Canvas, the procedures of DrawPath that I put in code snippet (here) ere very fast. I'll probably make a version of my B4J library that only uses BitmapCreator, if I have time
 
Upvote 0
I used your snippet for testing and it was dreadfull slow due to the invalidate.

you don't notice it on your rubiks cube but you will when drawing a few hundreds of polygons.

I don't think there's a real bitmapcreator fillpath or I looked over it.
 
Upvote 0
Invalidate needed only in b4jh, while release It is only necessary in b4i.
It is explained in the documentation of the Xui library
 
Upvote 0
well, that's the point of the problem. it's invalidating on each drawpath that's what causing the slow down.

it should be done once and 'manually' after all polys have been drawn.
 
Upvote 0
I did it at the end of rendering after drawing all the polygons
 
Upvote 0
I wrote a few times already that it is done automatically when using drawpath so you just did an extra invalidate.

here's an example that it does update the red line without the invalidate

Code: Copy
    Dim p As Pane
    p.Initialize("")
    MainForm.RootPane.AddNode(p,0,0,640,400)

    Dim can As B4XCanvas
    can.Initialize(p)

    Dim pp As B4XPath
    pp.Initialize(0,0)
    pp.LineTo(100,100)
    pp.LineTo(0,100)
    can.DrawPath(pp,0xffff0000,False,1)
    
'    can.Invalidate
 
Upvote 0
ok, that's a shame then.

my initial 3D model drawing example used the extended canvas lib (from Klaus?) .drawPolygon and it's way faster and there's no need to invalidate either.

I think it's 60fps vs 0.5fps so the difference is huge.
 
Upvote 0
Klaus uses the native android library, I use XUI.
I'll try a test using the native library
 
Upvote 0
ok, that makes sense.

I did tests before with clipping due to the lack of some function and indeed it's slow as hell.

drawPolygon exists in java fx but it's not exposed in B4J (yet)
 
Upvote 0
Back
Top