Call QSGPaintedItem::paint() when the scene graph is synced.

At that moment the GUI thread is blocked and it is therefore safe to
call paint() from the scenegraph thread.
This commit is contained in:
Yoann Lopes 2011-05-13 15:57:51 +02:00
parent 3032765079
commit 367a4fb872
3 changed files with 8 additions and 8 deletions

View File

@ -419,7 +419,8 @@ void QSGPaintedItem::setRenderTarget(RenderTarget target)
\note The QML Scene Graph uses two separate threads, the main thread does things such as
processing events or updating animations while a second thread does the actual OpenGL rendering.
As a consequence, paint() is not called from the main GUI thread but from the GL enabled
renderer thread.
renderer thread. At the moment paint() is called, the GUI thread is blocked and this is
therefore thread-safe.
*/
/*!

View File

@ -127,7 +127,6 @@ QSGPainterNode::QSGPainterNode(QSGPaintedItem *item)
setMaterial(&m_materialO);
setOpaqueMaterial(&m_material);
setGeometry(&m_geometry);
setFlag(UsePreprocess);
}
QSGPainterNode::~QSGPainterNode()
@ -137,11 +136,8 @@ QSGPainterNode::~QSGPainterNode()
delete m_multisampledFbo;
}
void QSGPainterNode::preprocess()
void QSGPainterNode::paint()
{
if (!m_dirtyContents)
return;
QRect dirtyRect = m_dirtyRect.isNull() ? QRect(0, 0, m_size.width(), m_size.height()) : m_dirtyRect;
QPainter painter;
@ -181,7 +177,6 @@ void QSGPainterNode::preprocess()
QGLFramebufferObject::blitFramebuffer(m_fbo, dirtyRect, m_multisampledFbo, dirtyRect);
}
m_dirtyContents = false;
m_dirtyRect = QRect();
}
@ -194,9 +189,13 @@ void QSGPainterNode::update()
if (m_dirtyTexture)
updateTexture();
if (m_dirtyContents)
paint();
m_dirtyGeometry = false;
m_dirtyRenderTarget = false;
m_dirtyTexture = false;
m_dirtyContents = false;
}
void QSGPainterNode::updateTexture()

View File

@ -101,7 +101,7 @@ public:
void update();
void preprocess();
void paint();
private:
void updateTexture();