[Development] QML Canvas Poor Performance

Matías Néstor Ares matnares at gmail.com
Mon Jul 13 04:33:25 CEST 2015


Hi Everybody!

I'm developing a very simple drawing tool for an application:
My target platform is android
The tool is quite simple
A MouseArea over a Canvas.
Every positionChange event on the MouseArea I add the new XY pair to an
array.
In a *workerScript* I make a subdivision of the trajectory to make the line
smother.
After that, in the onPaint of the canvas, I draw the latest additions to
the trajectory.(Not The entire line, just last segment)
The canvas "*renderStrategy*" is set to "Canvas.*Threaded*"

So, I expected, the main UI thread to be free of the line smoother
algorithm "expensive" calculations and the canvas drawing operations. BUT
the MouseArea onPositionChanged is triggered much less often when the
canvas is refresh.

I make 2 tests. Shown in this image:

http://s22.postimg.org/557dxj1kh/canvas_Mouse_Area_Performance.jpg

In both Figures:

-The blue thin line with red dots is the debug input of the android device.
(The nearest to real pen trajectory)
-The black circles is where MouseArea onPositionChanged Triggered
-The Green line is the smooth line result.

In *figure 1*: The program is operating normally, drawing just the new
segment as a new coordinate is input.

In *figure 2*: The canvas is not updated until the entire line is complete.
(Is not ultra perfect but acceptable the green line is under the thin Blue
one near all time)

So, I guess the MouseArea is refreshing less often because the CPU is
busier, But moving the smooth algorithm to a workerScript and set the
Canvas Render Strategy to Threaded didn't make any noticeable difference.

Is necessary to setup something else to make it work? like including
concurrence in the main cpp or in the pro file?
As far as I can tell, real multi-thread performance is not noticeable
following just the QML documentation.

Am I doing something wrong? Is this a bug? Can it be done in other way?

Thanks in advance!

Matias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20150712/1d62923a/attachment.html>


More information about the Development mailing list