Improve the Canvas threading model
authorGunnar Sletta <gunnar.sletta@digia.com>
Wed, 27 Nov 2013 16:04:06 +0000 (17:04 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 3 Dec 2013 17:06:36 +0000 (18:06 +0100)
commit9ad9615d0003c9fb84255152f0cbb473ee2a7a70
treec4aba681ddacd7eadb4defe7312e9020b43407c2
parent9e77d6c31b406e5941a2d287f3c8842954815db4
Improve the Canvas threading model

The canvas classes were mixing scene graph resources and GL
content across threads. This led to a number of potential crashes
in addition to that the FBO based rendering had significant
potential for stalling.

QQuickContext2DTexture is no longer a QSGTexture with ambiguous
ownership. Instead we use textureForNextFrame which is called
on the render thread while the GUI is locked to synchronize
state from the Context2D's "texture" into the actual QSGTexture.
This means that cleanup of the QQuickContext2DTexture and
the QSGTexture used for display is no longer in conflict.

QQuickPixmap no longer contains a QSGTexture either as these
are strictly for use on the scene graph thread. The Images are
anyway loaded explicitly as QImage files in QQuickContext2DContext
and uploaded again for every Canvas, so relying on the GL paint
engine to do the caching will give us the same with less code.

I also changed the default strategy to Immediate as that one
supports the full API (cooperative does not support readback)
and because cooperative is pretty bad for performance since the
rendering happens in the sync() step.

Task-number: QTBUG-34268
Task-number: QTBUG-31052
Task-number: QTBUG-21935
Task-number: QTBUG-30689
Task-number: QTBUG-29007

Change-Id: Ic540b22d5faa1188e21e56a3beee24191d13f423
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
src/quick/items/context2d/qquickcanvascontext_p.h
src/quick/items/context2d/qquickcanvasitem.cpp
src/quick/items/context2d/qquickcanvasitem_p.h
src/quick/items/context2d/qquickcontext2d.cpp
src/quick/items/context2d/qquickcontext2d_p.h
src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp
src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h
src/quick/items/context2d/qquickcontext2dtexture.cpp
src/quick/items/context2d/qquickcontext2dtexture_p.h