aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-05-28 15:24:18 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-05-28 15:35:03 +0200
commitba0899542cf03a685335bf4e02edfb377bade224 (patch)
tree554213486fd3420745da3821c3e4502e4c15830f /src/quick/scenegraph
parent6f411ef9d460d6a4f73a455b6eec9afc2f52d305 (diff)
parent43484528552cb2ba3dc1dabfcce22ed40bf4f8db (diff)
Merge remote-tracking branch 'origin/stable' into dev
Conflicts: src/quick/doc/src/appdevguide/porting.qdoc sync.profile Change-Id: Iec5516c596c3eca60a3e6ceb1d45f2a7a1595c12
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r--src/quick/scenegraph/coreapi/qsggeometry.cpp18
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterial.cpp1
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterial.h1
-rw-r--r--src/quick/scenegraph/coreapi/qsgnode.cpp6
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer.cpp52
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer.cpp21
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp19
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp2
-rw-r--r--src/quick/scenegraph/qsgdefaultimagenode_p.h2
-rw-r--r--src/quick/scenegraph/qsgdefaultrectanglenode_p.h2
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp39
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h12
-rw-r--r--src/quick/scenegraph/qsgrenderloop.cpp36
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp77
-rw-r--r--src/quick/scenegraph/qsgwindowsrenderloop.cpp45
-rw-r--r--src/quick/scenegraph/util/qsgflatcolormaterial.cpp10
-rw-r--r--src/quick/scenegraph/util/qsgtexture.cpp58
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial.cpp6
18 files changed, 264 insertions, 143 deletions
diff --git a/src/quick/scenegraph/coreapi/qsggeometry.cpp b/src/quick/scenegraph/coreapi/qsggeometry.cpp
index 818b9b26aa..7f09af4da3 100644
--- a/src/quick/scenegraph/coreapi/qsggeometry.cpp
+++ b/src/quick/scenegraph/coreapi/qsggeometry.cpp
@@ -332,42 +332,42 @@ const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_ColoredPoint2D()
/*!
\fn const QSGGeometry::ColoredPoint2D *QSGGeometry::vertexDataAsColoredPoint2D() const
- Convenience function to access the vertex data as an immuatble
+ Convenience function to access the vertex data as an immutable
array of QSGGeometry::ColoredPoint2D.
*/
/*!
\fn QSGGeometry::ColoredPoint2D *QSGGeometry::vertexDataAsColoredPoint2D()
- Convenience function to access the vertex data as a muatble
+ Convenience function to access the vertex data as a mutable
array of QSGGeometry::ColoredPoint2D.
*/
/*!
\fn const QSGGeometry::TexturedPoint2D *QSGGeometry::vertexDataAsTexturedPoint2D() const
- Convenience function to access the vertex data as an immuatble
+ Convenience function to access the vertex data as an immutable
array of QSGGeometry::TexturedPoint2D.
*/
/*!
\fn QSGGeometry::TexturedPoint2D *QSGGeometry::vertexDataAsTexturedPoint2D()
- Convenience function to access the vertex data as a muatble
+ Convenience function to access the vertex data as a mutable
array of QSGGeometry::TexturedPoint2D.
*/
/*!
\fn const QSGGeometry::Point2D *QSGGeometry::vertexDataAsPoint2D() const
- Convenience function to access the vertex data as an immuatble
+ Convenience function to access the vertex data as an immutable
array of QSGGeometry::Point2D.
*/
/*!
\fn QSGGeometry::Point2D *QSGGeometry::vertexDataAsPoint2D()
- Convenience function to access the vertex data as a muatble
+ Convenience function to access the vertex data as a mutable
array of QSGGeometry::Point2D.
*/
@@ -705,7 +705,8 @@ void QSGGeometry::updateTexturedRectGeometry(QSGGeometry *g, const QRectF &rect,
The default is AlwaysUploadPattern. When set to anything other than
the default, the user must call markIndexDataDirty() after changing
- the index data.
+ the index data, in addition to calling QSGNode::markDirty() with
+ QSGNode::DirtyGeometry.
*/
void QSGGeometry::setIndexDataPattern(DataPattern p)
@@ -728,7 +729,8 @@ void QSGGeometry::setIndexDataPattern(DataPattern p)
The default is AlwaysUploadPattern. When set to anything other than
the default, the user must call markVertexDataDirty() after changing
- the vertex data.
+ the vertex data, in addition to calling QSGNode::markDirty() with
+ QSGNode::DirtyGeometry.
*/
void QSGGeometry::setVertexDataPattern(DataPattern p)
diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.cpp b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
index c0794d0d69..9346236db9 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.cpp
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
@@ -556,6 +556,7 @@ static void qt_print_material_count()
QSGMaterial::QSGMaterial()
: m_flags(0)
+ , m_reserved(0)
{
#ifndef QT_NO_DEBUG
if (qsg_leak_check) {
diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.h b/src/quick/scenegraph/coreapi/qsgmaterial.h
index ee8889deac..20ab21ad28 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.h
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.h
@@ -133,6 +133,7 @@ public:
void setFlag(Flags flags, bool on = true);
private:
+ friend class QSGContext;
Flags m_flags;
void *m_reserved;
Q_DISABLE_COPY(QSGMaterial)
diff --git a/src/quick/scenegraph/coreapi/qsgnode.cpp b/src/quick/scenegraph/coreapi/qsgnode.cpp
index 8bf9ae8e76..25f8f342c9 100644
--- a/src/quick/scenegraph/coreapi/qsgnode.cpp
+++ b/src/quick/scenegraph/coreapi/qsgnode.cpp
@@ -129,12 +129,12 @@ static void qt_print_node_count()
before rendering starts.
\value OwnsGeometry Only valid for QSGGeometryNode and QSGClipNode.
The node has ownership over the QSGGeometry instance and will
- delete it when the node is destroyed.
+ delete it when the node is destroyed or a geometry is assigned.
\value OwnsMaterial Only valid for QSGGeometryNode. The node has ownership
- over the material and will delete it when the node is destroyed.
+ over the material and will delete it when the node is destroyed or a material is assigned.
\value OwnsOpaqueMaterial Only valid for QSGGeometryNode. The node has
ownership over the opaque material and will delete it when the node is
- destroyed.
+ destroyed or a material is assigned.
*/
/*!
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer.cpp b/src/quick/scenegraph/coreapi/qsgrenderer.cpp
index b46d45be57..805cfaad0d 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrenderer.cpp
@@ -53,6 +53,8 @@
#include <qdatetime.h>
+#include <private/qqmlprofilerservice_p.h>
+
QT_BEGIN_NAMESPACE
//#define RENDERER_DEBUG
@@ -62,9 +64,9 @@ QT_BEGIN_NAMESPACE
#ifndef QSG_NO_RENDER_TIMING
static bool qsg_render_timing = !qgetenv("QSG_RENDER_TIMING").isEmpty();
-static QTime frameTimer;
-static int preprocessTime;
-static int updatePassTime;
+static QElapsedTimer frameTimer;
+static qint64 preprocessTime;
+static qint64 updatePassTime;
#endif
void QSGBindable::clear(QSGRenderer::ClearMode mode) const
@@ -238,10 +240,11 @@ void QSGRenderer::renderScene(const QSGBindable &bindable)
#ifndef QSG_NO_RENDER_TIMING
- if (qsg_render_timing)
+ bool profileFrames = qsg_render_timing || QQmlProfilerService::enabled;
+ if (profileFrames)
frameTimer.start();
- int bindTime = 0;
- int renderTime = 0;
+ qint64 bindTime = 0;
+ qint64 renderTime = 0;
#endif
m_bindable = &bindable;
@@ -249,8 +252,8 @@ void QSGRenderer::renderScene(const QSGBindable &bindable)
bindable.bind();
#ifndef QSG_NO_RENDER_TIMING
- if (qsg_render_timing)
- bindTime = frameTimer.elapsed();
+ if (profileFrames)
+ bindTime = frameTimer.nsecsElapsed();
#endif
#ifndef QT_NO_DEBUG
@@ -270,8 +273,8 @@ void QSGRenderer::renderScene(const QSGBindable &bindable)
render();
#ifndef QSG_NO_RENDER_TIMING
- if (qsg_render_timing)
- renderTime = frameTimer.elapsed();
+ if (profileFrames)
+ renderTime = frameTimer.nsecsElapsed();
#endif
glDisable(GL_SCISSOR_TEST);
@@ -292,12 +295,22 @@ void QSGRenderer::renderScene(const QSGBindable &bindable)
#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing) {
printf(" - Breakdown of render time: preprocess=%d, updates=%d, binding=%d, render=%d, total=%d\n",
- preprocessTime,
- updatePassTime - preprocessTime,
- bindTime - updatePassTime,
- renderTime - bindTime,
- renderTime);
+ int(preprocessTime / 1000000),
+ int((updatePassTime - preprocessTime) / 1000000),
+ int((bindTime - updatePassTime) / 1000000),
+ int((renderTime - bindTime) / 1000000),
+ int(renderTime / 1000000));
+ }
+
+ if (QQmlProfilerService::enabled) {
+ QQmlProfilerService::sceneGraphFrame(
+ QQmlProfilerService::SceneGraphRendererFrame,
+ preprocessTime,
+ updatePassTime - preprocessTime,
+ bindTime - updatePassTime,
+ renderTime - bindTime);
}
+
#endif
}
@@ -380,16 +393,17 @@ void QSGRenderer::preprocess()
}
#ifndef QSG_NO_RENDER_TIMING
- if (qsg_render_timing)
- preprocessTime = frameTimer.elapsed();
+ bool profileFrames = qsg_render_timing || QQmlProfilerService::enabled;
+ if (profileFrames)
+ preprocessTime = frameTimer.nsecsElapsed();
#endif
nodeUpdater()->setToplevelOpacity(context()->renderAlpha());
nodeUpdater()->updateStates(m_root_node);
#ifndef QSG_NO_RENDER_TIMING
- if (qsg_render_timing)
- updatePassTime = frameTimer.elapsed();
+ if (profileFrames)
+ updatePassTime = frameTimer.nsecsElapsed();
#endif
}
diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp
index 1d534e3563..3536975e94 100644
--- a/src/quick/scenegraph/qsgadaptationlayer.cpp
+++ b/src/quick/scenegraph/qsgadaptationlayer.cpp
@@ -48,6 +48,7 @@
#include <QtGui/qguiapplication.h>
#include <qdir.h>
+#include <private/qqmlprofilerservice_p.h>
#include <QElapsedTimer>
QT_BEGIN_NAMESPACE
@@ -162,7 +163,8 @@ void QSGDistanceFieldGlyphCache::update()
return;
#ifndef QSG_NO_RENDER_TIMING
- if (qsg_render_timing)
+ bool profileFrames = qsg_render_timing || QQmlProfilerService::enabled;
+ if (profileFrames)
qsg_render_timer.start();
#endif
@@ -176,10 +178,10 @@ void QSGDistanceFieldGlyphCache::update()
}
#ifndef QSG_NO_RENDER_TIMING
- int renderTime = 0;
+ qint64 renderTime = 0;
int count = m_pendingGlyphs.size();
- if (qsg_render_timing)
- renderTime = qsg_render_timer.elapsed();
+ if (profileFrames)
+ renderTime = qsg_render_timer.nsecsElapsed();
#endif
m_pendingGlyphs.reset();
@@ -190,11 +192,18 @@ void QSGDistanceFieldGlyphCache::update()
if (qsg_render_timing) {
printf(" - glyphs: count=%d, render=%d, store=%d, total=%d\n",
count,
- renderTime,
- (int) qsg_render_timer.elapsed() - renderTime,
+ int(renderTime/1000000),
+ (int) qsg_render_timer.elapsed() - int(renderTime/1000000),
(int) qsg_render_timer.elapsed());
}
+ if (QQmlProfilerService::enabled) {
+ QQmlProfilerService::sceneGraphFrame(
+ QQmlProfilerService::SceneGraphAdaptationLayerFrame,
+ count,
+ renderTime,
+ qsg_render_timer.nsecsElapsed() - renderTime);
+ }
#endif
}
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index 5d894e5236..d3710c7bd5 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -67,6 +67,8 @@
#include <private/qobject_p.h>
#include <qmutex.h>
+#include <private/qqmlprofilerservice_p.h>
+
DEFINE_BOOL_CONFIG_OPTION(qmlFlashMode, QML_FLASH_MODE)
DEFINE_BOOL_CONFIG_OPTION(qmlTranslucentMode, QML_TRANSLUCENT_MODE)
DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
@@ -476,17 +478,24 @@ QSGDepthStencilBufferManager *QSGContext::depthStencilBufferManager()
QSGMaterialShader *QSGContext::prepareMaterial(QSGMaterial *material)
{
Q_D(QSGContext);
+
+ if (material->m_reserved)
+ return reinterpret_cast<QSGMaterialShader *>(material->m_reserved);
+
QSGMaterialType *type = material->type();
QSGMaterialShader *shader = d->materials.value(type);
- if (shader)
+ if (shader) {
+ material->m_reserved = shader;
return shader;
+ }
#ifndef QSG_NO_RENDER_TIMING
- if (qsg_render_timing)
+ if (qsg_render_timing || QQmlProfilerService::enabled)
qsg_renderer_timer.start();
#endif
shader = material->createShader();
+ material->m_reserved = shader;
shader->compile();
shader->initialize();
d->materials[type] = shader;
@@ -494,6 +503,12 @@ QSGMaterialShader *QSGContext::prepareMaterial(QSGMaterial *material)
#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing)
printf(" - compiling material: %dms\n", (int) qsg_renderer_timer.elapsed());
+
+ if (QQmlProfilerService::enabled) {
+ QQmlProfilerService::sceneGraphFrame(
+ QQmlProfilerService::SceneGraphContextFrame,
+ qsg_renderer_timer.nsecsElapsed());
+ }
#endif
return shader;
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index 3df11532e4..f5a461f19e 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -521,7 +521,7 @@ int QSGTextMaskMaterial::compare(const QSGMaterial *o) const
Q_ASSERT(o && type() == o->type());
const QSGTextMaskMaterial *other = static_cast<const QSGTextMaskMaterial *>(o);
if (m_glyphCache != other->m_glyphCache)
- return m_glyphCache - other->m_glyphCache;
+ return m_glyphCache.data() < other->m_glyphCache.data() ? -1 : 1;
QRgb c1 = m_color.rgba();
QRgb c2 = other->m_color.rgba();
return int(c2 < c1) - int(c1 < c2);
diff --git a/src/quick/scenegraph/qsgdefaultimagenode_p.h b/src/quick/scenegraph/qsgdefaultimagenode_p.h
index 7d299faee3..d7be5f7c14 100644
--- a/src/quick/scenegraph/qsgdefaultimagenode_p.h
+++ b/src/quick/scenegraph/qsgdefaultimagenode_p.h
@@ -60,7 +60,7 @@ protected:
virtual QSGMaterialShader *createShader() const;
};
-class QSGDefaultImageNode : public QSGImageNode
+class Q_QUICK_PRIVATE_EXPORT QSGDefaultImageNode : public QSGImageNode
{
public:
QSGDefaultImageNode();
diff --git a/src/quick/scenegraph/qsgdefaultrectanglenode_p.h b/src/quick/scenegraph/qsgdefaultrectanglenode_p.h
index 24bdbb3d34..9ca8a96de5 100644
--- a/src/quick/scenegraph/qsgdefaultrectanglenode_p.h
+++ b/src/quick/scenegraph/qsgdefaultrectanglenode_p.h
@@ -63,7 +63,7 @@ protected:
virtual QSGMaterialShader *createShader() const;
};
-class QSGDefaultRectangleNode : public QSGRectangleNode
+class Q_QUICK_PRIVATE_EXPORT QSGDefaultRectangleNode : public QSGRectangleNode
{
public:
QSGDefaultRectangleNode();
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
index 86c3356d58..bdbce6165b 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
@@ -144,8 +144,7 @@ void QSGDistanceFieldTextMaterialShader::updateState(const RenderState &state, Q
if (oldMaterial == 0
|| material->color() != oldMaterial->color()
|| state.isOpacityDirty()) {
- QColor c = material->color();
- QVector4D color(c.redF(), c.greenF(), c.blueF(), c.alphaF());
+ QVector4D color = material->color();
color *= state.opacity();
program()->setUniformValue(m_color_id, color);
}
@@ -206,10 +205,10 @@ QSGMaterialType *QSGDistanceFieldTextMaterial::type() const
void QSGDistanceFieldTextMaterial::setColor(const QColor &color)
{
- m_color = QColor::fromRgbF(color.redF() * color.alphaF(),
- color.greenF() * color.alphaF(),
- color.blueF() * color.alphaF(),
- color.alphaF());
+ m_color = QVector4D(color.redF() * color.alphaF(),
+ color.greenF() * color.alphaF(),
+ color.blueF() * color.alphaF(),
+ color.alphaF());
}
QSGMaterialShader *QSGDistanceFieldTextMaterial::createShader() const
@@ -239,10 +238,8 @@ int QSGDistanceFieldTextMaterial::compare(const QSGMaterial *o) const
if (m_fontScale != other->m_fontScale) {
return int(other->m_fontScale < m_fontScale) - int(m_fontScale < other->m_fontScale);
}
- QRgb c1 = m_color.rgba();
- QRgb c2 = other->m_color.rgba();
- if (c1 != c2)
- return int(c2 < c1) - int(c1 < c2);
+ if (m_color != other->m_color)
+ return &m_color < &other->m_color ? -1 : 1;
int t0 = m_texture ? m_texture->textureId : -1;
int t1 = other->m_texture ? other->m_texture->textureId : -1;
return t0 - t1;
@@ -284,8 +281,7 @@ void DistanceFieldStyledTextMaterialShader::updateState(const RenderState &state
if (oldMaterial == 0
|| material->styleColor() != oldMaterial->styleColor()
|| (state.isOpacityDirty())) {
- QColor c = material->styleColor();
- QVector4D color(c.redF(), c.greenF(), c.blueF(), c.alphaF());
+ QVector4D color = material->styleColor();
color *= state.opacity();
program()->setUniformValue(m_styleColor_id, color);
}
@@ -302,21 +298,18 @@ QSGDistanceFieldStyledTextMaterial::~QSGDistanceFieldStyledTextMaterial()
void QSGDistanceFieldStyledTextMaterial::setStyleColor(const QColor &color)
{
- m_styleColor = QColor::fromRgbF(color.redF() * color.alphaF(),
- color.greenF() * color.alphaF(),
- color.blueF() * color.alphaF(),
- color.alphaF());
+ m_styleColor = QVector4D(color.redF() * color.alphaF(),
+ color.greenF() * color.alphaF(),
+ color.blueF() * color.alphaF(),
+ color.alphaF());
}
int QSGDistanceFieldStyledTextMaterial::compare(const QSGMaterial *o) const
{
Q_ASSERT(o && type() == o->type());
const QSGDistanceFieldStyledTextMaterial *other = static_cast<const QSGDistanceFieldStyledTextMaterial *>(o);
- if (m_styleColor != other->m_styleColor) {
- QRgb c1 = m_styleColor.rgba();
- QRgb c2 = other->m_styleColor.rgba();
- return int(c2 < c1) - int(c1 < c2);
- }
+ if (m_styleColor != other->m_color)
+ return &m_styleColor < &other->m_styleColor ? -1 : 1;
return QSGDistanceFieldTextMaterial::compare(o);
}
@@ -657,8 +650,8 @@ void QSGHiQSubPixelDistanceFieldTextMaterialShader::updateState(const RenderStat
QSGDistanceFieldTextMaterial *oldMaterial = static_cast<QSGDistanceFieldTextMaterial *>(oldEffect);
if (oldMaterial == 0 || material->color() != oldMaterial->color()) {
- QColor c = material->color();
- state.context()->functions()->glBlendColor(c.redF(), c.greenF(), c.blueF(), 1.0f);
+ QVector4D c = material->color();
+ state.context()->functions()->glBlendColor(c.x(), c.y(), c.z(), 1.0f);
}
if (oldMaterial == 0 || material->fontScale() != oldMaterial->fontScale())
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h b/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
index 7fea8f65dc..54d4146ddb 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
@@ -59,7 +59,7 @@ public:
virtual int compare(const QSGMaterial *other) const;
virtual void setColor(const QColor &color);
- const QColor &color() const { return m_color; }
+ const QVector4D &color() const { return m_color; }
void setGlyphCache(QSGDistanceFieldGlyphCache *a) { m_glyph_cache = a; }
QSGDistanceFieldGlyphCache *glyphCache() const { return m_glyph_cache; }
@@ -76,7 +76,7 @@ public:
protected:
QSize m_size;
- QColor m_color;
+ QVector4D m_color;
QSGDistanceFieldGlyphCache *m_glyph_cache;
const QSGDistanceFieldGlyphCache::Texture *m_texture;
qreal m_fontScale;
@@ -93,10 +93,10 @@ public:
virtual int compare(const QSGMaterial *other) const;
void setStyleColor(const QColor &color);
- const QColor &styleColor() const { return m_styleColor; }
+ const QVector4D &styleColor() const { return m_styleColor; }
protected:
- QColor m_styleColor;
+ QVector4D m_styleColor;
};
class Q_QUICK_PRIVATE_EXPORT QSGDistanceFieldOutlineTextMaterial : public QSGDistanceFieldStyledTextMaterial
@@ -130,7 +130,7 @@ class Q_QUICK_PRIVATE_EXPORT QSGHiQSubPixelDistanceFieldTextMaterial : public QS
public:
virtual QSGMaterialType *type() const;
virtual QSGMaterialShader *createShader() const;
- void setColor(const QColor &color) { m_color = color; }
+ void setColor(const QColor &color) { m_color = QVector4D(color.redF(), color.greenF(), color.blueF(), color.alphaF()); }
};
class Q_QUICK_PRIVATE_EXPORT QSGLoQSubPixelDistanceFieldTextMaterial : public QSGDistanceFieldTextMaterial
@@ -138,7 +138,7 @@ class Q_QUICK_PRIVATE_EXPORT QSGLoQSubPixelDistanceFieldTextMaterial : public QS
public:
virtual QSGMaterialType *type() const;
virtual QSGMaterialShader *createShader() const;
- void setColor(const QColor &color) { m_color = color; }
+ void setColor(const QColor &color) { m_color = QVector4D(color.redF(), color.greenF(), color.blueF(), color.alphaF()); }
};
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp
index f71ccea294..3a608a911d 100644
--- a/src/quick/scenegraph/qsgrenderloop.cpp
+++ b/src/quick/scenegraph/qsgrenderloop.cpp
@@ -56,6 +56,7 @@
#include <QtQuick/QQuickWindow>
#include <QtQuick/private/qquickwindow_p.h>
#include <QtQuick/private/qsgcontext_p.h>
+#include <private/qqmlprofilerservice_p.h>
QT_BEGIN_NAMESPACE
@@ -273,20 +274,21 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window);
cd->polishItems();
- int renderTime = 0, syncTime = 0;
- QTime renderTimer;
- if (qsg_render_timing())
+ qint64 renderTime = 0, syncTime = 0;
+ QElapsedTimer renderTimer;
+ bool profileFrames = qsg_render_timing() || QQmlProfilerService::enabled;
+ if (profileFrames)
renderTimer.start();
cd->syncSceneGraph();
- if (qsg_render_timing())
- syncTime = renderTimer.elapsed();
+ if (profileFrames)
+ syncTime = renderTimer.nsecsElapsed();
cd->renderSceneGraph(window->size());
- if (qsg_render_timing())
- renderTime = renderTimer.elapsed() - syncTime;
+ if (profileFrames)
+ renderTime = renderTimer.nsecsElapsed() - syncTime;
if (data.grabOnly) {
grabContent = qt_gl_read_framebuffer(window->size(), false, false);
@@ -298,17 +300,29 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
cd->fireFrameSwapped();
}
+ qint64 swapTime = 0;
+ if (profileFrames) {
+ swapTime = renderTimer.nsecsElapsed() - renderTime - syncTime;
+ }
+
if (qsg_render_timing()) {
static QTime lastFrameTime = QTime::currentTime();
- const int swapTime = renderTimer.elapsed() - renderTime - syncTime;
- qDebug() << "- Breakdown of frame time; sync:" << syncTime
- << "ms render:" << renderTime << "ms swap:" << swapTime
- << "ms total:" << swapTime + renderTime + syncTime
+ qDebug() << "- Breakdown of frame time; sync:" << syncTime/1000000
+ << "ms render:" << renderTime/1000000 << "ms swap:" << swapTime/1000000
+ << "ms total:" << (swapTime + renderTime + syncTime)/1000000
<< "ms time since last frame:" << (lastFrameTime.msecsTo(QTime::currentTime()))
<< "ms";
lastFrameTime = QTime::currentTime();
}
+ if (QQmlProfilerService::enabled) {
+ QQmlProfilerService::sceneGraphFrame(
+ QQmlProfilerService::SceneGraphRenderLoopFrame,
+ syncTime,
+ renderTime,
+ swapTime);
+ }
+
// Might have been set during syncSceneGraph()
if (data.updatePending)
maybeUpdate(window);
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index de1e2517db..bd69fd5464 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -55,6 +55,8 @@
#include "qsgthreadedrenderloop_p.h"
+#include <private/qqmlprofilerservice_p.h>
+
/*
Overall design:
@@ -138,10 +140,10 @@ static inline int qsgrl_animation_interval() {
#ifndef QSG_NO_RENDER_TIMING
static bool qsg_render_timing = !qgetenv("QSG_RENDER_TIMING").isEmpty();
-static QTime threadTimer;
-static int syncTime;
-static int renderTime;
-static int sinceLastTime;
+static QElapsedTimer threadTimer;
+static qint64 syncTime;
+static qint64 renderTime;
+static qint64 sinceLastTime;
#endif
extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
@@ -545,8 +547,11 @@ void QSGRenderThread::sync()
void QSGRenderThread::syncAndRender()
{
#ifndef QSG_NO_RENDER_TIMING
- if (qsg_render_timing)
- sinceLastTime = threadTimer.restart();
+ bool profileFrames = qsg_render_timing || QQmlProfilerService::enabled;
+ if (profileFrames) {
+ sinceLastTime = threadTimer.nsecsElapsed();
+ threadTimer.start();
+ }
#endif
QElapsedTimer waitTimer;
waitTimer.start();
@@ -573,8 +578,8 @@ void QSGRenderThread::syncAndRender()
}
#ifndef QSG_NO_RENDER_TIMING
- if (qsg_render_timing)
- syncTime = threadTimer.elapsed();
+ if (profileFrames)
+ syncTime = threadTimer.nsecsElapsed();
#endif
RLDEBUG(" Render: - rendering starting");
@@ -588,8 +593,8 @@ void QSGRenderThread::syncAndRender()
gl->makeCurrent(w.window);
d->renderSceneGraph(w.size);
#ifndef QSG_NO_RENDER_TIMING
- if (qsg_render_timing && i == 0)
- renderTime = threadTimer.elapsed();
+ if (profileFrames && i == 0)
+ renderTime = threadTimer.nsecsElapsed();
#endif
gl->swapBuffers(w.window);
d->fireFrameSwapped();
@@ -599,10 +604,18 @@ void QSGRenderThread::syncAndRender()
#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing)
qDebug("window Time: sinceLast=%d, sync=%d, first render=%d, after final swap=%d",
- sinceLastTime,
- syncTime,
- renderTime - syncTime,
- threadTimer.elapsed() - renderTime);
+ int(sinceLastTime/1000000),
+ int(syncTime/1000000),
+ int((renderTime - syncTime)/1000000),
+ int(threadTimer.elapsed() - renderTime/1000000));
+
+ if (QQmlProfilerService::enabled) {
+ QQmlProfilerService::sceneGraphFrame(
+ QQmlProfilerService::SceneGraphRenderLoopFrame,
+ syncTime,
+ renderTime - syncTime,
+ threadTimer.nsecsElapsed() - renderTime);
+ }
#endif
}
@@ -950,10 +963,11 @@ void QSGThreadedRenderLoop::polishAndSync()
#ifndef QSG_NO_RENDER_TIMING
QElapsedTimer timer;
- int polishTime = 0;
- int waitTime = 0;
- int syncTime;
- if (qsg_render_timing)
+ qint64 polishTime = 0;
+ qint64 waitTime = 0;
+ qint64 syncTime = 0;
+ bool profileFrames = qsg_render_timing || QQmlProfilerService::enabled;
+ if (profileFrames)
timer.start();
#endif
@@ -964,8 +978,8 @@ void QSGThreadedRenderLoop::polishAndSync()
d->polishItems();
}
#ifndef QSG_NO_RENDER_TIMING
- if (qsg_render_timing)
- polishTime = timer.elapsed();
+ if (profileFrames)
+ polishTime = timer.nsecsElapsed();
#endif
m_sync_triggered_update = false;
@@ -977,8 +991,8 @@ void QSGThreadedRenderLoop::polishAndSync()
RLDEBUG("GUI: - wait for sync...");
#ifndef QSG_NO_RENDER_TIMING
- if (qsg_render_timing)
- waitTime = timer.elapsed();
+ if (profileFrames)
+ waitTime = timer.nsecsElapsed();
#endif
m_thread->waitCondition.wait(&m_thread->mutex);
m_thread->guiIsLocked = false;
@@ -986,8 +1000,8 @@ void QSGThreadedRenderLoop::polishAndSync()
RLDEBUG("GUI: - unlocked after sync...");
#ifndef QSG_NO_RENDER_TIMING
- if (qsg_render_timing)
- syncTime = timer.elapsed();
+ if (profileFrames)
+ syncTime = timer.nsecsElapsed();
#endif
killTimer(m_update_timer);
@@ -1006,7 +1020,20 @@ void QSGThreadedRenderLoop::polishAndSync()
#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing)
- qDebug(" - polish=%d, wait=%d, sync=%d -- animations=%d", polishTime, waitTime - polishTime, syncTime - waitTime, int(timer.elapsed() - syncTime));
+ qDebug(" - polish=%d, wait=%d, sync=%d -- animations=%d",
+ int(polishTime/1000000),
+ int((waitTime - polishTime)/1000000),
+ int((syncTime - waitTime)/1000000),
+ int((timer.nsecsElapsed() - syncTime)/1000000));
+
+ if (QQmlProfilerService::enabled) {
+ QQmlProfilerService::sceneGraphFrame(
+ QQmlProfilerService::SceneGraphPolishAndSync,
+ polishTime,
+ waitTime - polishTime,
+ syncTime - waitTime,
+ timer.nsecsElapsed() - syncTime);
+ }
#endif
}
diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
index 3e21af6ac0..ce43ccf531 100644
--- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp
+++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
@@ -51,6 +51,8 @@
#include <QtQuick/QQuickWindow>
+#include <private/qqmlprofilerservice_p.h>
+
QT_BEGIN_NAMESPACE
extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
@@ -67,7 +69,7 @@ static QElapsedTimer qsg_debug_timer;
#ifndef QSG_NO_RENDER_TIMING
static bool qsg_render_timing = !qgetenv("QSG_RENDER_TIMING").isEmpty();
static QElapsedTimer qsg_render_timer;
-#define QSG_RENDER_TIMING_SAMPLE(sampleName) int sampleName = 0; if (qsg_render_timing) sampleName = qsg_render_timer.elapsed()
+#define QSG_RENDER_TIMING_SAMPLE(sampleName) qint64 sampleName = 0; if (qsg_render_timing || QQmlProfilerService::enabled) sampleName = qsg_render_timer.nsecsElapsed()
#else
#define QSG_RENDER_TIMING_SAMPLE(sampleName)
#endif
@@ -174,9 +176,16 @@ void QSGWindowsRenderLoop::show(QQuickWindow *window)
#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing) {
qDebug("WindowsRenderLoop: GL=%d ms, makeCurrent=%d ms, SG=%d ms",
- int(time_created - time_start),
- int(time_current - time_created),
- int(qsg_render_timer.elapsed() - time_current));
+ int((time_created - time_start)/1000000),
+ int((time_current - time_created)/1000000),
+ int((qsg_render_timer.nsecsElapsed() - time_current)/1000000));
+ }
+ if (QQmlProfilerService::enabled) {
+ QQmlProfilerService::sceneGraphFrame(
+ QQmlProfilerService::SceneGraphWindowsRenderShow,
+ time_created - time_start,
+ time_current - time_created,
+ qsg_render_timer.nsecsElapsed() - time_current);
}
#endif
@@ -368,7 +377,12 @@ void QSGWindowsRenderLoop::render()
#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing) {
qDebug("WindowsRenderLoop: animations=%d ms",
- int(qsg_render_timer.elapsed() - time_start));
+ int((qsg_render_timer.nsecsElapsed() - time_start)/1000000));
+ }
+ if (QQmlProfilerService::Enabled) {
+ QQmlProfilerService::sceneGraphFrame(
+ QQmlProfilerService::SceneGraphWindowsAnimations,
+ qsg_render_timer.nsecsElapsed() - time_start);
}
#endif
@@ -424,10 +438,23 @@ void QSGWindowsRenderLoop::renderWindow(QQuickWindow *window)
qDebug("WindowsRenderLoop(t=%d): window=%p, polish=%d ms, sync=%d ms, render=%d ms, swap=%d ms",
int(qsg_render_timer.elapsed()),
window,
- int(time_polished - time_start),
- int(time_synced - time_polished),
- int(time_rendered - time_synced),
- int(time_swapped - time_rendered));
+ int((time_polished - time_start)/1000000),
+ int((time_synced - time_polished)/1000000),
+ int((time_rendered - time_synced)/1000000),
+ int((time_swapped - time_rendered)/1000000));
+ }
+ if (QQmlProfilerService::enabled) {
+ QQmlProfilerService::sceneGraphFrame(
+ QQmlProfilerService::SceneGraphWindowsPolishFrame,
+ time_polished - time_start
+ );
+
+ QQmlProfilerService::sceneGraphFrame(
+ QQmlProfilerService::SceneGraphRenderLoopFrame,
+ time_synced - time_polished,
+ time_rendered - time_synced,
+ time_swapped - time_rendered
+ );
}
#endif
}
diff --git a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
index 307201277c..09e2a7da27 100644
--- a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
+++ b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
@@ -74,11 +74,11 @@ void FlatColorMaterialShader::updateState(const RenderState &state, QSGMaterial
const QColor &c = newMaterial->color();
if (oldMaterial == 0 || c != oldMaterial->color() || state.isOpacityDirty()) {
- float opacity = state.opacity();
- QVector4D v(c.redF() * c.alphaF() * opacity,
- c.greenF() * c.alphaF() * opacity,
- c.blueF() * c.alphaF() * opacity,
- c.alphaF() * opacity);
+ float opacity = state.opacity() * c.alphaF();
+ QVector4D v(c.redF() * opacity,
+ c.greenF() * opacity,
+ c.blueF() * opacity,
+ opacity);
program()->setUniformValue(m_color_id, v);
}
diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp
index ad98fe9d47..a104e4af2f 100644
--- a/src/quick/scenegraph/util/qsgtexture.cpp
+++ b/src/quick/scenegraph/util/qsgtexture.cpp
@@ -614,7 +614,8 @@ void QSGPlainTexture::bind()
m_dirty_texture = false;
#ifndef QSG_NO_RENDER_TIMING
- if (qsg_render_timing)
+ bool profileFrames = qsg_render_timing || QQmlProfilerService::enabled;
+ if (profileFrames)
qsg_renderer_timer.start();
#endif
@@ -628,6 +629,11 @@ void QSGPlainTexture::bind()
m_texture_size.width(),
m_texture_size.height());
}
+ if (QQmlProfilerService::enabled) {
+ QQmlProfilerService::sceneGraphFrame(
+ QQmlProfilerService::SceneGraphTextureDeletion,
+ qsg_renderer_timer.nsecsElapsed());
+ }
#endif
}
m_texture_id = 0;
@@ -645,9 +651,9 @@ void QSGPlainTexture::bind()
glBindTexture(GL_TEXTURE_2D, m_texture_id);
#ifndef QSG_NO_RENDER_TIMING
- int bindTime = 0;
- if (qsg_render_timing)
- bindTime = qsg_renderer_timer.elapsed();
+ qint64 bindTime = 0;
+ if (profileFrames)
+ bindTime = qsg_renderer_timer.nsecsElapsed();
#endif
// ### TODO: check for out-of-memory situations...
@@ -659,9 +665,9 @@ void QSGPlainTexture::bind()
: m_image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
#ifndef QSG_NO_RENDER_TIMING
- int convertTime = 0;
- if (qsg_render_timing)
- convertTime = qsg_renderer_timer.elapsed();
+ qint64 convertTime = 0;
+ if (profileFrames)
+ convertTime = qsg_renderer_timer.nsecsElapsed();
#endif
updateBindOptions(m_dirty_bind_options);
@@ -684,16 +690,16 @@ void QSGPlainTexture::bind()
}
#ifndef QSG_NO_RENDER_TIMING
- int swizzleTime = 0;
- if (qsg_render_timing)
- swizzleTime = qsg_renderer_timer.elapsed();
+ qint64 swizzleTime = 0;
+ if (profileFrames)
+ swizzleTime = qsg_renderer_timer.nsecsElapsed();
#endif
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, w, h, 0, externalFormat, GL_UNSIGNED_BYTE, tmp.constBits());
#ifndef QSG_NO_RENDER_TIMING
- int uploadTime = 0;
- if (qsg_render_timing)
- uploadTime = qsg_renderer_timer.elapsed();
+ qint64 uploadTime = 0;
+ if (profileFrames)
+ uploadTime = qsg_renderer_timer.nsecsElapsed();
#endif
@@ -704,23 +710,35 @@ void QSGPlainTexture::bind()
}
#ifndef QSG_NO_RENDER_TIMING
- int mipmapTime = 0;
+ qint64 mipmapTime = 0;
if (qsg_render_timing) {
- mipmapTime = qsg_renderer_timer.elapsed();
+ mipmapTime = qsg_renderer_timer.nsecsElapsed();
printf(" - plaintexture(%dx%d) bind=%d, convert=%d, swizzle=%d (%s->%s), upload=%d, mipmap=%d, total=%d\n",
m_texture_size.width(), m_texture_size.height(),
- bindTime,
- convertTime - bindTime,
- swizzleTime - convertTime,
+ int(bindTime/1000000),
+ int((convertTime - bindTime)/1000000),
+ int((swizzleTime - convertTime)/1000000),
externalFormat == GL_BGRA ? "BGRA" : "RGBA",
internalFormat == GL_BGRA ? "BGRA" : "RGBA",
- uploadTime - swizzleTime,
- mipmapTime - uploadTime,
+ int((uploadTime - swizzleTime)/1000000),
+ int((mipmapTime - uploadTime)/1000000),
(int) qsg_renderer_timer.elapsed());
}
+ if (QQmlProfilerService::enabled) {
+ mipmapTime = qsg_renderer_timer.nsecsElapsed();
+
+ QQmlProfilerService::sceneGraphFrame(
+ QQmlProfilerService::SceneGraphTexturePrepare,
+ bindTime,
+ convertTime - bindTime,
+ swizzleTime - convertTime,
+ uploadTime - swizzleTime,
+ mipmapTime - uploadTime);
+ }
+
#endif
diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp
index ff91109a2a..87414766e3 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial.cpp
+++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp
@@ -145,7 +145,7 @@ void QSGOpaqueTextureMaterialShader::updateState(const RenderState &state, QSGMa
tuple. The QSGGeometry::defaultAttributes_TexturedPoint2D returns an
attribute set compatible with this material.
- The texture to be rendered is can be set using setTexture(). How the
+ The texture to be rendered can be set using setTexture(). How the
texture should be rendered can be specified using setMipmapFiltering(),
setFiltering(), setHorizontalWrapMode() and setVerticalWrapMode().
The rendering state is set on the texture instance just before it
@@ -208,7 +208,7 @@ QSGMaterialShader *QSGOpaqueTextureMaterial::createShader() const
/*!
Sets the texture of this material to \a texture.
- The material does not take ownership over the texture.
+ The material does not take ownership of the texture.
*/
void QSGOpaqueTextureMaterial::setTexture(QSGTexture *texture)
@@ -337,7 +337,7 @@ int QSGOpaqueTextureMaterial::compare(const QSGMaterial *o) const
tuple. The QSGGeometry::defaultAttributes_TexturedPoint2D returns an
attribute set compatible with this material.
- The texture to be rendered is set using setTexture(). How the
+ The texture to be rendered can be set using setTexture(). How the
texture should be rendered can be specified using setMipmapFiltering(),
setFiltering(), setHorizontalWrapMode() and setVerticalWrapMode().
The rendering state is set on the texture instance just before it