aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-02-18 09:58:57 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2014-02-18 09:58:57 +0100
commitba9ca0e3d64c46fc63cdbc62f3e4a96e36a842f8 (patch)
treef9631624c841281302a2a546fbcc06a2375f410e /src/quick
parenta65b8785621ebf58f34eb0c1759376fc0a1117c7 (diff)
parent464bd2bf975797241213191a374e70431c5c3763 (diff)
Merge remote-tracking branch 'origin/stable' into dev
Conflicts: src/qml/jsruntime/qv4functionobject.cpp src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h Change-Id: Id164f6c3b45501aa466908659ec4e3b957323753
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/items/qquickitemview.cpp2
-rw-r--r--src/quick/items/qquickrectangle.cpp20
-rw-r--r--src/quick/items/qquickrectangle_p.h6
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp22
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h3
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterial.cpp6
-rw-r--r--src/quick/scenegraph/coreapi/qsgnode.cpp5
-rw-r--r--src/quick/scenegraph/coreapi/qsgnode.h1
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer_p.h1
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp34
-rw-r--r--src/quick/scenegraph/qsgcontext_p.h3
11 files changed, 67 insertions, 36 deletions
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index 10f134f7ae..30d0619f7a 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -1872,7 +1872,7 @@ void QQuickItemViewPrivate::layout()
prepareVisibleItemTransitions();
- QRectF viewBounds(0, position(), q->width(), q->height());
+ QRectF viewBounds(q->contentX(), q->contentY(), q->width(), q->height());
for (QList<FxViewItem*>::Iterator it = releasePendingTransition.begin();
it != releasePendingTransition.end(); ) {
FxViewItem *item = *it;
diff --git a/src/quick/items/qquickrectangle.cpp b/src/quick/items/qquickrectangle.cpp
index ee1b66f2b5..8d9f6b9d4a 100644
--- a/src/quick/items/qquickrectangle.cpp
+++ b/src/quick/items/qquickrectangle.cpp
@@ -255,6 +255,18 @@ QQmlListProperty<QQuickGradientStop> QQuickGradient::stops()
return QQmlListProperty<QQuickGradientStop>(this, m_stops);
}
+QGradientStops QQuickGradient::gradientStops() const
+{
+ QGradientStops stops;
+ for (int i = 0; i < m_stops.size(); ++i){
+ int j = 0;
+ while (j < stops.size() && stops.at(j).first < m_stops[i]->position())
+ j++;
+ stops.insert(j, QGradientStop(m_stops.at(i)->position(), m_stops.at(i)->color()));
+ }
+ return stops;
+}
+
void QQuickGradient::doUpdate()
{
emit updated();
@@ -492,13 +504,7 @@ QSGNode *QQuickRectangle::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
QGradientStops stops;
if (d->gradient) {
- QList<QQuickGradientStop *> qxstops = d->gradient->m_stops;
- for (int i = 0; i < qxstops.size(); ++i){
- int j = 0;
- while (j < stops.size() && stops.at(j).first < qxstops[i]->position())
- j++;
- stops.insert(j, QGradientStop(qxstops.at(i)->position(), qxstops.at(i)->color()));
- }
+ stops = d->gradient->gradientStops();
}
rectangle->setGradientStops(stops);
diff --git a/src/quick/items/qquickrectangle_p.h b/src/quick/items/qquickrectangle_p.h
index 009512afd4..09b530c191 100644
--- a/src/quick/items/qquickrectangle_p.h
+++ b/src/quick/items/qquickrectangle_p.h
@@ -81,7 +81,7 @@ private:
bool m_valid : 1;
};
-class Q_AUTOTEST_EXPORT QQuickGradientStop : public QObject
+class Q_QUICK_PRIVATE_EXPORT QQuickGradientStop : public QObject
{
Q_OBJECT
@@ -105,7 +105,7 @@ private:
QColor m_color;
};
-class Q_AUTOTEST_EXPORT QQuickGradient : public QObject
+class Q_QUICK_PRIVATE_EXPORT QQuickGradient : public QObject
{
Q_OBJECT
@@ -118,6 +118,8 @@ public:
QQmlListProperty<QQuickGradientStop> stops();
+ QGradientStops gradientStops() const;
+
Q_SIGNALS:
void updated();
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index f121e16523..30081093f2 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -143,11 +143,6 @@ ShaderManager::Shader *ShaderManager::prepareMaterial(QSGMaterial *material)
QSurfaceFormat::OpenGLContextProfile profile = ctx->format().profile();
QOpenGLShaderProgram *p = s->program();
- p->addShaderFromSourceCode(QOpenGLShader::Vertex,
- qsgShaderRewriter_insertZAttributes(s->vertexShader(), profile));
- p->addShaderFromSourceCode(QOpenGLShader::Fragment,
- s->fragmentShader());
-
char const *const *attr = s->attributeNames();
int i;
for (i = 0; attr[i]; ++i) {
@@ -155,14 +150,10 @@ ShaderManager::Shader *ShaderManager::prepareMaterial(QSGMaterial *material)
p->bindAttributeLocation(attr[i], i);
}
p->bindAttributeLocation("_qt_order", i);
-
- p->link();
- if (!p->isLinked()) {
- qDebug() << "Renderer failed shader compilation:" << endl << p->log();
+ context->compile(s, material, qsgShaderRewriter_insertZAttributes(s->vertexShader(), profile), 0);
+ context->initialize(s);
+ if (!p->isLinked())
return 0;
- }
-
- s->initialize();
shader = new Shader;
shader->program = s;
@@ -198,8 +189,8 @@ ShaderManager::Shader *ShaderManager::prepareMaterialNoRewrite(QSGMaterial *mate
#endif
QSGMaterialShader *s = static_cast<QSGMaterialShader *>(material->createShader());
- s->compile();
- s->initialize();
+ context->compile(s, material);
+ context->initialize(s);
shader = new Shader();
shader->program = s;
@@ -292,6 +283,7 @@ void Updater::updateStates(QSGNode *n)
m_added = 0;
m_transformChange = 0;
+ m_opacityChange = 0;
Node *sn = renderer->m_nodes.value(n, 0);
Q_ASSERT(sn);
@@ -779,7 +771,7 @@ Renderer::Renderer(QSGRenderContext *ctx)
m_shaderManager = ctx->findChild<ShaderManager *>(QStringLiteral("__qt_ShaderManager"), Qt::FindDirectChildrenOnly);
if (!m_shaderManager) {
- m_shaderManager = new ShaderManager();
+ m_shaderManager = new ShaderManager(ctx);
m_shaderManager->setObjectName(QStringLiteral("__qt_ShaderManager"));
m_shaderManager->setParent(ctx);
QObject::connect(ctx, SIGNAL(invalidated()), m_shaderManager, SLOT(invalidated()), Qt::DirectConnection);
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
index c38c483df4..7c06de774a 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
@@ -371,7 +371,7 @@ public:
float lastOpacity;
};
- ShaderManager() : blitProgram(0), visualizeProgram(0) { }
+ ShaderManager(QSGRenderContext *ctx) : blitProgram(0), visualizeProgram(0), context(ctx) { }
~ShaderManager() {
qDeleteAll(rewrittenShaders.values());
qDeleteAll(stockShaders.values());
@@ -389,6 +389,7 @@ public:
QOpenGLShaderProgram *blitProgram;
QOpenGLShaderProgram *visualizeProgram;
+ QSGRenderContext *context;
};
class Q_QUICK_PRIVATE_EXPORT Renderer : public QSGRenderer
diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.cpp b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
index 686d1438b4..4954fe20bb 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.cpp
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
@@ -257,9 +257,6 @@ const char *QSGMaterialShader::fragmentShader() const
State that is global for all uses of the shader, independent of the geometry
that is being drawn, can be setup in this function.
-
- If reimplemented, make sure to either call the base class implementation to
- enable the vertex attribute registers.
*/
void QSGMaterialShader::activate()
@@ -271,9 +268,6 @@ void QSGMaterialShader::activate()
/*!
This function is called by the scene graph to indicate that geometry will
no longer to be rendered using this shader.
-
- If reimplemented, make sure to either call the base class implementation to
- disable the vertex attribute registers.
*/
void QSGMaterialShader::deactivate()
diff --git a/src/quick/scenegraph/coreapi/qsgnode.cpp b/src/quick/scenegraph/coreapi/qsgnode.cpp
index b0c869c096..5c196b252c 100644
--- a/src/quick/scenegraph/coreapi/qsgnode.cpp
+++ b/src/quick/scenegraph/coreapi/qsgnode.cpp
@@ -648,10 +648,7 @@ void QSGNode::setFlags(Flags f, bool enabled)
/*!
- Marks this node with the states in \a bits as dirty.
-
- When a node is marked dirty, it recursively marks the parent chain
- as dirty and notify all connected renderers that the has dirty states.
+ Notifies all connected renderers that the node has dirty \a bits.
*/
void QSGNode::markDirty(DirtyState bits)
diff --git a/src/quick/scenegraph/coreapi/qsgnode.h b/src/quick/scenegraph/coreapi/qsgnode.h
index 60e7652e7a..f85184db90 100644
--- a/src/quick/scenegraph/coreapi/qsgnode.h
+++ b/src/quick/scenegraph/coreapi/qsgnode.h
@@ -161,6 +161,7 @@ protected:
private:
friend class QSGRootNode;
friend class QSGBatchRenderer::Renderer;
+ friend class QSGRenderer;
void init();
void destroy();
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer_p.h b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
index 296d6e2cfd..55c9444365 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
@@ -150,6 +150,7 @@ protected:
void addNodesToPreprocess(QSGNode *node);
void removeNodesToPreprocess(QSGNode *node);
+ void markNodeDirtyState(QSGNode *node, QSGNode::DirtyState state) { node->m_dirtyState |= state; }
QColor m_clear_color;
ClearMode m_clear_mode;
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index dd00f75fae..9f58876def 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -631,4 +631,38 @@ void QSGRenderContext::textureFactoryDestroyed(QObject *o)
m_mutex.unlock();
}
+/*!
+ Compile \a shader, optionally using \a vertexCode and \a fragmentCode as
+ replacement for the source code supplied by \a shader.
+
+ If \a vertexCode or \a fragmentCode is supplied, the caller is responsible
+ for setting up attribute bindings.
+
+ \a material is supplied in case the implementation needs to take the
+ material flags into account.
+ */
+
+void QSGRenderContext::compile(QSGMaterialShader *shader, QSGMaterial *material, const char *vertexCode, const char *fragmentCode)
+{
+ Q_UNUSED(material);
+ if (vertexCode || fragmentCode) {
+ Q_ASSERT_X((material->flags() & QSGMaterial::CustomCompileStep) == 0,
+ "QSGRenderContext::compile()",
+ "materials with custom compile step cannot have custom vertex/fragment code");
+ QOpenGLShaderProgram *p = shader->program();
+ p->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexCode ? vertexCode : shader->vertexShader());
+ p->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentCode ? fragmentCode : shader->fragmentShader());
+ p->link();
+ if (!p->isLinked())
+ qWarning() << "shader compilation failed:" << endl << p->log();
+ } else {
+ shader->compile();
+ }
+}
+
+void QSGRenderContext::initialize(QSGMaterialShader *shader)
+{
+ shader->initialize();
+}
+
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h
index 3b58cecd6a..f8d5588649 100644
--- a/src/quick/scenegraph/qsgcontext_p.h
+++ b/src/quick/scenegraph/qsgcontext_p.h
@@ -106,6 +106,9 @@ public:
virtual QSGTexture *createTextureNoAtlas(const QImage &image) const;
virtual QSGRenderer *createRenderer();
+ virtual void compile(QSGMaterialShader *shader, QSGMaterial *material, const char *vertexCode = 0, const char *fragmentCode = 0);
+ virtual void initialize(QSGMaterialShader *shader);
+
void registerFontengineForCleanup(QFontEngine *engine);
static QSGRenderContext *from(QOpenGLContext *context);