aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/doc/qtquick.qdocconf3
-rw-r--r--src/quick/doc/src/advtutorial.qdoc8
-rw-r--r--src/quick/doc/src/dynamicview-tutorial.qdoc8
-rw-r--r--src/quick/items/qquickitem.h4
-rw-r--r--src/quick/items/qquickitemsmodule.cpp1
-rw-r--r--src/quick/items/qquicktextedit.cpp15
-rw-r--r--src/quick/items/qquicktextnode.cpp1
-rw-r--r--src/quick/items/qquickwindow.cpp2
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer.cpp16
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer.cpp10
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp8
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode.cpp63
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp279
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.h12
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p_p.h45
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp46
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h6
-rw-r--r--src/quick/scenegraph/qsgrenderloop.cpp17
-rw-r--r--src/quick/scenegraph/qsgrenderloop_p.h1
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp83
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop_p.h2
-rw-r--r--src/quick/scenegraph/util/qsgtexture.cpp20
-rw-r--r--src/quick/util/qquickanimation.cpp5
-rw-r--r--src/quick/util/qquickanimation_p_p.h2
-rw-r--r--src/quick/util/qquickglobal.cpp2
25 files changed, 483 insertions, 176 deletions
diff --git a/src/quick/doc/qtquick.qdocconf b/src/quick/doc/qtquick.qdocconf
index b0676218cd..d9b4e03818 100644
--- a/src/quick/doc/qtquick.qdocconf
+++ b/src/quick/doc/qtquick.qdocconf
@@ -5,6 +5,7 @@ description = Qt Quick Reference Documentation
url = http://qt-project.org/doc/qt-$QT_VER/qtquick-index.html
version = $QT_VERSION
+examplesinstallpath = quick
qhp.projects = QtQuick
@@ -39,7 +40,7 @@ headerdirs += ..
sourcedirs += ..
-exampledirs += ../../../examples/ \
+exampledirs += ../../../examples/quick \
snippets
diff --git a/src/quick/doc/src/advtutorial.qdoc b/src/quick/doc/src/advtutorial.qdoc
index f670e3a323..966233c371 100644
--- a/src/quick/doc/src/advtutorial.qdoc
+++ b/src/quick/doc/src/advtutorial.qdoc
@@ -71,7 +71,7 @@ directory.
\previouspage QML Advanced Tutorial
\nextpage QML Advanced Tutorial 2 - Populating the Game Canvas
-\example quick/tutorials/samegame/samegame1
+\example tutorials/samegame/samegame1
\section2 Creating the application screen
@@ -141,7 +141,7 @@ types to get started. Next, we will populate the game canvas with some blocks.
\previouspage QML Advanced Tutorial 1 - Creating the Game Canvas and Blocks
\nextpage QML Advanced Tutorial 3 - Implementing the Game Logic
-\example quick/tutorials/samegame/samegame2
+\example tutorials/samegame/samegame2
\section2 Generating the blocks in JavaScript
@@ -217,7 +217,7 @@ Now, we have a screen of blocks, and we can begin to add the game mechanics.
\previouspage QML Advanced Tutorial 2 - Populating the Game Canvas
\nextpage QML Advanced Tutorial 4 - Finishing Touches
-\example quick/tutorials/samegame/samegame3
+\example tutorials/samegame/samegame3
\section2 Making a playable game
@@ -305,7 +305,7 @@ until the next chapter - where your application becomes alive!
\contentspage QML Advanced Tutorial
\previouspage QML Advanced Tutorial 3 - Implementing the Game Logic
-\example quick/tutorials/samegame/samegame4
+\example tutorials/samegame/samegame4
\section2 Adding some flair
diff --git a/src/quick/doc/src/dynamicview-tutorial.qdoc b/src/quick/doc/src/dynamicview-tutorial.qdoc
index 9c224f8642..daa14a6973 100644
--- a/src/quick/doc/src/dynamicview-tutorial.qdoc
+++ b/src/quick/doc/src/dynamicview-tutorial.qdoc
@@ -57,7 +57,7 @@ directory.
\previouspage QML Dynamic View Ordering Tutorial
\nextpage QML Dynamic View Ordering Tutorial 2 - Dragging View Items
-\example quick/tutorials/dynamicview/dynamicview1
+\example tutorials/dynamicview/dynamicview1
We begin our application by defining a ListView, a model which will provide data to the view, and a
delegate which provides a template for constructing items in the view.
@@ -94,7 +94,7 @@ The second part of the application is the ListView itself to which we bind the m
\previouspage QML Dynamic View Ordering Tutorial 1 - A Simple ListView and Delegate
\nextpage QML Dynamic View Ordering Tutorial 3 - Moving Dragged Items
-\example quick/tutorials/dynamicview/dynamicview2
+\example tutorials/dynamicview/dynamicview2
Now that we have a visible list of items we want to be able to interact with them. We'll start
by extending the delegate so the visible content can be dragged up and down the screen. The
@@ -139,7 +139,7 @@ so that is above other items in the stacking order and isn't obscured as it is d
\previouspage QML Dynamic View Ordering Tutorial 2 - Dragging View Items
\nextpage QML Dynamic View Ordering Tutorial 4 - Sorting Items
-\example quick/tutorials/dynamicview/dynamicview3
+\example tutorials/dynamicview/dynamicview3
The next step in our application to move items within the list as they're dragged so that we
can re-order the list. To achieve this we introduce three new types to our application;
@@ -192,7 +192,7 @@ property of the view and bind the \l {QtQuick2::VisualDataModel::model}{model} a
\contentspage QML Dynamic View Ordering Tutorial
\previouspage QML Dynamic View Ordering Tutorial 3 - Moving Dragged Items
-\example quick/tutorials/dynamicview/dynamicview4
+\example tutorials/dynamicview/dynamicview4
Drag and drop isn't the only way items in a view can be re-ordered, using a VisualDataModel it is
also possible to sort items based on model data. To do that we extend our VisualDataModel instance
diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h
index c37bc10bdd..040f9d6888 100644
--- a/src/quick/items/qquickitem.h
+++ b/src/quick/items/qquickitem.h
@@ -132,7 +132,7 @@ class Q_QUICK_EXPORT QQuickItem : public QObject, public QQmlParserStatus
Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL)
Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL)
- Q_PROPERTY(bool activeFocusOnTab READ activeFocusOnTab WRITE setActiveFocusOnTab NOTIFY activeFocusOnTabChanged FINAL)
+ Q_PROPERTY(bool activeFocusOnTab READ activeFocusOnTab WRITE setActiveFocusOnTab NOTIFY activeFocusOnTabChanged FINAL REVISION 1)
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
@@ -349,7 +349,7 @@ Q_SIGNALS:
void stateChanged(const QString &);
void focusChanged(bool);
void activeFocusChanged(bool);
- void activeFocusOnTabChanged(bool);
+ Q_REVISION(1) void activeFocusOnTabChanged(bool);
void parentChanged(QQuickItem *);
void transformOriginChanged(TransformOrigin);
void smoothChanged(bool);
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index cd49377822..741583a95d 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -228,6 +228,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterUncreatableType<QQuickAccessibleAttached>("QtQuick", 2, 0, "Accessible",QQuickAccessibleAttached::tr("Accessible is only available via attached properties"));
#endif
+ qmlRegisterType<QQuickItem, 1>(uri, 2, 1,"Item");
qmlRegisterType<QQuickGrid, 1>(uri, 2, 1, "Grid");
qmlRegisterType<QQuickTextEdit, 1>(uri, 2, 1, "TextEdit");
}
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index 506b4caa52..dde3587018 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -125,6 +125,17 @@ TextEdit {
// into text nodes corresponding to a text block each so that the glyph node grouping doesn't become pointless.
static const int nodeBreakingSize = 300;
+namespace {
+ class ProtectedLayoutAccessor: public QAbstractTextDocumentLayout
+ {
+ public:
+ inline QTextCharFormat formatAccessor(int pos)
+ {
+ return format(pos);
+ }
+ };
+}
+
QQuickTextEdit::QQuickTextEdit(QQuickItem *parent)
: QQuickImplicitSizeItem(*(new QQuickTextEditPrivate), parent)
{
@@ -1772,9 +1783,11 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
node->setMatrix(transformMatrix);
}
const int pos = textFrame->firstPosition() - 1;
+ ProtectedLayoutAccessor *a = static_cast<ProtectedLayoutAccessor *>(d->document->documentLayout());
+ QTextCharFormat format = a->formatAccessor(pos);
QTextBlock block = textFrame->firstCursorPosition().block();
node->m_engine->setCurrentLine(block.layout()->lineForTextPosition(pos - block.position()));
- node->m_engine->addTextObject(QPointF(0, 0), block.charFormat(), QQuickTextNodeEngine::Unselected, d->document,
+ node->m_engine->addTextObject(QPointF(0, 0), format, QQuickTextNodeEngine::Unselected, d->document,
pos, textFrame->frameFormat().position());
} else {
diff --git a/src/quick/items/qquicktextnode.cpp b/src/quick/items/qquicktextnode.cpp
index d46959464a..4952a37082 100644
--- a/src/quick/items/qquicktextnode.cpp
+++ b/src/quick/items/qquicktextnode.cpp
@@ -249,6 +249,7 @@ void QQuickTextNode::addTextLayout(const QPointF &position, QTextLayout *textLay
int selectionStart, int selectionEnd,
int lineStart, int lineCount)
{
+ Q_UNUSED(position);
initEngine(color, selectedTextColor, selectionColor, anchorColor);
#ifndef QT_NO_IM
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 176f46e3b7..4789314e01 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -207,8 +207,6 @@ void QQuickWindow::exposeEvent(QExposeEvent *)
/*! \reimp */
void QQuickWindow::resizeEvent(QResizeEvent *)
{
- Q_D(QQuickWindow);
- d->windowManager->resize(this, size());
}
/*! \reimp */
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer.cpp b/src/quick/scenegraph/coreapi/qsgrenderer.cpp
index 45a0b4b6ab..b46d45be57 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrenderer.cpp
@@ -60,8 +60,8 @@ QT_BEGIN_NAMESPACE
-#ifndef QSG_NO_RENDERER_TIMING
-static bool qsg_render_timing = !qgetenv("QML_RENDERER_TIMING").isEmpty();
+#ifndef QSG_NO_RENDER_TIMING
+static bool qsg_render_timing = !qgetenv("QSG_RENDER_TIMING").isEmpty();
static QTime frameTimer;
static int preprocessTime;
static int updatePassTime;
@@ -237,7 +237,7 @@ void QSGRenderer::renderScene(const QSGBindable &bindable)
m_is_rendering = true;
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing)
frameTimer.start();
int bindTime = 0;
@@ -248,7 +248,7 @@ void QSGRenderer::renderScene(const QSGBindable &bindable)
preprocess();
bindable.bind();
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing)
bindTime = frameTimer.elapsed();
#endif
@@ -269,7 +269,7 @@ void QSGRenderer::renderScene(const QSGBindable &bindable)
#endif
render();
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing)
renderTime = frameTimer.elapsed();
#endif
@@ -289,7 +289,7 @@ void QSGRenderer::renderScene(const QSGBindable &bindable)
m_index_buffer_bound = false;
}
-#ifndef QSG_NO_RENDERER_TIMING
+#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,
@@ -379,7 +379,7 @@ void QSGRenderer::preprocess()
}
}
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing)
preprocessTime = frameTimer.elapsed();
#endif
@@ -387,7 +387,7 @@ void QSGRenderer::preprocess()
nodeUpdater()->setToplevelOpacity(context()->renderAlpha());
nodeUpdater()->updateStates(m_root_node);
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing)
updatePassTime = frameTimer.elapsed();
#endif
diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp
index 4e8bafbe95..1d534e3563 100644
--- a/src/quick/scenegraph/qsgadaptationlayer.cpp
+++ b/src/quick/scenegraph/qsgadaptationlayer.cpp
@@ -52,8 +52,8 @@
QT_BEGIN_NAMESPACE
-#ifndef QSG_NO_RENDERER_TIMING
-static bool qsg_render_timing = !qgetenv("QML_RENDERER_TIMING").isEmpty();
+#ifndef QSG_NO_RENDER_TIMING
+static bool qsg_render_timing = !qgetenv("QSG_RENDER_TIMING").isEmpty();
static QElapsedTimer qsg_render_timer;
#endif
@@ -161,7 +161,7 @@ void QSGDistanceFieldGlyphCache::update()
if (m_pendingGlyphs.isEmpty())
return;
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing)
qsg_render_timer.start();
#endif
@@ -175,7 +175,7 @@ void QSGDistanceFieldGlyphCache::update()
distanceFields.insert(glyphIndex, distanceField);
}
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
int renderTime = 0;
int count = m_pendingGlyphs.size();
if (qsg_render_timing)
@@ -186,7 +186,7 @@ void QSGDistanceFieldGlyphCache::update()
storeGlyphs(distanceFields);
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing) {
printf(" - glyphs: count=%d, render=%d, store=%d, total=%d\n",
count,
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index 705b12c4d4..8d36fce481 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -72,8 +72,8 @@ DEFINE_BOOL_CONFIG_OPTION(qmlTranslucentMode, QML_TRANSLUCENT_MODE)
DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
-#ifndef QSG_NO_RENDERER_TIMING
-static bool qsg_render_timing = !qgetenv("QML_RENDERER_TIMING").isEmpty();
+#ifndef QSG_NO_RENDER_TIMING
+static bool qsg_render_timing = !qgetenv("QSG_RENDER_TIMING").isEmpty();
static QElapsedTimer qsg_renderer_timer;
#endif
@@ -477,7 +477,7 @@ QSGMaterialShader *QSGContext::prepareMaterial(QSGMaterial *material)
if (shader)
return shader;
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing)
qsg_renderer_timer.start();
#endif
@@ -487,7 +487,7 @@ QSGMaterialShader *QSGContext::prepareMaterial(QSGMaterial *material)
shader->initialize();
d->materials[type] = shader;
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing)
printf(" - compiling material: %dms\n", (int) qsg_renderer_timer.elapsed());
#endif
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode.cpp b/src/quick/scenegraph/qsgdefaultglyphnode.cpp
index 55eadab704..8f24485fc0 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode.cpp
@@ -48,7 +48,8 @@
QT_BEGIN_NAMESPACE
QSGDefaultGlyphNode::QSGDefaultGlyphNode()
- : m_material(0)
+ : m_style(QQuickText::Normal)
+ , m_material(0)
, m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 0)
{
m_geometry.setDrawingMode(GL_TRIANGLES);
@@ -74,22 +75,62 @@ void QSGDefaultGlyphNode::setGlyphs(const QPointF &position, const QGlyphRun &gl
if (m_material != 0)
delete m_material;
- QRawFont font = glyphs.rawFont();
- m_material = new QSGTextMaskMaterial(font);
+ m_position = position;
+ m_glyphs = glyphs;
+
+#ifdef QML_RUNTIME_TESTING
+ description = QLatin1String("glyphs");
+#endif
+}
+
+void QSGDefaultGlyphNode::setStyle(QQuickText::TextStyle style)
+{
+ if (m_style == style)
+ return;
+ m_style = style;
+}
+
+void QSGDefaultGlyphNode::setStyleColor(const QColor &color)
+{
+ if (m_styleColor == color)
+ return;
+ m_styleColor = color;
+}
+
+void QSGDefaultGlyphNode::update()
+{
+ QRawFont font = m_glyphs.rawFont();
+ QMargins margins(0, 0, 0, 0);
+
+ if (m_style == QQuickText::Normal) {
+ m_material = new QSGTextMaskMaterial(font);
+ } else if (m_style == QQuickText::Outline) {
+ QSGOutlinedTextMaterial *material = new QSGOutlinedTextMaterial(font);
+ material->setStyleColor(m_styleColor);
+ m_material = material;
+ margins = QMargins(1, 1, 1, 1);
+ } else {
+ QSGStyledTextMaterial *material = new QSGStyledTextMaterial(font);
+ if (m_style == QQuickText::Sunken) {
+ material->setStyleShift(QPointF(0, -1));
+ margins.setTop(1);
+ } else if (m_style == QQuickText::Raised) {
+ material->setStyleShift(QPointF(0, 1));
+ margins.setBottom(1);
+ }
+ material->setStyleColor(m_styleColor);
+ m_material = material;
+ }
+
m_material->setColor(m_color);
QRectF boundingRect;
- m_material->populate(position, glyphs.glyphIndexes(), glyphs.positions(), geometry(),
- &boundingRect, &m_baseLine);
-
- setMaterial(m_material);
+ m_material->populate(m_position, m_glyphs.glyphIndexes(), m_glyphs.positions(), geometry(),
+ &boundingRect, &m_baseLine, margins);
setBoundingRect(boundingRect);
+ setMaterial(m_material);
markDirty(DirtyGeometry);
-
-#ifdef QML_RUNTIME_TESTING
- description = QLatin1String("glyphs");
-#endif
}
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index 9e0cfca069..419062d025 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -43,7 +43,6 @@
#include <qopenglshaderprogram.h>
-#include <QtGui/private/qopengltextureglyphcache_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
#include <private/qfontengine_p.h>
@@ -67,7 +66,7 @@ public:
virtual void activate();
virtual void deactivate();
-private:
+protected:
virtual void initialize();
virtual const char *vertexShader() const;
virtual const char *fragmentShader() const;
@@ -210,8 +209,197 @@ void QSGTextMaskMaterialData::updateState(const RenderState &state, QSGMaterial
}
}
-QSGTextMaskMaterial::QSGTextMaskMaterial(const QRawFont &font)
- : m_texture(0), m_glyphCache(), m_font(font)
+class QSGStyledTextMaterialData : public QSGTextMaskMaterialData
+{
+public:
+ QSGStyledTextMaterialData() { }
+
+ virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect);
+ virtual void activate();
+ virtual void deactivate();
+
+private:
+ virtual void initialize();
+ virtual const char *vertexShader() const;
+ virtual const char *fragmentShader() const;
+
+ int m_shift_id;
+ int m_styleColor_id;
+};
+
+void QSGStyledTextMaterialData::initialize()
+{
+ QSGTextMaskMaterialData::initialize();
+ m_shift_id = program()->uniformLocation("shift");
+ m_styleColor_id = program()->uniformLocation("styleColor");
+}
+
+void QSGStyledTextMaterialData::updateState(const RenderState &state,
+ QSGMaterial *newEffect,
+ QSGMaterial *oldEffect)
+{
+ Q_ASSERT(oldEffect == 0 || newEffect->type() == oldEffect->type());
+
+ QSGStyledTextMaterial *material = static_cast<QSGStyledTextMaterial *>(newEffect);
+ QSGStyledTextMaterial *oldMaterial = static_cast<QSGStyledTextMaterial *>(oldEffect);
+
+ if (oldMaterial == 0 || oldMaterial->styleShift() != material->styleShift())
+ program()->setUniformValue(m_shift_id, material->styleShift());
+
+ if (oldMaterial == 0 || material->color() != oldMaterial->color() || state.isOpacityDirty()) {
+ QColor c = material->color();
+ QVector4D color(c.redF() * c.alphaF(), c.greenF() * c.alphaF(), c.blueF() * c.alphaF(), c.alphaF());
+ color *= state.opacity();
+ program()->setUniformValue(m_color_id, color);
+ }
+
+ if (oldMaterial == 0 || material->styleColor() != oldMaterial->styleColor() || state.isOpacityDirty()) {
+ QColor c = material->styleColor();
+ QVector4D color(c.redF() * c.alphaF(), c.greenF() * c.alphaF(), c.blueF() * c.alphaF(), c.alphaF());
+ color *= state.opacity();
+ program()->setUniformValue(m_styleColor_id, color);
+ }
+
+ bool updated = material->ensureUpToDate();
+ Q_ASSERT(material->texture());
+
+ Q_ASSERT(oldMaterial == 0 || oldMaterial->texture());
+ if (updated
+ || oldMaterial == 0
+ || oldMaterial->texture()->textureId() != material->texture()->textureId()) {
+ program()->setUniformValue(m_textureScale_id, QVector2D(1.0 / material->cacheTextureWidth(),
+ 1.0 / material->cacheTextureHeight()));
+ glBindTexture(GL_TEXTURE_2D, material->texture()->textureId());
+
+ // Set the mag/min filters to be linear. We only need to do this when the texture
+ // has been recreated.
+ if (updated) {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ }
+ }
+
+ if (state.isMatrixDirty())
+ program()->setUniformValue(m_matrix_id, state.combinedMatrix());
+}
+
+void QSGStyledTextMaterialData::activate()
+{
+ QSGMaterialShader::activate();
+
+#if !defined(QT_OPENGL_ES_2) && defined(GL_ARB_framebuffer_sRGB)
+ // 0.25 was found to be acceptable error margin by experimentation. On Mac, the gamma is 2.0,
+ // but using sRGB looks okay.
+ if (qAbs(fontSmoothingGamma() - 2.2) < 0.25)
+ glEnable(GL_FRAMEBUFFER_SRGB);
+#endif
+}
+
+void QSGStyledTextMaterialData::deactivate()
+{
+ QSGMaterialShader::deactivate();
+
+#if !defined(QT_OPENGL_ES_2) && defined(GL_ARB_framebuffer_sRGB)
+ if (qAbs(fontSmoothingGamma() - 2.2) < 0.25)
+ glDisable(GL_FRAMEBUFFER_SRGB);
+#endif
+}
+
+const char *QSGStyledTextMaterialData::vertexShader() const
+{
+ return
+ "uniform highp mat4 matrix; \n"
+ "uniform highp vec2 textureScale; \n"
+ "uniform highp vec2 shift; \n"
+ "attribute highp vec4 vCoord; \n"
+ "attribute highp vec2 tCoord; \n"
+ "varying highp vec2 sampleCoord; \n"
+ "varying highp vec2 shiftedSampleCoord; \n"
+ "void main() { \n"
+ " sampleCoord = tCoord * textureScale; \n"
+ " shiftedSampleCoord = (tCoord - shift) * textureScale; \n"
+ " gl_Position = matrix * vCoord; \n"
+ "}";
+}
+
+const char *QSGStyledTextMaterialData::fragmentShader() const
+{
+ return
+ "varying highp vec2 sampleCoord; \n"
+ "varying highp vec2 shiftedSampleCoord; \n"
+ "uniform sampler2D texture; \n"
+ "uniform lowp vec4 color; \n"
+ "uniform lowp vec4 styleColor; \n"
+ "void main() { \n"
+ " lowp float glyph = texture2D(texture, sampleCoord).a; \n"
+ " lowp float style = clamp(texture2D(texture, shiftedSampleCoord).a - glyph, \n"
+ " 0.0, 1.0); \n"
+ " gl_FragColor = style * styleColor + glyph * color; \n"
+ "}";
+}
+
+
+class QSGOutlinedTextMaterialData : public QSGStyledTextMaterialData
+{
+public:
+ QSGOutlinedTextMaterialData() { }
+
+private:
+ const char *vertexShader() const;
+ const char *fragmentShader() const;
+};
+
+const char *QSGOutlinedTextMaterialData::vertexShader() const
+{
+ return
+ "uniform highp mat4 matrix; \n"
+ "uniform highp vec2 textureScale; \n"
+ "uniform highp vec2 shift; \n"
+ "attribute highp vec4 vCoord; \n"
+ "attribute highp vec2 tCoord; \n"
+ "varying highp vec2 sampleCoord; \n"
+ "varying highp vec2 sCoordUp; \n"
+ "varying highp vec2 sCoordDown; \n"
+ "varying highp vec2 sCoordLeft; \n"
+ "varying highp vec2 sCoordRight; \n"
+ "void main() { \n"
+ " sampleCoord = tCoord * textureScale; \n"
+ " sCoordUp = (tCoord - vec2(0.0, -1.0)) * textureScale; \n"
+ " sCoordDown = (tCoord - vec2(0.0, 1.0)) * textureScale; \n"
+ " sCoordLeft = (tCoord - vec2(-1.0, 0.0)) * textureScale; \n"
+ " sCoordRight = (tCoord - vec2(1.0, 0.0)) * textureScale; \n"
+ " gl_Position = matrix * vCoord; \n"
+ "}";
+}
+
+const char *QSGOutlinedTextMaterialData::fragmentShader() const
+{
+ return
+ "varying highp vec2 sampleCoord; \n"
+ "varying highp vec2 sCoordUp; \n"
+ "varying highp vec2 sCoordDown; \n"
+ "varying highp vec2 sCoordLeft; \n"
+ "varying highp vec2 sCoordRight; \n"
+ "uniform sampler2D texture; \n"
+ "uniform lowp vec4 color; \n"
+ "uniform lowp vec4 styleColor; \n"
+ "void main() { \n"
+ "lowp float glyph = texture2D(texture, sampleCoord).a; \n"
+ " lowp float outline = clamp(clamp(texture2D(texture, sCoordUp).a + \n"
+ " texture2D(texture, sCoordDown).a + \n"
+ " texture2D(texture, sCoordLeft).a + \n"
+ " texture2D(texture, sCoordRight).a, \n"
+ " 0.0, 1.0) - glyph, \n"
+ " 0.0, 1.0); \n"
+ " gl_FragColor = outline * styleColor + glyph * color; \n"
+ "}";
+}
+
+QSGTextMaskMaterial::QSGTextMaskMaterial(const QRawFont &font, QFontEngineGlyphCache::Type cacheType)
+ : m_texture(0)
+ , m_cacheType(cacheType)
+ , m_glyphCache(0)
+ , m_font(font)
{
init();
}
@@ -224,7 +412,6 @@ void QSGTextMaskMaterial::init()
{
Q_ASSERT(m_font.isValid());
- QFontEngineGlyphCache::Type type = QFontEngineGlyphCache::Raster_RGBMask;
setFlag(Blending, true);
QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext());
@@ -232,20 +419,21 @@ void QSGTextMaskMaterial::init()
QRawFontPrivate *fontD = QRawFontPrivate::get(m_font);
if (fontD->fontEngine != 0) {
- m_glyphCache = fontD->fontEngine->glyphCache(ctx, type, QTransform());
- if (!m_glyphCache || m_glyphCache->cacheType() != type) {
- m_glyphCache = new QOpenGLTextureGlyphCache(type, QTransform());
+ m_glyphCache = fontD->fontEngine->glyphCache(ctx, m_cacheType, QTransform());
+ if (!m_glyphCache || m_glyphCache->cacheType() != m_cacheType) {
+ m_glyphCache = new QOpenGLTextureGlyphCache(m_cacheType, QTransform());
fontD->fontEngine->setGlyphCache(ctx, m_glyphCache.data());
}
}
}
void QSGTextMaskMaterial::populate(const QPointF &p,
- const QVector<quint32> &glyphIndexes,
- const QVector<QPointF> &glyphPositions,
- QSGGeometry *geometry,
- QRectF *boundingRect,
- QPointF *baseLine)
+ const QVector<quint32> &glyphIndexes,
+ const QVector<QPointF> &glyphPositions,
+ QSGGeometry *geometry,
+ QRectF *boundingRect,
+ QPointF *baseLine,
+ const QMargins &margins)
{
Q_ASSERT(m_font.isValid());
QVector<QFixedPoint> fixedPointPositions;
@@ -283,15 +471,15 @@ void QSGTextMaskMaterial::populate(const QPointF &p,
*boundingRect |= QRectF(x + margin, y + margin, c.w, c.h);
- float cx1 = x;
- float cx2 = x + c.w;
- float cy1 = y;
- float cy2 = y + c.h;
+ float cx1 = x - margins.left();
+ float cx2 = x + c.w + margins.right();
+ float cy1 = y - margins.top();
+ float cy2 = y + c.h + margins.bottom();
- float tx1 = c.x;
- float tx2 = (c.x + c.w);
- float ty1 = c.y;
- float ty2 = (c.y + c.h);
+ float tx1 = c.x - margins.left();
+ float tx2 = c.x + c.w + margins.right();
+ float ty1 = c.y - margins.top();
+ float ty2 = c.y + c.h + margins.bottom();
if (baseLine->isNull())
*baseLine = glyphPosition;
@@ -367,4 +555,53 @@ int QSGTextMaskMaterial::cacheTextureHeight() const
return glyphCache()->height();
}
+
+QSGStyledTextMaterial::QSGStyledTextMaterial(const QRawFont &font)
+ : QSGTextMaskMaterial(font, QFontEngineGlyphCache::Raster_A8)
+{
+}
+
+QSGMaterialType *QSGStyledTextMaterial::type() const
+{
+ static QSGMaterialType type;
+ return &type;
+}
+
+QSGMaterialShader *QSGStyledTextMaterial::createShader() const
+{
+ return new QSGStyledTextMaterialData;
+}
+
+int QSGStyledTextMaterial::compare(const QSGMaterial *o) const
+{
+ const QSGStyledTextMaterial *other = static_cast<const QSGStyledTextMaterial *>(o);
+
+ if (m_styleShift != other->m_styleShift)
+ return m_styleShift.y() - other->m_styleShift.y();
+
+ QRgb c1 = m_styleColor.rgba();
+ QRgb c2 = other->m_styleColor.rgba();
+ if (c1 != c2)
+ return int(c2 < c1) - int(c1 < c2);
+
+ return QSGTextMaskMaterial::compare(o);
+}
+
+
+QSGOutlinedTextMaterial::QSGOutlinedTextMaterial(const QRawFont &font)
+ : QSGStyledTextMaterial(font)
+{
+}
+
+QSGMaterialType *QSGOutlinedTextMaterial::type() const
+{
+ static QSGMaterialType type;
+ return &type;
+}
+
+QSGMaterialShader *QSGOutlinedTextMaterial::createShader() const
+{
+ return new QSGOutlinedTextMaterialData;
+}
+
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.h b/src/quick/scenegraph/qsgdefaultglyphnode_p.h
index a3d5d7c3ae..e264c1b70e 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.h
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.h
@@ -53,22 +53,24 @@ class QSGDefaultGlyphNode: public QSGGlyphNode
{
public:
QSGDefaultGlyphNode();
- ~QSGDefaultGlyphNode();
+ virtual ~QSGDefaultGlyphNode();
virtual QPointF baseLine() const { return m_baseLine; }
virtual void setGlyphs(const QPointF &position, const QGlyphRun &glyphs);
virtual void setColor(const QColor &color);
virtual void setPreferredAntialiasingMode(AntialiasingMode) { }
- virtual void setStyle(QQuickText::TextStyle) { }
- virtual void setStyleColor(const QColor &) { }
+ virtual void setStyle(QQuickText::TextStyle);
+ virtual void setStyleColor(const QColor &);
- virtual void update() { }
+ virtual void update();
-private:
+protected:
QGlyphRun m_glyphs;
QPointF m_position;
QColor m_color;
+ QQuickText::TextStyle m_style;
+ QColor m_styleColor;
QPointF m_baseLine;
QSGTextMaskMaterial *m_material;
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h b/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h
index 263523221e..d1a739de88 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h
@@ -43,24 +43,25 @@
#define QSGDEFAULTGLYPHNODE_P_P_H
#include <qcolor.h>
+#include <QtGui/private/qopengltextureglyphcache_p.h>
#include <QtQuick/qsgmaterial.h>
#include <QtQuick/qsgtexture.h>
#include <QtQuick/qsggeometry.h>
#include <qshareddata.h>
#include <QtQuick/private/qsgtexture_p.h>
#include <qrawfont.h>
+#include <qmargins.h>
QT_BEGIN_NAMESPACE
-class QFontEngineGlyphCache;
-class QOpenGLTextureGlyphCache;
class QFontEngine;
class Geometry;
class QSGTextMaskMaterial: public QSGMaterial
{
public:
- QSGTextMaskMaterial(const QRawFont &font);
- ~QSGTextMaskMaterial();
+ QSGTextMaskMaterial(const QRawFont &font,
+ QFontEngineGlyphCache::Type cacheType = QFontEngineGlyphCache::Raster_RGBMask);
+ virtual ~QSGTextMaskMaterial();
virtual QSGMaterialType *type() const;
virtual QSGMaterialShader *createShader() const;
@@ -79,18 +80,52 @@ public:
QOpenGLTextureGlyphCache *glyphCache() const;
void populate(const QPointF &position,
const QVector<quint32> &glyphIndexes, const QVector<QPointF> &glyphPositions,
- QSGGeometry *geometry, QRectF *boundingRect, QPointF *baseLine);
+ QSGGeometry *geometry, QRectF *boundingRect, QPointF *baseLine,
+ const QMargins &margins = QMargins(0, 0, 0, 0));
private:
void init();
QSGPlainTexture *m_texture;
+ QFontEngineGlyphCache::Type m_cacheType;
QExplicitlySharedDataPointer<QFontEngineGlyphCache> m_glyphCache;
QRawFont m_font;
QColor m_color;
QSize m_size;
};
+class QSGStyledTextMaterial : public QSGTextMaskMaterial
+{
+public:
+ QSGStyledTextMaterial(const QRawFont &font);
+ virtual ~QSGStyledTextMaterial() { }
+
+ void setStyleShift(const QPointF &shift) { m_styleShift = shift; }
+ const QPointF &styleShift() const { return m_styleShift; }
+
+ void setStyleColor(const QColor &color) { m_styleColor = color; }
+ const QColor &styleColor() const { return m_styleColor; }
+
+ virtual QSGMaterialType *type() const;
+ virtual QSGMaterialShader *createShader() const;
+
+ int compare(const QSGMaterial *other) const;
+
+private:
+ QPointF m_styleShift;
+ QColor m_styleColor;
+};
+
+class QSGOutlinedTextMaterial : public QSGStyledTextMaterial
+{
+public:
+ QSGOutlinedTextMaterial(const QRawFont &font);
+ ~QSGOutlinedTextMaterial() { }
+
+ QSGMaterialType *type() const;
+ QSGMaterialShader *createShader() const;
+};
+
QT_END_NAMESPACE
#endif
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
index d409cea81a..86c3356d58 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
@@ -144,8 +144,8 @@ void QSGDistanceFieldTextMaterialShader::updateState(const RenderState &state, Q
if (oldMaterial == 0
|| material->color() != oldMaterial->color()
|| state.isOpacityDirty()) {
- QVector4D color(material->color().redF(), material->color().greenF(),
- material->color().blueF(), material->color().alphaF());
+ QColor c = material->color();
+ QVector4D color(c.redF(), c.greenF(), c.blueF(), c.alphaF());
color *= state.opacity();
program()->setUniformValue(m_color_id, color);
}
@@ -204,6 +204,14 @@ QSGMaterialType *QSGDistanceFieldTextMaterial::type() const
return &type;
}
+void QSGDistanceFieldTextMaterial::setColor(const QColor &color)
+{
+ m_color = QColor::fromRgbF(color.redF() * color.alphaF(),
+ color.greenF() * color.alphaF(),
+ color.blueF() * color.alphaF(),
+ color.alphaF());
+}
+
QSGMaterialShader *QSGDistanceFieldTextMaterial::createShader() const
{
return new QSGDistanceFieldTextMaterialShader;
@@ -276,8 +284,8 @@ void DistanceFieldStyledTextMaterialShader::updateState(const RenderState &state
if (oldMaterial == 0
|| material->styleColor() != oldMaterial->styleColor()
|| (state.isOpacityDirty())) {
- QVector4D color(material->styleColor().redF(), material->styleColor().greenF(),
- material->styleColor().blueF(), material->styleColor().alphaF());
+ QColor c = material->styleColor();
+ QVector4D color(c.redF(), c.greenF(), c.blueF(), c.alphaF());
color *= state.opacity();
program()->setUniformValue(m_styleColor_id, color);
}
@@ -292,6 +300,14 @@ 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());
+}
+
int QSGDistanceFieldStyledTextMaterial::compare(const QSGMaterial *o) const
{
Q_ASSERT(o && type() == o->type());
@@ -316,7 +332,7 @@ protected:
virtual void initialize();
virtual const char *fragmentShader() const;
- void updateOutlineAlphaRange(int dfRadius);
+ void updateOutlineAlphaRange(ThresholdFunc thresholdFunc, AntialiasingSpreadFunc spreadFunc, int dfRadius);
int m_outlineAlphaMax0_id;
int m_outlineAlphaMax1_id;
@@ -351,14 +367,18 @@ void DistanceFieldOutlineTextMaterialShader::initialize()
m_outlineAlphaMax1_id = program()->uniformLocation("outlineAlphaMax1");
}
-void DistanceFieldOutlineTextMaterialShader::updateOutlineAlphaRange(int dfRadius)
+void DistanceFieldOutlineTextMaterialShader::updateOutlineAlphaRange(ThresholdFunc thresholdFunc,
+ AntialiasingSpreadFunc spreadFunc,
+ int dfRadius)
{
- qreal outlineLimit = qMax(qreal(0.2), qreal(0.5 - 0.5 / dfRadius / m_fontScale));
+ float combinedScale = m_fontScale * m_matrixScale;
+ float base = thresholdFunc(combinedScale);
+ float range = spreadFunc(combinedScale);
+ float outlineLimit = qMax(0.2f, base - 0.5f / dfRadius / m_fontScale);
- qreal combinedScale = m_fontScale * m_matrixScale;
- qreal alphaMin = qMax(0.0, 0.5 - 0.07 / combinedScale);
- qreal styleAlphaMin0 = qMax(0.0, outlineLimit - 0.07 / combinedScale);
- qreal styleAlphaMin1 = qMin(qreal(outlineLimit + 0.07 / combinedScale), alphaMin);
+ float alphaMin = qMax(0.0f, base - range);
+ float styleAlphaMin0 = qMax(0.0f, outlineLimit - range);
+ float styleAlphaMin1 = qMin(outlineLimit + range, alphaMin);
program()->setUniformValue(m_outlineAlphaMax0_id, GLfloat(styleAlphaMin0));
program()->setUniformValue(m_outlineAlphaMax1_id, GLfloat(styleAlphaMin1));
}
@@ -373,7 +393,9 @@ void DistanceFieldOutlineTextMaterialShader::updateState(const RenderState &stat
if (oldMaterial == 0
|| material->fontScale() != oldMaterial->fontScale()
|| state.isMatrixDirty())
- updateOutlineAlphaRange(material->glyphCache()->distanceFieldRadius());
+ updateOutlineAlphaRange(material->glyphCache()->manager()->thresholdFunc(),
+ material->glyphCache()->manager()->antialiasingSpreadFunc(),
+ material->glyphCache()->distanceFieldRadius());
}
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h b/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
index d6aa38affa..7fea8f65dc 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
@@ -58,7 +58,7 @@ public:
virtual QSGMaterialShader *createShader() const;
virtual int compare(const QSGMaterial *other) const;
- void setColor(const QColor &color) { m_color = color; }
+ virtual void setColor(const QColor &color);
const QColor &color() const { return m_color; }
void setGlyphCache(QSGDistanceFieldGlyphCache *a) { m_glyph_cache = a; }
@@ -92,7 +92,7 @@ public:
virtual QSGMaterialShader *createShader() const = 0;
virtual int compare(const QSGMaterial *other) const;
- void setStyleColor(const QColor &color) { m_styleColor = color; }
+ void setStyleColor(const QColor &color);
const QColor &styleColor() const { return m_styleColor; }
protected:
@@ -130,6 +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; }
};
class Q_QUICK_PRIVATE_EXPORT QSGLoQSubPixelDistanceFieldTextMaterial : public QSGDistanceFieldTextMaterial
@@ -137,6 +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; }
};
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp
index a55658bf71..33a99d1506 100644
--- a/src/quick/scenegraph/qsgrenderloop.cpp
+++ b/src/quick/scenegraph/qsgrenderloop.cpp
@@ -58,7 +58,7 @@
QT_BEGIN_NAMESPACE
-DEFINE_BOOL_CONFIG_OPTION(qquick_render_timing, QML_RENDER_TIMING)
+DEFINE_BOOL_CONFIG_OPTION(qsg_render_timing, QSG_RENDER_TIMING)
extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
@@ -95,7 +95,6 @@ public:
void renderWindow(QQuickWindow *window);
void exposureChanged(QQuickWindow *window);
QImage grab(QQuickWindow *window);
- void resize(QQuickWindow *window, const QSize &size);
void maybeUpdate(QQuickWindow *window);
void update(QQuickWindow *window) { maybeUpdate(window); } // identical for this implementation.
@@ -272,17 +271,17 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
int renderTime = 0, syncTime = 0;
QTime renderTimer;
- if (qquick_render_timing())
+ if (qsg_render_timing())
renderTimer.start();
cd->syncSceneGraph();
- if (qquick_render_timing())
+ if (qsg_render_timing())
syncTime = renderTimer.elapsed();
cd->renderSceneGraph(window->size());
- if (qquick_render_timing())
+ if (qsg_render_timing())
renderTime = renderTimer.elapsed() - syncTime;
if (data.grabOnly) {
@@ -295,7 +294,7 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
cd->fireFrameSwapped();
}
- if (qquick_render_timing()) {
+ if (qsg_render_timing()) {
static QTime lastFrameTime = QTime::currentTime();
const int swapTime = renderTimer.elapsed() - renderTime - syncTime;
qDebug() << "- Breakdown of frame time; sync:" << syncTime
@@ -335,12 +334,6 @@ QImage QSGGuiThreadRenderLoop::grab(QQuickWindow *window)
-void QSGGuiThreadRenderLoop::resize(QQuickWindow *, const QSize &)
-{
-}
-
-
-
void QSGGuiThreadRenderLoop::maybeUpdate(QQuickWindow *window)
{
if (!m_windows.contains(window))
diff --git a/src/quick/scenegraph/qsgrenderloop_p.h b/src/quick/scenegraph/qsgrenderloop_p.h
index 2ec6de9411..b18e6f00ad 100644
--- a/src/quick/scenegraph/qsgrenderloop_p.h
+++ b/src/quick/scenegraph/qsgrenderloop_p.h
@@ -63,7 +63,6 @@ public:
virtual void exposureChanged(QQuickWindow *window) = 0;
virtual QImage grab(QQuickWindow *window) = 0;
- virtual void resize(QQuickWindow *window, const QSize &size) = 0;
virtual void update(QQuickWindow *window) = 0;
virtual void maybeUpdate(QQuickWindow *window) = 0;
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index ef50d5a89d..b457c33bed 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -136,8 +136,8 @@ static inline int qsgrl_animation_interval() {
}
-#ifndef QSG_NO_WINDOW_TIMING
-static bool qquick_window_timing = !qgetenv("QML_WINDOW_TIMING").isEmpty();
+#ifndef QSG_NO_RENDER_TIMING
+static bool qsg_render_timing = !qgetenv("QSG_RENDER_TIMING").isEmpty();
static QTime threadTimer;
static int syncTime;
static int renderTime;
@@ -168,9 +168,6 @@ const QEvent::Type WM_RequestSync = QEvent::Type(QEvent::User + 4);
// typically a result of QQuickWindow::update().
const QEvent::Type WM_RequestRepaint = QEvent::Type(QEvent::User + 5);
-// Passed by the RL to the RT when a window has changed size.
-const QEvent::Type WM_Resize = QEvent::Type(QEvent::User + 6);
-
// Passed by the RL to the RT to free up maybe release SG and GL contexts
// if no windows are rendering.
const QEvent::Type WM_TryRelease = QEvent::Type(QEvent::User + 7);
@@ -213,14 +210,6 @@ public:
bool inDestructor;
};
-class WMResizeEvent : public WMWindowEvent
-{
-public:
- WMResizeEvent(QQuickWindow *c, const QSize &s) : WMWindowEvent(c, WM_Resize), size(s) { }
- QSize size;
-};
-
-
class WMExposeEvent : public WMWindowEvent
{
public:
@@ -374,7 +363,8 @@ bool QSGRenderThread::event(QEvent *e)
pendingUpdate |= RepaintRequest;
- if (windowFor(m_windows, se->window)) {
+ if (Window *w = windowFor(m_windows, se->window)) {
+ w->size = se->size;
RLDEBUG1(" Render: - window already added...");
return true;
}
@@ -409,14 +399,6 @@ bool QSGRenderThread::event(QEvent *e)
pendingUpdate |= SyncRequest;
return true;
- case WM_Resize: {
- RLDEBUG(" Render: WM_Resize");
- WMResizeEvent *re = static_cast<WMResizeEvent *>(e);
- Window *w = windowFor(m_windows, re->window);
- w->size = re->size;
- // No need to wake up here as we will get a sync shortly.. (see QSGThreadedRenderLoop::resize());
- return true; }
-
case WM_TryRelease:
RLDEBUG1(" Render: WM_TryRelease");
mutex.lock();
@@ -563,8 +545,8 @@ void QSGRenderThread::sync()
void QSGRenderThread::syncAndRender()
{
-#ifndef QSG_NO_WINDOW_TIMING
- if (qquick_window_timing)
+#ifndef QSG_NO_RENDER_TIMING
+ if (qsg_render_timing)
sinceLastTime = threadTimer.restart();
#endif
QElapsedTimer waitTimer;
@@ -589,8 +571,8 @@ void QSGRenderThread::syncAndRender()
return;
}
-#ifndef QSG_NO_WINDOW_TIMING
- if (qquick_window_timing)
+#ifndef QSG_NO_RENDER_TIMING
+ if (qsg_render_timing)
syncTime = threadTimer.elapsed();
#endif
RLDEBUG(" Render: - rendering starting");
@@ -604,8 +586,8 @@ void QSGRenderThread::syncAndRender()
}
gl->makeCurrent(w.window);
d->renderSceneGraph(w.size);
-#ifndef QSG_NO_WINDOW_TIMING
- if (qquick_window_timing && i == 0)
+#ifndef QSG_NO_RENDER_TIMING
+ if (qsg_render_timing && i == 0)
renderTime = threadTimer.elapsed();
#endif
gl->swapBuffers(w.window);
@@ -613,8 +595,8 @@ void QSGRenderThread::syncAndRender()
}
RLDEBUG(" Render: - rendering done");
-#ifndef QSG_NO_WINDOW_TIMING
- if (qquick_window_timing)
+#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,
@@ -965,12 +947,12 @@ void QSGThreadedRenderLoop::polishAndSync()
RLDEBUG("GUI: polishAndSync()");
-#ifndef QSG_NO_WINDOW_TIMING
+#ifndef QSG_NO_RENDER_TIMING
QElapsedTimer timer;
int polishTime = 0;
int waitTime = 0;
int syncTime;
- if (qquick_window_timing)
+ if (qsg_render_timing)
timer.start();
#endif
@@ -980,8 +962,8 @@ void QSGThreadedRenderLoop::polishAndSync()
QQuickWindowPrivate *d = QQuickWindowPrivate::get(w.window);
d->polishItems();
}
-#ifndef QSG_NO_WINDOW_TIMING
- if (qquick_window_timing)
+#ifndef QSG_NO_RENDER_TIMING
+ if (qsg_render_timing)
polishTime = timer.elapsed();
#endif
@@ -993,8 +975,8 @@ void QSGThreadedRenderLoop::polishAndSync()
m_thread->postEvent(new QEvent(WM_RequestSync));
RLDEBUG("GUI: - wait for sync...");
-#ifndef QSG_NO_WINDOW_TIMING
- if (qquick_window_timing)
+#ifndef QSG_NO_RENDER_TIMING
+ if (qsg_render_timing)
waitTime = timer.elapsed();
#endif
m_thread->waitCondition.wait(&m_thread->mutex);
@@ -1002,8 +984,8 @@ void QSGThreadedRenderLoop::polishAndSync()
m_thread->mutex.unlock();
RLDEBUG("GUI: - unlocked after sync...");
-#ifndef QSG_NO_WINDOW_TIMING
- if (qquick_window_timing)
+#ifndef QSG_NO_RENDER_TIMING
+ if (qsg_render_timing)
syncTime = timer.elapsed();
#endif
@@ -1021,8 +1003,8 @@ void QSGThreadedRenderLoop::polishAndSync()
maybePostPolishRequest();
}
-#ifndef QSG_NO_WINDOW_TIMING
- if (qquick_window_timing)
+#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));
#endif
}
@@ -1086,27 +1068,6 @@ QImage QSGThreadedRenderLoop::grab(QQuickWindow *window)
return result;
}
-/*
- Notify the render thread that the window is now a new size. Then
- locks GUI until render has adapted.
- */
-
-void QSGThreadedRenderLoop::resize(QQuickWindow *w, const QSize &size)
-{
- RLDEBUG1("GUI: resize");
-
- if (!m_thread->isRunning() || !m_windows.size() || !w->isExposed() || windowFor(m_windows, w) == 0) {
- return;
- }
-
- if (size.width() == 0 || size.height() == 0)
- return;
-
- RLDEBUG("GUI: - posting resize event...");
- m_thread->postEvent(new WMResizeEvent(w, size));
-
- polishAndSync();
-}
#include "qsgthreadedrenderloop.moc"
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop_p.h b/src/quick/scenegraph/qsgthreadedrenderloop_p.h
index 63b2b442e6..aab0e8726f 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop_p.h
+++ b/src/quick/scenegraph/qsgthreadedrenderloop_p.h
@@ -69,8 +69,6 @@ public:
QImage grab(QQuickWindow *);
- void resize(QQuickWindow *, const QSize &);
-
void update(QQuickWindow *window);
void maybeUpdate(QQuickWindow *window);
QSGContext *sceneGraphContext() const;
diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp
index cd95d9f445..ad98fe9d47 100644
--- a/src/quick/scenegraph/util/qsgtexture.cpp
+++ b/src/quick/scenegraph/util/qsgtexture.cpp
@@ -69,8 +69,8 @@
static bool qsg_leak_check = !qgetenv("QML_LEAK_CHECK").isEmpty();
#endif
-#ifndef QSG_NO_RENDERER_TIMING
-static bool qsg_render_timing = !qgetenv("QML_RENDERER_TIMING").isEmpty();
+#ifndef QSG_NO_RENDER_TIMING
+static bool qsg_render_timing = !qgetenv("QSG_RENDER_TIMING").isEmpty();
static QElapsedTimer qsg_renderer_timer;
#endif
@@ -613,7 +613,7 @@ void QSGPlainTexture::bind()
m_dirty_texture = false;
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing)
qsg_renderer_timer.start();
#endif
@@ -621,7 +621,7 @@ void QSGPlainTexture::bind()
if (m_image.isNull()) {
if (m_texture_id && m_owns_texture) {
glDeleteTextures(1, &m_texture_id);
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing) {
printf(" - texture deleted in %dms (size: %dx%d)\n",
(int) qsg_renderer_timer.elapsed(),
@@ -644,7 +644,7 @@ void QSGPlainTexture::bind()
glGenTextures(1, &m_texture_id);
glBindTexture(GL_TEXTURE_2D, m_texture_id);
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
int bindTime = 0;
if (qsg_render_timing)
bindTime = qsg_renderer_timer.elapsed();
@@ -658,7 +658,7 @@ void QSGPlainTexture::bind()
? m_image
: m_image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
int convertTime = 0;
if (qsg_render_timing)
convertTime = qsg_renderer_timer.elapsed();
@@ -675,8 +675,6 @@ void QSGPlainTexture::bind()
#ifdef QT_OPENGL_ES
internalFormat = GL_BGRA;
#endif
- } else if (strstr(extensions, "GL_APPLE_texture_format_BGRA8888")) {
- externalFormat = GL_BGRA;
} else if (strstr(extensions, "GL_EXT_texture_format_BGRA8888")
|| strstr(extensions, "GL_IMG_texture_format_BGRA8888")) {
externalFormat = GL_BGRA;
@@ -685,14 +683,14 @@ void QSGPlainTexture::bind()
qsg_swizzleBGRAToRGBA(&tmp);
}
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
int swizzleTime = 0;
if (qsg_render_timing)
swizzleTime = qsg_renderer_timer.elapsed();
#endif
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, w, h, 0, externalFormat, GL_UNSIGNED_BYTE, tmp.constBits());
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
int uploadTime = 0;
if (qsg_render_timing)
uploadTime = qsg_renderer_timer.elapsed();
@@ -705,7 +703,7 @@ void QSGPlainTexture::bind()
m_mipmaps_generated = true;
}
-#ifndef QSG_NO_RENDERER_TIMING
+#ifndef QSG_NO_RENDER_TIMING
int mipmapTime = 0;
if (qsg_render_timing) {
mipmapTime = qsg_renderer_timer.elapsed();
diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp
index 8bbd3a788a..f74ad20bc6 100644
--- a/src/quick/util/qquickanimation.cpp
+++ b/src/quick/util/qquickanimation.cpp
@@ -2565,4 +2565,9 @@ QAbstractAnimationJob* QQuickPropertyAnimation::transition(QQuickStateActions &a
return initInstance(animator);
}
+QQuickAnimationPropertyUpdater::~QQuickAnimationPropertyUpdater()
+{
+ if (wasDeleted) *wasDeleted = true;
+}
+
QT_END_NAMESPACE
diff --git a/src/quick/util/qquickanimation_p_p.h b/src/quick/util/qquickanimation_p_p.h
index eb36a702a7..fb5f2d341f 100644
--- a/src/quick/util/qquickanimation_p_p.h
+++ b/src/quick/util/qquickanimation_p_p.h
@@ -303,7 +303,7 @@ class Q_AUTOTEST_EXPORT QQuickAnimationPropertyUpdater : public QQuickBulkValueU
{
public:
QQuickAnimationPropertyUpdater() : interpolatorType(0), interpolator(0), prevInterpolatorType(0), reverse(false), fromSourced(false), fromDefined(false), wasDeleted(0) {}
- ~QQuickAnimationPropertyUpdater() { if (wasDeleted) *wasDeleted = true; }
+ ~QQuickAnimationPropertyUpdater();
void setValue(qreal v);
diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp
index 4d17399222..3ea1bc73ad 100644
--- a/src/quick/util/qquickglobal.cpp
+++ b/src/quick/util/qquickglobal.cpp
@@ -1014,6 +1014,6 @@ static bool initializeProviders()
return true;
}
-static bool initialized = initializeProviders();
+Q_CONSTRUCTOR_FUNCTION(initializeProviders)
QT_END_NAMESPACE