diff options
109 files changed, 972 insertions, 730 deletions
diff --git a/src/3rdparty/v8 b/src/3rdparty/v8 -Subproject dc2cad4f8fc88c52fcea09b8d0262d35cd32dc4 +Subproject 472c04c9e7a64e8734c76d2cf97a7cc5b773b78 diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro index 2d9248ef66..336766b7cf 100644 --- a/src/declarative/declarative.pro +++ b/src/declarative/declarative.pro @@ -6,7 +6,8 @@ QPRO_PWD = $$PWD CONFIG += module MODULE_PRI += ../../modules/qt_declarative.pri -QT = core-private gui-private network opengl-private +QT = core-private gui-private network opengl opengl-private widgets-private sql + contains(QT_CONFIG, svg): QT += svg DEFINES += QT_BUILD_DECLARATIVE_LIB QT_NO_URL_CAST_FROM_STRING win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000 diff --git a/src/declarative/items/context2d/qsgcontext2d.cpp b/src/declarative/items/context2d/qsgcontext2d.cpp index 4cfe1ba012..4d455419ad 100644 --- a/src/declarative/items/context2d/qsgcontext2d.cpp +++ b/src/declarative/items/context2d/qsgcontext2d.cpp @@ -47,9 +47,9 @@ #include <QtCore/qdebug.h> #include "private/qsgcontext_p.h" -#include <QtGui/qgraphicsitem.h> -#include <QtGui/qapplication.h> -#include <QtGui/qgraphicseffect.h> +#include <QtWidgets/qgraphicsitem.h> +#include <QtWidgets/qapplication.h> +#include <QtWidgets/qgraphicseffect.h> #include <qdeclarativeinfo.h> #include <QtCore/qmath.h> #include "qdeclarativepixmapcache_p.h" diff --git a/src/declarative/items/qsgborderimage.cpp b/src/declarative/items/qsgborderimage.cpp index 931a681c1a..8d54bce419 100644 --- a/src/declarative/items/qsgborderimage.cpp +++ b/src/declarative/items/qsgborderimage.cpp @@ -585,11 +585,16 @@ QSGNode *QSGBorderImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData * node->setTexture(texture); - const QSGScaleGrid *border = d->getScaleGrid(); - node->setInnerRect(QRectF(border->left(), - border->top(), - qMax(1, d->pix.width() - border->right() - border->left()), - qMax(1, d->pix.height() - border->bottom() - border->top()))); + // Don't implicitly create the scalegrid in the rendering thread... + if (d->border) { + const QSGScaleGrid *border = d->getScaleGrid(); + node->setInnerRect(QRectF(border->left(), + border->top(), + qMax(1, d->pix.width() - border->right() - border->left()), + qMax(1, d->pix.height() - border->bottom() - border->top()))); + } else { + node->setInnerRect(QRectF(0, 0, width(), height())); + } node->setRect(QRectF(0, 0, width(), height())); node->setFiltering(d->smooth ? QSGTexture::Linear : QSGTexture::Nearest); node->setHorzontalTileMode(d->horizontalTileMode); diff --git a/src/declarative/items/qsgcanvas.cpp b/src/declarative/items/qsgcanvas.cpp index 6873c41cef..0d4001a393 100644 --- a/src/declarative/items/qsgcanvas.cpp +++ b/src/declarative/items/qsgcanvas.cpp @@ -50,12 +50,14 @@ #include <private/qsgrenderer_p.h> #include <private/qsgflashnode_p.h> +#include <private/qguiapplication_p.h> +#include <QtGui/QPlatformInputContext> + #include <private/qabstractanimation_p.h> #include <QtGui/qpainter.h> -#include <QtGui/qgraphicssceneevent.h> +#include <QtWidgets/qgraphicssceneevent.h> #include <QtGui/qmatrix4x4.h> -#include <QtGui/qinputcontext.h> #include <QtCore/qvarlengtharray.h> #include <QtCore/qabstractanimation.h> @@ -63,7 +65,6 @@ QT_BEGIN_NAMESPACE -DEFINE_BOOL_CONFIG_OPTION(qmlNoThreadedRenderer, QML_NO_THREADED_RENDERER) DEFINE_BOOL_CONFIG_OPTION(qmlFixedAnimationStep, QML_FIXED_ANIMATION_STEP) extern Q_OPENGL_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); @@ -165,134 +166,40 @@ QSGRootItem::QSGRootItem() { } -void QSGCanvas::paintEvent(QPaintEvent *) +void QSGCanvas::exposeEvent(QExposeEvent *) { Q_D(QSGCanvas); - - if (!d->threadedRendering) { -#ifdef FRAME_TIMING - int lastFrame = frameTimer.restart(); -#endif - - if (d->animationDriver && d->animationDriver->isRunning()) - d->animationDriver->advance(); - -#ifdef FRAME_TIMING - int animationTime = frameTimer.elapsed(); -#endif - - Q_ASSERT(d->context); - - d->polishItems(); - - QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::FramePaint); - QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Painting); - -#ifdef FRAME_TIMING - int polishTime = frameTimer.elapsed(); -#endif - - makeCurrent(); - -#ifdef FRAME_TIMING - int makecurrentTime = frameTimer.elapsed(); -#endif - - d->syncSceneGraph(); - -#ifdef FRAME_TIMING - int syncTime = frameTimer.elapsed(); -#endif - - d->renderSceneGraph(d->widgetSize); - - swapBuffers(); - -#ifdef FRAME_TIMING - printf("FrameTimes, last=%d, animations=%d, polish=%d, makeCurrent=%d, sync=%d, sgrender=%d, readback=%d, total=%d\n", - lastFrame, - animationTime, - polishTime - animationTime, - makecurrentTime - polishTime, - syncTime - makecurrentTime, - sceneGraphRenderTime - syncTime, - readbackTime - sceneGraphRenderTime, - frameTimer.elapsed()); -#endif - - QDeclarativeDebugTrace::endRange(QDeclarativeDebugTrace::Painting); - - if (d->animationDriver && d->animationDriver->isRunning()) - update(); - } else { - if (updatesEnabled()) { - d->thread->paint(); - setUpdatesEnabled(false); - } - } + d->thread->paint(); } void QSGCanvas::resizeEvent(QResizeEvent *e) { Q_D(QSGCanvas); - if (d->threadedRendering) { - d->thread->resize(e->size()); - } else { - d->widgetSize = e->size(); - d->viewportSize = d->widgetSize; - QGLWidget::resizeEvent(e); - } + d->thread->resize(size()); } void QSGCanvas::showEvent(QShowEvent *e) { Q_D(QSGCanvas); - - QGLWidget::showEvent(e); - - if (!d->contextFailed) { - if (d->threadedRendering) { - if (d->vsyncAnimations) { - if (!d->animationDriver) { - d->animationDriver = d->context->createAnimationDriver(this); - connect(d->animationDriver, SIGNAL(started()), d->thread, SLOT(animationStarted()), Qt::DirectConnection); - connect(d->animationDriver, SIGNAL(stopped()), d->thread, SLOT(animationStopped()), Qt::DirectConnection); - } - d->animationDriver->install(); - } - d->thread->startRenderThread(); - setUpdatesEnabled(true); - } else { - makeCurrent(); - - if (!d->context || !d->context->isReady()) { - d->initializeSceneGraph(); - if (d->vsyncAnimations) { - d->animationDriver = d->context->createAnimationDriver(this); - connect(d->animationDriver, SIGNAL(started()), this, SLOT(update())); - } - } - - if (d->animationDriver) - d->animationDriver->install(); + if (d->vsyncAnimations) { + if (!d->animationDriver) { + d->animationDriver = d->context->createAnimationDriver(this); + connect(d->animationDriver, SIGNAL(started()), d->thread, SLOT(animationStarted()), Qt::DirectConnection); + connect(d->animationDriver, SIGNAL(stopped()), d->thread, SLOT(animationStopped()), Qt::DirectConnection); } + d->animationDriver->install(); + } + + if (!d->thread->isRunning()) { + d->thread->windowSize = size(); + d->thread->startRenderThread(); } } void QSGCanvas::hideEvent(QHideEvent *e) { Q_D(QSGCanvas); - - if (!d->contextFailed) { - if (d->threadedRendering) { - d->thread->stopRenderThread(); - } - - if (d->animationDriver) - d->animationDriver->uninstall(); - } - - QGLWidget::hideEvent(e); + d->thread->stopRenderThread(); } @@ -313,7 +220,7 @@ void QSGCanvas::hideEvent(QHideEvent *e) void QSGCanvas::setVSyncAnimations(bool enabled) { Q_D(QSGCanvas); - if (isVisible()) { + if (visible()) { qWarning("QSGCanvas::setVSyncAnimations: Cannot be changed when widget is shown"); return; } @@ -332,22 +239,28 @@ bool QSGCanvas::vsyncAnimations() const return d->vsyncAnimations; } - - -void QSGCanvas::focusOutEvent(QFocusEvent *event) +/*! + This function is an attempt to localize all uses of QInputContext::update in + one place up until the point where we have public API for the QInputContext API. + */ +void QSGCanvasPrivate::updateInputContext() { - Q_D(QSGCanvas); - d->rootItem->setFocus(false); - QGLWidget::focusOutEvent(event); + QPlatformInputContext *ic = QGuiApplicationPrivate::platformIntegration()->inputContext(); + if (ic) + ic->update(); } - -void QSGCanvas::focusInEvent(QFocusEvent *event) +/*! + This function is an attempt to localize all uses of QInputContext::reset in + one place up until the point where we have public API for the QInputContext API. + */ +void QSGCanvasPrivate::resetInputContext() { - Q_D(QSGCanvas); - d->rootItem->setFocus(true); - QGLWidget::focusInEvent(event); + QPlatformInputContext *ic = QGuiApplicationPrivate::platformIntegration()->inputContext(); + if (ic) + ic->reset(); } + void QSGCanvasPrivate::initializeSceneGraph() { if (!context) @@ -359,11 +272,9 @@ void QSGCanvasPrivate::initializeSceneGraph() QGLContext *glctx = const_cast<QGLContext *>(QGLContext::currentContext()); context->initialize(glctx); - if (!threadedRendering) { - Q_Q(QSGCanvas); - QObject::connect(context->renderer(), SIGNAL(sceneGraphChanged()), q, SLOT(maybeUpdate()), - Qt::DirectConnection); - } + Q_Q(QSGCanvas); + QObject::connect(context->renderer(), SIGNAL(sceneGraphChanged()), q, SLOT(maybeUpdate()), + Qt::DirectConnection); if (!QSGItemPrivate::get(rootItem)->itemNode()->parent()) { context->rootNode()->appendChildNode(QSGItemPrivate::get(rootItem)->itemNode()); @@ -417,15 +328,12 @@ void QSGCanvas::sceneGraphChanged() // d->needsRepaint = true; } - QSGCanvasPrivate::QSGCanvasPrivate() : rootItem(0) , activeFocusItem(0) , mouseGrabberItem(0) , dirtyItemList(0) , context(0) - , contextFailed(false) - , threadedRendering(false) , animationRunning(false) , renderThreadAwakened(false) , vsyncAnimations(false) @@ -433,7 +341,6 @@ QSGCanvasPrivate::QSGCanvasPrivate() , animationDriver(0) , renderTarget(0) { - threadedRendering = !qmlNoThreadedRenderer(); } QSGCanvasPrivate::~QSGCanvasPrivate() @@ -444,31 +351,25 @@ void QSGCanvasPrivate::init(QSGCanvas *c) { QUnifiedTimer::instance(true)->setConsistentTiming(qmlFixedAnimationStep()); - if (!c->context() || !c->context()->isValid()) { - contextFailed = true; - qWarning("QSGCanvas: Couldn't acquire a GL context."); - } - q_ptr = c; Q_Q(QSGCanvas); - q->setAttribute(Qt::WA_AcceptTouchEvents); - q->setFocusPolicy(Qt::StrongFocus); - rootItem = new QSGRootItem; QSGItemPrivate *rootItemPrivate = QSGItemPrivate::get(rootItem); rootItemPrivate->canvas = q; rootItemPrivate->flags |= QSGItem::ItemIsFocusScope; - context = QSGContext::createDefaultContext(); + // QML always has focus. It is important that this call happens after the rootItem + // has a canvas.. + rootItem->setFocus(true); - if (threadedRendering) { - thread = new QSGCanvasRenderThread; - thread->renderer = q; - thread->d = this; - } + thread = new QSGCanvasRenderThread; + thread->renderer = q; + thread->d = this; + context = QSGContext::createDefaultContext(); + context->moveToThread(thread); } void QSGCanvasPrivate::sceneMouseEventForTransform(QGraphicsSceneMouseEvent &sceneEvent, @@ -516,8 +417,6 @@ Fill in the data in \a sceneEvent based on \a event. This method leaves the ite */ void QSGCanvasPrivate::sceneMouseEventFromMouseEvent(QGraphicsSceneMouseEvent &sceneEvent, QMouseEvent *event) { - Q_Q(QSGCanvas); - Q_ASSERT(event); if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick) { @@ -549,16 +448,16 @@ void QSGCanvasPrivate::sceneMouseEventFromMouseEvent(QGraphicsSceneMouseEvent &s sceneEvent.setScenePos(event->pos()); sceneEvent.setScreenPos(event->globalPos()); sceneEvent.setLastScenePos(lastMousePosition); - sceneEvent.setLastScreenPos(q->mapToGlobal(lastMousePosition)); + sceneEvent.setLastScreenPos(lastMousePosition); // ### refactor: should do mapToGlobal sceneEvent.setButtons(event->buttons()); sceneEvent.setButton(event->button()); sceneEvent.setModifiers(event->modifiers()); - sceneEvent.setWidget(q); +// sceneEvent.setWidget(q); // ### refactor: for (int ii = 0; ii < 5; ++ii) { if (sceneEvent.buttons() & (1 << ii)) { sceneEvent.setButtonDownScenePos((Qt::MouseButton)(1 << ii), buttonDownPositions[ii]); - sceneEvent.setButtonDownScreenPos((Qt::MouseButton)(1 << ii), q->mapToGlobal(buttonDownPositions[ii])); + sceneEvent.setButtonDownScreenPos((Qt::MouseButton)(1 << ii), buttonDownPositions[ii]); // ### refactor: should do mapToGlobal } } @@ -571,9 +470,9 @@ Translates the data in \a touchEvent to this canvas. This method leaves the ite */ void QSGCanvasPrivate::translateTouchEvent(QTouchEvent *touchEvent) { - Q_Q(QSGCanvas); +// Q_Q(QSGCanvas); - touchEvent->setWidget(q); +// touchEvent->setWidget(q); // ### refactor... QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints(); for (int i = 0; i < touchPoints.count(); ++i) { @@ -626,8 +525,7 @@ void QSGCanvasPrivate::setFocusInScope(QSGItem *scope, QSGItem *item, FocusOptio if (oldActiveFocusItem) { #ifndef QT_NO_IM - if (QInputContext *ic = inputContext()) - ic->reset(); + resetInputContext(); #endif activeFocusItem = 0; @@ -671,13 +569,13 @@ void QSGCanvasPrivate::setFocusInScope(QSGItem *scope, QSGItem *item, FocusOptio } if (!(options & DontChangeFocusProperty)) { - if (item != rootItem || q->hasFocus()) { + // if (item != rootItem || q->hasFocus()) { // ### refactor: focus handling... itemPrivate->focus = true; changed << item; - } + // } } - if (newActiveFocusItem && q->hasFocus()) { + if (newActiveFocusItem) { // ### refactor: && q->hasFocus()) { activeFocusItem = newActiveFocusItem; QSGItemPrivate::get(newActiveFocusItem)->activeFocus = true; @@ -736,8 +634,7 @@ void QSGCanvasPrivate::clearFocusInScope(QSGItem *scope, QSGItem *item, FocusOpt Q_ASSERT(oldActiveFocusItem); #ifndef QT_NO_IM - if (QInputContext *ic = inputContext()) - ic->reset(); + resetInputContext(); #endif activeFocusItem = 0; @@ -816,11 +713,12 @@ void QSGCanvasPrivate::notifyFocusChangesRecur(QSGItem **items, int remaining) void QSGCanvasPrivate::updateInputMethodData() { - Q_Q(QSGCanvas); - bool enabled = activeFocusItem - && (QSGItemPrivate::get(activeFocusItem)->flags & QSGItem::ItemAcceptsInputMethod); - q->setAttribute(Qt::WA_InputMethodEnabled, enabled); - q->setInputMethodHints(enabled ? activeFocusItem->inputMethodHints() : Qt::ImhNone); + // Q_Q(QSGCanvas); + // ### refactor: port.. +// bool enabled = activeFocusItem +// && (QSGItemPrivate::get(activeFocusItem)->flags & QSGItem::ItemAcceptsInputMethod); +// q->setAttribute(Qt::WA_InputMethodEnabled, enabled); +// q->setInputMethodHints(enabled ? activeFocusItem->inputMethodHints() : Qt::ImhNone); } QVariant QSGCanvas::inputMethodQuery(Qt::InputMethodQuery query) const @@ -857,42 +755,18 @@ void QSGCanvasPrivate::cleanup(QSGNode *n) q->maybeUpdate(); } -static QGLFormat tweakFormat(const QGLFormat &format = QGLFormat::defaultFormat()) -{ - QGLFormat f = format; - f.setSwapInterval(0); - return f; -} - -QSGCanvas::QSGCanvas(QWidget *parent, Qt::WindowFlags f) - : QGLWidget(*(new QSGCanvasPrivate), tweakFormat(), parent, (QGLWidget *) 0, f) -{ - Q_D(QSGCanvas); - d->init(this); -} - -QSGCanvas::QSGCanvas(const QGLFormat &format, QWidget *parent, Qt::WindowFlags f) - : QGLWidget(*(new QSGCanvasPrivate), tweakFormat(format), parent, (QGLWidget *) 0, f) +QSGCanvas::QSGCanvas(QWindow *parent) + : QWindow(parent) { Q_D(QSGCanvas); - d->init(this); } -QSGCanvas::QSGCanvas(QSGCanvasPrivate &dd, QWidget *parent, Qt::WindowFlags f) -: QGLWidget(dd, tweakFormat(), parent, 0, f) +QSGCanvas::QSGCanvas(QSGCanvasPrivate &dd, QWindow *parent) + : QWindow(dd, parent) { Q_D(QSGCanvas); - - d->init(this); -} - -QSGCanvas::QSGCanvas(QSGCanvasPrivate &dd, const QGLFormat &format, QWidget *parent, Qt::WindowFlags f) -: QGLWidget(dd, tweakFormat(format), parent, 0, f) -{ - Q_D(QSGCanvas); - d->init(this); } @@ -900,7 +774,7 @@ QSGCanvas::~QSGCanvas() { Q_D(QSGCanvas); - if (d->threadedRendering && d->thread->isRunning()) { + if (d->thread->isRunning()) { d->thread->stopRenderThread(); delete d->thread; d->thread = 0; @@ -913,21 +787,6 @@ QSGCanvas::~QSGCanvas() delete d->rootItem; d->rootItem = 0; d->cleanupNodes(); - - if (!d->contextFailed) { - // We need to remove all references to textures pointing to "our" QSGContext - // from the QDeclarativePixmapCache. Call into the cache to remove the GL / Scene Graph - // part of those cache entries. - // To "play nice" with other GL apps that are potentially running in the GUI thread, - // We get the current context and only temporarily make our own current - QGLContext *currentContext = const_cast<QGLContext *>(QGLContext::currentContext()); - makeCurrent(); - extern void qt_declarative_pixmapstore_clean(QSGContext *context); - qt_declarative_pixmapstore_clean(d->context); - delete d->context; - if (currentContext) - currentContext->makeCurrent(); - } } QSGItem *QSGCanvas::rootItem() const @@ -958,7 +817,7 @@ bool QSGCanvasPrivate::clearHover() if (hoverItems.isEmpty()) return false; - QPointF pos = q->mapFromGlobal(QCursor::pos()); + QPointF pos = QCursor::pos(); // ### refactor: q->mapFromGlobal(QCursor::pos()); bool accepted = false; foreach (QSGItem* item, hoverItems) @@ -1022,7 +881,7 @@ bool QSGCanvas::event(QEvent *e) break; } - return QGLWidget::event(e); + return QWindow::event(e); } void QSGCanvas::keyPressEvent(QKeyEvent *e) @@ -1137,7 +996,7 @@ void QSGCanvas::mouseReleaseEvent(QMouseEvent *event) #endif if (!d->mouseGrabberItem) { - QGLWidget::mouseReleaseEvent(event); + QWindow::mouseReleaseEvent(event); return; } @@ -1462,7 +1321,7 @@ bool QSGCanvasPrivate::deliverTouchPoints(QSGItem *item, QTouchEvent *event, con if (eventStates != Qt::TouchPointStationary) { QTouchEvent touchEvent(eventType); - touchEvent.setWidget(q); + // touchEvent.setWidget(q); // ### refactor: what is the consequence of not setting the widget? touchEvent.setDeviceType(event->deviceType()); touchEvent.setModifiers(event->modifiers()); touchEvent.setTouchPointStates(eventStates); @@ -1916,7 +1775,7 @@ void QSGCanvas::maybeUpdate() { Q_D(QSGCanvas); - if (d->threadedRendering && d->thread && d->thread->isRunning()) { + if (d->thread && d->thread->isRunning()) { Q_ASSERT_X(QThread::currentThread() == QApplication::instance()->thread() || d->thread->inSync, "QSGCanvas::update", "Function can only be called from GUI thread or during QSGItem::updatePaintNode()"); @@ -1935,8 +1794,6 @@ void QSGCanvas::maybeUpdate() d->thread->wake(); d->thread->unlockInGui(); } - } else if (!d->animationDriver || !d->animationDriver->isRunning()) { - update(); } } @@ -2009,17 +1866,13 @@ QGLFramebufferObject *QSGCanvas::renderTarget() const This function might not work if the view is not visible. \warning Calling this function will cause performance problems. + + \warning This function can only be called from the GUI thread. */ QImage QSGCanvas::grabFrameBuffer() { Q_D(QSGCanvas); - if (d->threadedRendering) - return d->thread ? d->thread->grab() : QImage(); - else { - // render a fresh copy of the scene graph in the current thread. - d->renderSceneGraph(size()); - return QGLWidget::grabFrameBuffer(false); - } + return d->thread ? d->thread->grab() : QImage(); } @@ -2029,11 +1882,15 @@ void QSGCanvasRenderThread::run() qDebug("QML Rendering Thread Started"); #endif - renderer->makeCurrent(); + if (!guiContext) { + guiContext = new QGuiGLContext(); + guiContext->create(); + guiContext->makeCurrent(renderer); - if (!d->context->isReady()) d->initializeSceneGraph(); - + } else { + guiContext->makeCurrent(renderer); + } while (!shouldExit) { lock(); @@ -2104,8 +1961,8 @@ void QSGCanvasRenderThread::run() printf(" RenderThread: wait for swap...\n"); #endif - renderer->swapBuffers(); - + guiContext->swapBuffers(renderer); + emit renderer->frameSwapped();//notify compositor that frame has been swapped #ifdef THREAD_DEBUG printf(" RenderThread: swap complete...\n"); #endif @@ -2131,13 +1988,16 @@ void QSGCanvasRenderThread::run() } unlock(); + + // Process any "deleteLater" objects... + QCoreApplication::processEvents(); } #ifdef THREAD_DEBUG - printf(" RenderThread: exited... Good Night!\n"); + printf(" RenderThread: render loop exited... Good Night!\n"); #endif - renderer->doneCurrent(); + guiContext->doneCurrent(); lock(); hasExited = true; @@ -2146,6 +2006,10 @@ void QSGCanvasRenderThread::run() #endif wake(); unlock(); + +#ifdef THREAD_DEBUG + printf(" RenderThread: All done...\n"); +#endif } @@ -2165,8 +2029,6 @@ void QSGCanvasRenderThread::sync(bool guiAlreadyLocked) #ifdef THREAD_DEBUG printf("GUI: sync - %s\n", guiAlreadyLocked ? "outside event" : "inside event"); #endif - Q_ASSERT(d->threadedRendering); - if (!guiAlreadyLocked) d->thread->lockInGui(); @@ -2266,10 +2128,6 @@ void QSGCanvasRenderThread::paint() wait(); } unlockInGui(); - - // paint is only called for the inital show. After that we will do all - // drawing ourselves, so block future updates.. - renderer->setUpdatesEnabled(false); } @@ -2309,8 +2167,6 @@ void QSGCanvasRenderThread::startRenderThread() shouldExit = false; isGuiBlocked = 0; isGuiBlockPending = false; - - renderer->doneCurrent(); start(); } @@ -2348,6 +2204,11 @@ void QSGCanvasRenderThread::stopRenderThread() // Actually wait for the thread to terminate. Otherwise we can delete it // too early and crash. QThread::wait(); + +#ifdef THREAD_DEBUG + printf("GUI: thread has terminated and we're all good..\n"); +#endif + } @@ -2357,6 +2218,11 @@ QImage QSGCanvasRenderThread::grab() if (!isRunning()) return QImage(); + if (QThread::currentThread() != qApp->thread()) { + qWarning("QSGCanvas::grabFrameBuffer: can only be called from the GUI thread"); + return QImage(); + } + #ifdef THREAD_DEBUG printf("GUI: doing a pixelwise grab..\n"); #endif diff --git a/src/declarative/items/qsgcanvas.h b/src/declarative/items/qsgcanvas.h index a5f69ff559..86efdcbfdc 100644 --- a/src/declarative/items/qsgcanvas.h +++ b/src/declarative/items/qsgcanvas.h @@ -44,7 +44,7 @@ #include <QtCore/qmetatype.h> #include <QtOpenGL/qgl.h> -#include <QtGui/qwidget.h> +#include <QtWidgets/qwidget.h> QT_BEGIN_HEADER @@ -57,13 +57,13 @@ class QSGEngine; class QSGCanvasPrivate; class QGLFramebufferObject; -class Q_DECLARATIVE_EXPORT QSGCanvas : public QGLWidget +class Q_DECLARATIVE_EXPORT QSGCanvas : public QWindow { Q_OBJECT Q_DECLARE_PRIVATE(QSGCanvas) public: - QSGCanvas(QWidget *parent = 0, Qt::WindowFlags f = 0); - QSGCanvas(const QGLFormat &format, QWidget *parent = 0, Qt::WindowFlags f = 0); + QSGCanvas(QWindow *parent = 0); + virtual ~QSGCanvas(); QSGItem *rootItem() const; @@ -85,22 +85,21 @@ public: void setRenderTarget(QGLFramebufferObject *fbo); QGLFramebufferObject *renderTarget() const; +signals: + void frameSwapped(); + Q_SIGNALS: void sceneGraphInitialized(); protected: - QSGCanvas(QSGCanvasPrivate &dd, QWidget *parent = 0, Qt::WindowFlags f = 0); - QSGCanvas(QSGCanvasPrivate &dd, const QGLFormat &format, QWidget *parent = 0, Qt::WindowFlags f = 0); + QSGCanvas(QSGCanvasPrivate &dd, QWindow *parent = 0); - virtual void paintEvent(QPaintEvent *); + virtual void exposeEvent(QExposeEvent *); virtual void resizeEvent(QResizeEvent *); virtual void showEvent(QShowEvent *); virtual void hideEvent(QHideEvent *); - virtual void focusOutEvent(QFocusEvent *); - virtual void focusInEvent(QFocusEvent *); - virtual bool event(QEvent *); virtual void keyPressEvent(QKeyEvent *); virtual void keyReleaseEvent(QKeyEvent *); @@ -119,6 +118,7 @@ private Q_SLOTS: private: friend class QSGItem; + friend class QSGCanvasRenderThread; Q_DISABLE_COPY(QSGCanvas) }; diff --git a/src/declarative/items/qsgcanvas_p.h b/src/declarative/items/qsgcanvas_p.h index d26b311e59..bf65e95812 100644 --- a/src/declarative/items/qsgcanvas_p.h +++ b/src/declarative/items/qsgcanvas_p.h @@ -64,7 +64,9 @@ #include <QtCore/qmutex.h> #include <QtCore/qwaitcondition.h> #include <private/qwidget_p.h> +#include <private/qwindow_p.h> #include <private/qgl_p.h> +#include <qguiglcontext_qpa.h> #include <QtOpenGL/qglframebufferobject.h> QT_BEGIN_NAMESPACE @@ -82,7 +84,7 @@ class QSGCanvasPrivate; class QTouchEvent; class QSGCanvasRenderThread; -class QSGCanvasPrivate : public QGLWidgetPrivate +class QSGCanvasPrivate : public QWindowPrivate { public: Q_DECLARE_PUBLIC(QSGCanvas) @@ -141,6 +143,9 @@ public: void syncSceneGraph(); void renderSceneGraph(const QSize &size); + void updateInputContext(); + void resetInputContext(); + QSGItem::UpdatePaintNodeData updatePaintNodeData; QSGItem *dirtyItemList; @@ -156,8 +161,6 @@ public: QSGContext *context; - uint contextFailed : 1; - uint threadedRendering : 1; uint animationRunning: 1; uint renderThreadAwakened : 1; @@ -182,6 +185,7 @@ class QSGCanvasRenderThread : public QThread public: QSGCanvasRenderThread() : mutex(QMutex::NonRecursive) + , guiContext(0) , isGuiBlocked(0) , isPaintCompleted(false) , isGuiBlockPending(false) @@ -225,6 +229,8 @@ public: QSGCanvas *renderer; QSGCanvasPrivate *d; + QGuiGLContext *guiContext; + int isGuiBlocked; uint isPaintCompleted : 1; uint isGuiBlockPending : 1; diff --git a/src/declarative/items/qsgflickable.cpp b/src/declarative/items/qsgflickable.cpp index d62197f7d6..e63698eca7 100644 --- a/src/declarative/items/qsgflickable.cpp +++ b/src/declarative/items/qsgflickable.cpp @@ -45,8 +45,8 @@ #include "qsgcanvas_p.h" #include <QtDeclarative/qdeclarativeinfo.h> -#include <QtGui/qgraphicssceneevent.h> -#include <QtGui/qapplication.h> +#include <QtWidgets/qgraphicssceneevent.h> +#include <QtWidgets/qapplication.h> #include "qplatformdefs.h" QT_BEGIN_NAMESPACE diff --git a/src/declarative/items/qsgimage.cpp b/src/declarative/items/qsgimage.cpp index e2e766ff0a..cb12c177cd 100644 --- a/src/declarative/items/qsgimage.cpp +++ b/src/declarative/items/qsgimage.cpp @@ -42,6 +42,8 @@ #include "qsgimage_p.h" #include "qsgimage_p_p.h" +#include <private/qsgtextureprovider_p.h> + #include <private/qsgcontext_p.h> #include <private/qsgadaptationlayer_p.h> @@ -50,6 +52,36 @@ QT_BEGIN_NAMESPACE +class QSGImageTextureProvider : public QSGTextureProvider +{ + Q_OBJECT +public: + QSGImageTextureProvider(const QSGImage *imageItem) + : d((QSGImagePrivate *) QSGItemPrivate::get(imageItem)) + , m_texture(0) + , m_smooth(false) + { + } + + QSGTexture *texture() const { + if (m_texture) { + m_texture->setFiltering(m_smooth ? QSGTexture::Linear : QSGTexture::Nearest); + m_texture->setMipmapFiltering(QSGTexture::Nearest); + m_texture->setHorizontalWrapMode(QSGTexture::ClampToEdge); + m_texture->setVerticalWrapMode(QSGTexture::ClampToEdge); + } + return m_texture; + } + + friend class QSGImage; + + QSGImagePrivate *d; + QSGTexture *m_texture; + bool m_smooth; +}; + +#include "qsgimage.moc" + QSGImagePrivate::QSGImagePrivate() : fillMode(QSGImage::Stretch) , paintedWidth(0) @@ -57,6 +89,7 @@ QSGImagePrivate::QSGImagePrivate() , pixmapChanged(false) , hAlign(QSGImage::AlignHCenter) , vAlign(QSGImage::AlignVCenter) + , provider(0) { } @@ -127,6 +160,9 @@ QSGImage::QSGImage(QSGImagePrivate &dd, QSGItem *parent) QSGImage::~QSGImage() { + Q_D(QSGImage); + if (d->provider) + d->provider->deleteLater(); } void QSGImagePrivate::setPixmap(const QPixmap &pixmap) @@ -500,17 +536,20 @@ QRectF QSGImage::boundingRect() const return QRectF(0, 0, qMax(width(), d->paintedWidth), qMax(height(), d->paintedHeight)); } -QSGTexture *QSGImage::texture() const +QSGTextureProvider *QSGImage::textureProvider() const { Q_D(const QSGImage); - QSGTexture *t = d->pix.texture(d->sceneGraphContext()); - if (t) { - t->setFiltering(QSGItemPrivate::get(this)->smooth ? QSGTexture::Linear : QSGTexture::Nearest); - t->setMipmapFiltering(QSGTexture::None); - t->setHorizontalWrapMode(QSGTexture::ClampToEdge); - t->setVerticalWrapMode(QSGTexture::ClampToEdge); + if (!d->provider) { + // Make sure it gets thread affinity on the rendering thread so deletion works properly.. + Q_ASSERT_X(d->canvas + && d->sceneGraphContext() + && QThread::currentThread() == d->sceneGraphContext()->thread(), + "QSGImage::textureProvider", + "Cannot be used outside the GUI thread"); + const_cast<QSGImagePrivate *>(d)->provider = new QSGImageTextureProvider(this); } - return t; + + return d->provider; } QSGNode *QSGImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) @@ -519,6 +558,12 @@ QSGNode *QSGImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) QSGTexture *texture = d->pix.texture(d->sceneGraphContext()); + // Copy over the current texture state into the texture provider... + if (d->provider) { + d->provider->m_smooth = d->smooth; + d->provider->m_texture = texture; + } + if (!texture || width() <= 0 || height() <= 0) { delete oldNode; return 0; diff --git a/src/declarative/items/qsgimage_p.h b/src/declarative/items/qsgimage_p.h index 4faf96dfa0..9bf1d910d1 100644 --- a/src/declarative/items/qsgimage_p.h +++ b/src/declarative/items/qsgimage_p.h @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QSGImagePrivate; -class Q_AUTOTEST_EXPORT QSGImage : public QSGImageBase, public QSGTextureProvider +class Q_AUTOTEST_EXPORT QSGImage : public QSGImageBase { Q_OBJECT Q_ENUMS(FillMode) @@ -63,12 +63,9 @@ class Q_AUTOTEST_EXPORT QSGImage : public QSGImageBase, public QSGTextureProvide Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged) Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedGeometryChanged) Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedGeometryChanged) - Q_PROPERTY(QSGTexture *texture READ texture) Q_PROPERTY(HAlignment horizontalAlignment READ horizontalAlignment WRITE setHorizontalAlignment NOTIFY horizontalAlignmentChanged) Q_PROPERTY(VAlignment verticalAlignment READ verticalAlignment WRITE setVerticalAlignment NOTIFY verticalAlignmentChanged) - Q_INTERFACES(QSGTextureProvider) - public: QSGImage(QSGItem *parent=0); ~QSGImage(); @@ -90,14 +87,15 @@ public: QRectF boundingRect() const; - virtual QSGTexture *texture() const; - HAlignment horizontalAlignment() const; void setHorizontalAlignment(HAlignment align); VAlignment verticalAlignment() const; void setVerticalAlignment(VAlignment align); + bool isTextureProvider() const { return true; } + QSGTextureProvider *textureProvider() const; + Q_SIGNALS: void fillModeChanged(); void paintedGeometryChanged(); diff --git a/src/declarative/items/qsgimage_p_p.h b/src/declarative/items/qsgimage_p_p.h index d0b109942a..9f8b9716c7 100644 --- a/src/declarative/items/qsgimage_p_p.h +++ b/src/declarative/items/qsgimage_p_p.h @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE -class QSGImagePrivate; +class QSGImageTextureProvider; class QSGImagePrivate : public QSGImageBasePrivate { @@ -76,6 +76,8 @@ public: bool pixmapChanged : 1; QSGImage::HAlignment hAlign; QSGImage::VAlignment vAlign; + + QSGImageTextureProvider *provider; }; QT_END_NAMESPACE diff --git a/src/declarative/items/qsgitem.cpp b/src/declarative/items/qsgitem.cpp index c2abc46ab9..a7797630c0 100644 --- a/src/declarative/items/qsgitem.cpp +++ b/src/declarative/items/qsgitem.cpp @@ -51,9 +51,8 @@ #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecomponent.h> #include <QtDeclarative/qdeclarativeinfo.h> -#include <QtGui/qgraphicstransform.h> +#include <QtWidgets/qgraphicstransform.h> #include <QtGui/qpen.h> -#include <QtGui/qinputcontext.h> #include <QtCore/qdebug.h> #include <QtCore/qcoreevent.h> #include <QtCore/qnumeric.h> @@ -2046,9 +2045,6 @@ void QSGItemPrivate::initCanvas(InitializationState *state, QSGCanvas *c) if (canvas && polishScheduled) QSGCanvasPrivate::get(canvas)->itemsToPolish.insert(q); - if (canvas && hoverEnabled && !canvas->hasMouseTracking()) - canvas->setMouseTracking(true); - itemNodeInstance = 0; opacityNode = 0; clipNode = 0; @@ -2929,11 +2925,10 @@ void QSGItem::setInputMethodHints(Qt::InputMethodHints hints) if (!d->canvas || d->canvas->activeFocusItem() != this) return; - QSGCanvasPrivate::get(d->canvas)->updateInputMethodData(); + QSGCanvasPrivate *cd = QSGCanvasPrivate::get(d->canvas); + cd->updateInputMethodData(); #ifndef QT_NO_IM - if (d->canvas->hasFocus()) - if (QInputContext *inputContext = d->canvas->inputContext()) - inputContext->update(); + cd->updateInputContext(); #endif } @@ -2941,9 +2936,8 @@ void QSGItem::updateMicroFocus() { #ifndef QT_NO_IM Q_D(QSGItem); - if (d->canvas && d->canvas->hasFocus()) - if (QInputContext *inputContext = d->canvas->inputContext()) - inputContext->update(); + if (d->canvas) + QSGCanvasPrivate::get(d->canvas)->updateInputContext(); #endif } @@ -4415,7 +4409,7 @@ bool QSGItem::isUnderMouse() const return false; QPoint cursorPos = QCursor::pos(); - if (QRectF(0, 0, width(), height()).contains(mapFromScene(d->canvas->mapFromGlobal(cursorPos)))) + if (QRectF(0, 0, width(), height()).contains(mapFromScene(cursorPos))) // ### refactor: d->canvas->mapFromGlobal(cursorPos)))) return true; return false; } @@ -4430,22 +4424,6 @@ void QSGItem::setAcceptHoverEvents(bool enabled) { Q_D(QSGItem); d->hoverEnabled = enabled; - - if (d->canvas){ - QSGCanvasPrivate *c = QSGCanvasPrivate::get(d->canvas); - if (d->hoverEnabled){ - if (!d->canvas->hasMouseTracking()) - d->canvas->setMouseTracking(true); - if (isUnderMouse()) - c->hoverItems.prepend(this); - c->sendHoverEvent(QEvent::HoverEnter, this, c->lastMousePosition, c->lastMousePosition, - QApplication::keyboardModifiers(), true); - } else { - c->hoverItems.removeAll(this); - c->sendHoverEvent(QEvent::HoverLeave, this, c->lastMousePosition, c->lastMousePosition, - QApplication::keyboardModifiers(), true); - } - } } void QSGItem::grabMouse() @@ -4980,6 +4958,24 @@ qint64 QSGItemPrivate::restart(QElapsedTimer &t) return ((QElapsedTimerConsistentTimeHack*)&t)->restart(); } +/*! + \fn bool QSGItem::isTextureProvider() const + + Returns true if this item is a texture provider. The default + implementation returns false. + + This function can be called from any thread. + */ + +/*! + \fn QSGTextureProvider *QSGItem::textureProvider() const + + Returns the texture provider for an item. The default implementation + returns 0. + + This function may only be called on the rendering thread. + */ + QT_END_NAMESPACE #include <moc_qsgitem.cpp> diff --git a/src/declarative/items/qsgitem.h b/src/declarative/items/qsgitem.h index 249a2065dd..02a7a33ed8 100644 --- a/src/declarative/items/qsgitem.h +++ b/src/declarative/items/qsgitem.h @@ -48,9 +48,9 @@ #include <QtCore/QObject> #include <QtCore/QList> -#include <QtGui/qgraphicssceneevent.h> +#include <QtWidgets/qgraphicssceneevent.h> #include <QtGui/qfont.h> -#include <QtGui/qaction.h> +#include <QtWidgets/qaction.h> QT_BEGIN_HEADER @@ -95,6 +95,8 @@ class QSGEngine; class QTouchEvent; class QSGNode; class QSGTransformNode; +class QSGTextureProvider; + class Q_DECLARATIVE_EXPORT QSGItem : public QObject, public QDeclarativeParserStatus { Q_OBJECT @@ -305,6 +307,9 @@ public: UpdatePaintNodeData(); }; + virtual bool isTextureProvider() const { return false; } + virtual QSGTextureProvider *textureProvider() const { return 0; } + public Q_SLOTS: void update(); void updateMicroFocus(); diff --git a/src/declarative/items/qsgmousearea.cpp b/src/declarative/items/qsgmousearea.cpp index 0f9d0a4780..7d86d2e248 100644 --- a/src/declarative/items/qsgmousearea.cpp +++ b/src/declarative/items/qsgmousearea.cpp @@ -45,8 +45,8 @@ #include "qsgevent.h" #include "qsgevents_p_p.h" -#include <QtGui/qgraphicssceneevent.h> -#include <QtGui/qapplication.h> +#include <QtWidgets/qgraphicssceneevent.h> +#include <QtWidgets/qapplication.h> #include <float.h> diff --git a/src/declarative/items/qsgmousearea_p_p.h b/src/declarative/items/qsgmousearea_p_p.h index 30ec75c3a9..ff531c627c 100644 --- a/src/declarative/items/qsgmousearea_p_p.h +++ b/src/declarative/items/qsgmousearea_p_p.h @@ -56,7 +56,7 @@ #include "qsgitem_p.h" -#include <QtGui/qgraphicssceneevent.h> +#include <QtWidgets/qgraphicssceneevent.h> #include <QtCore/qbasictimer.h> QT_BEGIN_NAMESPACE diff --git a/src/declarative/items/qsgpathview.cpp b/src/declarative/items/qsgpathview.cpp index 88c5df9cfb..2c3e3cee71 100644 --- a/src/declarative/items/qsgpathview.cpp +++ b/src/declarative/items/qsgpathview.cpp @@ -48,8 +48,8 @@ #include <private/qlistmodelinterface_p.h> #include <QtGui/qevent.h> -#include <QtGui/qgraphicssceneevent.h> -#include <QtGui/qapplication.h> +#include <QtWidgets/qgraphicssceneevent.h> +#include <QtWidgets/qapplication.h> #include <QtCore/qmath.h> #include <math.h> diff --git a/src/declarative/items/qsgpincharea.cpp b/src/declarative/items/qsgpincharea.cpp index b37dcaf646..54c32e5025 100644 --- a/src/declarative/items/qsgpincharea.cpp +++ b/src/declarative/items/qsgpincharea.cpp @@ -42,8 +42,8 @@ #include "qsgpincharea_p_p.h" #include "qsgcanvas.h" -#include <QtGui/qgraphicssceneevent.h> -#include <QtGui/qapplication.h> +#include <QtWidgets/qgraphicssceneevent.h> +#include <QtWidgets/qapplication.h> #include <float.h> #include <math.h> diff --git a/src/declarative/items/qsgshadereffect.cpp b/src/declarative/items/qsgshadereffect.cpp index 6045c5fee9..6649dc9f2c 100644 --- a/src/declarative/items/qsgshadereffect.cpp +++ b/src/declarative/items/qsgshadereffect.cpp @@ -49,6 +49,9 @@ #include <private/qsgtextureprovider_p.h> #include "qsgcanvas.h" +#include <qsgimage_p.h> +#include <qsgshadereffectsource_p.h> + #include <QtCore/qsignalmapper.h> #include <QtOpenGL/qglframebufferobject.h> @@ -402,7 +405,7 @@ void QSGShaderEffect::setSource(const QVariant &var, int index) SourceData &source = m_sources[index]; - source.item = 0; + source.sourceObject = 0; if (var.isNull()) { return; } else if (!qVariantCanConvert<QObject *>(var)) { @@ -411,21 +414,23 @@ void QSGShaderEffect::setSource(const QVariant &var, int index) } QObject *obj = qVariantValue<QObject *>(var); - - QSGTextureProvider *int3rface = QSGTextureProvider::from(obj); - if (!int3rface) { - qWarning("Could not assign property '%s', did not implement QSGTextureProvider.", source.name.constData()); + QSGItem *item = qobject_cast<QSGItem *>(obj); + if (!item || !item->isTextureProvider()) { + qWarning("ShaderEffect: source uniform [%s] is not assigned a valid texture provider: %s [%s]", + qPrintable(source.name), qPrintable(obj->objectName()), obj->metaObject()->className()); + return; } - source.item = qobject_cast<QSGItem *>(obj); + source.sourceObject = item; + // TODO: Find better solution. - // 'source.item' needs a canvas to get a scenegraph node. + // 'item' needs a canvas to get a scenegraph node. // The easiest way to make sure it gets a canvas is to // make it a part of the same item tree as 'this'. - if (source.item && source.item->parentItem() == 0) { - source.item->setParentItem(this); - source.item->setVisible(false); + if (item && item->parentItem() == 0) { + item->setParentItem(this); + item->setVisible(false); } } @@ -484,8 +489,9 @@ void QSGShaderEffect::reset() for (int i = 0; i < m_sources.size(); ++i) { const SourceData &source = m_sources.at(i); delete source.mapper; - if (source.item && source.item->parentItem() == this) - source.item->setParentItem(0); + QSGItem *item = qobject_cast<QSGItem *>(source.sourceObject); + if (item && item->parentItem() == this) + item->setParentItem(0); } m_sources.clear(); @@ -558,7 +564,7 @@ void QSGShaderEffect::lookThroughShaderCode(const QByteArray &code) SourceData d; d.mapper = new QSignalMapper; d.name = name; - d.item = 0; + d.sourceObject = 0; m_sources.append(d); } } @@ -578,12 +584,13 @@ QSGNode *QSGShaderEffect::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData if (!node) { node = new QSGShaderEffectNode; - node->setMaterial(&m_material); m_programDirty = true; m_dirtyData = true; m_dirtyGeometry = true; } + QSGShaderEffectMaterial *material = node->shaderMaterial(); + if (m_dirtyMesh) { node->setGeometry(0); m_dirtyMesh = false; @@ -616,45 +623,45 @@ QSGNode *QSGShaderEffect::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData s.vertexCode = qt_default_vertex_code; s.className = metaObject()->className(); - m_material.setProgramSource(s); + material->setProgramSource(s); node->markDirty(QSGNode::DirtyMaterial); m_programDirty = false; } // Update blending - if (bool(m_material.flags() & QSGMaterial::Blending) != m_blending) { - m_material.setFlag(QSGMaterial::Blending, m_blending); + if (bool(material->flags() & QSGMaterial::Blending) != m_blending) { + material->setFlag(QSGMaterial::Blending, m_blending); node->markDirty(QSGNode::DirtyMaterial); } - if (int(m_material.cullMode()) != int(m_cullMode)) { - m_material.setCullMode(QSGShaderEffectMaterial::CullMode(m_cullMode)); + if (int(material->cullMode()) != int(m_cullMode)) { + material->setCullMode(QSGShaderEffectMaterial::CullMode(m_cullMode)); node->markDirty(QSGNode::DirtyMaterial); } if (m_dirtyData) { QVector<QPair<QByteArray, QVariant> > values; - QVector<QPair<QByteArray, QPointer<QSGItem> > > textures; - const QVector<QPair<QByteArray, QPointer<QSGItem> > > &oldTextures = m_material.textureProviders(); + QVector<QPair<QByteArray, QSGTextureProvider *> > textures; + const QVector<QPair<QByteArray, QSGTextureProvider *> > &oldTextures = material->textureProviders(); for (QSet<QByteArray>::const_iterator it = m_source.uniformNames.begin(); it != m_source.uniformNames.end(); ++it) { values.append(qMakePair(*it, property(*it))); } for (int i = 0; i < oldTextures.size(); ++i) { - QSGTextureProvider *oldSource = QSGTextureProvider::from(oldTextures.at(i).second); - if (oldSource && oldSource->textureChangedSignal()) - disconnect(oldTextures.at(i).second, oldSource->textureChangedSignal(), node, SLOT(markDirtyTexture())); + QSGTextureProvider *t = oldTextures.at(i).second; + if (t) + disconnect(t, SIGNAL(textureChanged()), node, SLOT(markDirtyTexture())); } for (int i = 0; i < m_sources.size(); ++i) { const SourceData &source = m_sources.at(i); - textures.append(qMakePair(source.name, source.item)); - QSGTextureProvider *t = QSGTextureProvider::from(source.item); - if (t && t->textureChangedSignal()) - connect(source.item, t->textureChangedSignal(), node, SLOT(markDirtyTexture()), Qt::DirectConnection); + QSGTextureProvider *t = source.sourceObject->textureProvider(); + textures.append(qMakePair(source.name, t)); + if (t) + connect(t, SIGNAL(textureChanged()), node, SLOT(markDirtyTexture()), Qt::DirectConnection); } - m_material.setUniforms(values); - m_material.setTextureProviders(textures); + material->setUniforms(values); + material->setTextureProviders(textures); node->markDirty(QSGNode::DirtyMaterial); m_dirtyData = false; } diff --git a/src/declarative/items/qsgshadereffect_p.h b/src/declarative/items/qsgshadereffect_p.h index 0cced9a229..5d90fe0e61 100644 --- a/src/declarative/items/qsgshadereffect_p.h +++ b/src/declarative/items/qsgshadereffect_p.h @@ -138,11 +138,10 @@ private: struct SourceData { QSignalMapper *mapper; - QPointer<QSGItem> item; + QPointer<QSGItem> sourceObject; QByteArray name; }; QVector<SourceData> m_sources; - QSGShaderEffectMaterial m_material; uint m_blending : 1; uint m_dirtyData : 1; diff --git a/src/declarative/items/qsgshadereffectnode.cpp b/src/declarative/items/qsgshadereffectnode.cpp index 8bd781ce58..d51317a122 100644 --- a/src/declarative/items/qsgshadereffectnode.cpp +++ b/src/declarative/items/qsgshadereffectnode.cpp @@ -110,15 +110,15 @@ void QSGCustomMaterialShader::updateState(const RenderState &state, QSGMaterial QGLFunctions *functions = state.context()->functions(); for (int i = material->m_textures.size() - 1; i >= 0; --i) { - QPointer<QSGItem> source = material->m_textures.at(i).second; - QSGTextureProvider *provider = QSGTextureProvider::from(source); - QSGTexture *texture = provider ? provider->texture() : 0; - if (!source || !provider || !texture) { - qWarning("ShaderEffectItem: source or provider missing when binding textures"); - continue; - } functions->glActiveTexture(GL_TEXTURE0 + i); - provider->texture()->bind(); + if (QSGTextureProvider *provider = material->m_textures.at(i).second) { + if (QSGTexture *texture = provider->texture()) { + texture->bind(); + continue; + } + } + qWarning("ShaderEffectItem: source or provider missing when binding textures"); + glBindTexture(GL_TEXTURE_2D, 0); } if (material->m_source.respectsOpacity) @@ -271,12 +271,12 @@ void QSGShaderEffectMaterial::setUniforms(const QVector<QPair<QByteArray, QVaria m_uniformValues = uniformValues; } -void QSGShaderEffectMaterial::setTextureProviders(const QVector<QPair<QByteArray, QPointer<QSGItem> > > &textures) +void QSGShaderEffectMaterial::setTextureProviders(const QVector<QPair<QByteArray, QSGTextureProvider *> > &textures) { m_textures = textures; } -const QVector<QPair<QByteArray, QPointer<QSGItem> > > &QSGShaderEffectMaterial::textureProviders() const +const QVector<QPair<QByteArray, QSGTextureProvider *> > &QSGShaderEffectMaterial::textureProviders() const { return m_textures; } @@ -284,20 +284,9 @@ const QVector<QPair<QByteArray, QPointer<QSGItem> > > &QSGShaderEffectMaterial:: void QSGShaderEffectMaterial::updateTextures() const { for (int i = 0; i < m_textures.size(); ++i) { - QSGItem *item = m_textures.at(i).second; - if (item) { - QSGTextureProvider *provider = QSGTextureProvider::from(item); - if (provider) { - QSGTexture *texture = provider->texture(); - if (!texture) { - qWarning("QSGShaderEffectMaterial: no texture from %s [%s]", - qPrintable(item->objectName()), - item->metaObject()->className()); - } - if (QSGDynamicTexture *t = qobject_cast<QSGDynamicTexture *>(provider->texture())) { - t->updateTexture(); - } - } + if (QSGTextureProvider *provider = m_textures.at(i).second) { + if (QSGDynamicTexture *texture = qobject_cast<QSGDynamicTexture *>(provider->texture())) + texture->updateTexture(); } } } @@ -306,6 +295,7 @@ void QSGShaderEffectMaterial::updateTextures() const QSGShaderEffectNode::QSGShaderEffectNode() { QSGNode::setFlag(UsePreprocess, true); + setMaterial(&m_material); } QSGShaderEffectNode::~QSGShaderEffectNode() diff --git a/src/declarative/items/qsgshadereffectnode_p.h b/src/declarative/items/qsgshadereffectnode_p.h index eee70703ea..d95dfaf3cb 100644 --- a/src/declarative/items/qsgshadereffectnode_p.h +++ b/src/declarative/items/qsgshadereffectnode_p.h @@ -100,8 +100,8 @@ public: void setProgramSource(const QSGShaderEffectProgram &); void setUniforms(const QVector<QPair<QByteArray, QVariant> > &uniformValues); - void setTextureProviders(const QVector<QPair<QByteArray, QPointer<QSGItem> > > &textures); - const QVector<QPair<QByteArray, QPointer<QSGItem> > > &textureProviders() const; + void setTextureProviders(const QVector<QPair<QByteArray, QSGTextureProvider *> > &textures); + const QVector<QPair<QByteArray, QSGTextureProvider *> > &textureProviders() const; void updateTextures() const; protected: @@ -118,7 +118,7 @@ protected: QSGShaderEffectProgram m_source; QVector<QPair<QByteArray, QVariant> > m_uniformValues; - QVector<QPair<QByteArray, QPointer<QSGItem> > > m_textures; + QVector<QPair<QByteArray, QSGTextureProvider *> > m_textures; CullMode m_cullMode; static QHash<QSGShaderEffectMaterialKey, QSharedPointer<QSGMaterialType> > materialMap; @@ -136,9 +136,13 @@ public: virtual void preprocess(); + QSGShaderEffectMaterial *shaderMaterial() { return &m_material; } + private Q_SLOTS: void markDirtyTexture(); +private: + QSGShaderEffectMaterial m_material; }; QT_END_NAMESPACE diff --git a/src/declarative/items/qsgshadereffectsource.cpp b/src/declarative/items/qsgshadereffectsource.cpp index d7653b578b..ef6dd64532 100644 --- a/src/declarative/items/qsgshadereffectsource.cpp +++ b/src/declarative/items/qsgshadereffectsource.cpp @@ -54,6 +54,33 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(qmlFboOverlay, QML_FBO_OVERLAY) +class QSGShaderEffectSourceTextureProvider : public QSGTextureProvider +{ + Q_OBJECT +public: + QSGShaderEffectSourceTextureProvider() + : sourceTexture(0) + { + } + + QSGTexture *texture() const { + sourceTexture->setMipmapFiltering(mipmapFiltering); + sourceTexture->setFiltering(filtering); + sourceTexture->setHorizontalWrapMode(horizontalWrap); + sourceTexture->setVerticalWrapMode(verticalWrap); + return sourceTexture; + } + + QSGShaderEffectTexture *sourceTexture; + + QSGTexture::Filtering mipmapFiltering; + QSGTexture::Filtering filtering; + QSGTexture::WrapMode horizontalWrap; + QSGTexture::WrapMode verticalWrap; +}; +#include "qsgshadereffectsource.moc" + + QSGShaderEffectSourceNode::QSGShaderEffectSourceNode() { setFlag(UsePreprocess, true); @@ -76,6 +103,7 @@ QSGShaderEffectTexture::QSGShaderEffectTexture(QSGItem *shaderSource) #ifdef QSG_DEBUG_FBO_OVERLAY , m_debugOverlay(0) #endif + , m_context(0) , m_mipmap(false) , m_live(true) , m_recursive(false) @@ -96,6 +124,17 @@ QSGShaderEffectTexture::~QSGShaderEffectTexture() #endif } +void QSGShaderEffectTexture::scheduleForCleanup() +{ + if (m_context) + m_context->scheduleTextureForCleanup(this); + else { + // Never really been used, hence we can delete it right away.. + Q_ASSERT(!m_fbo); + delete this; + } +} + int QSGShaderEffectTexture::textureId() const { @@ -226,10 +265,12 @@ void QSGShaderEffectTexture::grab() return; } - QSGContext *context = QSGItemPrivate::get(m_shaderSource)->sceneGraphContext(); + if (!m_context) + m_context = QSGItemPrivate::get(m_shaderSource)->sceneGraphContext(); + Q_ASSERT(QSGItemPrivate::get(m_shaderSource)->sceneGraphContext() == m_context); if (!m_renderer) { - m_renderer = context->createRenderer(); + m_renderer = m_context->createRenderer(); connect(m_renderer, SIGNAL(sceneGraphChanged()), this, SLOT(markDirtyTexture()), Qt::DirectConnection); } m_renderer->setRootNode(static_cast<QSGRootNode *>(root)); @@ -293,7 +334,7 @@ void QSGShaderEffectTexture::grab() #ifdef QSG_DEBUG_FBO_OVERLAY if (qmlFboOverlay()) { if (!m_debugOverlay) - m_debugOverlay = context->createRectangleNode(); + m_debugOverlay = m_context->createRectangleNode(); m_debugOverlay->setRect(QRectF(0, 0, m_size.width(), m_size.height())); m_debugOverlay->setColor(QColor(0xff, 0x00, 0x80, 0x40)); m_debugOverlay->setPenColor(QColor()); @@ -306,7 +347,7 @@ void QSGShaderEffectTexture::grab() m_dirtyTexture = false; - const QGLContext *ctx = QGLContext::currentContext(); + const QGLContext *ctx = m_context->glContext(); m_renderer->setDeviceRect(m_size); m_renderer->setViewportRect(m_size); QRectF mirrored(m_rect.left(), m_rect.bottom(), m_rect.width(), -m_rect.height()); @@ -444,6 +485,7 @@ void QSGShaderEffectTexture::grab() QSGShaderEffectSource::QSGShaderEffectSource(QSGItem *parent) : QSGItem(parent) + , m_provider(0) , m_wrapMode(ClampToEdge) , m_sourceItem(0) , m_textureSize(0, 0) @@ -456,17 +498,36 @@ QSGShaderEffectSource::QSGShaderEffectSource(QSGItem *parent) { setFlag(ItemHasContents); m_texture = new QSGShaderEffectTexture(this); - connect(m_texture, SIGNAL(textureChanged()), this, SIGNAL(textureChanged()), Qt::DirectConnection); connect(m_texture, SIGNAL(textureChanged()), this, SLOT(update())); } QSGShaderEffectSource::~QSGShaderEffectSource() { - delete m_texture; + m_texture->scheduleForCleanup(); + + if (m_provider) + m_provider->deleteLater(); + if (m_sourceItem) QSGItemPrivate::get(m_sourceItem)->derefFromEffectItem(m_hideSource); } +QSGTextureProvider *QSGShaderEffectSource::textureProvider() const +{ + if (!m_provider) { + // Make sure it gets thread affinity on the rendering thread so deletion works properly.. + Q_ASSERT_X(QSGItemPrivate::get(this)->canvas + && QSGItemPrivate::get(this)->sceneGraphContext() + && QThread::currentThread() == QSGItemPrivate::get(this)->sceneGraphContext()->thread(), + "QSGShaderEffectSource::textureProvider", + "Cannot be used outside the GUI thread"); + const_cast<QSGShaderEffectSource *>(this)->m_provider = new QSGShaderEffectSourceTextureProvider(); + connect(m_texture, SIGNAL(textureChanged()), m_provider, SIGNAL(textureChanged()), Qt::DirectConnection); + m_provider->sourceTexture = m_texture; + } + return m_provider; +} + /*! \qmlproperty enumeration ShaderEffectSource::wrapMode @@ -753,17 +814,6 @@ static void get_wrap_mode(QSGShaderEffectSource::WrapMode mode, QSGTexture::Wrap } -QSGTexture *QSGShaderEffectSource::texture() const -{ - m_texture->setMipmapFiltering(m_mipmap ? QSGTexture::Linear : QSGTexture::None); - m_texture->setFiltering(QSGItemPrivate::get(this)->smooth ? QSGTexture::Linear : QSGTexture::Nearest); - QSGTexture::WrapMode h, v; - get_wrap_mode(m_wrapMode, &h, &v); - m_texture->setHorizontalWrapMode(h); - m_texture->setVerticalWrapMode(v); - return m_texture; -} - QSGNode *QSGShaderEffectSource::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) { if (!m_sourceItem || m_sourceItem->width() == 0 || m_sourceItem->height() == 0) { @@ -771,19 +821,7 @@ QSGNode *QSGShaderEffectSource::updatePaintNode(QSGNode *oldNode, UpdatePaintNod return 0; } - QSGShaderEffectSourceNode *node = static_cast<QSGShaderEffectSourceNode *>(oldNode); - if (!node) { - node = new QSGShaderEffectSourceNode; - node->setTexture(m_texture); - connect(m_texture, SIGNAL(textureChanged()), node, SLOT(markDirtyTexture()), Qt::DirectConnection); - } - - // If live and recursive, update continuously. - if (m_live && m_recursive) - node->markDirty(QSGNode::DirtyMaterial); - QSGShaderEffectTexture *tex = qobject_cast<QSGShaderEffectTexture *>(m_texture); - tex->setLive(m_live); tex->setItem(QSGItemPrivate::get(m_sourceItem)->itemNode()); QRectF sourceRect = m_sourceRect.width() == 0 || m_sourceRect.height() == 0 @@ -815,12 +853,35 @@ QSGNode *QSGShaderEffectSource::updatePaintNode(QSGNode *oldNode, UpdatePaintNod ? QSGTexture::Linear : QSGTexture::Nearest; QSGTexture::Filtering mmFiltering = m_mipmap ? filtering : QSGTexture::None; - node->setMipmapFiltering(mmFiltering); - node->setFiltering(filtering); - QSGTexture::WrapMode hWrap, vWrap; get_wrap_mode(m_wrapMode, &hWrap, &vWrap); + if (m_provider) { + m_provider->mipmapFiltering = mmFiltering; + m_provider->filtering = filtering; + m_provider->horizontalWrap = hWrap; + m_provider->verticalWrap = vWrap; + } + + // Don't create the paint node if we're not spanning any area + if (width() == 0 || height() == 0) { + delete oldNode; + return 0; + } + + QSGShaderEffectSourceNode *node = static_cast<QSGShaderEffectSourceNode *>(oldNode); + if (!node) { + node = new QSGShaderEffectSourceNode; + node->setTexture(m_texture); + connect(m_texture, SIGNAL(textureChanged()), node, SLOT(markDirtyTexture()), Qt::DirectConnection); + } + + // If live and recursive, update continuously. + if (m_live && m_recursive) + node->markDirty(QSGNode::DirtyMaterial); + + node->setMipmapFiltering(mmFiltering); + node->setFiltering(filtering); node->setHorizontalWrapMode(hWrap); node->setVerticalWrapMode(vWrap); node->setTargetRect(QRectF(0, 0, width(), height())); diff --git a/src/declarative/items/qsgshadereffectsource_p.h b/src/declarative/items/qsgshadereffectsource_p.h index ac8fde50d9..92a4ce8a76 100644 --- a/src/declarative/items/qsgshadereffectsource_p.h +++ b/src/declarative/items/qsgshadereffectsource_p.h @@ -64,6 +64,8 @@ class QSGNode; class UpdatePaintNodeData; class QGLFramebufferObject; +class QSGShaderEffectSourceTextureProvider; + class QSGShaderEffectSourceNode : public QObject, public QSGDefaultImageNode { Q_OBJECT @@ -114,6 +116,8 @@ public: void scheduleUpdate(); + void scheduleForCleanup(); + Q_SIGNALS: void textureChanged(); @@ -137,6 +141,8 @@ private: QSGRectangleNode *m_debugOverlay; #endif + QSGContext *m_context; + uint m_mipmap : 1; uint m_live : 1; uint m_recursive : 1; @@ -146,7 +152,7 @@ private: uint m_grab : 1; }; -class QSGShaderEffectSource : public QSGItem, public QSGTextureProvider +class QSGShaderEffectSource : public QSGItem { Q_OBJECT Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged) @@ -158,7 +164,7 @@ class QSGShaderEffectSource : public QSGItem, public QSGTextureProvider Q_PROPERTY(bool hideSource READ hideSource WRITE setHideSource NOTIFY hideSourceChanged) Q_PROPERTY(bool mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged) Q_PROPERTY(bool recursive READ recursive WRITE setRecursive NOTIFY recursiveChanged) - Q_INTERFACES(QSGTextureProvider) + Q_ENUMS(Format WrapMode) public: enum WrapMode { @@ -204,8 +210,8 @@ public: bool recursive() const; void setRecursive(bool enabled); - QSGTexture *texture() const; - const char *textureChangedSignal() const { return SIGNAL(textureChanged()); } + bool isTextureProvider() const { return true; } + QSGTextureProvider *textureProvider() const; Q_INVOKABLE void scheduleUpdate(); @@ -226,7 +232,8 @@ protected: virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); private: - QSGTexture *m_texture; + QSGShaderEffectSourceTextureProvider *m_provider; + QSGShaderEffectTexture *m_texture; WrapMode m_wrapMode; QPointer<QSGItem> m_sourceItem; QRectF m_sourceRect; diff --git a/src/declarative/items/qsgtext.cpp b/src/declarative/items/qsgtext.cpp index 7e8cf2d099..bac0be969b 100644 --- a/src/declarative/items/qsgtext.cpp +++ b/src/declarative/items/qsgtext.cpp @@ -50,13 +50,13 @@ #include <private/qsgtexture_p.h> #include <QtDeclarative/qdeclarativeinfo.h> -#include <QtGui/qgraphicssceneevent.h> +#include <QtWidgets/qgraphicssceneevent.h> #include <QtGui/qabstracttextdocumentlayout.h> #include <QtGui/qpainter.h> #include <QtGui/qtextdocument.h> #include <QtGui/qtextobject.h> #include <QtGui/qtextcursor.h> -#include <QtGui/qapplication.h> +#include <QtWidgets/qapplication.h> #include <private/qdeclarativestyledtext_p.h> #include <private/qdeclarativepixmapcache_p.h> diff --git a/src/declarative/items/qsgtextedit.cpp b/src/declarative/items/qsgtextedit.cpp index eeeaa206db..1c0ed62f0d 100644 --- a/src/declarative/items/qsgtextedit.cpp +++ b/src/declarative/items/qsgtextedit.cpp @@ -47,8 +47,8 @@ #include "qsgsimplerectnode.h" #include <QtDeclarative/qdeclarativeinfo.h> -#include <QtGui/qapplication.h> -#include <QtGui/qgraphicssceneevent.h> +#include <QtWidgets/qapplication.h> +#include <QtWidgets/qgraphicssceneevent.h> #include <QtGui/qpainter.h> #include <QtGui/qtextobject.h> #include <QtCore/qmath.h> @@ -1360,9 +1360,11 @@ void QSGTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) d->control->processEvent(event, QPointF(0, -d->yoff)); if (!d->showInputPanelOnFocus) { // input panel on click if (d->focusOnPress && !isReadOnly() && boundingRect().contains(event->pos())) { - if (canvas() && canvas() == qApp->focusWidget()) { - qt_widget_private(canvas())->handleSoftwareInputPanel(event->button(), d->clickCausedFocus); - } + // ### refactor: port properly + qDebug("QSGTextEdit: virtual keyboard handling not implemented"); +// if (canvas() && canvas() == qApp->focusWidget()) { +// qt_widget_private(canvas())->handleSoftwareInputPanel(event->button(), d->clickCausedFocus); +// } } } d->clickCausedFocus = false; @@ -1412,7 +1414,7 @@ void QSGTextEdit::itemChange(ItemChange change, const ItemChangeData &value) { Q_D(QSGTextEdit); if (change == ItemActiveFocusHasChanged) { - setCursorVisible(value.boolValue && d->canvas && d->canvas->hasFocus()); + setCursorVisible(value.boolValue); // ### refactor: focus handling && d->canvas && d->canvas->hasFocus()); } QSGItem::itemChange(change, value); } @@ -1906,7 +1908,7 @@ void QSGTextEditPrivate::updateDefaultTextOption() void QSGTextEdit::openSoftwareInputPanel() { if (qApp) { - if (canvas() && canvas() == qApp->focusWidget()) { + if (canvas()) { QEvent event(QEvent::RequestSoftwareInputPanel); QApplication::sendEvent(canvas(), &event); } @@ -1953,9 +1955,9 @@ void QSGTextEdit::openSoftwareInputPanel() \endcode */ void QSGTextEdit::closeSoftwareInputPanel() -{ +{ if (qApp) { - if (canvas() && canvas() == qApp->focusWidget()) { + if (canvas()) { QEvent event(QEvent::CloseSoftwareInputPanel); QApplication::sendEvent(canvas(), &event); } diff --git a/src/declarative/items/qsgtextinput.cpp b/src/declarative/items/qsgtextinput.cpp index 222a9002e7..d30faadb34 100644 --- a/src/declarative/items/qsgtextinput.cpp +++ b/src/declarative/items/qsgtextinput.cpp @@ -48,8 +48,8 @@ #include <private/qsgdistancefieldglyphcache_p.h> #include <QtDeclarative/qdeclarativeinfo.h> -#include <QtGui/qgraphicssceneevent.h> -#include <QtGui/qinputcontext.h> +#include <QtWidgets/qgraphicssceneevent.h> +#include <QtWidgets/qinputcontext.h> #include <QTextBoundaryFinder> #include <qstyle.h> #include <qsgtextnode_p.h> @@ -888,7 +888,7 @@ void QSGTextInput::setEchoMode(QSGTextInput::EchoMode echo) Q_D(QSGTextInput); if (echoMode() == echo) return; - d->control->setEchoMode((uint)echo); + d->control->setEchoMode((QLineControl::EchoMode)echo); d->updateInputMethodHints(); q_textChanged(); emit echoModeChanged(echoMode()); @@ -1149,8 +1149,10 @@ void QSGTextInput::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } if (!d->showInputPanelOnFocus) { // input panel on click if (d->focusOnPress && !isReadOnly() && boundingRect().contains(event->pos())) { - if (canvas() && canvas() == qApp->focusWidget()) { - qt_widget_private(canvas())->handleSoftwareInputPanel(event->button(), d->clickCausedFocus); + if (canvas() && canvas() == QGuiApplication::activeWindow()) { + // ### refactor: implement virtual keyboard properly.. + qDebug("QSGTextInput: virtual keyboard no implemented..."); +// qt_widget_private(canvas())->handleSoftwareInputPanel(event->button(), d->clickCausedFocus); } } } @@ -1230,7 +1232,6 @@ bool QSGTextInput::event(QEvent* ev) void QSGTextInput::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { - Q_D(QSGTextInput); if (newGeometry.width() != oldGeometry.width()) { updateSize(); updateCursorRectangle(); @@ -1741,9 +1742,8 @@ void QSGTextInput::moveCursorSelection(int pos, SelectionMode mode) */ void QSGTextInput::openSoftwareInputPanel() { - QEvent event(QEvent::RequestSoftwareInputPanel); if (qApp) { - if (canvas() && canvas() == qApp->focusWidget()) { + if (canvas()) { QEvent event(QEvent::RequestSoftwareInputPanel); QApplication::sendEvent(canvas(), &event); } @@ -1792,7 +1792,7 @@ void QSGTextInput::openSoftwareInputPanel() void QSGTextInput::closeSoftwareInputPanel() { if (qApp) { - if (canvas() && canvas() == qApp->focusWidget()) { + if (canvas()) { QEvent event(QEvent::CloseSoftwareInputPanel); QApplication::sendEvent(canvas(), &event); } @@ -1816,7 +1816,7 @@ void QSGTextInput::itemChange(ItemChange change, const ItemChangeData &value) if (change == ItemActiveFocusHasChanged) { bool hasFocus = value.boolValue; d->focused = hasFocus; - setCursorVisible(hasFocus && d->canvas && d->canvas->hasFocus()); + setCursorVisible(hasFocus); // ### refactor: && d->canvas && d->canvas->hasFocus() if(echoMode() == QSGTextInput::PasswordEchoOnEdit && !hasFocus) d->control->updatePasswordEchoEditing(false);//QLineControl sets it on key events, but doesn't deal with focus events if (!hasFocus) diff --git a/src/declarative/items/qsgtextnode.cpp b/src/declarative/items/qsgtextnode.cpp index ef0f98bf1d..1ae457b6fa 100644 --- a/src/declarative/items/qsgtextnode.cpp +++ b/src/declarative/items/qsgtextnode.cpp @@ -132,6 +132,15 @@ QSGGlyphNode *QSGTextNode::addGlyphs(const QPointF &position, const QGlyphRun &g node->setColor(color); node->update(); + /* We flag the geometry as static, but we never call markVertexDataDirty + or markIndexDataDirty on them. This is because all text nodes are + discarded when a change occurs. If we start appending/removing from + existing geometry, then we also need to start marking the geometry as + dirty. + */ + node->geometry()->setIndexDataPattern(QSGGeometry::StaticPattern); + node->geometry()->setVertexDataPattern(QSGGeometry::StaticPattern); + if (parentNode == 0) parentNode = this; parentNode->appendChildNode(node); diff --git a/src/declarative/items/qsgview.cpp b/src/declarative/items/qsgview.cpp index 416b803814..48b3074363 100644 --- a/src/declarative/items/qsgview.cpp +++ b/src/declarative/items/qsgview.cpp @@ -87,18 +87,19 @@ public: QSGView::ResizeMode resizeMode; QSize initialSize; QElapsedTimer frameTimer; + + bool resized; }; void QSGViewPrivate::init() { - q_func()->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); QDeclarativeEnginePrivate::get(&engine)->sgContext = QSGCanvasPrivate::context; QDeclarativeInspectorService::instance()->addView(q_func()); } QSGViewPrivate::QSGViewPrivate() -: root(0), component(0), resizeMode(QSGView::SizeViewToRootObject), initialSize(0,0) + : root(0), component(0), resizeMode(QSGView::SizeViewToRootObject), initialSize(0,0), resized(false) { } @@ -141,28 +142,17 @@ void QSGViewPrivate::itemGeometryChanged(QSGItem *resizeItem, const QRectF &newG QSGItemChangeListener::itemGeometryChanged(resizeItem, newGeometry, oldGeometry); } -QSGView::QSGView(QWidget *parent, Qt::WindowFlags f) -: QSGCanvas(*(new QSGViewPrivate), parent, f) -{ - d_func()->init(); -} - -QSGView::QSGView(const QGLFormat &format, QWidget *parent, Qt::WindowFlags f) -: QSGCanvas(*(new QSGViewPrivate), format, parent, f) +QSGView::QSGView(QWindow *parent, Qt::WindowFlags f) +: QSGCanvas(*(new QSGViewPrivate), parent) { + setWindowFlags(f); d_func()->init(); } -QSGView::QSGView(const QUrl &source, QWidget *parent, Qt::WindowFlags f) -: QSGCanvas(*(new QSGViewPrivate), parent, f) -{ - d_func()->init(); - setSource(source); -} - -QSGView::QSGView(const QUrl &source, const QGLFormat &format, QWidget *parent, Qt::WindowFlags f) -: QSGCanvas(*(new QSGViewPrivate), format, parent, f) +QSGView::QSGView(const QUrl &source, QWindow *parent, Qt::WindowFlags f) +: QSGCanvas(*(new QSGViewPrivate), parent) { + setWindowFlags(f); d_func()->init(); setSource(source); } @@ -260,8 +250,6 @@ void QSGViewPrivate::updateSize() if (!qFuzzyCompare(q->height(), root->height())) root->setHeight(q->height()); } - - q->updateGeometry(); } QSize QSGViewPrivate::rootObjectSize() const @@ -348,14 +336,13 @@ void QSGViewPrivate::setRootObject(QObject *obj) delete obj; root = 0; } - if (root) { initialSize = rootObjectSize(); - if ((resizeMode == QSGView::SizeViewToRootObject || !q->testAttribute(Qt::WA_Resized)) + if ((resizeMode == QSGView::SizeViewToRootObject || !resized) // ### refactor: || !q->testAttribute(Qt::WA_Resized) && initialSize != q->size()) { - if (!(q->parentWidget() && q->parentWidget()->layout())) { - q->resize(initialSize); - } + + q->resize(initialSize); + resized = true; } initResize(); } @@ -416,22 +403,6 @@ void QSGView::resizeEvent(QResizeEvent *e) QSGCanvas::resizeEvent(e); } -/*! - \internal -*/ -void QSGView::paintEvent(QPaintEvent *event) -{ - Q_D(QSGView); - int time = 0; - if (frameRateDebug()) - time = d->frameTimer.restart(); - - QSGCanvas::paintEvent(event); - - if (frameRateDebug()) - qDebug() << "paintEvent:" << d->frameTimer.elapsed() << "time since last frame:" << time; -} - void QSGView::keyPressEvent(QKeyEvent *e) { QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Key); diff --git a/src/declarative/items/qsgview.h b/src/declarative/items/qsgview.h index 9b5ace13f3..62b52c865b 100644 --- a/src/declarative/items/qsgview.h +++ b/src/declarative/items/qsgview.h @@ -66,10 +66,8 @@ class Q_DECLARATIVE_EXPORT QSGView : public QSGCanvas Q_PROPERTY(QUrl source READ source WRITE setSource DESIGNABLE true) Q_ENUMS(ResizeMode Status) public: - explicit QSGView(QWidget *parent = 0, Qt::WindowFlags f = 0); - explicit QSGView(const QGLFormat &format, QWidget *parent = 0, Qt::WindowFlags f = 0); - QSGView(const QUrl &source, QWidget *parent = 0, Qt::WindowFlags f = 0); - QSGView(const QUrl &source, const QGLFormat &format, QWidget *parent = 0, Qt::WindowFlags f = 0); + explicit QSGView(QWindow *parent = 0, Qt::WindowFlags f = 0); + QSGView(const QUrl &source, QWindow *parent = 0, Qt::WindowFlags f = 0); virtual ~QSGView(); QUrl source() const; @@ -102,7 +100,6 @@ private Q_SLOTS: protected: virtual void resizeEvent(QResizeEvent *); - virtual void paintEvent(QPaintEvent *event); virtual void timerEvent(QTimerEvent*); virtual void keyPressEvent(QKeyEvent *); diff --git a/src/declarative/particles/qsgcustomparticle.cpp b/src/declarative/particles/qsgcustomparticle.cpp index 2d86306dc2..db544d20e8 100644 --- a/src/declarative/particles/qsgcustomparticle.cpp +++ b/src/declarative/particles/qsgcustomparticle.cpp @@ -131,11 +131,20 @@ QSGCustomParticle::QSGCustomParticle(QSGItem* parent) : QSGParticlePainter(parent) , m_pleaseReset(true) , m_dirtyData(true) + , m_material(0) , m_rootNode(0) { setFlag(QSGItem::ItemHasContents); } +class QSGShaderEffectMaterialObject : public QObject, public QSGShaderEffectMaterial { }; + +QSGCustomParticle::~QSGCustomParticle() +{ + if (m_material) + m_material->deleteLater(); +} + void QSGCustomParticle::componentComplete() { reset(); @@ -235,13 +244,12 @@ void QSGCustomParticle::setSource(const QVariant &var, int index) } QObject *obj = qVariantValue<QObject *>(var); - - QSGTextureProvider *int3rface = QSGTextureProvider::from(obj); - if (!int3rface) { - qWarning("Could not assign property '%s', did not implement QSGTextureProvider.", source.name.constData()); - } - source.item = qobject_cast<QSGItem *>(obj); + if (!source.item || !source.item->isTextureProvider()) { + qWarning("ShaderEffect: source uniform [%s] is not assigned a valid texture provider: %s [%s]", + qPrintable(source.name), qPrintable(obj->objectName()), obj->metaObject()->className()); + return; + } // TODO: Copy better solution in QSGShaderEffect when they find it. // 'source.item' needs a canvas to get a scenegraph node. @@ -430,7 +438,12 @@ QSGShaderEffectNode* QSGCustomParticle::buildCustomNodes() s.fragmentCode = qt_particles_default_fragment_code; if (s.vertexCode.isEmpty()) s.vertexCode = qt_particles_default_vertex_code; - m_material.setProgramSource(s); + + if (!m_material) { + m_material = new QSGShaderEffectMaterialObject; + } + + m_material->setProgramSource(s); foreach (const QString &str, m_particles){ int gIdx = m_system->m_groupIds[str]; int count = m_system->m_groupData[gIdx]->size(); @@ -470,7 +483,7 @@ QSGShaderEffectNode* QSGCustomParticle::buildCustomNodes() QSGShaderEffectNode* node = new QSGShaderEffectNode(); node->setGeometry(g); - node->setMaterial(&m_material); + node->setMaterial(m_material); node->markDirty(QSGNode::DirtyMaterial); m_nodes.insert(gIdx, node); @@ -491,29 +504,29 @@ void QSGCustomParticle::buildData() if (!m_rootNode) return; QVector<QPair<QByteArray, QVariant> > values; - QVector<QPair<QByteArray, QPointer<QSGItem> > > textures; - const QVector<QPair<QByteArray, QPointer<QSGItem> > > &oldTextures = m_material.textureProviders(); + QVector<QPair<QByteArray, QSGTextureProvider *> > textures; + const QVector<QPair<QByteArray, QSGTextureProvider *> > &oldTextures = m_material->textureProviders(); for (int i = 0; i < oldTextures.size(); ++i) { - QSGTextureProvider *oldSource = QSGTextureProvider::from(oldTextures.at(i).second); - if (oldSource && oldSource->textureChangedSignal()) + QSGTextureProvider *t = oldTextures.at(i).second; + if (t) foreach (QSGShaderEffectNode* node, m_nodes) - disconnect(oldTextures.at(i).second, oldSource->textureChangedSignal(), node, SLOT(markDirtyTexture())); + disconnect(t, SIGNAL(textureChanged()), node, SLOT(markDirtyTexture())); } for (int i = 0; i < m_sources.size(); ++i) { const SourceData &source = m_sources.at(i); - textures.append(qMakePair(source.name, source.item)); - QSGTextureProvider *t = QSGTextureProvider::from(source.item); - if (t && t->textureChangedSignal()) + QSGTextureProvider *t = source.item->textureProvider(); + textures.append(qMakePair(source.name, t)); + if (t) foreach (QSGShaderEffectNode* node, m_nodes) - connect(source.item, t->textureChangedSignal(), node, SLOT(markDirtyTexture()), Qt::DirectConnection); + connect(t, SIGNAL(textureChanged()), node, SLOT(markDirtyTexture()), Qt::DirectConnection); } for (QSet<QByteArray>::const_iterator it = m_source.uniformNames.begin(); it != m_source.uniformNames.end(); ++it) { values.append(qMakePair(*it, property(*it))); } values.append(qMakePair(timestampName, QVariant(m_lastTime))); - m_material.setUniforms(values); - m_material.setTextureProviders(textures); + m_material->setUniforms(values); + m_material->setTextureProviders(textures); m_dirtyData = false; foreach (QSGShaderEffectNode* node, m_nodes) node->markDirty(QSGNode::DirtyMaterial); diff --git a/src/declarative/particles/qsgcustomparticle_p.h b/src/declarative/particles/qsgcustomparticle_p.h index 1fec963d84..f51e576d34 100644 --- a/src/declarative/particles/qsgcustomparticle_p.h +++ b/src/declarative/particles/qsgcustomparticle_p.h @@ -53,6 +53,9 @@ QT_MODULE(Declarative) class QSGNode; struct PlainVertices; + +class QSGShaderEffectMaterialObject; + //Genealogy: Hybrid of UltraParticle and ShaderEffect class QSGCustomParticle : public QSGParticlePainter { @@ -62,6 +65,7 @@ class QSGCustomParticle : public QSGParticlePainter public: explicit QSGCustomParticle(QSGItem* parent=0); + ~QSGCustomParticle(); QByteArray fragmentShader() const { return m_source.fragmentCode; } void setFragmentShader(const QByteArray &code); @@ -105,7 +109,7 @@ private: QByteArray name; }; QVector<SourceData> m_sources; - QSGShaderEffectMaterial m_material; + QSGShaderEffectMaterialObject *m_material; QSGShaderEffectNode* m_rootNode; QHash<int, QSGShaderEffectNode*> m_nodes; qreal m_lastTime; diff --git a/src/declarative/qml/parser/qdeclarativejsparser.cpp b/src/declarative/qml/parser/qdeclarativejsparser.cpp index d820c5d67a..01132e5362 100644 --- a/src/declarative/qml/parser/qdeclarativejsparser.cpp +++ b/src/declarative/qml/parser/qdeclarativejsparser.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include <QtCore/QtDebug> -#include <QtGui/QApplication> +#include <QtWidgets/QApplication> #include <string.h> diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index c61849a8ac..1906612e8a 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -91,7 +91,7 @@ #include <QtCore/qmutex.h> #include <QtGui/qcolor.h> #include <QtGui/qvector3d.h> -#include <QtGui/qsound.h> +#include <QtWidgets/qsound.h> #include <QtCore/qcryptographichash.h> #include <private/qobject_p.h> diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp index 41705bce72..a989ae847b 100644 --- a/src/declarative/qml/qdeclarativemetatype.cpp +++ b/src/declarative/qml/qdeclarativemetatype.cpp @@ -1093,13 +1093,13 @@ QT_END_NAMESPACE #include <QtGui/qbrush.h> #include <QtGui/qcolor.h> #include <QtGui/qpalette.h> -#include <QtGui/qicon.h> +#include <QtWidgets/qicon.h> #include <QtGui/qimage.h> #include <QtGui/qpolygon.h> #include <QtGui/qregion.h> #include <QtGui/qbitmap.h> #include <QtGui/qcursor.h> -#include <QtGui/qsizepolicy.h> +#include <QtWidgets/qsizepolicy.h> #include <QtGui/qkeysequence.h> #include <QtGui/qpen.h> diff --git a/src/declarative/scenegraph/coreapi/qsgdefaultrenderer.cpp b/src/declarative/scenegraph/coreapi/qsgdefaultrenderer.cpp index 382ac37d2c..ce05e76969 100644 --- a/src/declarative/scenegraph/coreapi/qsgdefaultrenderer.cpp +++ b/src/declarative/scenegraph/coreapi/qsgdefaultrenderer.cpp @@ -46,7 +46,7 @@ #include "qsgmaterial.h" #include <QtCore/qvarlengtharray.h> -#include <QtGui/qapplication.h> +#include <QtWidgets/qapplication.h> #include <QtCore/qpair.h> #include <QtCore/QElapsedTimer> @@ -510,8 +510,7 @@ void QSGDefaultRenderer::renderNodes(const QDataBuffer<QSGGeometryNode *> &list) //glDepthRange((geomNode->renderOrder() + 0.1) * scale, (geomNode->renderOrder() + 0.9) * scale); const QSGGeometry *g = geomNode->geometry(); - bindGeometry(program, g); - draw(geomNode); + draw(program, g); #ifdef RENDERER_DEBUG geometryNodesDrawn++; diff --git a/src/declarative/scenegraph/coreapi/qsggeometry.cpp b/src/declarative/scenegraph/coreapi/qsggeometry.cpp index 71b5cb63f1..6b622afd8d 100644 --- a/src/declarative/scenegraph/coreapi/qsggeometry.cpp +++ b/src/declarative/scenegraph/coreapi/qsggeometry.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qsggeometry.h" +#include "qsggeometry_p.h" QT_BEGIN_NAMESPACE @@ -122,7 +123,10 @@ QSGGeometry::QSGGeometry(const QSGGeometry::AttributeSet &attributes, , m_attributes(attributes) , m_data(0) , m_index_data_offset(-1) + , m_server_data(0) , m_owns_data(false) + , m_index_usage_pattern(AlwaysUploadPattern) + , m_vertex_usage_pattern(AlwaysUploadPattern) { Q_ASSERT(m_attributes.count > 0); Q_ASSERT(m_attributes.stride > 0); @@ -136,6 +140,9 @@ QSGGeometry::~QSGGeometry() { if (m_owns_data) qFree(m_data); + + if (m_server_data) + delete m_server_data; } /*! @@ -250,6 +257,15 @@ void QSGGeometry::allocate(int vertexCount, int indexCount) m_owns_data = true; } + // If we have associated vbo data we could potentially crash later if + // the old buffers are used with the new vertex and index count, so we force + // an update in the renderer in that case. This is really the users responsibility + // but it is cheap for us to enforce this, so why not... + if (m_server_data) { + markIndexDataDirty(); + markVertexDataDirty(); + } + } /*! @@ -307,4 +323,101 @@ void QSGGeometry::updateTexturedRectGeometry(QSGGeometry *g, const QRectF &rect, v[3].ty = textureRect.bottom(); } + + +/*! + \enum QSGGeometry::DataPattern + + The DataPattern enum is used to specify the use pattern for the vertex + and index data in a geometry object. + + \value AlwaysUploadPattern The data is always uploaded. This means that + the user does not need to explicitly mark index and vertex data as + dirty after changing it. This is the default. + + \value DynamicPattern The data is modified repeatedly and drawn many times. + This is a hint that may provide better performance. When set + the user must make sure to mark the data as dirty after changing it. + + \value StaticPattern The data is modified once and drawn many times. This is + a hint that may provide better performance. When set the user must make sure + to mark the data as dirty after changing it. + */ + + +/*! + \fn QSGGeometry::DataPattern QSGGeometry::indexDataPattern() const + + Returns the usage pattern for indices in this geometry. The default + pattern is AlwaysUploadPattern. + */ + +/*! + Sets the usage pattern for indices to \a p. + + The default is AlwaysUploadPattern. When set to anything other than + the default, the user must call markIndexDataDirty() after changing + the index data. + */ + +void QSGGeometry::setIndexDataPattern(DataPattern p) +{ + m_index_usage_pattern = p; +} + + + + +/*! + \fn QSGGeometry::DataPattern QSGGeometry::vertexDataPattern() const + + Returns the usage pattern for vertices in this geometry. The default + pattern is AlwaysUploadPattern. + */ + +/*! + Sets the usage pattern for vertices to \a p. + + The default is AlwaysUploadPattern. When set to anything other than + the default, the user must call markVertexDataDirty() after changing + the vertex data. + */ + +void QSGGeometry::setVertexDataPattern(DataPattern p) +{ + m_vertex_usage_pattern = p; +} + + + + +/*! + Mark that the vertices in this geometry has changed and must be uploaded + again. + + This function only has an effect when the usage pattern for vertices is + StaticData and the renderer that renders this geometry uploads the geometry + into Vertex Buffer Objects (VBOs). + */ +void QSGGeometry::markIndexDataDirty() +{ + m_dirty_index_data = true; +} + + + +/*! + Mark that the vertices in this geometry has changed and must be uploaded + again. + + This function only has an effect when the usage pattern for vertices is + StaticData and the renderer that renders this geometry uploads the geometry + into Vertex Buffer Objects (VBOs). + */ +void QSGGeometry::markVertexDataDirty() +{ + m_dirty_vertex_data = true; +} + + QT_END_NAMESPACE diff --git a/src/declarative/scenegraph/coreapi/qsggeometry.h b/src/declarative/scenegraph/coreapi/qsggeometry.h index 432503085d..f99eee3c4b 100644 --- a/src/declarative/scenegraph/coreapi/qsggeometry.h +++ b/src/declarative/scenegraph/coreapi/qsggeometry.h @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) +class QSGGeometryData; + class Q_DECLARATIVE_EXPORT QSGGeometry { public: @@ -92,6 +94,13 @@ public: static const AttributeSet &defaultAttributes_TexturedPoint2D(); static const AttributeSet &defaultAttributes_ColoredPoint2D(); + enum DataPattern { + AlwaysUploadPattern = 0, + StreamPattern = 1, + DynamicPattern = 2, + StaticPattern = 3 + }; + QSGGeometry(const QSGGeometry::AttributeSet &attribs, int vertexCount, int indexCount = 0, @@ -134,7 +143,18 @@ public: static void updateRectGeometry(QSGGeometry *g, const QRectF &rect); static void updateTexturedRectGeometry(QSGGeometry *g, const QRectF &rect, const QRectF &sourceRect); + void setIndexDataPattern(DataPattern p); + DataPattern indexDataPattern() const { return (DataPattern) m_index_usage_pattern; } + + void setVertexDataPattern(DataPattern p); + DataPattern vertexDataPattern() const { return (DataPattern) m_vertex_usage_pattern; } + + void markIndexDataDirty(); + void markVertexDataDirty(); + private: + friend class QSGGeometryData; + int m_drawing_mode; int m_vertex_count; int m_index_count; @@ -143,10 +163,14 @@ private: void *m_data; int m_index_data_offset; - void *m_reserved_pointer; + QSGGeometryData *m_server_data; uint m_owns_data : 1; - uint m_reserved_bits : 31; + uint m_index_usage_pattern : 2; + uint m_vertex_usage_pattern : 2; + uint m_dirty_index_data : 1; + uint m_dirty_vertex_data : 1; + uint m_reserved_bits : 27; float m_prealloc[16]; }; diff --git a/src/declarative/scenegraph/coreapi/qsggeometry_p.h b/src/declarative/scenegraph/coreapi/qsggeometry_p.h new file mode 100644 index 0000000000..2fba155000 --- /dev/null +++ b/src/declarative/scenegraph/coreapi/qsggeometry_p.h @@ -0,0 +1,32 @@ +#ifndef QSGGEOMETRY_P_H +#define QSGGEOMETRY_P_H + +#include "qsggeometry.h" + +QT_BEGIN_NAMESPACE + +class QSGGeometryData +{ +public: + virtual ~QSGGeometryData() {} + + static inline QSGGeometryData *data(const QSGGeometry *g) { + return g->m_server_data; + } + + static inline void install(const QSGGeometry *g, QSGGeometryData *data) { + Q_ASSERT(!g->m_server_data); + const_cast<QSGGeometry *>(g)->m_server_data = data; + } + + static bool inline hasDirtyVertexData(const QSGGeometry *g) { return g->m_dirty_vertex_data; } + static void inline clearDirtyVertexData(const QSGGeometry *g) { const_cast<QSGGeometry *>(g)->m_dirty_vertex_data = false; } + + static bool inline hasDirtyIndexData(const QSGGeometry *g) { return g->m_dirty_vertex_data; } + static void inline clearDirtyIndexData(const QSGGeometry *g) { const_cast<QSGGeometry *>(g)->m_dirty_index_data = false; } + +}; + +QT_END_NAMESPACE + +#endif // QSGGEOMETRY_P_H diff --git a/src/declarative/scenegraph/coreapi/qsgnode.cpp b/src/declarative/scenegraph/coreapi/qsgnode.cpp index bff289b332..95afbb51ab 100644 --- a/src/declarative/scenegraph/coreapi/qsgnode.cpp +++ b/src/declarative/scenegraph/coreapi/qsgnode.cpp @@ -1264,8 +1264,6 @@ void QSGNodeDumper::dump(QSGNode *n) void QSGNodeDumper::visitNode(QSGNode *n) { - if (n->isSubtreeBlocked()) - return; qDebug() << QString(m_indent * 2, QLatin1Char(' ')) << n; QSGNodeVisitor::visitNode(n); } diff --git a/src/declarative/scenegraph/coreapi/qsgrenderer.cpp b/src/declarative/scenegraph/coreapi/qsgrenderer.cpp index 67575597ff..c92d943708 100644 --- a/src/declarative/scenegraph/coreapi/qsgrenderer.cpp +++ b/src/declarative/scenegraph/coreapi/qsgrenderer.cpp @@ -43,12 +43,13 @@ #include "qsgnode.h" #include "qsgmaterial.h" #include "qsgnodeupdater_p.h" +#include "qsggeometry_p.h" #include "private/qsgadaptationlayer_p.h" #include <QGLShaderProgram> #include <qglframebufferobject.h> -#include <QtGui/qapplication.h> +#include <QtWidgets/qapplication.h> #include <qdatetime.h> @@ -130,6 +131,8 @@ QSGRenderer::QSGRenderer(QSGContext *context) , m_changed_emitted(false) , m_mirrored(false) , m_is_rendering(false) + , m_vertex_buffer_bound(false) + , m_index_buffer_bound(false) { initializeGLFunctions(); } @@ -254,6 +257,16 @@ void QSGRenderer::renderScene(const QSGBindable &bindable) m_changed_emitted = false; m_bindable = 0; + if (m_vertex_buffer_bound) { + glBindBuffer(GL_ARRAY_BUFFER, 0); + m_vertex_buffer_bound = false; + } + + if (m_index_buffer_bound) { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + m_index_buffer_bound = false; + } + #ifdef QSG_RENDERER_TIMING printf(" - Breakdown of frametime: preprocess=%d, updates=%d, binding=%d, render=%d, total=%d\n", preprocessTime, @@ -473,14 +486,17 @@ QSGRenderer::ClipType QSGRenderer::updateStencilClip(const QSGClipNode *clip) glStencilFunc(GL_EQUAL, clipDepth, 0xff); // stencil test, ref, test mask glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); // stencil fail, z fail, z pass - const QSGGeometry *geometry = clip->geometry(); - Q_ASSERT(geometry->attributeCount() > 0); - const QSGGeometry::Attribute *a = geometry->attributes(); - - glVertexAttribPointer(0, a->tupleSize, a->type, GL_FALSE, geometry->stride(), geometry->vertexData()); + const QSGGeometry *g = clip->geometry(); + Q_ASSERT(g->attributeCount() > 0); + const QSGGeometry::Attribute *a = g->attributes(); + glVertexAttribPointer(0, a->tupleSize, a->type, GL_FALSE, g->stride(), g->vertexData()); m_clip_program.setUniformValue(m_clip_matrix_id, m); - draw(clip); + if (g->indexCount()) { + glDrawElements(g->drawingMode(), g->indexCount(), g->indexType(), g->indexData()); + } else { + glDrawArrays(g->drawingMode(), 0, g->vertexCount()); + } ++clipDepth; } @@ -507,25 +523,6 @@ QSGRenderer::ClipType QSGRenderer::updateStencilClip(const QSGClipNode *clip) } -/*! - Issues the GL draw call for \a geometryNode. - - The function assumes that attributes have been bound and set up prior - to making this call. - - \internal - */ - -void QSGRenderer::draw(const QSGBasicGeometryNode *node) -{ - const QSGGeometry *g = node->geometry(); - if (g->indexCount()) { - glDrawElements(g->drawingMode(), g->indexCount(), g->indexType(), g->indexData()); - } else { - glDrawArrays(g->drawingMode(), 0, g->vertexCount()); - } -} - static inline int size_of_type(GLenum type) { @@ -542,19 +539,102 @@ static inline int size_of_type(GLenum type) 4, sizeof(double) }; + Q_ASSERT(type >= GL_BYTE && type <= 0x140A); // the value of GL_DOUBLE return sizes[type - GL_BYTE]; } + +class QSGRendererVBOGeometryData : public QSGGeometryData +{ +public: + QSGRendererVBOGeometryData() + : vertexBuffer(0) + , indexBuffer(0) + { + } + + ~QSGRendererVBOGeometryData() + { + QGLFunctions *func = QGLContext::currentContext()->functions(); + if (vertexBuffer) + func->glDeleteBuffers(1, &vertexBuffer); + if (indexBuffer) + func->glDeleteBuffers(1, &indexBuffer); + } + + GLuint vertexBuffer; + GLuint indexBuffer; + + static QSGRendererVBOGeometryData *get(const QSGGeometry *g) { + QSGRendererVBOGeometryData *gd = static_cast<QSGRendererVBOGeometryData *>(QSGGeometryData::data(g)); + if (!gd) { + gd = new QSGRendererVBOGeometryData; + QSGGeometryData::install(g, gd); + } + return gd; + } + +}; + +static inline GLenum qt_drawTypeForPattern(QSGGeometry::DataPattern p) +{ + Q_ASSERT(p > 0 && p <= 3); + static GLenum drawTypes[] = { 0, + GL_STREAM_DRAW, + GL_DYNAMIC_DRAW, + GL_STATIC_DRAW + }; + return drawTypes[p]; +} + + /*! - Convenience function to set up and bind the vertex data in \a g to the - required attribute positions defined in \a material. + Issues the GL draw call for the geometry \a g using the material \a shader. + + The function assumes that attributes have been bound and set up prior + to making this call. \internal */ -void QSGRenderer::bindGeometry(QSGMaterialShader *material, const QSGGeometry *g) +void QSGRenderer::draw(const QSGMaterialShader *shader, const QSGGeometry *g) { - char const *const *attrNames = material->attributeNames(); + // ### remove before final release... + static bool use_vbo = !QApplication::arguments().contains("--no-vbo"); + + const void *vertexData; + int vertexByteSize = g->vertexCount() * g->stride(); + if (use_vbo && g->vertexDataPattern() != QSGGeometry::AlwaysUploadPattern && vertexByteSize > 1024) { + + // The base pointer for a VBO is 0 + vertexData = 0; + + bool updateData = QSGGeometryData::hasDirtyVertexData(g); + QSGRendererVBOGeometryData *gd = QSGRendererVBOGeometryData::get(g); + if (!gd->vertexBuffer) { + glGenBuffers(1, &gd->vertexBuffer); + updateData = true; + } + + glBindBuffer(GL_ARRAY_BUFFER, gd->vertexBuffer); + m_vertex_buffer_bound = true; + + if (updateData) { + glBufferData(GL_ARRAY_BUFFER, vertexByteSize, g->vertexData(), + qt_drawTypeForPattern(g->vertexDataPattern())); + QSGGeometryData::clearDirtyVertexData(g); + } + + } else { + if (m_vertex_buffer_bound) { + glBindBuffer(GL_ARRAY_BUFFER, 0); + m_vertex_buffer_bound = false; + } + vertexData = g->vertexData(); + } + + // Bind the vertices to attributes... + char const *const *attrNames = shader->attributeNames(); int offset = 0; for (int j = 0; attrNames[j]; ++j) { if (!*attrNames[j]) @@ -562,15 +642,62 @@ void QSGRenderer::bindGeometry(QSGMaterialShader *material, const QSGGeometry *g Q_ASSERT_X(j < g->attributeCount(), "QSGRenderer::bindGeometry()", "Geometry lacks attribute required by material"); const QSGGeometry::Attribute &a = g->attributes()[j]; Q_ASSERT_X(j == a.position, "QSGRenderer::bindGeometry()", "Geometry does not have continuous attribute positions"); + #if defined(QT_OPENGL_ES_2) GLboolean normalize = a.type != GL_FLOAT; #else GLboolean normalize = a.type != GL_FLOAT && a.type != GL_DOUBLE; #endif - glVertexAttribPointer(a.position, a.tupleSize, a.type, normalize, g->stride(), (char *) g->vertexData() + offset); + glVertexAttribPointer(a.position, a.tupleSize, a.type, normalize, g->stride(), (char *) vertexData + offset); offset += a.tupleSize * size_of_type(a.type); } + + // Set up the indices... + const void *indexData; + if (use_vbo && g->indexDataPattern() != QSGGeometry::AlwaysUploadPattern && g->indexCount() > 512) { + + // Base pointer for a VBO is 0 + indexData = 0; + + bool updateData = QSGGeometryData::hasDirtyIndexData(g); + QSGRendererVBOGeometryData *gd = QSGRendererVBOGeometryData::get(g); + if (!gd->indexBuffer) { + glGenBuffers(1, &gd->indexBuffer); + updateData = true; + } + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gd->indexBuffer); + m_index_buffer_bound = true; + + if (updateData) { + glBufferData(GL_ELEMENT_ARRAY_BUFFER, + g->indexCount() * (g->indexType() == GL_UNSIGNED_SHORT ? 2 : 4), + g->indexData(), + qt_drawTypeForPattern(g->indexDataPattern())); + QSGGeometryData::clearDirtyIndexData(g); + } + + } else { + if (m_index_buffer_bound) { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + m_index_buffer_bound = false; + } + indexData = g->indexData(); + } + + + // draw the stuff... + if (g->indexCount()) { + glDrawElements(g->drawingMode(), g->indexCount(), g->indexType(), indexData); + } else { + glDrawArrays(g->drawingMode(), 0, g->vertexCount()); + } + + // We leave buffers bound for now... They will be reset by bind on next draw() or + // set back to 0 if next draw is not using VBOs + } + QT_END_NAMESPACE diff --git a/src/declarative/scenegraph/coreapi/qsgrenderer_p.h b/src/declarative/scenegraph/coreapi/qsgrenderer_p.h index 3fdcf06a08..842286b47c 100644 --- a/src/declarative/scenegraph/coreapi/qsgrenderer_p.h +++ b/src/declarative/scenegraph/coreapi/qsgrenderer_p.h @@ -137,8 +137,7 @@ signals: void sceneGraphChanged(); // Add, remove, ChangeFlags changes... protected: - void draw(const QSGBasicGeometryNode *geometry); - void bindGeometry(QSGMaterialShader *material, const QSGGeometry *g); + void draw(const QSGMaterialShader *material, const QSGGeometry *g); virtual void render() = 0; QSGRenderer::ClipType updateStencilClip(const QSGClipNode *clip); @@ -174,9 +173,12 @@ private: const QSGBindable *m_bindable; - bool m_changed_emitted : 1; - bool m_mirrored : 1; - bool m_is_rendering : 1; + uint m_changed_emitted : 1; + uint m_mirrored : 1; + uint m_is_rendering : 1; + + uint m_vertex_buffer_bound : 1; + uint m_index_buffer_bound : 1; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QSGRenderer::ClearMode) diff --git a/src/declarative/scenegraph/qsgcontextplugin.cpp b/src/declarative/scenegraph/qsgcontextplugin.cpp index b5e74e6cc3..c744444aeb 100644 --- a/src/declarative/scenegraph/qsgcontextplugin.cpp +++ b/src/declarative/scenegraph/qsgcontextplugin.cpp @@ -41,7 +41,7 @@ #include "qsgcontextplugin_p.h" #include <private/qsgcontext_p.h> -#include <QtGui/qapplication.h> +#include <QtWidgets/qapplication.h> #include <QtCore/private/qfactoryloader_p.h> #include <QtCore/qlibraryinfo.h> diff --git a/src/declarative/scenegraph/scenegraph.pri b/src/declarative/scenegraph/scenegraph.pri index aa9d2bc6b2..6fea47be05 100644 --- a/src/declarative/scenegraph/scenegraph.pri +++ b/src/declarative/scenegraph/scenegraph.pri @@ -11,7 +11,9 @@ HEADERS += \ $$PWD/coreapi/qsgmaterial.h \ $$PWD/coreapi/qsgnode.h \ $$PWD/coreapi/qsgnodeupdater_p.h \ - $$PWD/coreapi/qsgrenderer_p.h + $$PWD/coreapi/qsgrenderer_p.h \ + $$PWD/coreapi/qsggeometry_p.h + SOURCES += \ $$PWD/coreapi/qsgdefaultrenderer.cpp \ $$PWD/coreapi/qsggeometry.cpp \ diff --git a/src/declarative/scenegraph/util/qsgtextureprovider.cpp b/src/declarative/scenegraph/util/qsgtextureprovider.cpp index abaf96ed5a..49d157d480 100644 --- a/src/declarative/scenegraph/util/qsgtextureprovider.cpp +++ b/src/declarative/scenegraph/util/qsgtextureprovider.cpp @@ -41,6 +41,9 @@ #include "qsgtextureprovider_p.h" +#include <qsgimage_p.h> +#include <qsgshadereffectsource_p.h> + #ifndef GL_CLAMP_TO_EDGE #define GL_CLAMP_TO_EDGE 0x812F #endif @@ -50,16 +53,10 @@ QT_BEGIN_NAMESPACE /*! \class QSGTextureProvider \brief The QSGTextureProvider class encapsulates texture based entities in QML. - */ - -/*! - Convenience function for casting a QObject to a QSGTextureProvider + The QSGTextureProvider lives primarily in the scene graph rendering thread. */ -QSGTextureProvider *QSGTextureProvider::from(QObject *object) -{ - return object ? static_cast<QSGTextureProvider *>(object->qt_metacast("QSGTextureProvider")) : 0; -} + QT_END_NAMESPACE diff --git a/src/declarative/scenegraph/util/qsgtextureprovider_p.h b/src/declarative/scenegraph/util/qsgtextureprovider_p.h index 756f1c613a..ebb6ca8507 100644 --- a/src/declarative/scenegraph/util/qsgtextureprovider_p.h +++ b/src/declarative/scenegraph/util/qsgtextureprovider_p.h @@ -42,8 +42,6 @@ #ifndef QSGTEXTUREPROVIDER_H #define QSGTEXTUREPROVIDER_H -#include <qgl.h> - #include "qsgtexture.h" #include "qobject.h" @@ -53,15 +51,15 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QSGTextureProvider +class Q_DECLARATIVE_EXPORT QSGTextureProvider : public QObject { + Q_OBJECT public: virtual QSGTexture *texture() const = 0; - virtual const char *textureChangedSignal() const { return 0; } - static QSGTextureProvider *from(QObject *object); +Q_SIGNALS: + void textureChanged(); }; -Q_DECLARE_INTERFACE(QSGTextureProvider, "QSGTextureProvider") QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativeapplication.cpp b/src/declarative/util/qdeclarativeapplication.cpp index 11b0b636cb..f745ba6fa8 100644 --- a/src/declarative/util/qdeclarativeapplication.cpp +++ b/src/declarative/util/qdeclarativeapplication.cpp @@ -41,7 +41,7 @@ #include "qdeclarativeapplication_p.h" #include <private/qobject_p.h> -#include <QtGui/QApplication> +#include <QtWidgets/QApplication> QT_BEGIN_NAMESPACE diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 6ac21002a5..32f36105fc 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -53,7 +53,7 @@ #include "private/qdeclarativestate_p_p.h" #include <QtCore/qdebug.h> -#include <QtGui/qgraphicsitem.h> +#include <QtWidgets/qgraphicsitem.h> #include <QtCore/qmath.h> #include <private/qobject_p.h> diff --git a/src/imports/gestures/gestures.pro b/src/imports/gestures/gestures.pro index d94b402f4c..3b735efac5 100644 --- a/src/imports/gestures/gestures.pro +++ b/src/imports/gestures/gestures.pro @@ -2,7 +2,7 @@ TARGET = qmlgesturesplugin TARGETPATH = Qt/labs/gestures include(../qimportbase.pri) -QT += core-private gui-private declarative-private qtquick1 qtquick1-private +QT += core-private gui-private declarative-private qtquick1 qtquick1-private widgets-private SOURCES += qdeclarativegesturearea.cpp plugin.cpp HEADERS += qdeclarativegesturearea_p.h diff --git a/src/imports/gestures/qdeclarativegesturearea_p.h b/src/imports/gestures/qdeclarativegesturearea_p.h index 64da7f9a11..802703c767 100644 --- a/src/imports/gestures/qdeclarativegesturearea_p.h +++ b/src/imports/gestures/qdeclarativegesturearea_p.h @@ -48,7 +48,7 @@ #include <QtCore/qobject.h> #include <QtCore/qstring.h> -#include <QtGui/qgesture.h> +#include <QtWidgets/qgesture.h> #ifndef QT_NO_GESTURES diff --git a/src/imports/imports.pro b/src/imports/imports.pro index c60e72db08..6096ad7a6a 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,5 +1,6 @@ TEMPLATE = subdirs SUBDIRS += qtquick1 qt47 folderlistmodel particles gestures inputcontext etcprovider -contains(QT_CONFIG, qmltest): SUBDIRS += testlib +# ### refactor: port properly +# contains(QT_CONFIG, qmltest): SUBDIRS += testlib diff --git a/src/imports/inputcontext/declarativeinputcontext.h b/src/imports/inputcontext/declarativeinputcontext.h index 757c6c43ed..9e6e65fd6e 100644 --- a/src/imports/inputcontext/declarativeinputcontext.h +++ b/src/imports/inputcontext/declarativeinputcontext.h @@ -42,7 +42,7 @@ #ifndef DECLARATIVEINPUTCONTEXT_H #define DECLARATIVEINPUTCONTEXT_H -#include <QtGui/qinputcontext.h> +#include <QtWidgets/qinputcontext.h> QT_BEGIN_HEADER diff --git a/src/imports/inputcontext/inputcontext.pro b/src/imports/inputcontext/inputcontext.pro index cbad82c5b1..c8641d20e3 100755 --- a/src/imports/inputcontext/inputcontext.pro +++ b/src/imports/inputcontext/inputcontext.pro @@ -2,7 +2,7 @@ TARGET = qmlinputcontextplugin TARGETPATH = Qt/labs/inputcontext include(../qimportbase.pri) -QT += declarative +QT += declarative widgets SOURCES += \ declarativeinputcontext.cpp \ diff --git a/src/imports/inputcontext/inputcontextfilter.cpp b/src/imports/inputcontext/inputcontextfilter.cpp index 656a869a88..be89841b85 100644 --- a/src/imports/inputcontext/inputcontextfilter.cpp +++ b/src/imports/inputcontext/inputcontextfilter.cpp @@ -43,7 +43,7 @@ #include "declarativeinputcontext.h" -#include <QtGui/qapplication.h> +#include <QtWidgets/qapplication.h> QT_BEGIN_NAMESPACE diff --git a/src/imports/inputcontext/inputcontextmodule.cpp b/src/imports/inputcontext/inputcontextmodule.cpp index d5f9161c0c..578fb98733 100644 --- a/src/imports/inputcontext/inputcontextmodule.cpp +++ b/src/imports/inputcontext/inputcontextmodule.cpp @@ -44,9 +44,9 @@ #include "declarativeinputcontext.h" #include <QtCore/qdebug.h> -#include <QtGui/qapplication.h> #include <QtGui/qevent.h> #include <QtGui/qtextformat.h> +#include <QtWidgets/qapplication.h> QT_BEGIN_NAMESPACE diff --git a/src/imports/inputcontext/plugin.cpp b/src/imports/inputcontext/plugin.cpp index 5ce9e5b475..70fed2e241 100644 --- a/src/imports/inputcontext/plugin.cpp +++ b/src/imports/inputcontext/plugin.cpp @@ -44,7 +44,7 @@ #include "inputcontextmodule.h" #include <QtDeclarative/qdeclarativeextensionplugin.h> -#include <QtGui/qapplication.h> +#include <QtWidgets/qapplication.h> QT_BEGIN_NAMESPACE diff --git a/src/imports/particles/V1/qdeclarativeparticles.cpp b/src/imports/particles/V1/qdeclarativeparticles.cpp index f307109ee8..92248347aa 100644 --- a/src/imports/particles/V1/qdeclarativeparticles.cpp +++ b/src/imports/particles/V1/qdeclarativeparticles.cpp @@ -48,7 +48,7 @@ #include <QtCore/QAbstractAnimation> #include <QPainter> -#include <QtGui/qdrawutil.h> +#include <QtWidgets/qdrawutil.h> #include <QVarLengthArray> #include <stdlib.h> diff --git a/src/imports/particles/particles.pro b/src/imports/particles/particles.pro index c73d068e2c..79906563f8 100644 --- a/src/imports/particles/particles.pro +++ b/src/imports/particles/particles.pro @@ -9,7 +9,7 @@ SOURCES += \ particles.cpp \ V1/qdeclarativeparticles.cpp -QT += declarative opengl core gui declarative-private core-private gui-private qtquick1 qtquick1-private +QT += declarative opengl core gui declarative-private core-private gui-private qtquick1 qtquick1-private widgets-private OTHER_FILES += \ qmldir diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp index 3323d54246..3cb35e5738 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp @@ -50,7 +50,7 @@ #include <QtDeclarative/private/qdeclarativedebughelper_p.h> #include "QtDeclarative/private/qdeclarativeinspectorservice_p.h" -#include <QtGui/QVBoxLayout> +#include <QtWidgets/QVBoxLayout> #include <QtGui/QMouseEvent> #include <QtCore/QSettings> diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp index da9f442026..98fbc7e453 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp @@ -44,7 +44,7 @@ #include "../qdeclarativeviewinspector.h" #include "../qmlinspectorconstants.h" -#include <QtGui/QGraphicsPolygonItem> +#include <QtWidgets/QGraphicsPolygonItem> #include <QtCore/QTimer> #include <QtCore/QObject> diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp index 72e1380146..5058f5e471 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp @@ -48,7 +48,7 @@ #include <QtCore/QRectF> #include <QtGui/QRgb> #include <QtGui/QImage> -#include <QtGui/QApplication> +#include <QtWidgets/QApplication> #include <QtGui/QPalette> namespace QmlJSDebugger { diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.h b/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.h index 4dccc0b6f3..15f9a27fa4 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.h +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.h @@ -42,7 +42,7 @@ #ifndef LIVELAYERITEM_H #define LIVELAYERITEM_H -#include <QtGui/QGraphicsObject> +#include <QtWidgets/QGraphicsObject> namespace QmlJSDebugger { diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.cpp index b08682a396..eda81f0775 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.cpp @@ -43,7 +43,7 @@ #include "../qdeclarativeviewinspector_p.h" -#include <QtGui/QGraphicsItem> +#include <QtWidgets/QGraphicsItem> #include <QtCore/QDebug> diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.cpp index c57bc0e26c..036eb975a8 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.cpp @@ -44,9 +44,9 @@ #include "../qdeclarativeviewinspector_p.h" #include "../qmlinspectorconstants.h" -#include <QtGui/QGraphicsRectItem> -#include <QtGui/QGraphicsObject> -#include <QtGui/QGraphicsScene> +#include <QtWidgets/QGraphicsRectItem> +#include <QtWidgets/QGraphicsObject> +#include <QtWidgets/QGraphicsScene> #include <QtGui/QPen> namespace QmlJSDebugger { diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.cpp index 4e144589b7..23577561a4 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.cpp @@ -44,9 +44,9 @@ #include "../qmlinspectorconstants.h" #include <QtGui/QPen> -#include <QtGui/QGraphicsRectItem> -#include <QtGui/QGraphicsObject> -#include <QtGui/QGraphicsScene> +#include <QtWidgets/QGraphicsRectItem> +#include <QtWidgets/QGraphicsObject> +#include <QtWidgets/QGraphicsScene> #include <QtCore/QtDebug> diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp index 9b52de1c53..884e1928a4 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp @@ -44,13 +44,13 @@ #include "../qdeclarativeviewinspector_p.h" -#include <QtGui/QApplication> +#include <QtWidgets/QApplication> #include <QtGui/QWheelEvent> #include <QtGui/QMouseEvent> #include <QtGui/QClipboard> -#include <QtGui/QMenu> -#include <QtGui/QAction> -#include <QtGui/QGraphicsObject> +#include <QtWidgets/QMenu> +#include <QtWidgets/QAction> +#include <QtWidgets/QGraphicsObject> #include <QtQuick1/QDeclarativeItem> #include <QtDeclarative/QDeclarativeEngine> diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.cpp index 4e0e37518a..1f3a1e12c2 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.cpp @@ -42,10 +42,10 @@ #include "qmltoolbar.h" #include "toolbarcolorbox.h" -#include <QtGui/QLabel> -#include <QtGui/QIcon> -#include <QtGui/QAction> -#include <QtGui/QMenu> +#include <QtWidgets/QLabel> +#include <QtWidgets/QIcon> +#include <QtWidgets/QAction> +#include <QtWidgets/QMenu> #include <QtCore/QDebug> diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.h b/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.h index 2abf1660f0..177885f700 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.h +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.h @@ -42,8 +42,8 @@ #ifndef QMLTOOLBAR_H #define QMLTOOLBAR_H -#include <QtGui/QToolBar> -#include <QtGui/QIcon> +#include <QtWidgets/QToolBar> +#include <QtWidgets/QIcon> #include "../qmlinspectorconstants.h" diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.h b/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.h index e41d70a61b..72c74663a1 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.h +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.h @@ -42,7 +42,7 @@ #ifndef SUBCOMPONENTMASKLAYERITEM_H #define SUBCOMPONENTMASKLAYERITEM_H -#include <QtGui/QGraphicsPolygonItem> +#include <QtWidgets/QGraphicsPolygonItem> namespace QmlJSDebugger { diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.cpp index 091466284f..64d4035d09 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.cpp @@ -45,12 +45,12 @@ #include <QtGui/QPixmap> #include <QtGui/QPainter> -#include <QtGui/QMenu> -#include <QtGui/QAction> +#include <QtWidgets/QMenu> +#include <QtWidgets/QAction> #include <QtGui/QContextMenuEvent> #include <QtGui/QClipboard> -#include <QtGui/QApplication> -#include <QtGui/QColorDialog> +#include <QtWidgets/QApplication> +#include <QtWidgets/QColorDialog> #include <QtGui/QDrag> #include <QtCore/QMimeData> diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.h b/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.h index 8ef75a4114..ce5ecf0e7e 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.h +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.h @@ -42,7 +42,7 @@ #ifndef TOOLBARCOLORBOX_H #define TOOLBARCOLORBOX_H -#include <QtGui/QLabel> +#include <QtWidgets/QLabel> #include <QtGui/QColor> #include <QtCore/QPoint> diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp index c8ade825a2..1aad9c351b 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp @@ -46,8 +46,8 @@ #include <QtGui/QMouseEvent> #include <QtGui/QWheelEvent> #include <QtGui/QKeyEvent> -#include <QtGui/QMenu> -#include <QtGui/QAction> +#include <QtWidgets/QMenu> +#include <QtWidgets/QAction> #include <QtCore/QRectF> #include <QtCore/QDebug> diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp index bef218ca6b..f97ce010ba 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp @@ -52,9 +52,9 @@ #include <QtDeclarative/QDeclarativeEngine> #include <QtDeclarative/QDeclarativeContext> #include <QtDeclarative/QDeclarativeExpression> -#include <QtGui/QWidget> +#include <QtWidgets/QWidget> #include <QtGui/QMouseEvent> -#include <QtGui/QGraphicsObject> +#include <QtWidgets/QGraphicsObject> namespace QmlJSDebugger { diff --git a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro index 7f4d54e53a..d547422cb0 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro +++ b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro @@ -1,7 +1,7 @@ load(qt_module) TARGET = qmldbg_inspector -QT += declarative-private core-private gui-private opengl-private qtquick1 +QT += declarative-private core-private gui-private opengl-private qtquick1 widgets widgets-private load(qt_plugin) diff --git a/src/plugins/qmltooling/qmldbg_inspector/sgselectiontool.cpp b/src/plugins/qmltooling/qmldbg_inspector/sgselectiontool.cpp index 36e2818674..653c059d53 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/sgselectiontool.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/sgselectiontool.cpp @@ -44,7 +44,7 @@ #include "sghighlight.h" #include "sgviewinspector.h" -#include <QtGui/QMenu> +#include <QtWidgets/QMenu> #include <QtGui/QMouseEvent> #include <QtDeclarative/QSGView> #include <QtDeclarative/QSGItem> diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h index 5ec278bf0e..f6886714c8 100644 --- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h +++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h @@ -42,6 +42,7 @@ #ifndef QTCPSERVERCONNECTION_H #define QTCPSERVERCONNECTION_H +#include <QtWidgets/QStylePlugin> #include <QtDeclarative/private/qdeclarativedebugserverconnection_p.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro index 8220109efc..d400f741cc 100644 --- a/src/plugins/qmltooling/qmltooling.pro +++ b/src/plugins/qmltooling/qmltooling.pro @@ -1,4 +1,8 @@ TEMPLATE = subdirs -SUBDIRS = qmldbg_tcp qmldbg_inspector +SUBDIRS = qmldbg_tcp + +# ### refactor: +# SUBDIRS = qmldbg_inspector + symbian:SUBDIRS += qmldbg_ost diff --git a/src/qmltest/quicktest.h b/src/qmltest/quicktest.h index ebf7ce6cb3..1f8fe210e7 100644 --- a/src/qmltest/quicktest.h +++ b/src/qmltest/quicktest.h @@ -43,7 +43,7 @@ #define QUICKTEST_H #include <QtQuickTest/quicktestglobal.h> -#include <QtGui/qwidget.h> +#include <QtWidgets/qwidget.h> #ifdef QT_OPENGL_LIB #include <QtOpenGL/qgl.h> #endif diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp index 1be6a6f6e6..67f1eefe57 100644 --- a/src/qmltest/quicktestevent.cpp +++ b/src/qmltest/quicktestevent.cpp @@ -49,7 +49,7 @@ #include <QtDeclarative/qsgcanvas.h> #define QUICK_TEST_SCENEGRAPH 1 #endif -#include <QtGui/qgraphicsscene.h> +#include <QtWidgets/qgraphicsscene.h> QT_BEGIN_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeborderimage.cpp b/src/qtquick1/graphicsitems/qdeclarativeborderimage.cpp index 63b00d1114..1beef966f0 100644 --- a/src/qtquick1/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativeborderimage.cpp @@ -49,6 +49,8 @@ #include <QNetworkReply> #include <QFile> +#include <QtWidgets/qdrawutil.h> + QT_BEGIN_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeflipable.cpp b/src/qtquick1/graphicsitems/qdeclarativeflipable.cpp index a3aba31c57..e9c23b4dfd 100644 --- a/src/qtquick1/graphicsitems/qdeclarativeflipable.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativeflipable.cpp @@ -46,7 +46,7 @@ #include <QtDeclarative/qdeclarativeinfo.h> -#include <QtGui/qgraphicstransform.h> +#include <QtWidgets/qgraphicstransform.h> QT_BEGIN_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativefocuspanel.cpp b/src/qtquick1/graphicsitems/qdeclarativefocuspanel.cpp index 4797033bff..b3285716ca 100644 --- a/src/qtquick1/graphicsitems/qdeclarativefocuspanel.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativefocuspanel.cpp @@ -43,7 +43,7 @@ #include "QtQuick1/private/qdeclarativeitem_p.h" -#include <QtGui/qgraphicsscene.h> +#include <QtWidgets/qgraphicsscene.h> #include <QEvent> QT_BEGIN_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeitem.cpp b/src/qtquick1/graphicsitems/qdeclarativeitem.cpp index 00d5fd672d..b32898fe38 100644 --- a/src/qtquick1/graphicsitems/qdeclarativeitem.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativeitem.cpp @@ -60,9 +60,10 @@ #include <QGraphicsSceneMouseEvent> #include <QtCore/qnumeric.h> #include <QtDeclarative/qjsengine.h> -#include <QtGui/qgraphicstransform.h> #include <private/qv8engine_p.h> +#include <QtWidgets/qgraphicstransform.h> +#include <private/qlistmodelinterface_p.h> #include <float.h> @@ -2896,7 +2897,7 @@ QDeclarativeListProperty<QDeclarative1Transition> QDeclarativeItemPrivate::trans If clipping is enabled, an item will clip its own painting, as well as the painting of its children, to its bounding rectangle. If you set - clipping during an item's paint operation, remember to re-set it to + clipping during an item's paint operation, remember to re-set it to prevent clipping the rest of your scene. Non-rectangular clipping regions are not supported for performance reasons. diff --git a/src/qtquick1/graphicsitems/qdeclarativeitem.h b/src/qtquick1/graphicsitems/qdeclarativeitem.h index a3f4931316..609af803f6 100644 --- a/src/qtquick1/graphicsitems/qdeclarativeitem.h +++ b/src/qtquick1/graphicsitems/qdeclarativeitem.h @@ -47,10 +47,10 @@ #include <QtCore/QObject> #include <QtCore/QList> -#include <QtGui/qgraphicsitem.h> -#include <QtGui/qgraphicstransform.h> #include <QtGui/qfont.h> -#include <QtGui/qaction.h> +#include <QtWidgets/qgraphicsitem.h> +#include <QtWidgets/qgraphicstransform.h> +#include <QtWidgets/qaction.h> QT_BEGIN_HEADER diff --git a/src/qtquick1/graphicsitems/qdeclarativeitem_p.h b/src/qtquick1/graphicsitems/qdeclarativeitem_p.h index 58d57abbf3..0604194004 100644 --- a/src/qtquick1/graphicsitems/qdeclarativeitem_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeitem_p.h @@ -72,7 +72,7 @@ #include <QtCore/qrect.h> #include <QtCore/qdebug.h> -#include <private/qgraphicsitem_p.h> +#include <QtWidgets/private/qgraphicsitem_p.h> QT_BEGIN_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeitemsmodule.cpp b/src/qtquick1/graphicsitems/qdeclarativeitemsmodule.cpp index 47fd2ddf38..0a20b949b8 100644 --- a/src/qtquick1/graphicsitems/qdeclarativeitemsmodule.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativeitemsmodule.cpp @@ -41,10 +41,10 @@ #include "QtQuick1/private/qdeclarativeitemsmodule_p.h" -#include <QtGui/qaction.h> +#include <QtWidgets/qaction.h> #include <QtGui/qvalidator.h> -#include <QtGui/qgraphicseffect.h> -#include <QtGui/qgraphicsitem.h> +#include <QtWidgets/qgraphicseffect.h> +#include <QtWidgets/qgraphicsitem.h> #include "QtQuick1/private/qdeclarativeevents_p_p.h" #include "QtQuick1/private/qdeclarativescalegrid_p_p.h" diff --git a/src/qtquick1/graphicsitems/qdeclarativerectangle.cpp b/src/qtquick1/graphicsitems/qdeclarativerectangle.cpp index 32f8197192..088c296a26 100644 --- a/src/qtquick1/graphicsitems/qdeclarativerectangle.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativerectangle.cpp @@ -45,6 +45,7 @@ #include <QPainter> #include <QStringBuilder> #include <QtCore/qmath.h> +#include <QtWidgets/qdrawutil.h> QT_BEGIN_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp b/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp index a14d837be0..271595a863 100644 --- a/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp @@ -900,7 +900,7 @@ void QDeclarative1TextInput::setEchoMode(QDeclarative1TextInput::EchoMode echo) Q_D(QDeclarative1TextInput); if (echoMode() == echo) return; - d->control->setEchoMode((uint)echo); + d->control->setEchoMode((QLineControl::EchoMode)echo); d->updateInputMethodHints(); q_textChanged(); emit echoModeChanged(echoMode()); diff --git a/src/qtquick1/qtquick1.pro b/src/qtquick1/qtquick1.pro index 7fc670f801..2e3113e214 100644 --- a/src/qtquick1/qtquick1.pro +++ b/src/qtquick1/qtquick1.pro @@ -7,8 +7,7 @@ CONFIG += module CONFIG += dll warn_on MODULE_PRI += ../../modules/qt_qtquick1.pri -QT += testlib-private declarative testlib declarative-private core-private gui-private network -DEFINES += QT_NO_URL_CAST_FROM_STRING +QT += testlib-private declarative testlib declarative-private core-private gui-private network widgets-private load(qt_module_config) diff --git a/src/qtquick1/util/qdeclarativeapplication.cpp b/src/qtquick1/util/qdeclarativeapplication.cpp index 3cc572f27b..0947fe4f15 100644 --- a/src/qtquick1/util/qdeclarativeapplication.cpp +++ b/src/qtquick1/util/qdeclarativeapplication.cpp @@ -41,7 +41,7 @@ #include "QtQuick1/private/qdeclarativeapplication_p.h" #include <private/qobject_p.h> -#include <QtGui/QApplication> +#include <QtWidgets/QApplication> QT_BEGIN_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativestateoperations.cpp b/src/qtquick1/util/qdeclarativestateoperations.cpp index e405fba34f..7d57083c59 100644 --- a/src/qtquick1/util/qdeclarativestateoperations.cpp +++ b/src/qtquick1/util/qdeclarativestateoperations.cpp @@ -55,7 +55,7 @@ #include <QtQuick1/private/qdeclarativestate_p_p.h> #include <QtCore/qdebug.h> -#include <QtGui/qgraphicsitem.h> +#include <QtWidgets/qgraphicsitem.h> #include <QtCore/qmath.h> #include <private/qobject_p.h> diff --git a/src/qtquick1/util/qdeclarativeview.cpp b/src/qtquick1/util/qdeclarativeview.cpp index d10d34fcd1..fd5f9debf7 100644 --- a/src/qtquick1/util/qdeclarativeview.cpp +++ b/src/qtquick1/util/qdeclarativeview.cpp @@ -64,8 +64,8 @@ #include <qgraphicswidget.h> #include <qbasictimer.h> #include <QtCore/qabstractanimation.h> -#include <private/qgraphicsview_p.h> #include <QtQuick1/private/qdeclarativeitem_p.h> +#include <QtWidgets/private/qgraphicsview_p.h> #include <private/qabstractanimation_p.h> #include <QtQuick1/private/qdeclarativeitemchangelistener_p.h> diff --git a/src/qtquick1/util/qdeclarativeview.h b/src/qtquick1/util/qdeclarativeview.h index 39a2322f99..b655d2830f 100644 --- a/src/qtquick1/util/qdeclarativeview.h +++ b/src/qtquick1/util/qdeclarativeview.h @@ -44,9 +44,9 @@ #include <QtCore/qdatetime.h> #include <QtCore/qurl.h> -#include <QtGui/qgraphicssceneevent.h> -#include <QtGui/qgraphicsview.h> -#include <QtGui/qwidget.h> +#include <QtWidgets/qgraphicssceneevent.h> +#include <QtWidgets/qgraphicsview.h> +#include <QtWidgets/qwidget.h> QT_BEGIN_HEADER diff --git a/src/src.pro b/src/src.pro index a8a33a7fd6..f214763f52 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,5 +1,9 @@ TEMPLATE = subdirs CONFIG += ordered SUBDIRS += declarative qtquick1 plugins -contains(QT_CONFIG, qmltest): SUBDIRS += qmltest + +# ### refactor: port properly +# contains(QT_CONFIG, qmltest): SUBDIRS += qmltest + SUBDIRS += imports +QT += script widgets widgets-private diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro index d1593960de..297559ef97 100644 --- a/tests/auto/declarative/examples/examples.pro +++ b/tests/auto/declarative/examples/examples.pro @@ -18,6 +18,6 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private qtquick1-private +QT += core-private gui-private declarative-private qtquick1-private widgets-private qpa:CONFIG+=insignificant_test # QTBUG-20990, aborts diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index 072ab7524e..e2edc3e93c 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -245,7 +245,8 @@ void tst_examples::sgexamples() QCOMPARE(view.status(), QSGView::Ready); view.show(); - QTest::qWaitForWindowShown(&view); + QTest::qWait(100); + } QTEST_MAIN(tst_examples) diff --git a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp index 24330c9f2e..91485e48d8 100644 --- a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "tst_qjsvalue.h" -#include <QtGui/QPushButton> +#include <QtWidgets/QPushButton> //TESTED_CLASS= //TESTED_FILES= diff --git a/tests/auto/declarative/qsglistview/qsglistview.pro b/tests/auto/declarative/qsglistview/qsglistview.pro index 9b31bcb7bf..3e18e9b467 100644 --- a/tests/auto/declarative/qsglistview/qsglistview.pro +++ b/tests/auto/declarative/qsglistview/qsglistview.pro @@ -14,5 +14,5 @@ symbian: { } CONFIG += parallel_test -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private widgets widgets-private QT += opengl-private diff --git a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp index 0cd10f6046..94d6cf3d45 100644 --- a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp +++ b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include <QtTest/QtTest> -#include <QtGui/QStringListModel> +#include <QtWidgets/QStringListModel> #include <QtDeclarative/qsgview.h> #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecontext.h> diff --git a/tests/auto/headersclean/headersclean.pro b/tests/auto/headersclean/headersclean.pro index 54ea66a51d..c9522f9b50 100644 --- a/tests/auto/headersclean/headersclean.pro +++ b/tests/auto/headersclean/headersclean.pro @@ -2,4 +2,4 @@ load(qttest_p4) SOURCES += tst_headersclean.cpp QT = core -contains(QT_CONFIG,declarative): QT += declarative +contains(QT_CONFIG,declarative): QT += declarative declarative-private diff --git a/tests/auto/headersclean/tst_headersclean.cpp b/tests/auto/headersclean/tst_headersclean.cpp index 9aa7f1d693..60bb799076 100644 --- a/tests/auto/headersclean/tst_headersclean.cpp +++ b/tests/auto/headersclean/tst_headersclean.cpp @@ -49,7 +49,6 @@ #include <QtCore/QtCore> #include <QtTest/QtTest> -#include <QtDeclarative/QtDeclarative> class tst_HeadersClean: public QObject { diff --git a/tests/auto/qtquick1/qdeclarativeview/qdeclarativeview.pro b/tests/auto/qtquick1/qdeclarativeview/qdeclarativeview.pro index 603eab08d7..d2b157ec1b 100644 --- a/tests/auto/qtquick1/qdeclarativeview/qdeclarativeview.pro +++ b/tests/auto/qtquick1/qdeclarativeview/qdeclarativeview.pro @@ -11,4 +11,4 @@ symbian: { } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } -QT += core-private gui-private declarative-private qtquick1-private +QT += core-private gui-private declarative-private qtquick1-private widgets diff --git a/tests/auto/qtquick1/qdeclarativeview/tst_qdeclarativeview.cpp b/tests/auto/qtquick1/qdeclarativeview/tst_qdeclarativeview.cpp index 325071f489..9b844de946 100644 --- a/tests/auto/qtquick1/qdeclarativeview/tst_qdeclarativeview.cpp +++ b/tests/auto/qtquick1/qdeclarativeview/tst_qdeclarativeview.cpp @@ -44,7 +44,7 @@ #include <QtDeclarative/qdeclarativecontext.h> #include <QtQuick1/qdeclarativeview.h> #include <QtQuick1/qdeclarativeitem.h> -#include <QtGui/qgraphicswidget.h> +#include <QtWidgets/qgraphicswidget.h> #include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN diff --git a/tests/auto/qtquick1/qdeclarativeviewer/qdeclarativeviewer.pro b/tests/auto/qtquick1/qdeclarativeviewer/qdeclarativeviewer.pro index 010fa3696a..ca214b1210 100644 --- a/tests/auto/qtquick1/qdeclarativeviewer/qdeclarativeviewer.pro +++ b/tests/auto/qtquick1/qdeclarativeviewer/qdeclarativeviewer.pro @@ -17,4 +17,4 @@ symbian: { } CONFIG += parallel_test -QT += core-private gui-private declarative-private qtquick1-private +QT += core-private gui-private declarative-private qtquick1-private widgets-private diff --git a/tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index f4fc4f0d46..e6bd2d0a31 100644 --- a/tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -44,7 +44,7 @@ #include <QtQuick1/qdeclarativeview.h> #include <QtQuick1/qdeclarativeitem.h> #include <QtDeclarative/qdeclarativecontext.h> -#include <QtGui/qmenubar.h> +#include <QtWidgets/qmenubar.h> #include <QSignalSpy> #include "../../../shared/util.h" #include "qmlruntime.h" diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index 46d31739ee..c553070123 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -43,7 +43,7 @@ #include <QtDeclarative/private/qdeclarativemetatype_p.h> #include <QtDeclarative/private/qdeclarativeopenmetaobject_p.h> -#include <QtGui/QApplication> +#include <QtWidgets/QApplication> #include <QtCore/QSet> #include <QtCore/QMetaObject> diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp index e6603adbd8..0139f591a6 100644 --- a/tools/qmlscene/main.cpp +++ b/tools/qmlscene/main.cpp @@ -41,19 +41,19 @@ #include <QtCore/qdebug.h> #include <QtCore/qabstractanimation.h> -#include <QtGui/qapplication.h> +#include <QtWidgets/qapplication.h> #include <QtDeclarative/qdeclarative.h> #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecomponent.h> #include <QtQuick1/qdeclarativeview.h> #include <QtCore/qdir.h> -#include <QtGui/QFormLayout> -#include <QtGui/QComboBox> -#include <QtGui/QCheckBox> -#include <QtGui/QDialog> -#include <QtGui/QDialogButtonBox> -#include <QtGui/QFileDialog> -#include <QtGui/QGraphicsView> +#include <QtWidgets/QFormLayout> +#include <QtWidgets/QComboBox> +#include <QtWidgets/QCheckBox> +#include <QtWidgets/QDialog> +#include <QtWidgets/QDialogButtonBox> +#include <QtWidgets/QFileDialog> +#include <QtWidgets/QGraphicsView> #include <QtDeclarative/qdeclarativecontext.h> @@ -143,36 +143,13 @@ void RenderStatistics::printTotalStats() } #endif - -static QGLFormat getFormat() -{ - QGLFormat f = QGLFormat::defaultFormat(); - f.setSampleBuffers(!qApp->arguments().contains("--no-multisample")); - f.setSwapInterval(qApp->arguments().contains("--nonblocking-swap") ? 0 : 1); - f.setStereo(qApp->arguments().contains("--stereo")); - return f; -} - class MyQSGView : public QSGView { public: - MyQSGView() : QSGView(getFormat()) + MyQSGView() : QSGView() { setResizeMode(QSGView::SizeRootObjectToView); } - -protected: - void paintEvent(QPaintEvent *e) { - QSGView::paintEvent(e); - -#ifdef QML_RUNTIME_TESTING -// RenderStatistics::updateStats(); -#endif - - static bool continuousUpdate = qApp->arguments().contains("--continuous-update"); - if (continuousUpdate) - update(); - } }; class MyDeclarativeView: public QDeclarativeView @@ -182,20 +159,6 @@ public: { setResizeMode(QDeclarativeView::SizeRootObjectToView); } - -protected: - void paintEvent(QPaintEvent *event) - { - QDeclarativeView::paintEvent(event); - -#ifdef QML_RUNTIME_TESTING - RenderStatistics::updateStats(); -#endif - - static bool continuousUpdate = qApp->arguments().contains("--continuous-update"); - if (continuousUpdate) - scene()->update(); - } }; #ifndef QT_NO_SCENEGRAPHITEM @@ -497,7 +460,7 @@ int main(int argc, char ** argv) displayFileDialog(&options); #endif - QWidget *view = 0; + QWindow *window = 0; QDeclarativeEngine *engine = 0; int exitCode = 0; @@ -518,54 +481,37 @@ int main(int argc, char ** argv) item->setSource(options.file); } else #endif - if (!options.originalQml && !options.originalQmlRaster) { - if (options.versionDetection) - checkAndAdaptVersion(options.file); - QSGView *qxView = new MyQSGView(); - qxView->setVSyncAnimations(options.vsync); - engine = qxView->engine(); - for (int i = 0; i < imports.size(); ++i) - engine->addImportPath(imports.at(i)); - view = qxView; - if (options.file.isLocalFile()) { - QFileInfo fi(options.file.toLocalFile()); - loadDummyDataFiles(*engine, fi.path()); - } - qxView->setSource(options.file); - - } else { - MyDeclarativeView *gvView = new MyDeclarativeView(); - engine = gvView->engine(); - for (int i = 0; i < imports.size(); ++i) - engine->addImportPath(imports.at(i)); - view = gvView; - if (options.file.isLocalFile()) { - QFileInfo fi(options.file.toLocalFile()); - loadDummyDataFiles(*engine, fi.path()); - } - gvView->setSource(options.file); - if (!options.originalQmlRaster) { - QGLWidget *viewport = new QGLWidget(getFormat()); - gvView->setViewport(viewport); - } + if (options.versionDetection) + checkAndAdaptVersion(options.file); + QSGView *qxView = new MyQSGView(); + qxView->setVSyncAnimations(options.vsync); + engine = qxView->engine(); + for (int i = 0; i < imports.size(); ++i) + engine->addImportPath(imports.at(i)); + window = qxView; + if (options.file.isLocalFile()) { + QFileInfo fi(options.file.toLocalFile()); + loadDummyDataFiles(*engine, fi.path()); } + qxView->setSource(options.file); QObject::connect(engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit())); if (options.fullscreen) - view->showFullScreen(); + window->showFullScreen(); else if (options.maximized) - view->showMaximized(); + window->showMaximized(); else - view->show(); + window->show(); + #ifdef Q_WS_MAC - view->raise(); + window->raise(); #endif exitCode = app.exec(); - delete view; + delete window; #ifdef QML_RUNTIME_TESTING RenderStatistics::printTotalStats(); diff --git a/tools/qmlviewer/qmlruntime.cpp b/tools/qmlviewer/qmlruntime.cpp index ca1593225c..c5b94abac7 100644 --- a/tools/qmlviewer/qmlruntime.cpp +++ b/tools/qmlviewer/qmlruntime.cpp @@ -1426,9 +1426,9 @@ void QDeclarativeViewer::recordFrame() if (frame_fmt == QLatin1String(".gif")) { // ffmpeg can't do 32bpp with gif QImage rgb24 = frame.convertToFormat(QImage::Format_RGB888); - frame_stream->write((char*)rgb24.bits(),rgb24.numBytes()); + frame_stream->write((char*)rgb24.bits(),rgb24.byteCount()); } else { - frame_stream->write((char*)frame.bits(),frame.numBytes()); + frame_stream->write((char*)frame.bits(),frame.byteCount()); } } else { frames.append(new QImage(frame)); diff --git a/tools/qmlviewer/qmlviewer.pro b/tools/qmlviewer/qmlviewer.pro index 5dd95b3ff2..1f7a6024f4 100644 --- a/tools/qmlviewer/qmlviewer.pro +++ b/tools/qmlviewer/qmlviewer.pro @@ -1,7 +1,7 @@ TEMPLATE = app CONFIG += qt uic declarative_debug DESTDIR = $$QT.declarative.bins -QT += declarative qtquick1 qtquick1-private +QT += declarative qtquick1 qtquick1-private widgets widgets-private include(qml.pri) @@ -10,6 +10,7 @@ SOURCES += main.cpp INCLUDEPATH += ../../include/QtDeclarative INCLUDEPATH += ../../src/declarative/util INCLUDEPATH += ../../src/declarative/graphicsitems +INCLUDEPATH += ../../src/3rdparty/v8/include DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII diff --git a/tools/tools.pro b/tools/tools.pro index dccdce8160..29340c61b0 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -1,4 +1,6 @@ TEMPLATE = subdirs SUBDIRS += qmlviewer qmlscene qmlplugindump -contains(QT_CONFIG, qmltest): SUBDIRS += qmltestrunner + +# ### refactor: port properly +# contains(QT_CONFIG, qmltest): SUBDIRS += qmltestrunner |