aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@jollamobile.com>2014-08-07 11:31:23 +0200
committerGunnar Sletta <gunnar.sletta@jollamobile.com>2014-08-07 11:31:23 +0200
commit9737b35ac0638dd301b670e940f4e424aab4b4f3 (patch)
tree2f0225f0f2b05d8422126b2b91a7f0fc73e93700 /src
parent0a43c561891a46477c4e78f6a6d05fd9731ebb04 (diff)
parent3f5141e5b7227630ca89329a92b6ebddbcb1b7a5 (diff)
Merge branch '5.3' into dev
Conflicts: src/quick/items/context2d/qquickcontext2d.cpp src/quick/items/context2d/qquickcontext2dtexture.cpp Change-Id: I1a9b911b3a92333a5dddbaf43275f71bad2006f0
Diffstat (limited to 'src')
-rw-r--r--src/qml/qml/qqmlcomponent.cpp1
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp25
-rw-r--r--src/qml/types/qqmldelegatemodel_p.h2
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp14
-rw-r--r--src/quick/items/context2d/qquickcontext2d_p.h3
-rw-r--r--src/quick/items/context2d/qquickcontext2dtexture.cpp50
-rw-r--r--src/quick/items/context2d/qquickcontext2dtexture_p.h10
-rw-r--r--src/quick/items/qquickwindow.cpp9
8 files changed, 75 insertions, 39 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 616f54d174..e087785901 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -1542,7 +1542,6 @@ void QmlIncubatorObject::statusChanged(QQmlIncubator::Status s)
callData->args[0] = QV4::Primitive::fromUInt32(s);
f->call(callData);
if (scope.hasException()) {
- ctx->catchException();
QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
QQmlEnginePrivate::warning(QQmlEnginePrivate::get(d()->v8->engine()), error);
}
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index e2f1cffb16..91ddcf57e5 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -1526,6 +1526,18 @@ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelInd
_q_itemsChanged(begin.row(), end.row() - begin.row() + 1, roles);
}
+bool QQmlDelegateModel::isDescendantOf(const QPersistentModelIndex& desc, const QList< QPersistentModelIndex >& parents) const
+{
+ for (int i = 0, c = parents.count(); i < c; ++i) {
+ for (QPersistentModelIndex parent = desc; parent.isValid(); parent = parent.parent()) {
+ if (parent == parents[i])
+ return true;
+ }
+ }
+
+ return false;
+}
+
void QQmlDelegateModel::_q_layoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint)
{
Q_D(QQmlDelegateModel);
@@ -1534,8 +1546,9 @@ void QQmlDelegateModel::_q_layoutAboutToBeChanged(const QList<QPersistentModelIn
if (hint == QAbstractItemModel::VerticalSortHint) {
d->m_storedPersistentIndexes.clear();
- if (!parents.contains(d->m_adaptorModel.rootIndex))
+ if (!parents.isEmpty() && d->m_adaptorModel.rootIndex.isValid() && !isDescendantOf(d->m_adaptorModel.rootIndex, parents)) {
return;
+ }
for (int i = 0; i < d->m_count; ++i) {
const QModelIndex index = d->m_adaptorModel.aim()->index(i, 0, d->m_adaptorModel.rootIndex);
@@ -1555,20 +1568,16 @@ void QQmlDelegateModel::_q_layoutChanged(const QList<QPersistentModelIndex> &par
return;
if (hint == QAbstractItemModel::VerticalSortHint) {
- if (!parents.contains(d->m_adaptorModel.rootIndex))
+ if (!parents.isEmpty() && d->m_adaptorModel.rootIndex.isValid() && !isDescendantOf(d->m_adaptorModel.rootIndex, parents)) {
return;
+ }
for (int i = 0, c = d->m_storedPersistentIndexes.count(); i < c; ++i) {
const QPersistentModelIndex &index = d->m_storedPersistentIndexes.at(i);
if (i == index.row())
continue;
- QVector<Compositor::Insert> inserts;
- QVector<Compositor::Remove> removes;
- d->m_compositor.listItemsMoved(&d->m_adaptorModel, i, index.row(), 1, &removes, &inserts);
- if (!removes.isEmpty() || !inserts.isEmpty()) {
- d->itemsMoved(removes, inserts);
- }
+ _q_itemsMoved(i, index.row(), 1);
}
d->m_storedPersistentIndexes.clear();
diff --git a/src/qml/types/qqmldelegatemodel_p.h b/src/qml/types/qqmldelegatemodel_p.h
index 0b67179163..53cc94bbdf 100644
--- a/src/qml/types/qqmldelegatemodel_p.h
+++ b/src/qml/types/qqmldelegatemodel_p.h
@@ -143,6 +143,8 @@ private Q_SLOTS:
void _q_layoutChanged(const QList<QPersistentModelIndex>&, QAbstractItemModel::LayoutChangeHint);
private:
+ bool isDescendantOf(const QPersistentModelIndex &desc, const QList<QPersistentModelIndex> &parents) const;
+
Q_DISABLE_COPY(QQmlDelegateModel)
};
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index 4b70934320..57c7bd4a00 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -4031,6 +4031,8 @@ public:
void run() Q_DECL_OVERRIDE { delete texture; }
};
+QMutex QQuickContext2D::mutex;
+
QQuickContext2D::QQuickContext2D(QObject *parent)
: QQuickCanvasContext(parent)
, m_buffer(new QQuickContext2DCommandBuffer)
@@ -4044,6 +4046,8 @@ QQuickContext2D::QQuickContext2D(QObject *parent)
QQuickContext2D::~QQuickContext2D()
{
+ mutex.lock();
+ m_texture->setItem(0);
delete m_buffer;
if (m_renderTarget == QQuickCanvasItem::FramebufferObject) {
@@ -4064,7 +4068,7 @@ QQuickContext2D::~QQuickContext2D()
c->texture = m_texture;
m_canvas->window()->scheduleRenderJob(c, QQuickWindow::AfterSynchronizingStage);
} else {
- delete m_texture;
+ m_texture->deleteLater();
}
}
} else {
@@ -4073,6 +4077,7 @@ QQuickContext2D::~QQuickContext2D()
// currently be doing.
m_texture->deleteLater();
}
+ mutex.unlock();
}
QV4::ReturnedValue QQuickContext2D::v4value() const
@@ -4143,6 +4148,7 @@ void QQuickContext2D::init(QQuickCanvasItem *canvasItem, const QVariantMap &args
m_glContext->setShareContext(cc);
if (renderThread != QThread::currentThread())
m_glContext->moveToThread(renderThread);
+ m_texture->initializeOpenGL(m_glContext, m_surface.data());
}
connect(m_texture, SIGNAL(textureChanged()), SIGNAL(textureChanged()));
@@ -4331,10 +4337,4 @@ void QQuickContext2D::setV8Engine(QV8Engine *engine)
}
}
-QQuickContext2DCommandBuffer* QQuickContext2D::nextBuffer()
-{
- QMutexLocker lock(&m_mutex);
- return m_bufferQueue.isEmpty() ? 0 : m_bufferQueue.dequeue();
-}
-
QT_END_NAMESPACE
diff --git a/src/quick/items/context2d/qquickcontext2d_p.h b/src/quick/items/context2d/qquickcontext2d_p.h
index bd1a83ce08..c679bc33cb 100644
--- a/src/quick/items/context2d/qquickcontext2d_p.h
+++ b/src/quick/items/context2d/qquickcontext2d_p.h
@@ -185,7 +185,6 @@ public:
QQuickCanvasItem* canvas() const { return m_canvas; }
QQuickContext2DCommandBuffer* buffer() const { return m_buffer; }
- QQuickContext2DCommandBuffer* nextBuffer();
bool bufferValid() const { return m_buffer != 0; }
void popState();
@@ -255,7 +254,7 @@ public:
QImage m_grabbedImage;
bool m_grabbed:1;
- QMutex m_mutex;
+ static QMutex mutex;
};
diff --git a/src/quick/items/context2d/qquickcontext2dtexture.cpp b/src/quick/items/context2d/qquickcontext2dtexture.cpp
index 7e88e18c65..17d4feae6b 100644
--- a/src/quick/items/context2d/qquickcontext2dtexture.cpp
+++ b/src/quick/items/context2d/qquickcontext2dtexture.cpp
@@ -90,6 +90,8 @@ struct GLAcquireContext {
QQuickContext2DTexture::QQuickContext2DTexture()
: m_context(0)
+ , m_gl(0)
+ , m_surface(0)
, m_item(0)
, m_canvasWindowChanged(false)
, m_dirtyTexture(false)
@@ -146,8 +148,12 @@ void QQuickContext2DTexture::setAntialiasing(bool antialiasing)
void QQuickContext2DTexture::setItem(QQuickCanvasItem* item)
{
m_item = item;
- m_context = (QQuickContext2D*)item->rawContext(); // FIXME
- m_state = m_context->state;
+ if (m_item) {
+ m_context = (QQuickContext2D*) item->rawContext(); // FIXME
+ m_state = m_context->state;
+ } else {
+ m_context = 0;
+ }
}
bool QQuickContext2DTexture::setCanvasWindow(const QRect& r)
@@ -239,12 +245,15 @@ bool QQuickContext2DTexture::canvasDestroyed()
void QQuickContext2DTexture::paint(QQuickContext2DCommandBuffer *ccb)
{
+ QQuickContext2D::mutex.lock();
if (canvasDestroyed()) {
delete ccb;
+ QQuickContext2D::mutex.unlock();
return;
}
+ QQuickContext2D::mutex.unlock();
- GLAcquireContext currentContext(m_context->glContext(), m_context->surface());
+ GLAcquireContext currentContext(m_gl, m_surface);
if (!m_tiledCanvas) {
paintWithoutTiles(ccb);
@@ -442,7 +451,7 @@ QSGTexture *QQuickContext2DFBOTexture::textureForNextFrame(QSGTexture *lastTextu
}
if (m_dirtyTexture) {
- if (!m_context->glContext()) {
+ if (!m_gl) {
// on a rendering thread, use the fbo directly...
texture->setTextureId(m_fbo->texture());
} else {
@@ -500,18 +509,18 @@ bool QQuickContext2DFBOTexture::doMultisampling() const
void QQuickContext2DFBOTexture::grabImage(const QRectF& rf)
{
Q_ASSERT(rf.isValid());
- if (!m_fbo) {
- m_context->setGrabbedImage(QImage());
- return;
- }
-
- QImage grabbed;
- {
- GLAcquireContext ctx(m_context->glContext(), m_context->surface());
- grabbed = m_fbo->toImage().scaled(m_fboSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).mirrored().copy(rf.toRect());
+ QQuickContext2D::mutex.lock();
+ if (m_context) {
+ if (!m_fbo) {
+ m_context->setGrabbedImage(QImage());
+ } else {
+ QImage grabbed;
+ GLAcquireContext ctx(m_gl, m_surface);
+ grabbed = m_fbo->toImage().scaled(m_fboSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).mirrored().copy(rf.toRect());
+ m_context->setGrabbedImage(grabbed);
+ }
}
-
- m_context->setGrabbedImage(grabbed);
+ QQuickContext2D::mutex.unlock();
}
void QQuickContext2DFBOTexture::compositeTile(QQuickContext2DTile* tile)
@@ -601,7 +610,7 @@ void QQuickContext2DFBOTexture::endPainting()
if (m_multisampledFbo)
QOpenGLFramebufferObject::blitFramebuffer(m_fbo, m_multisampledFbo);
- if (m_context->glContext()) {
+ if (m_gl) {
/* When rendering happens on the render thread, the fbo's texture is
* used directly for display. If we are on the GUI thread or a
* dedicated Canvas render thread, we need to decouple the FBO from
@@ -657,9 +666,12 @@ QQuickContext2DTile* QQuickContext2DImageTexture::createTile() const
void QQuickContext2DImageTexture::grabImage(const QRectF& rf)
{
Q_ASSERT(rf.isValid());
- Q_ASSERT(m_context);
- QImage grabbed = m_displayImage.copy(rf.toRect());
- m_context->setGrabbedImage(grabbed);
+ QQuickContext2D::mutex.lock();
+ if (m_context) {
+ QImage grabbed = m_displayImage.copy(rf.toRect());
+ m_context->setGrabbedImage(grabbed);
+ }
+ QQuickContext2D::mutex.unlock();
}
QSGTexture *QQuickContext2DImageTexture::textureForNextFrame(QSGTexture *last)
diff --git a/src/quick/items/context2d/qquickcontext2dtexture_p.h b/src/quick/items/context2d/qquickcontext2dtexture_p.h
index 7c48453857..169eef8b95 100644
--- a/src/quick/items/context2d/qquickcontext2dtexture_p.h
+++ b/src/quick/items/context2d/qquickcontext2dtexture_p.h
@@ -113,6 +113,11 @@ public:
virtual QSGTexture *textureForNextFrame(QSGTexture *lastFrame) = 0;
bool event(QEvent *e);
+ void initializeOpenGL(QOpenGLContext *gl, QOffscreenSurface *s) {
+ m_gl = gl;
+ m_surface = s;
+ }
+
Q_SIGNALS:
void textureChanged();
@@ -137,7 +142,10 @@ protected:
QRect createTiles(const QRect& window);
QList<QQuickContext2DTile*> m_tiles;
- QQuickContext2D* m_context;
+ QQuickContext2D *m_context;
+
+ QOpenGLContext *m_gl;
+ QSurface *m_surface;
QQuickContext2D::State m_state;
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 04539800a5..fc61ef7d98 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -3226,6 +3226,8 @@ QQmlIncubationController *QQuickWindow::incubationController() const
\warning Make very sure that a signal handler for beforeSynchronizing leaves the GL
context in the same state as it was when the signal handler was entered. Failing to
do so can result in the scene not rendering properly.
+
+ \sa resetOpenGLState()
*/
/*!
@@ -3247,6 +3249,7 @@ QQmlIncubationController *QQuickWindow::incubationController() const
do so can result in the scene not rendering properly.
\since 5.3
+ \sa resetOpenGLState()
*/
/*!
@@ -3267,6 +3270,8 @@ QQmlIncubationController *QQuickWindow::incubationController() const
\warning Make very sure that a signal handler for beforeRendering leaves the GL
context in the same state as it was when the signal handler was entered. Failing to
do so can result in the scene not rendering properly.
+
+ \sa resetOpenGLState()
*/
/*!
@@ -3286,6 +3291,8 @@ QQmlIncubationController *QQuickWindow::incubationController() const
\warning Make very sure that a signal handler for afterRendering() leaves the GL
context in the same state as it was when the signal handler was entered. Failing to
do so can result in the scene not rendering properly.
+
+ \sa resetOpenGLState()
*/
/*!
@@ -3338,7 +3345,7 @@ QQmlIncubationController *QQuickWindow::incubationController() const
context in the same state as it was when the signal handler was entered. Failing to
do so can result in the scene not rendering properly.
- \sa sceneGraphInvalidated()
+ \sa sceneGraphInvalidated(), resetOpenGLState()
\since 5.3
*/