Fixed issues with ShaderEffectSource and threaded rendering.

This commit is contained in:
Kim Motoyoshi Kalland 2011-05-09 12:58:40 +02:00
parent 02582f6c80
commit c962253085
7 changed files with 47 additions and 18 deletions

View File

@ -54,6 +54,17 @@ QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(qmlFboOverlay, QML_FBO_OVERLAY)
QSGShaderEffectSourceNode::QSGShaderEffectSourceNode()
{
setFlag(UsePreprocess, true);
}
void QSGShaderEffectSourceNode::markDirtyTexture()
{
markDirty(DirtyMaterial);
}
QSGShaderEffectTexture::QSGShaderEffectTexture(QSGItem *shaderSource)
: QSGDynamicTexture()
, m_item(0)
@ -260,9 +271,8 @@ void QSGShaderEffectTexture::grab()
}
// Render texture.
QSGNode::DirtyFlags dirty = root->dirtyFlags();
root->markDirty(QSGNode::DirtyNodeAdded); // Force matrix and clip update.
m_renderer->nodeChanged(root, QSGNode::DirtyNodeAdded); // Force render list update.
root->markDirty(QSGNode::DirtyForceUpdate); // Force matrix, clip and opacity update.
m_renderer->nodeChanged(root, QSGNode::DirtyForceUpdate); // Force render list update.
#ifdef QSG_DEBUG_FBO_OVERLAY
if (qmlFboOverlay()) {
@ -329,7 +339,7 @@ void QSGShaderEffectTexture::grab()
ctx->functions()->glGenerateMipmap(GL_TEXTURE_2D);
}
root->markDirty(dirty | QSGNode::DirtyNodeAdded); // Force matrix, clip and render list update.
root->markDirty(QSGNode::DirtyForceUpdate); // Force matrix, clip, opacity and render list update.
#ifdef QSG_DEBUG_FBO_OVERLAY
if (qmlFboOverlay())
@ -488,7 +498,6 @@ void QSGShaderEffectSource::setMipmap(bool enabled)
{
if (enabled == m_mipmap)
return;
printf("setting mipmap to: %d\n", enabled);
m_mipmap = enabled;
update();
emit mipmapChanged();
@ -560,13 +569,17 @@ QSGNode *QSGShaderEffectSource::updatePaintNode(QSGNode *oldNode, UpdatePaintNod
return 0;
}
QSGImageNode *node = static_cast<QSGImageNode *>(oldNode);
QSGShaderEffectSourceNode *node = static_cast<QSGShaderEffectSourceNode *>(oldNode);
if (!node) {
node = QSGItemPrivate::get(this)->sceneGraphContext()->createImageNode();
node->setFlag(QSGNode::UsePreprocess, true);
node = new QSGShaderEffectSourceNode;
node->setTexture(m_texture);
connect(m_texture, SIGNAL(textureChanged()), node, SLOT(markDirtyTexture()), Qt::DirectConnection);
}
// If live and recursive, update continuously.
if (m_live && m_recursive)
node->markDirty(QSGNode::DirtyMaterial);
QSGShaderEffectTexture *tex = qobject_cast<QSGShaderEffectTexture *>(m_texture);
tex->setItem(QSGItemPrivate::get(m_sourceItem)->itemNode());

View File

@ -46,6 +46,7 @@
#include <private/qsgtextureprovider_p.h>
#include <private/qsgadaptationlayer_p.h>
#include <private/qsgcontext_p.h>
#include <private/qsgdefaultimagenode_p.h>
#include "qpointer.h"
#include "qsize.h"
@ -63,6 +64,17 @@ class QSGNode;
class UpdatePaintNodeData;
class QGLFramebufferObject;
class QSGShaderEffectSourceNode : public QObject, public QSGDefaultImageNode
{
Q_OBJECT
public:
QSGShaderEffectSourceNode();
private Q_SLOTS:
void markDirtyTexture();
};
class QSGShaderEffectTexture : public QSGDynamicTexture
{
Q_OBJECT

View File

@ -177,7 +177,9 @@ void QMLRenderer::nodeChanged(QSGNode *node, QSGNode::DirtyFlags flags)
{
QSGRenderer::nodeChanged(node, flags);
quint32 rebuildFlags = QSGNode::DirtyNodeAdded | QSGNode::DirtyNodeRemoved | QSGNode::DirtyMaterial | QSGNode::DirtyOpacity;
quint32 rebuildFlags = QSGNode::DirtyNodeAdded | QSGNode::DirtyNodeRemoved
| QSGNode::DirtyMaterial | QSGNode::DirtyOpacity
| QSGNode::DirtyForceUpdate;
if (flags & rebuildFlags)
m_rebuild_lists = true;

View File

@ -83,14 +83,16 @@ public:
DirtyNodeRemoved = 0x0008,
DirtyGeometry = 0x0010,
DirtyRenderOrder = 0x0020,
DirtyMaterial = 0x0100,
DirtyOpacity = 0x0200,
DirtyMaterial = 0x0040,
DirtyOpacity = 0x0080,
DirtyForceUpdate = 0x0100,
DirtyAll = 0xffff,
DirtyPropagationMask = DirtyMatrix
| DirtyClipList
| DirtyNodeAdded
| DirtyOpacity,
| DirtyOpacity
| DirtyForceUpdate,
};
Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)

View File

@ -227,7 +227,7 @@ void QSGNodeUpdater::visitNode(QSGNode *n)
#endif
if (n->dirtyFlags() || m_force_update) {
bool forceUpdate = n->dirtyFlags() & (QSGNode::DirtyNodeAdded);
bool forceUpdate = n->dirtyFlags() & (QSGNode::DirtyNodeAdded | QSGNode::DirtyForceUpdate);
if (forceUpdate)
++m_force_update;

View File

@ -126,10 +126,10 @@ QSGRenderer::QSGRenderer(QSGContext *context)
, m_context(context)
, m_root_node(0)
, m_node_updater(0)
, m_bindable(0)
, m_changed_emitted(false)
, m_mirrored(false)
, m_is_rendering(false)
, m_bindable(0)
{
initializeGLFunctions();
}

View File

@ -174,11 +174,11 @@ private:
QGLShaderProgram m_clip_program;
int m_clip_matrix_id;
bool m_changed_emitted;
bool m_mirrored;
bool m_is_rendering;
const Bindable *m_bindable;
bool m_changed_emitted : 1;
bool m_mirrored : 1;
bool m_is_rendering : 1;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QSGRenderer::ClearMode)