aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/declarative.pro3
-rw-r--r--src/declarative/items/context2d/qsgcontext2d.cpp8
-rw-r--r--src/declarative/items/qsgborderimage.cpp15
-rw-r--r--src/declarative/items/qsgcanvas.cpp651
-rw-r--r--src/declarative/items/qsgcanvas.h30
-rw-r--r--src/declarative/items/qsgcanvas_p.h91
-rw-r--r--src/declarative/items/qsgflickable.cpp4
-rw-r--r--src/declarative/items/qsgimage.cpp61
-rw-r--r--src/declarative/items/qsgimage_p.h10
-rw-r--r--src/declarative/items/qsgimage_p_p.h4
-rw-r--r--src/declarative/items/qsgitem.cpp54
-rw-r--r--src/declarative/items/qsgitem.h9
-rw-r--r--src/declarative/items/qsgmousearea.cpp4
-rw-r--r--src/declarative/items/qsgmousearea_p_p.h2
-rw-r--r--src/declarative/items/qsgpainteditem.cpp6
-rw-r--r--src/declarative/items/qsgpathview.cpp4
-rw-r--r--src/declarative/items/qsgpincharea.cpp4
-rw-r--r--src/declarative/items/qsgshadereffect.cpp76
-rw-r--r--src/declarative/items/qsgshadereffect_p.h3
-rw-r--r--src/declarative/items/qsgshadereffectmesh_p.h3
-rw-r--r--src/declarative/items/qsgshadereffectnode.cpp40
-rw-r--r--src/declarative/items/qsgshadereffectnode_p.h10
-rw-r--r--src/declarative/items/qsgshadereffectsource.cpp157
-rw-r--r--src/declarative/items/qsgshadereffectsource_p.h22
-rw-r--r--src/declarative/items/qsgspriteengine.cpp2
-rw-r--r--src/declarative/items/qsgtext.cpp4
-rw-r--r--src/declarative/items/qsgtextedit.cpp20
-rw-r--r--src/declarative/items/qsgtextinput.cpp20
-rw-r--r--src/declarative/items/qsgtextnode.cpp9
-rw-r--r--src/declarative/items/qsgtextnode_p.h1
-rw-r--r--src/declarative/items/qsgview.cpp65
-rw-r--r--src/declarative/items/qsgview.h7
-rw-r--r--src/declarative/items/qsgview_p.h2
-rw-r--r--src/declarative/particles/qsgcustomparticle.cpp52
-rw-r--r--src/declarative/particles/qsgcustomparticle_p.h6
-rw-r--r--src/declarative/particles/qsgimageparticle.cpp22
-rw-r--r--src/declarative/qml/parser/qdeclarativejsparser.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp2
-rw-r--r--src/declarative/qml/qdeclarativemetatype.cpp4
-rw-r--r--src/declarative/scenegraph/coreapi/qsgdefaultrenderer.cpp5
-rw-r--r--src/declarative/scenegraph/coreapi/qsggeometry.cpp113
-rw-r--r--src/declarative/scenegraph/coreapi/qsggeometry.h31
-rw-r--r--src/declarative/scenegraph/coreapi/qsggeometry_p.h32
-rw-r--r--src/declarative/scenegraph/coreapi/qsgmaterial.cpp16
-rw-r--r--src/declarative/scenegraph/coreapi/qsgmaterial.h8
-rw-r--r--src/declarative/scenegraph/coreapi/qsgnode.cpp2
-rw-r--r--src/declarative/scenegraph/coreapi/qsgrenderer.cpp201
-rw-r--r--src/declarative/scenegraph/coreapi/qsgrenderer_p.h30
-rw-r--r--src/declarative/scenegraph/qsgadaptationlayer_p.h1
-rw-r--r--src/declarative/scenegraph/qsgcontext.cpp12
-rw-r--r--src/declarative/scenegraph/qsgcontext_p.h11
-rw-r--r--src/declarative/scenegraph/qsgcontextplugin.cpp2
-rw-r--r--src/declarative/scenegraph/qsgdefaultglyphnode.cpp2
-rw-r--r--src/declarative/scenegraph/qsgdefaultglyphnode_p.cpp21
-rw-r--r--src/declarative/scenegraph/qsgdefaultglyphnode_p_p.h5
-rw-r--r--src/declarative/scenegraph/qsgdefaultimagenode.cpp6
-rw-r--r--src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp49
-rw-r--r--src/declarative/scenegraph/qsgdistancefieldglyphcache_p.h46
-rw-r--r--src/declarative/scenegraph/qsgdistancefieldglyphnode_p.cpp2
-rw-r--r--src/declarative/scenegraph/qsgpathsimplifier.cpp2
-rw-r--r--src/declarative/scenegraph/scenegraph.pri7
-rw-r--r--src/declarative/scenegraph/util/qsgflatcolormaterial.cpp2
-rw-r--r--src/declarative/scenegraph/util/qsgflatcolormaterial.h1
-rw-r--r--src/declarative/scenegraph/util/qsgpainternode.cpp33
-rw-r--r--src/declarative/scenegraph/util/qsgpainternode_p.h6
-rw-r--r--src/declarative/scenegraph/util/qsgtexture.cpp112
-rw-r--r--src/declarative/scenegraph/util/qsgtexture_p.h2
-rw-r--r--src/declarative/scenegraph/util/qsgtexturematerial.cpp6
-rw-r--r--src/declarative/scenegraph/util/qsgtextureprovider.cpp13
-rw-r--r--src/declarative/scenegraph/util/qsgtextureprovider_p.h10
-rw-r--r--src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp2
-rw-r--r--src/declarative/util/qdeclarativeapplication.cpp2
-rw-r--r--src/declarative/util/qdeclarativepixmapcache.cpp3
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp2
-rw-r--r--src/imports/etcprovider/qetcprovider.cpp5
-rw-r--r--src/imports/etcprovider/qetcprovider.h2
-rw-r--r--src/imports/gestures/gestures.pro2
-rw-r--r--src/imports/gestures/qdeclarativegesturearea_p.h2
-rw-r--r--src/imports/imports.pro3
-rw-r--r--src/imports/inputcontext/declarativeinputcontext.h2
-rwxr-xr-xsrc/imports/inputcontext/inputcontext.pro2
-rw-r--r--src/imports/inputcontext/inputcontextfilter.cpp2
-rw-r--r--src/imports/inputcontext/inputcontextmodule.cpp2
-rw-r--r--src/imports/inputcontext/plugin.cpp2
-rw-r--r--src/imports/particles/V1/qdeclarativeparticles.cpp2
-rw-r--r--src/imports/particles/particles.pro2
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.cpp6
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.cpp6
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp8
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.cpp8
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.h4
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.cpp8
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp4
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp4
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro2
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/sgselectiontool.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h1
-rw-r--r--src/plugins/qmltooling/qmltooling.pro6
-rw-r--r--src/qmltest/quicktest.cpp2
-rw-r--r--src/qmltest/quicktest.h8
-rw-r--r--src/qmltest/quicktestevent.cpp2
-rw-r--r--src/qtquick1/graphicsitems/qdeclarativeborderimage.cpp2
-rw-r--r--src/qtquick1/graphicsitems/qdeclarativeflipable.cpp2
-rw-r--r--src/qtquick1/graphicsitems/qdeclarativefocuspanel.cpp2
-rw-r--r--src/qtquick1/graphicsitems/qdeclarativeitem.cpp5
-rw-r--r--src/qtquick1/graphicsitems/qdeclarativeitem.h6
-rw-r--r--src/qtquick1/graphicsitems/qdeclarativeitem_p.h2
-rw-r--r--src/qtquick1/graphicsitems/qdeclarativeitemsmodule.cpp6
-rw-r--r--src/qtquick1/graphicsitems/qdeclarativerectangle.cpp1
-rw-r--r--src/qtquick1/graphicsitems/qdeclarativetextinput.cpp2
-rw-r--r--src/qtquick1/qtquick1.pro2
-rw-r--r--src/qtquick1/util/qdeclarativeapplication.cpp2
-rw-r--r--src/qtquick1/util/qdeclarativestateoperations.cpp2
-rw-r--r--src/qtquick1/util/qdeclarativeview.cpp2
-rw-r--r--src/qtquick1/util/qdeclarativeview.h6
-rw-r--r--src/src.pro6
-rw-r--r--tests/auto/declarative/examples/examples.pro2
-rw-r--r--tests/auto/declarative/examples/tst_examples.cpp3
-rw-r--r--tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp2
-rw-r--r--tests/auto/declarative/qsglistview/qsglistview.pro2
-rw-r--r--tests/auto/declarative/qsglistview/tst_qsglistview.cpp2
-rw-r--r--tests/auto/headersclean/headersclean.pro2
-rw-r--r--tests/auto/headersclean/tst_headersclean.cpp1
-rw-r--r--tests/auto/qtquick1/qdeclarativeview/qdeclarativeview.pro2
-rw-r--r--tests/auto/qtquick1/qdeclarativeview/tst_qdeclarativeview.cpp2
-rw-r--r--tests/auto/qtquick1/qdeclarativeviewer/qdeclarativeviewer.pro2
-rw-r--r--tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp2
-rw-r--r--tools/qmlplugindump/main.cpp2
-rw-r--r--tools/qmlscene/main.cpp110
-rw-r--r--tools/qmlviewer/qmlruntime.cpp4
-rw-r--r--tools/qmlviewer/qmlviewer.pro3
-rw-r--r--tools/tools.pro4
139 files changed, 1553 insertions, 1040 deletions
diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro
index 22907d894c..5db77a79dd 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 v8-private
+QT = core-private gui gui-private network widgets-private sql v8-private
+
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..71bc7df980 100644
--- a/src/declarative/items/context2d/qsgcontext2d.cpp
+++ b/src/declarative/items/context2d/qsgcontext2d.cpp
@@ -43,13 +43,13 @@
#include "qsgcontext2d_p_p.h"
#include "private/qsgadaptationlayer_p.h"
#include "qsgcanvasitem_p.h"
-#include <QtOpenGL/qglframebufferobject.h>
+#include <QtGui/qopenglframebufferobject.h>
#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 bd62eaf1bb..30b10321a0 100644
--- a/src/declarative/items/qsgborderimage.cpp
+++ b/src/declarative/items/qsgborderimage.cpp
@@ -582,11 +582,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 845617c7a5..95ee95d0f7 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,26 +65,105 @@
QT_BEGIN_NAMESPACE
-DEFINE_BOOL_CONFIG_OPTION(qmlNoThreadedRenderer, QML_NO_THREADED_RENDERER)
DEFINE_BOOL_CONFIG_OPTION(qmlFixedAnimationStep, QML_FIXED_ANIMATION_STEP)
+DEFINE_BOOL_CONFIG_OPTION(qmlNoThreadedRenderer, QML_BAD_GUI_RENDER_LOOP)
+
+extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
+
+class QSGCanvasPlainRenderLoop : public QObject, public QSGCanvasRenderLoop
+{
+public:
+ QSGCanvasPlainRenderLoop()
+ : updatePending(false)
+ , animationRunning(false)
+ {
+ qWarning("QSGCanvas: using non-threaded render loop. Be very sure to not access scene graph "
+ "objects outside the QSGItem::updatePaintNode() call. Failing to do so will cause "
+ "your code to crash on other platforms!");
+ }
+
+ virtual void paint() {
+ if (animationRunning && animationDriver())
+ animationDriver()->advance();
+ syncSceneGraph();
+ makeCurrent();
+ glViewport(0, 0, size.width(), size.height());
+ renderSceneGraph(size);
+ swapBuffers();
+ updatePending = false;
+
+ if (animationRunning)
+ maybeUpdate();
+ }
+
+ virtual QImage grab() {
+ return qt_gl_read_framebuffer(size, false, false);
+ }
+
+ virtual void startRendering() {
+ if (!glContext()) {
+ createGLContext();
+ makeCurrent();
+ initializeSceneGraph();
+ } else {
+ makeCurrent();
+ }
+ maybeUpdate();
+ }
+
+ virtual void stopRendering() { }
+
+ virtual void maybeUpdate() {
+ if (!updatePending) {
+ QApplication::postEvent(this, new QEvent(QEvent::User));
+ updatePending = true;
+ }
+ }
+
+ virtual void animationStarted() {
+ animationRunning = true;
+ maybeUpdate();
+ }
+
+ virtual void animationStopped() {
+ animationRunning = false;
+ }
+
+ virtual bool isRunning() const { return glContext(); } // Event loop is always running...
+ virtual void resize(const QSize &s) { size = s; }
+ virtual void setWindowSize(const QSize &s) { size = s; }
+
+ bool event(QEvent *e) {
+ if (e->type() == QEvent::User) {
+ paint();
+ return true;
+ }
+ return QObject::event(e);
+ }
+
+ QSize size;
+
+ uint updatePending : 1;
+ uint animationRunning : 1;
+};
+
-extern Q_OPENGL_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
/*
Focus behavior
==============
-Prior to being added to a valid canvas items can set and clear focus with no
+Prior to being added to a valid canvas items can set and clear focus with no
effect. Only once items are added to a canvas (by way of having a parent set that
-already belongs to a canvas) do the focus rules apply. Focus goes back to
+already belongs to a canvas) do the focus rules apply. Focus goes back to
having no effect if an item is removed from a canvas.
When an item is moved into a new focus scope (either being added to a canvas
-for the first time, or having its parent changed), if the focus scope already has
+for the first time, or having its parent changed), if the focus scope already has
a scope focused item that takes precedence over the item being added. Otherwise,
-the focus of the added tree is used. In the case of of a tree of items being
+the focus of the added tree is used. In the case of of a tree of items being
added to a canvas for the first time, which may have a conflicted focus state (two
-or more items in one scope having focus set), the same rule is applied item by item -
+or more items in one scope having focus set), the same rule is applied item by item -
thus the first item that has focus will get it (assuming the scope doesn't already
have a scope focused item), and the other items will have their focus cleared.
*/
@@ -165,134 +246,50 @@ 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)
+void QSGCanvas::animationStarted()
{
- 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()));
- }
- }
+ d_func()->thread->animationStarted();
+}
- if (d->animationDriver)
- d->animationDriver->install();
- }
- }
+void QSGCanvas::animationStopped()
+{
+ d_func()->thread->animationStopped();
}
-void QSGCanvas::hideEvent(QHideEvent *e)
+void QSGCanvas::showEvent(QShowEvent *e)
{
Q_D(QSGCanvas);
-
- if (!d->contextFailed) {
- if (d->threadedRendering) {
- d->thread->stopRenderThread();
+ if (d->vsyncAnimations) {
+ if (!d->animationDriver) {
+ d->animationDriver = d->context->createAnimationDriver(this);
+ connect(d->animationDriver, SIGNAL(started()), this, SLOT(animationStarted()), Qt::DirectConnection);
+ connect(d->animationDriver, SIGNAL(stopped()), this, SLOT(animationStopped()), Qt::DirectConnection);
}
+ d->animationDriver->install();
+ }
- if (d->animationDriver)
- d->animationDriver->uninstall();
+ if (!d->thread->isRunning()) {
+ d->thread->setWindowSize(size());
+ d->thread->startRendering();
}
+}
- QGLWidget::hideEvent(e);
+void QSGCanvas::hideEvent(QHideEvent *e)
+{
+ Q_D(QSGCanvas);
+ d->thread->stopRendering();
}
@@ -313,7 +310,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 +329,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)
@@ -356,14 +359,12 @@ void QSGCanvasPrivate::initializeSceneGraph()
if (context->isReady())
return;
- QGLContext *glctx = const_cast<QGLContext *>(QGLContext::currentContext());
+ QOpenGLContext *glctx = const_cast<QOpenGLContext *>(QOpenGLContext::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,23 +418,17 @@ 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)
, thread(0)
, animationDriver(0)
, renderTarget(0)
{
- threadedRendering = !qmlNoThreadedRenderer();
}
QSGCanvasPrivate::~QSGCanvasPrivate()
@@ -444,31 +439,36 @@ 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);
+
+ bool threaded = !qmlNoThreadedRenderer();
- if (threadedRendering) {
- thread = new QSGCanvasRenderThread;
- thread->renderer = q;
- thread->d = this;
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL)) {
+ qWarning("QSGCanvas: platform does not support threaded rendering!");
+ threaded = false;
}
+ if (threaded)
+ thread = new QSGCanvasRenderThread();
+ else
+ thread = new QSGCanvasPlainRenderLoop();
+
+ thread->renderer = q;
+ thread->d = this;
+
+ context = QSGContext::createDefaultContext();
+ thread->moveContextToThread(context);
}
void QSGCanvasPrivate::sceneMouseEventForTransform(QGraphicsSceneMouseEvent &sceneEvent,
@@ -478,7 +478,7 @@ void QSGCanvasPrivate::sceneMouseEventForTransform(QGraphicsSceneMouseEvent &sce
sceneEvent.setLastPos(transform.map(sceneEvent.lastScenePos()));
for (int ii = 0; ii < 5; ++ii) {
if (sceneEvent.buttons() & (1 << ii)) {
- sceneEvent.setButtonDownPos((Qt::MouseButton)(1 << ii),
+ sceneEvent.setButtonDownPos((Qt::MouseButton)(1 << ii),
transform.map(sceneEvent.buttonDownScenePos((Qt::MouseButton)(1 << ii))));
}
}
@@ -516,8 +516,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 +547,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 +569,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 +624,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 +668,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;
@@ -695,7 +692,7 @@ void QSGCanvasPrivate::setFocusInScope(QSGItem *scope, QSGItem *item, FocusOptio
updateInputMethodData();
QFocusEvent event(QEvent::FocusIn, Qt::OtherFocusReason);
- q->sendEvent(newActiveFocusItem, &event);
+ q->sendEvent(newActiveFocusItem, &event);
} else {
updateInputMethodData();
}
@@ -736,8 +733,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;
@@ -782,12 +778,12 @@ void QSGCanvasPrivate::clearFocusInScope(QSGItem *scope, QSGItem *item, FocusOpt
updateInputMethodData();
QFocusEvent event(QEvent::FocusIn, Qt::OtherFocusReason);
- q->sendEvent(newActiveFocusItem, &event);
+ q->sendEvent(newActiveFocusItem, &event);
} else {
updateInputMethodData();
}
- if (!changed.isEmpty())
+ if (!changed.isEmpty())
notifyFocusChangesRecur(changed.data(), changed.count() - 1);
}
@@ -811,16 +807,17 @@ void QSGCanvasPrivate::notifyFocusChangesRecur(QSGItem **items, int remaining)
itemPrivate->itemChange(QSGItem::ItemActiveFocusHasChanged, itemPrivate->activeFocus);
emit item->activeFocusChanged(itemPrivate->activeFocus);
}
- }
+ }
}
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 +854,18 @@ void QSGCanvasPrivate::cleanup(QSGNode *n)
q->maybeUpdate();
}
-static QGLFormat tweakFormat(const QGLFormat &format = QGLFormat::defaultFormat())
-{
- QGLFormat f = format;
- f.setSwapInterval(1);
- 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)
-{
- Q_D(QSGCanvas);
-
- d->init(this);
-}
-QSGCanvas::QSGCanvas(QSGCanvasPrivate &dd, QWidget *parent, Qt::WindowFlags f)
-: QGLWidget(dd, tweakFormat(), parent, 0, f)
+QSGCanvas::QSGCanvas(QWindow *parent)
+ : QWindow(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)
+QSGCanvas::QSGCanvas(QSGCanvasPrivate &dd, QWindow *parent)
+ : QWindow(dd, parent)
{
Q_D(QSGCanvas);
-
d->init(this);
}
@@ -900,8 +873,8 @@ QSGCanvas::~QSGCanvas()
{
Q_D(QSGCanvas);
- if (d->threadedRendering && d->thread->isRunning()) {
- d->thread->stopRenderThread();
+ if (d->thread->isRunning()) {
+ d->thread->stopRendering();
delete d->thread;
d->thread = 0;
}
@@ -913,41 +886,26 @@ 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
{
Q_D(const QSGCanvas);
-
+
return d->rootItem;
}
QSGItem *QSGCanvas::activeFocusItem() const
{
Q_D(const QSGCanvas);
-
+
return d->activeFocusItem;
}
QSGItem *QSGCanvas::mouseGrabberItem() const
{
Q_D(const QSGCanvas);
-
+
return d->mouseGrabberItem;
}
@@ -958,7 +916,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)
@@ -972,29 +930,6 @@ bool QSGCanvas::event(QEvent *e)
{
Q_D(QSGCanvas);
- if (e->type() == QEvent::User) {
- if (!d->thread->syncAlreadyHappened)
- d->thread->sync(false);
- else
- d->renderThreadAwakened = false;
-
- d->thread->syncAlreadyHappened = false;
-
- if (d->animationRunning && d->animationDriver) {
-#ifdef THREAD_DEBUG
- qDebug("GUI: Advancing animations...\n");
-#endif
-
- d->animationDriver->advance();
-
-#ifdef THREAD_DEBUG
- qDebug("GUI: Animations advanced...\n");
-#endif
- }
-
- return true;
- }
-
switch (e->type()) {
case QEvent::TouchBegin:
@@ -1024,7 +959,7 @@ bool QSGCanvas::event(QEvent *e)
break;
}
- return QGLWidget::event(e);
+ return QWindow::event(e);
}
void QSGCanvas::keyPressEvent(QKeyEvent *e)
@@ -1081,7 +1016,7 @@ bool QSGCanvasPrivate::deliverInitialMousePressEvent(QSGItem *item, QGraphicsSce
event->accept();
mouseGrabberItem = item;
q->sendEvent(item, event);
- if (event->isAccepted())
+ if (event->isAccepted())
return true;
mouseGrabberItem->ungrabMouse();
mouseGrabberItem = 0;
@@ -1095,10 +1030,10 @@ bool QSGCanvasPrivate::deliverMouseEvent(QGraphicsSceneMouseEvent *sceneEvent)
{
Q_Q(QSGCanvas);
- if (!mouseGrabberItem &&
+ if (!mouseGrabberItem &&
sceneEvent->type() == QEvent::GraphicsSceneMousePress &&
(sceneEvent->button() & sceneEvent->buttons()) == sceneEvent->buttons()) {
-
+
return deliverInitialMousePressEvent(rootItem, sceneEvent);
}
@@ -1118,7 +1053,7 @@ bool QSGCanvasPrivate::deliverMouseEvent(QGraphicsSceneMouseEvent *sceneEvent)
void QSGCanvas::mousePressEvent(QMouseEvent *event)
{
Q_D(QSGCanvas);
-
+
#ifdef MOUSE_DEBUG
qWarning() << "QSGCanvas::mousePressEvent()" << event->pos() << event->button() << event->buttons();
#endif
@@ -1133,13 +1068,13 @@ void QSGCanvas::mousePressEvent(QMouseEvent *event)
void QSGCanvas::mouseReleaseEvent(QMouseEvent *event)
{
Q_D(QSGCanvas);
-
+
#ifdef MOUSE_DEBUG
qWarning() << "QSGCanvas::mouseReleaseEvent()" << event->pos() << event->button() << event->buttons();
#endif
if (!d->mouseGrabberItem) {
- QGLWidget::mouseReleaseEvent(event);
+ QWindow::mouseReleaseEvent(event);
return;
}
@@ -1155,7 +1090,7 @@ void QSGCanvas::mouseReleaseEvent(QMouseEvent *event)
void QSGCanvas::mouseDoubleClickEvent(QMouseEvent *event)
{
Q_D(QSGCanvas);
-
+
#ifdef MOUSE_DEBUG
qWarning() << "QSGCanvas::mouseDoubleClickEvent()" << event->pos() << event->button() << event->buttons();
#endif
@@ -1169,7 +1104,7 @@ void QSGCanvas::mouseDoubleClickEvent(QMouseEvent *event)
else
event->ignore();
return;
- }
+ }
d->deliverMouseEvent(&sceneEvent);
event->setAccepted(sceneEvent.isAccepted());
@@ -1194,7 +1129,7 @@ bool QSGCanvasPrivate::sendHoverEvent(QEvent::Type type, QSGItem *item,
void QSGCanvas::mouseMoveEvent(QMouseEvent *event)
{
Q_D(QSGCanvas);
-
+
#ifdef MOUSE_DEBUG
qWarning() << "QSGCanvas::mouseMoveEvent()" << event->pos() << event->button() << event->buttons();
#endif
@@ -1462,7 +1397,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);
@@ -1568,17 +1503,17 @@ bool QSGCanvasPrivate::sendFilteredMouseEvent(QSGItem *target, QSGItem *item, QG
return true;
QSGItemPrivate *targetPrivate = QSGItemPrivate::get(target);
- if (targetPrivate->filtersChildMouseEvents)
+ if (targetPrivate->filtersChildMouseEvents)
if (target->childMouseEventFilter(item, event))
return true;
return false;
}
-bool QSGCanvas::sendEvent(QSGItem *item, QEvent *e)
-{
+bool QSGCanvas::sendEvent(QSGItem *item, QEvent *e)
+{
Q_D(QSGCanvas);
-
+
if (!item) {
qWarning("QSGCanvas::sendEvent: Cannot send event to a null item");
return false;
@@ -1612,7 +1547,7 @@ bool QSGCanvas::sendEvent(QSGItem *item, QEvent *e)
case QEvent::GraphicsSceneMouseRelease:
case QEvent::GraphicsSceneMouseDoubleClick:
case QEvent::GraphicsSceneMouseMove:
- // XXX todo - should sendEvent be doing this? how does it relate to forwarded events?
+ // XXX todo - should sendEvent be doing this? how does it relate to forwarded events?
{
QGraphicsSceneMouseEvent *se = static_cast<QGraphicsSceneMouseEvent *>(e);
if (!d->sendFilteredMouseEvent(item->parentItem(), item, se)) {
@@ -1644,7 +1579,7 @@ bool QSGCanvas::sendEvent(QSGItem *item, QEvent *e)
break;
}
- return false;
+ return false;
}
void QSGCanvasPrivate::cleanupNodes()
@@ -1689,12 +1624,12 @@ void QSGCanvasPrivate::updateDirtyNode(QSGItem *item)
itemPriv->dirtyAttributes = 0;
if ((dirty & QSGItemPrivate::TransformUpdateMask) ||
- (dirty & QSGItemPrivate::Size && itemPriv->origin != QSGItem::TopLeft &&
+ (dirty & QSGItemPrivate::Size && itemPriv->origin != QSGItem::TopLeft &&
(itemPriv->scale != 1. || itemPriv->rotation != 0.))) {
QMatrix4x4 matrix;
- if (itemPriv->x != 0. || itemPriv->y != 0.)
+ if (itemPriv->x != 0. || itemPriv->y != 0.)
matrix.translate(itemPriv->x, itemPriv->y);
for (int ii = itemPriv->transforms.count() - 1; ii >= 0; --ii)
@@ -1842,10 +1777,10 @@ void QSGCanvasPrivate::updateDirtyNode(QSGItem *item)
if (dirty & QSGItemPrivate::ContentUpdateMask) {
if (itemPriv->flags & QSGItem::ItemHasContents) {
- updatePaintNodeData.transformNode = itemPriv->itemNode();
+ updatePaintNodeData.transformNode = itemPriv->itemNode();
itemPriv->paintNode = item->updatePaintNode(itemPriv->paintNode, &updatePaintNodeData);
- Q_ASSERT(itemPriv->paintNode == 0 ||
+ Q_ASSERT(itemPriv->paintNode == 0 ||
itemPriv->paintNode->parent() == 0 ||
itemPriv->paintNode->parent() == itemPriv->childContainerNode());
@@ -1916,28 +1851,8 @@ void QSGCanvas::maybeUpdate()
{
Q_D(QSGCanvas);
- if (d->threadedRendering && 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()");
-
- if (d->thread->inSync) {
- d->thread->isExternalUpdatePending = true;
-
- } else if (!d->renderThreadAwakened) {
-#ifdef THREAD_DEBUG
- printf("GUI: doing update...\n");
-#endif
- d->renderThreadAwakened = true;
- d->thread->lockInGui();
- d->thread->isExternalUpdatePending = true;
- if (d->thread->isRenderBlocked)
- d->thread->wake();
- d->thread->unlockInGui();
- }
- } else if (!d->animationDriver || !d->animationDriver->isRunning()) {
- update();
- }
+ if (d->thread && d->thread->isRunning())
+ d->thread->maybeUpdate();
}
/*!
@@ -1977,7 +1892,7 @@ QSGEngine *QSGCanvas::sceneGraphEngine() const
the rendering.
*/
-void QSGCanvas::setRenderTarget(QGLFramebufferObject *fbo)
+void QSGCanvas::setRenderTarget(QOpenGLFramebufferObject *fbo)
{
Q_D(QSGCanvas);
if (d->context && d->context && QThread::currentThread() != d->context->thread()) {
@@ -1996,7 +1911,7 @@ void QSGCanvas::setRenderTarget(QGLFramebufferObject *fbo)
The default is to render to the surface of the canvas, in which
case the render target is 0.
*/
-QGLFramebufferObject *QSGCanvas::renderTarget() const
+QOpenGLFramebufferObject *QSGCanvas::renderTarget() const
{
Q_D(const QSGCanvas);
return d->renderTarget;
@@ -2009,17 +1924,21 @@ 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();
+}
+
+
+
+void QSGCanvasRenderLoop::createGLContext()
+{
+ gl = new QOpenGLContext();
+ gl->create();
}
@@ -2029,12 +1948,14 @@ void QSGCanvasRenderThread::run()
qDebug("QML Rendering Thread Started");
#endif
- renderer->makeCurrent();
-
- if (!d->context->isReady())
- d->initializeSceneGraph();
+ if (!glContext()) {
+ createGLContext();
+ makeCurrent();
+ initializeSceneGraph();
+ } else {
+ makeCurrent();
+ }
-
while (!shouldExit) {
lock();
@@ -2059,7 +1980,7 @@ void QSGCanvasRenderThread::run()
#ifdef THREAD_DEBUG
printf(" RenderThread: aquired sync lock...\n");
#endif
- QApplication::postEvent(renderer, new QEvent(QEvent::User));
+ QApplication::postEvent(this, new QEvent(QEvent::User));
#ifdef THREAD_DEBUG
printf(" RenderThread: going to sleep...\n");
#endif
@@ -2072,7 +1993,7 @@ void QSGCanvasRenderThread::run()
printf(" RenderThread: Doing locked sync\n");
#endif
inSync = true;
- d->syncSceneGraph();
+ syncSceneGraph();
inSync = false;
// Wake GUI after sync to let it continue animating and event processing.
@@ -2088,7 +2009,7 @@ void QSGCanvasRenderThread::run()
printf(" RenderThread: rendering... %d x %d\n", windowSize.width(), windowSize.height());
#endif
- d->renderSceneGraph(windowSize);
+ renderSceneGraph(windowSize);
// The content of the target buffer is undefined after swap() so grab needs
// to happen before swap();
@@ -2104,8 +2025,7 @@ void QSGCanvasRenderThread::run()
printf(" RenderThread: wait for swap...\n");
#endif
- renderer->swapBuffers();
-
+ swapBuffers();
#ifdef THREAD_DEBUG
printf(" RenderThread: swap complete...\n");
#endif
@@ -2121,7 +2041,7 @@ void QSGCanvasRenderThread::run()
// but we don't want to lock an extra time.
wake();
- if (!d->animationRunning && !isExternalUpdatePending && !shouldExit && !doGrab) {
+ if (!animationRunning && !isExternalUpdatePending && !shouldExit && !doGrab) {
#ifdef THREAD_DEBUG
printf(" RenderThread: nothing to do, going to sleep...\n");
#endif
@@ -2131,13 +2051,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();
+ doneCurrent();
lock();
hasExited = true;
@@ -2146,6 +2069,40 @@ void QSGCanvasRenderThread::run()
#endif
wake();
unlock();
+
+#ifdef THREAD_DEBUG
+ printf(" RenderThread: All done...\n");
+#endif
+}
+
+
+
+bool QSGCanvasRenderThread::event(QEvent *e)
+{
+ Q_ASSERT(QThread::currentThread() == qApp->thread());
+
+ if (e->type() == QEvent::User) {
+ if (!syncAlreadyHappened)
+ sync(false);
+
+ syncAlreadyHappened = false;
+
+ if (animationRunning && animationDriver()) {
+#ifdef THREAD_DEBUG
+ qDebug("GUI: Advancing animations...\n");
+#endif
+
+ animationDriver()->advance();
+
+#ifdef THREAD_DEBUG
+ qDebug("GUI: Animations advanced...\n");
+#endif
+ }
+
+ return true;
+ }
+
+ return QThread::event(e);
}
@@ -2165,20 +2122,18 @@ 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();
+ lockInGui();
- d->renderThreadAwakened = false;
+ renderThreadAwakened = false;
- d->polishItems();
+ polishItems();
- d->thread->wake();
- d->thread->wait();
+ wake();
+ wait();
if (!guiAlreadyLocked)
- d->thread->unlockInGui();
+ unlockInGui();
}
@@ -2228,7 +2183,7 @@ void QSGCanvasRenderThread::animationStarted()
lockInGui();
- d->animationRunning = true;
+ animationRunning = true;
if (isRenderBlocked)
wake();
@@ -2245,7 +2200,7 @@ void QSGCanvasRenderThread::animationStopped()
#endif
lockInGui();
- d->animationRunning = false;
+ animationRunning = false;
unlockInGui();
}
@@ -2266,10 +2221,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);
}
@@ -2300,7 +2251,7 @@ void QSGCanvasRenderThread::resize(const QSize &size)
-void QSGCanvasRenderThread::startRenderThread()
+void QSGCanvasRenderThread::startRendering()
{
#ifdef THREAD_DEBUG
printf("GUI: Starting Render Thread\n");
@@ -2309,14 +2260,12 @@ void QSGCanvasRenderThread::startRenderThread()
shouldExit = false;
isGuiBlocked = 0;
isGuiBlockPending = false;
-
- renderer->doneCurrent();
start();
}
-void QSGCanvasRenderThread::stopRenderThread()
+void QSGCanvasRenderThread::stopRendering()
{
#ifdef THREAD_DEBUG
printf("GUI: stopping render thread\n");
@@ -2348,6 +2297,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 +2311,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
@@ -2381,6 +2340,30 @@ QImage QSGCanvasRenderThread::grab()
}
+
+void QSGCanvasRenderThread::maybeUpdate()
+{
+ Q_ASSERT_X(QThread::currentThread() == QApplication::instance()->thread() || inSync,
+ "QSGCanvas::update",
+ "Function can only be called from GUI thread or during QSGItem::updatePaintNode()");
+
+ if (inSync) {
+ isExternalUpdatePending = true;
+
+ } else if (!renderThreadAwakened) {
+#ifdef THREAD_DEBUG
+ printf("GUI: doing update...\n");
+#endif
+ renderThreadAwakened = true;
+ lockInGui();
+ isExternalUpdatePending = true;
+ if (isRenderBlocked)
+ wake();
+ unlockInGui();
+ }
+}
+
+
#include "moc_qsgcanvas.cpp"
QT_END_NAMESPACE
diff --git a/src/declarative/items/qsgcanvas.h b/src/declarative/items/qsgcanvas.h
index a5f69ff559..e364ee88f5 100644
--- a/src/declarative/items/qsgcanvas.h
+++ b/src/declarative/items/qsgcanvas.h
@@ -43,8 +43,8 @@
#define QSGCANVAS_H
#include <QtCore/qmetatype.h>
-#include <QtOpenGL/qgl.h>
-#include <QtGui/qwidget.h>
+#include <QtGui/qopengl.h>
+#include <QtWidgets/qwidget.h>
QT_BEGIN_HEADER
@@ -55,15 +55,15 @@ QT_MODULE(Declarative)
class QSGItem;
class QSGEngine;
class QSGCanvasPrivate;
-class QGLFramebufferObject;
+class QOpenGLFramebufferObject;
-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;
@@ -82,25 +82,24 @@ public:
QImage grabFrameBuffer();
- void setRenderTarget(QGLFramebufferObject *fbo);
- QGLFramebufferObject *renderTarget() const;
+ void setRenderTarget(QOpenGLFramebufferObject *fbo);
+ QOpenGLFramebufferObject *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 *);
@@ -116,9 +115,12 @@ protected:
private Q_SLOTS:
void sceneGraphChanged();
void maybeUpdate();
+ void animationStarted();
+ void animationStopped();
private:
friend class QSGItem;
+ friend class QSGCanvasRenderLoop;
Q_DISABLE_COPY(QSGCanvas)
};
diff --git a/src/declarative/items/qsgcanvas_p.h b/src/declarative/items/qsgcanvas_p.h
index d26b311e59..e5347f53ae 100644
--- a/src/declarative/items/qsgcanvas_p.h
+++ b/src/declarative/items/qsgcanvas_p.h
@@ -64,8 +64,10 @@
#include <QtCore/qmutex.h>
#include <QtCore/qwaitcondition.h>
#include <private/qwidget_p.h>
-#include <private/qgl_p.h>
-#include <QtOpenGL/qglframebufferobject.h>
+#include <private/qwindow_p.h>
+#include <private/qopengl_p.h>
+#include <qopenglcontext.h>
+#include <QtGui/qopenglframebufferobject.h>
QT_BEGIN_NAMESPACE
@@ -80,9 +82,9 @@ public:
class QSGCanvasPrivate;
class QTouchEvent;
-class QSGCanvasRenderThread;
+class QSGCanvasRenderLoop;
-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,32 +161,77 @@ public:
QSGContext *context;
- uint contextFailed : 1;
- uint threadedRendering : 1;
- uint animationRunning: 1;
- uint renderThreadAwakened : 1;
-
uint vsyncAnimations : 1;
- QSGCanvasRenderThread *thread;
+ QSGCanvasRenderLoop *thread;
QSize widgetSize;
QSize viewportSize;
QAnimationDriver *animationDriver;
- QGLFramebufferObject *renderTarget;
+ QOpenGLFramebufferObject *renderTarget;
QHash<int, QSGItem *> itemForTouchPointId;
};
+class QSGCanvasRenderLoop
+{
+public:
+ QSGCanvasRenderLoop()
+ : d(0)
+ , renderer(0)
+ , gl(0)
+ {
+ }
+ virtual ~QSGCanvasRenderLoop()
+ {
+ delete gl;
+ }
+
+ friend class QSGCanvasPrivate;
+
+ virtual void paint() = 0;
+ virtual void resize(const QSize &size) = 0;
+ virtual void startRendering() = 0;
+ virtual void stopRendering() = 0;
+ virtual QImage grab() = 0;
+ virtual void setWindowSize(const QSize &size) = 0;
+ virtual void maybeUpdate() = 0;
+ virtual bool isRunning() const = 0;
+ virtual void animationStarted() = 0;
+ virtual void animationStopped() = 0;
+ virtual void moveContextToThread(QSGContext *) { }
+
+protected:
+ void initializeSceneGraph() { d->initializeSceneGraph(); }
+ void syncSceneGraph() { d->syncSceneGraph(); }
+ void renderSceneGraph(const QSize &size) { d->renderSceneGraph(size); }
+ void polishItems() { d->polishItems(); }
+ QAnimationDriver *animationDriver() const { return d->animationDriver; }
+
+ inline QOpenGLContext *glContext() const { return gl; }
+ void createGLContext();
+ void makeCurrent() { gl->makeCurrent(renderer); }
+ void doneCurrent() { gl->doneCurrent(); }
+ void swapBuffers() {
+ gl->swapBuffers(renderer);
+ emit renderer->frameSwapped();
+ }
+
+private:
+ QSGCanvasPrivate *d;
+ QSGCanvas *renderer;
+ QOpenGLContext *gl;
+};
-class QSGCanvasRenderThread : public QThread
+class QSGCanvasRenderThread : public QThread, public QSGCanvasRenderLoop
{
Q_OBJECT
public:
QSGCanvasRenderThread()
: mutex(QMutex::NonRecursive)
+ , animationRunning(false)
, isGuiBlocked(0)
, isPaintCompleted(false)
, isGuiBlockPending(false)
@@ -192,6 +242,7 @@ public:
, doGrab(false)
, shouldExit(false)
, hasExited(false)
+ , renderThreadAwakened(false)
{}
inline void lock() { mutex.lock(); }
@@ -204,10 +255,16 @@ public:
void paint();
void resize(const QSize &size);
- void startRenderThread();
- void stopRenderThread();
+ void startRendering();
+ void stopRendering();
void exhaustSyncEvent();
void sync(bool guiAlreadyLocked);
+ bool isRunning() const { return QThread::isRunning(); }
+ void setWindowSize(const QSize &size) { windowSize = size; }
+ void maybeUpdate();
+ void moveContextToThread(QSGContext *c) { c->moveToThread(this); }
+
+ bool event(QEvent *);
QImage grab();
@@ -222,9 +279,7 @@ public:
QSize windowSize;
QSize renderedSize;
- QSGCanvas *renderer;
- QSGCanvasPrivate *d;
-
+ uint animationRunning: 1;
int isGuiBlocked;
uint isPaintCompleted : 1;
uint isGuiBlockPending : 1;
@@ -232,10 +287,10 @@ public:
uint isExternalUpdatePending : 1;
uint syncAlreadyHappened : 1;
uint inSync : 1;
-
uint doGrab : 1;
uint shouldExit : 1;
uint hasExited : 1;
+ uint renderThreadAwakened : 1;
QImage grabContent;
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/qsgpainteditem.cpp b/src/declarative/items/qsgpainteditem.cpp
index 95aa2b4fb2..76d5a00e90 100644
--- a/src/declarative/items/qsgpainteditem.cpp
+++ b/src/declarative/items/qsgpainteditem.cpp
@@ -56,10 +56,10 @@ QT_BEGIN_NAMESPACE
The QSGPaintedItem makes it possible to use the QPainter API with the QML Scene Graph.
It sets up a textured rectangle in the Scene Graph and uses a QPainter to paint
- onto the texture. The render target can be either a QImage or a QGLFramebufferObject.
+ onto the texture. The render target can be either a QImage or a QOpenGLFramebufferObject.
When the render target is a QImage, QPainter first renders into the image then
the content is uploaded to the texture.
- When a QGLFramebufferObject is used, QPainter paints directly onto the texture.
+ When a QOpenGLFramebufferObject is used, QPainter paints directly onto the texture.
Call update() to trigger a repaint.
To enable QPainter to do anti-aliased rendering, use setAntialiasing().
@@ -84,7 +84,7 @@ QT_BEGIN_NAMESPACE
can potentially be slow if the item is large. This render target allows high quality
anti-aliasing and fast item resizing.
- \value FramebufferObject QPainter paints into a QGLFramebufferObject using the GL
+ \value FramebufferObject QPainter paints into a QOpenGLFramebufferObject using the GL
paint engine. Painting can be faster as no texture upload is required, but anti-aliasing
quality is not as good as if using an image. This render target allows faster rendering
in some cases, but you should avoid using it if the item is resized often.
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 c5ea64dcd2..b81e7f15af 100644
--- a/src/declarative/items/qsgshadereffect.cpp
+++ b/src/declarative/items/qsgshadereffect.cpp
@@ -49,8 +49,11 @@
#include <private/qsgtextureprovider_p.h>
#include "qsgcanvas.h"
+#include <qsgimage_p.h>
+#include <qsgshadereffectsource_p.h>
+
#include <QtCore/qsignalmapper.h>
-#include <QtOpenGL/qglframebufferobject.h>
+#include <QtGui/qopenglframebufferobject.h>
QT_BEGIN_NAMESPACE
@@ -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);
}
}
@@ -576,14 +582,22 @@ QSGNode *QSGShaderEffect::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
{
QSGShaderEffectNode *node = static_cast<QSGShaderEffectNode *>(oldNode);
+ // In the case of a bad vertex shader, don't try to create a node...
+ if (m_source.attributeNames.isEmpty()) {
+ if (node)
+ delete node;
+ return 0;
+ }
+
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 +630,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/qsgshadereffectmesh_p.h b/src/declarative/items/qsgshadereffectmesh_p.h
index 463c3d9073..4a1a8ae61b 100644
--- a/src/declarative/items/qsgshadereffectmesh_p.h
+++ b/src/declarative/items/qsgshadereffectmesh_p.h
@@ -41,10 +41,11 @@
#include "qdeclarativeparserstatus.h"
+#include <QtGui/qcolor.h>
#include <QtCore/qobject.h>
#include <QtCore/qsize.h>
#include <QtCore/qvariant.h>
-#include <QtOpenGL/qglfunctions.h>
+#include <QtGui/qopenglfunctions.h>
#ifndef SHADEREFFECTMESH_H
#define SHADEREFFECTMESH_H
diff --git a/src/declarative/items/qsgshadereffectnode.cpp b/src/declarative/items/qsgshadereffectnode.cpp
index 8bd781ce58..c5d208345e 100644
--- a/src/declarative/items/qsgshadereffectnode.cpp
+++ b/src/declarative/items/qsgshadereffectnode.cpp
@@ -108,17 +108,17 @@ void QSGCustomMaterialShader::updateState(const RenderState &state, QSGMaterial
}
}
- QGLFunctions *functions = state.context()->functions();
+ QOpenGLFunctions *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 e05d20ed69..bb55af524b 100644
--- a/src/declarative/items/qsgshadereffectsource.cpp
+++ b/src/declarative/items/qsgshadereffectsource.cpp
@@ -46,7 +46,7 @@
#include <private/qsgadaptationlayer_p.h>
#include <private/qsgrenderer_p.h>
-#include "qglframebufferobject.h"
+#include "qopenglframebufferobject.h"
#include "qmath.h"
#include <private/qsgtexture_p.h>
@@ -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));
@@ -248,27 +289,27 @@ void QSGShaderEffectTexture::grab()
// Don't delete the FBO right away in case it is used recursively.
deleteFboLater = true;
delete m_secondaryFbo;
- QGLFramebufferObjectFormat format;
+ QOpenGLFramebufferObjectFormat format;
- format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
+ format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setInternalTextureFormat(m_format);
format.setSamples(8);
- m_secondaryFbo = new QGLFramebufferObject(m_size, format);
+ m_secondaryFbo = new QOpenGLFramebufferObject(m_size, format);
} else {
- QGLFramebufferObjectFormat format;
- format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
+ QOpenGLFramebufferObjectFormat format;
+ format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setInternalTextureFormat(m_format);
format.setMipmap(m_mipmap);
if (m_recursive) {
deleteFboLater = true;
delete m_secondaryFbo;
- m_secondaryFbo = new QGLFramebufferObject(m_size, format);
+ m_secondaryFbo = new QOpenGLFramebufferObject(m_size, format);
glBindTexture(GL_TEXTURE_2D, m_secondaryFbo->texture());
updateBindOptions(true);
} else {
delete m_fbo;
delete m_secondaryFbo;
- m_fbo = new QGLFramebufferObject(m_size, format);
+ m_fbo = new QOpenGLFramebufferObject(m_size, format);
m_secondaryFbo = 0;
glBindTexture(GL_TEXTURE_2D, m_fbo->texture());
updateBindOptions(true);
@@ -281,7 +322,7 @@ void QSGShaderEffectTexture::grab()
Q_ASSERT(m_fbo);
Q_ASSERT(!m_multisampling);
- m_secondaryFbo = new QGLFramebufferObject(m_size, m_fbo->format());
+ m_secondaryFbo = new QOpenGLFramebufferObject(m_size, m_fbo->format());
glBindTexture(GL_TEXTURE_2D, m_secondaryFbo->texture());
updateBindOptions(true);
}
@@ -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();
+ QOpenGLContext *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());
@@ -318,29 +359,29 @@ void QSGShaderEffectTexture::grab()
if (deleteFboLater) {
delete m_fbo;
- QGLFramebufferObjectFormat format;
+ QOpenGLFramebufferObjectFormat format;
format.setInternalTextureFormat(m_format);
- format.setAttachment(QGLFramebufferObject::NoAttachment);
+ format.setAttachment(QOpenGLFramebufferObject::NoAttachment);
format.setMipmap(m_mipmap);
format.setSamples(0);
- m_fbo = new QGLFramebufferObject(m_size, format);
+ m_fbo = new QOpenGLFramebufferObject(m_size, format);
glBindTexture(GL_TEXTURE_2D, m_fbo->texture());
updateBindOptions(true);
}
QRect r(QPoint(), m_size);
- QGLFramebufferObject::blitFramebuffer(m_fbo, r, m_secondaryFbo, r);
+ QOpenGLFramebufferObject::blitFramebuffer(m_fbo, r, m_secondaryFbo, r);
} else {
if (m_recursive) {
m_renderer->renderScene(QSGBindableFbo(m_secondaryFbo));
if (deleteFboLater) {
delete m_fbo;
- QGLFramebufferObjectFormat format;
- format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
+ QOpenGLFramebufferObjectFormat format;
+ format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setInternalTextureFormat(m_format);
format.setMipmap(m_mipmap);
- m_fbo = new QGLFramebufferObject(m_size, format);
+ m_fbo = new QOpenGLFramebufferObject(m_size, format);
glBindTexture(GL_TEXTURE_2D, m_fbo->texture());
updateBindOptions(true);
}
@@ -452,6 +493,7 @@ QImage QSGShaderEffectTexture::toImage() const
QSGShaderEffectSource::QSGShaderEffectSource(QSGItem *parent)
: QSGItem(parent)
+ , m_provider(0)
, m_wrapMode(ClampToEdge)
, m_sourceItem(0)
, m_textureSize(0, 0)
@@ -464,17 +506,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
@@ -761,17 +822,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) {
@@ -779,19 +829,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
@@ -823,12 +861,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 0cb449a46c..77cb412884 100644
--- a/src/declarative/items/qsgshadereffectsource_p.h
+++ b/src/declarative/items/qsgshadereffectsource_p.h
@@ -62,7 +62,9 @@ QT_MODULE(Declarative)
class QSGNode;
class UpdatePaintNodeData;
-class QGLFramebufferObject;
+class QOpenGLFramebufferObject;
+
+class QSGShaderEffectSourceTextureProvider;
class QSGShaderEffectSourceNode : public QObject, public QSGDefaultImageNode
{
@@ -114,6 +116,7 @@ public:
void scheduleUpdate();
+ void scheduleForCleanup();
QImage toImage() const;
Q_SIGNALS:
@@ -132,13 +135,15 @@ private:
QSGItem *m_shaderSource;
QSGRenderer *m_renderer;
- QGLFramebufferObject *m_fbo;
- QGLFramebufferObject *m_secondaryFbo;
+ QOpenGLFramebufferObject *m_fbo;
+ QOpenGLFramebufferObject *m_secondaryFbo;
#ifdef QSG_DEBUG_FBO_OVERLAY
QSGRectangleNode *m_debugOverlay;
#endif
+ QSGContext *m_context;
+
uint m_mipmap : 1;
uint m_live : 1;
uint m_recursive : 1;
@@ -148,7 +153,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)
@@ -160,7 +165,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 {
@@ -206,8 +211,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();
@@ -228,7 +233,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/qsgspriteengine.cpp b/src/declarative/items/qsgspriteengine.cpp
index 1915db6000..7e6492e419 100644
--- a/src/declarative/items/qsgspriteengine.cpp
+++ b/src/declarative/items/qsgspriteengine.cpp
@@ -44,7 +44,7 @@
#include <QDebug>
#include <QPainter>
#include <QSet>
-#include <QtOpenGL>
+#include <QtGui>
QT_BEGIN_NAMESPACE
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/qsgtextnode_p.h b/src/declarative/items/qsgtextnode_p.h
index 4c5199aefa..e9b9b98edf 100644
--- a/src/declarative/items/qsgtextnode_p.h
+++ b/src/declarative/items/qsgtextnode_p.h
@@ -44,6 +44,7 @@
#include <qsgnode.h>
#include <qsgtext_p.h>
+#include <qglyphrun.h>
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/items/qsgview.cpp b/src/declarative/items/qsgview.cpp
index e2fb42e22b..236fd4ec1f 100644
--- a/src/declarative/items/qsgview.cpp
+++ b/src/declarative/items/qsgview.cpp
@@ -54,7 +54,7 @@
#include <QtCore/qbasictimer.h>
-// XXX todo - This whole class should probably be merged with QDeclarativeView for
+// XXX todo - This whole class should probably be merged with QDeclarativeView for
// maximum seamlessness
QT_BEGIN_NAMESPACE
@@ -62,19 +62,18 @@ DEFINE_BOOL_CONFIG_OPTION(frameRateDebug, QML_SHOW_FRAMERATE)
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)
{
}
-QSGViewPrivate::~QSGViewPrivate()
-{
+QSGViewPrivate::~QSGViewPrivate()
+{
QDeclarativeInspectorService::instance()->removeView(q_func());
delete root;
@@ -96,7 +95,7 @@ void QSGViewPrivate::execute()
if (!component->isLoading()) {
q->continueExecute();
} else {
- QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)),
+ QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)),
q, SLOT(continueExecute()));
}
}
@@ -112,28 +111,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)
-{
- d_func()->init();
-}
-
-QSGView::QSGView(const QUrl &source, QWidget *parent, Qt::WindowFlags f)
-: QSGCanvas(*(new QSGViewPrivate), parent, f)
+QSGView::QSGView(QWindow *parent, Qt::WindowFlags f)
+: QSGCanvas(*(new QSGViewPrivate), parent)
{
+ setWindowFlags(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);
}
@@ -231,8 +219,6 @@ void QSGViewPrivate::updateSize()
if (!qFuzzyCompare(q->height(), root->height()))
root->setHeight(q->height());
}
-
- q->updateGeometry();
}
QSize QSGViewPrivate::rootObjectSize() const
@@ -319,14 +305,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();
}
@@ -381,26 +366,10 @@ QSGItem *QSGView::rootObject() const
void QSGView::resizeEvent(QResizeEvent *e)
{
Q_D(QSGView);
- if (d->resizeMode == SizeRootObjectToView)
+ if (d->resizeMode == SizeRootObjectToView)
d->updateSize();
-
- 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;
+ QSGCanvas::resizeEvent(e);
}
void QSGView::keyPressEvent(QKeyEvent *e)
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/items/qsgview_p.h b/src/declarative/items/qsgview_p.h
index 8b2ee88ee8..3f8d69e8c0 100644
--- a/src/declarative/items/qsgview_p.h
+++ b/src/declarative/items/qsgview_p.h
@@ -97,6 +97,8 @@ public:
QSGView::ResizeMode resizeMode;
QSize initialSize;
QElapsedTimer frameTimer;
+
+ bool resized;
};
QT_END_NAMESPACE
diff --git a/src/declarative/particles/qsgcustomparticle.cpp b/src/declarative/particles/qsgcustomparticle.cpp
index 11bc7e35fb..12d32a27b4 100644
--- a/src/declarative/particles/qsgcustomparticle.cpp
+++ b/src/declarative/particles/qsgcustomparticle.cpp
@@ -132,11 +132,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();
@@ -269,13 +278,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.
@@ -457,8 +465,14 @@ QSGShaderEffectNode* QSGCustomParticle::buildCustomNodes()
s.fragmentCode = qt_particles_default_fragment_code;
if (s.vertexCode.isEmpty())
s.vertexCode = qt_particles_default_vertex_code;
+
+ if (!m_material) {
+ m_material = new QSGShaderEffectMaterialObject;
+ }
+
s.vertexCode = qt_particles_template_vertex_code + s.vertexCode;
- m_material.setProgramSource(s);
+ 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();
@@ -498,7 +512,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);
@@ -519,29 +533,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/particles/qsgimageparticle.cpp b/src/declarative/particles/qsgimageparticle.cpp
index a12d1c223e..853a08a890 100644
--- a/src/declarative/particles/qsgimageparticle.cpp
+++ b/src/declarative/particles/qsgimageparticle.cpp
@@ -49,7 +49,7 @@
#include "qsgparticleemitter_p.h"
#include "qsgsprite_p.h"
#include "qsgspriteengine_p.h"
-#include <QGLFunctions>
+#include <QOpenGLFunctions>
#include <qsgengine.h>
QT_BEGIN_NAMESPACE
@@ -128,7 +128,7 @@ public:
program()->bind();
program()->setUniformValue("texture", 0);
program()->setUniformValue("colortable", 1);
- glFuncs = QGLContext::currentContext()->functions();
+ glFuncs = QOpenGLContext::currentContext()->functions();
m_timestamp_id = program()->uniformLocation("timestamp");
m_entry_id = program()->uniformLocation("entry");
m_sizetable_id = program()->uniformLocation("sizetable");
@@ -156,7 +156,7 @@ public:
int m_opacitytable_id;
QByteArray m_vertex_code;
QByteArray m_fragment_code;
- QGLFunctions* glFuncs;
+ QOpenGLFunctions* glFuncs;
};
class DeformableMaterialData : public ImageMaterialData {};
@@ -195,7 +195,7 @@ public:
QSGSimpleMaterialShader<DeformableMaterialData>::initialize();
program()->bind();
program()->setUniformValue("texture", 0);
- glFuncs = QGLContext::currentContext()->functions();
+ glFuncs = QOpenGLContext::currentContext()->functions();
m_timestamp_id = program()->uniformLocation("timestamp");
m_entry_id = program()->uniformLocation("entry");
}
@@ -212,7 +212,7 @@ public:
int m_timestamp_id;
QByteArray m_vertex_code;
QByteArray m_fragment_code;
- QGLFunctions* glFuncs;
+ QOpenGLFunctions* glFuncs;
};
class SpriteMaterialData : public ImageMaterialData {};
@@ -252,7 +252,7 @@ public:
program()->bind();
program()->setUniformValue("texture", 0);
program()->setUniformValue("colortable", 1);
- glFuncs = QGLContext::currentContext()->functions();
+ glFuncs = QOpenGLContext::currentContext()->functions();
m_timestamp_id = program()->uniformLocation("timestamp");
m_framecount_id = program()->uniformLocation("framecount");
m_animcount_id = program()->uniformLocation("animcount");
@@ -285,7 +285,7 @@ public:
int m_opacitytable_id;
QByteArray m_vertex_code;
QByteArray m_fragment_code;
- QGLFunctions* glFuncs;
+ QOpenGLFunctions* glFuncs;
};
class ColoredMaterialData : public ImageMaterialData {};
@@ -339,7 +339,7 @@ public:
QSGSimpleMaterialShader<ColoredMaterialData>::initialize();
program()->bind();
program()->setUniformValue("texture", 0);
- glFuncs = QGLContext::currentContext()->functions();
+ glFuncs = QOpenGLContext::currentContext()->functions();
m_timestamp_id = program()->uniformLocation("timestamp");
m_entry_id = program()->uniformLocation("entry");
}
@@ -356,7 +356,7 @@ public:
int m_entry_id;
QByteArray m_vertex_code;
QByteArray m_fragment_code;
- QGLFunctions* glFuncs;
+ QOpenGLFunctions* glFuncs;
};
class SimpleMaterialData : public ImageMaterialData {};
@@ -408,7 +408,7 @@ public:
QSGSimpleMaterialShader<SimpleMaterialData>::initialize();
program()->bind();
program()->setUniformValue("texture", 0);
- glFuncs = QGLContext::currentContext()->functions();
+ glFuncs = QOpenGLContext::currentContext()->functions();
m_timestamp_id = program()->uniformLocation("timestamp");
m_entry_id = program()->uniformLocation("entry");
}
@@ -425,7 +425,7 @@ public:
int m_entry_id;
QByteArray m_vertex_code;
QByteArray m_fragment_code;
- QGLFunctions* glFuncs;
+ QOpenGLFunctions* glFuncs;
};
void fillUniformArrayFromImage(float* array, const QImage& img, int size)
diff --git a/src/declarative/qml/parser/qdeclarativejsparser.cpp b/src/declarative/qml/parser/qdeclarativejsparser.cpp
index 9f45293343..546cfdd100 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 7e8f93e202..051739be59 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 5947a9a684..091a561993 100644
--- a/src/declarative/qml/qdeclarativemetatype.cpp
+++ b/src/declarative/qml/qdeclarativemetatype.cpp
@@ -1346,13 +1346,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..107cabc506 100644
--- a/src/declarative/scenegraph/coreapi/qsggeometry.h
+++ b/src/declarative/scenegraph/coreapi/qsggeometry.h
@@ -42,7 +42,8 @@
#ifndef QSGGEOMETRY_H
#define QSGGEOMETRY_H
-#include <QtOpenGL/qgl.h>
+#include <QtGui/qopengl.h>
+#include <QRectF>
QT_BEGIN_HEADER
@@ -50,6 +51,8 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+class QSGGeometryData;
+
class Q_DECLARATIVE_EXPORT QSGGeometry
{
public:
@@ -92,6 +95,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 +144,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 +164,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/qsgmaterial.cpp b/src/declarative/scenegraph/coreapi/qsgmaterial.cpp
index ca172d6f49..65ce9eec93 100644
--- a/src/declarative/scenegraph/coreapi/qsgmaterial.cpp
+++ b/src/declarative/scenegraph/coreapi/qsgmaterial.cpp
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
The QSGMaterial and QSGMaterialShader form a tight relationship. For one
scene graph (including nested graphs), there is one unique QSGMaterialShader
- instance which encapsulates the QGLShaderProgram the scene graph uses
+ instance which encapsulates the QOpenGLShaderProgram the scene graph uses
to render that material, such as a shader to flat coloring of geometry.
Each QSGGeometryNode can have a unique QSGMaterial containing the
how the shader should be configured when drawing that node, such as
@@ -152,7 +152,7 @@ QSGMaterialShader::QSGMaterialShader()
/*!
- \fn QGLShaderProgram *QSGMaterialShader::program() const
+ \fn QOpenGLShaderProgram *QSGMaterialShader::program() const
Returns the shader program used by this QSGMaterialShader.
*/
@@ -228,7 +228,7 @@ void QSGMaterialShader::updateState(const RenderState &state, QSGMaterial *newMa
/*!
This function is called when the shader is initialized to compile the
- actual QGLShaderProgram. Do not call it explicitely.
+ actual QOpenGLShaderProgram. Do not call it explicitely.
The default implementation will extract the vertexShader() and
fragmentShader() and bind the names returned from attributeNames()
@@ -239,8 +239,8 @@ void QSGMaterialShader::compile()
{
Q_ASSERT_X(!m_program.isLinked(), "QSGSMaterialShader::compile()", "Compile called multiple times!");
- program()->addShaderFromSourceCode(QGLShader::Vertex, vertexShader());
- program()->addShaderFromSourceCode(QGLShader::Fragment, fragmentShader());
+ program()->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShader());
+ program()->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShader());
char const *const *attr = attributeNames();
#ifndef QT_NO_DEBUG
@@ -385,10 +385,10 @@ QRect QSGMaterialShader::RenderState::deviceRect() const
/*!
- Returns the QGLContext that is being used for rendering
+ Returns the QOpenGLContext that is being used for rendering
*/
-const QGLContext *QSGMaterialShader::RenderState::context() const
+QOpenGLContext *QSGMaterialShader::RenderState::context() const
{
return static_cast<const QSGRenderer *>(m_data)->glContext();
}
@@ -417,7 +417,7 @@ static void qt_print_material_count()
The QSGMaterial and QSGMaterialShader subclasses form a tight relationship. For
one scene graph (including nested graphs), there is one unique QSGMaterialShader
- instance which encapsulates the QGLShaderProgram the scene graph uses
+ instance which encapsulates the QOpenGLShaderProgram the scene graph uses
to render that material, such as a shader to flat coloring of geometry.
Each QSGGeometryNode can have a unique QSGMaterial containing the
how the shader should be configured when drawing that node, such as
diff --git a/src/declarative/scenegraph/coreapi/qsgmaterial.h b/src/declarative/scenegraph/coreapi/qsgmaterial.h
index 7c6935899e..084219bfba 100644
--- a/src/declarative/scenegraph/coreapi/qsgmaterial.h
+++ b/src/declarative/scenegraph/coreapi/qsgmaterial.h
@@ -42,7 +42,7 @@
#ifndef MATERIAL_H
#define MATERIAL_H
-#include <qglshaderprogram.h>
+#include <qopenglshaderprogram.h>
QT_BEGIN_HEADER
@@ -75,7 +75,7 @@ public:
QRect viewportRect() const;
QRect deviceRect() const;
- const QGLContext *context() const;
+ QOpenGLContext *context() const;
private:
friend class QSGRenderer;
@@ -91,7 +91,7 @@ public:
virtual void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
virtual char const *const *attributeNames() const = 0; // Array must end with null.
- inline QGLShaderProgram *program() { return &m_program; }
+ inline QOpenGLShaderProgram *program() { return &m_program; }
protected:
@@ -104,7 +104,7 @@ protected:
virtual const char *fragmentShader() const = 0;
private:
- QGLShaderProgram m_program;
+ QOpenGLShaderProgram m_program;
void *m_reserved;
};
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..607c5b5b1f 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 <QOpenGLShaderProgram>
+#include <qopenglframebufferobject.h>
+#include <QtWidgets/qapplication.h>
#include <qdatetime.h>
@@ -80,7 +81,7 @@ void QSGBindable::reactivate() const
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
-QSGBindableFbo::QSGBindableFbo(QGLFramebufferObject *fbo) : m_fbo(fbo)
+QSGBindableFbo::QSGBindableFbo(QOpenGLFramebufferObject *fbo) : m_fbo(fbo)
{
}
@@ -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();
}
@@ -206,7 +209,7 @@ void QSGRenderer::renderScene()
class B : public QSGBindable
{
public:
- void bind() const { QGLFramebufferObject::bindDefault(); }
+ void bind() const { QOpenGLFramebufferObject::bindDefault(); }
} b;
renderScene(b);
}
@@ -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,
@@ -441,13 +454,13 @@ QSGRenderer::ClipType QSGRenderer::updateStencilClip(const QSGClipNode *clip)
} else {
if (!stencilEnabled) {
if (!m_clip_program.isLinked()) {
- m_clip_program.addShaderFromSourceCode(QGLShader::Vertex,
+ m_clip_program.addShaderFromSourceCode(QOpenGLShader::Vertex,
"attribute highp vec4 vCoord; \n"
"uniform highp mat4 matrix; \n"
"void main() { \n"
" gl_Position = matrix * vCoord; \n"
"}");
- m_clip_program.addShaderFromSourceCode(QGLShader::Fragment,
+ m_clip_program.addShaderFromSourceCode(QOpenGLShader::Fragment,
"void main() { \n"
" gl_FragColor = vec4(0.81, 0.83, 0.12, 1.0); \n" // Trolltech green ftw!
"}");
@@ -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()
+ {
+ QOpenGLFunctions *func = QOpenGLContext::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..eed6483cdb 100644
--- a/src/declarative/scenegraph/coreapi/qsgrenderer_p.h
+++ b/src/declarative/scenegraph/coreapi/qsgrenderer_p.h
@@ -45,8 +45,9 @@
#include <qset.h>
#include <qhash.h>
-#include <qglfunctions.h>
-#include <qglshaderprogram.h>
+#include <qcolor.h>
+#include <qopenglfunctions.h>
+#include <qopenglshaderprogram.h>
#include "qsgnode.h"
#include "qsgmaterial.h"
@@ -62,13 +63,12 @@ QT_MODULE(Declarative)
class QSGMaterialShader;
struct QSGMaterialType;
-class QGLFramebufferObject;
+class QOpenGLFramebufferObject;
class TextureReference;
class QSGBindable;
class QSGNodeUpdater;
-
-class Q_DECLARATIVE_EXPORT QSGRenderer : public QObject, public QGLFunctions
+class Q_DECLARATIVE_EXPORT QSGRenderer : public QObject, public QOpenGLFunctions
{
Q_OBJECT
public:
@@ -116,7 +116,7 @@ public:
void setClearColor(const QColor &color);
QColor clearColor() const { return m_clear_color; }
- const QGLContext *glContext() const { Q_ASSERT(m_context); return m_context->glContext(); }
+ QOpenGLContext *glContext() const { Q_ASSERT(m_context); return m_context->glContext(); }
QSGContext *context();
@@ -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);
@@ -169,14 +168,17 @@ private:
QSet<QSGNode *> m_nodes_to_preprocess;
QMatrix4x4 m_projection_matrix;
- QGLShaderProgram m_clip_program;
+ QOpenGLShaderProgram m_clip_program;
int m_clip_matrix_id;
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)
@@ -193,10 +195,10 @@ public:
class QSGBindableFbo : public QSGBindable
{
public:
- QSGBindableFbo(QGLFramebufferObject *fbo);
+ QSGBindableFbo(QOpenGLFramebufferObject *fbo);
virtual void bind() const;
private:
- QGLFramebufferObject *m_fbo;
+ QOpenGLFramebufferObject *m_fbo;
};
diff --git a/src/declarative/scenegraph/qsgadaptationlayer_p.h b/src/declarative/scenegraph/qsgadaptationlayer_p.h
index f2c0cbe9ef..f1e9a89f43 100644
--- a/src/declarative/scenegraph/qsgadaptationlayer_p.h
+++ b/src/declarative/scenegraph/qsgadaptationlayer_p.h
@@ -47,6 +47,7 @@
#include <private/qsgtext_p.h>
#include <QtCore/qobject.h>
#include <QtCore/qrect.h>
+#include <QtGui/qbrush.h>
#include <QtGui/qcolor.h>
#include <QtCore/qsharedpointer.h>
#include <QtGui/qglyphrun.h>
diff --git a/src/declarative/scenegraph/qsgcontext.cpp b/src/declarative/scenegraph/qsgcontext.cpp
index 2a9e007264..c472ed1260 100644
--- a/src/declarative/scenegraph/qsgcontext.cpp
+++ b/src/declarative/scenegraph/qsgcontext.cpp
@@ -55,7 +55,7 @@
#include <qsgengine.h>
#include <QApplication>
-#include <QGLContext>
+#include <QOpenGLContext>
#include <private/qobject_p.h>
#include <qmutex.h>
@@ -105,7 +105,7 @@ public:
QSGRootNode *rootNode;
QSGRenderer *renderer;
- QGLContext *gl;
+ QOpenGLContext *gl;
QSGEngine engine;
@@ -127,7 +127,7 @@ public:
\brief The QSGContext holds the scene graph entry points for one QML engine.
- The context is not ready for use until it has a QGLContext. Once that happens,
+ The context is not ready for use until it has a QOpenGLContext. Once that happens,
the scene graph population can start.
\internal
@@ -214,7 +214,7 @@ QSGRootNode *QSGContext::rootNode() const
}
-QGLContext *QSGContext::glContext() const
+QOpenGLContext *QSGContext::glContext() const
{
Q_D(const QSGContext);
return d->gl;
@@ -224,7 +224,7 @@ QGLContext *QSGContext::glContext() const
Initializes the scene graph context with the GL context \a context. This also
emits the ready() signal so that the QML graph can start building scene graph nodes.
*/
-void QSGContext::initialize(QGLContext *context)
+void QSGContext::initialize(QOpenGLContext *context)
{
Q_D(QSGContext);
@@ -253,7 +253,7 @@ bool QSGContext::isReady() const
}
-void QSGContext::renderNextFrame(QGLFramebufferObject *fbo)
+void QSGContext::renderNextFrame(QOpenGLFramebufferObject *fbo)
{
Q_D(QSGContext);
diff --git a/src/declarative/scenegraph/qsgcontext_p.h b/src/declarative/scenegraph/qsgcontext_p.h
index 29a5aac4b9..a05854ebe8 100644
--- a/src/declarative/scenegraph/qsgcontext_p.h
+++ b/src/declarative/scenegraph/qsgcontext_p.h
@@ -42,6 +42,7 @@
#ifndef QSGCONTEXT_H
#define QSGCONTEXT_H
+#include <QImage>
#include <QObject>
#include <qabstractanimation.h>
@@ -64,8 +65,8 @@ class QSGMaterial;
class QSGMaterialShader;
class QSGEngine;
-class QGLContext;
-class QGLFramebufferObject;
+class QOpenGLContext;
+class QOpenGLFramebufferObject;
class Q_DECLARATIVE_EXPORT QSGContext : public QObject
{
@@ -76,7 +77,7 @@ public:
explicit QSGContext(QObject *parent = 0);
~QSGContext();
- virtual void initialize(QGLContext *context);
+ virtual void initialize(QOpenGLContext *context);
QSGRenderer *renderer() const;
@@ -84,13 +85,13 @@ public:
QSGRootNode *rootNode() const;
QSGEngine *engine() const;
- QGLContext *glContext() const;
+ QOpenGLContext *glContext() const;
bool isReady() const;
QSGMaterialShader *prepareMaterial(QSGMaterial *material);
- virtual void renderNextFrame(QGLFramebufferObject *fbo = 0);
+ virtual void renderNextFrame(QOpenGLFramebufferObject *fbo = 0);
virtual QSGRectangleNode *createRectangleNode();
virtual QSGImageNode *createImageNode();
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/qsgdefaultglyphnode.cpp b/src/declarative/scenegraph/qsgdefaultglyphnode.cpp
index 3e8510e943..b8cd247908 100644
--- a/src/declarative/scenegraph/qsgdefaultglyphnode.cpp
+++ b/src/declarative/scenegraph/qsgdefaultglyphnode.cpp
@@ -42,7 +42,7 @@
#include "qsgdefaultglyphnode_p.h"
#include "qsgdefaultglyphnode_p_p.h"
-#include <qglshaderprogram.h>
+#include <qopenglshaderprogram.h>
#include <private/qfont_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/scenegraph/qsgdefaultglyphnode_p.cpp b/src/declarative/scenegraph/qsgdefaultglyphnode_p.cpp
index b00c6f0937..1e56b94236 100644
--- a/src/declarative/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/declarative/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -41,11 +41,11 @@
#include "qsgdefaultglyphnode_p_p.h"
-#include <qglshaderprogram.h>
+#include <qopenglshaderprogram.h>
-#include <private/qtextureglyphcache_gl_p.h>
+#include <QtGui/private/qopengltextureglyphcache_p.h>
#include <private/qfontengine_p.h>
-#include <private/qglextensions_p.h>
+#include <private/qopenglextensions_p.h>
#include <private/qsgtexture_p.h>
@@ -163,24 +163,17 @@ void QSGTextMaskMaterial::init()
QFontEngineGlyphCache::Type type = QFontEngineGlyphCache::Raster_A8;
setFlag(Blending, true);
- QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
+ QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext());
Q_ASSERT(ctx != 0);
QRawFontPrivate *fontD = QRawFontPrivate::get(m_font);
if (fontD->fontEngine != 0) {
m_glyphCache = fontD->fontEngine->glyphCache(ctx, type, QTransform());
if (!m_glyphCache || m_glyphCache->cacheType() != type) {
- m_glyphCache = new QGLTextureGlyphCache(ctx, type, QTransform());
+ m_glyphCache = new QOpenGLTextureGlyphCache(type, QTransform());
fontD->fontEngine->setGlyphCache(ctx, m_glyphCache.data());
}
}
-
-#if !defined(QT_OPENGL_ES_2)
- bool success = qt_resolve_version_2_0_functions(ctx)
- && qt_resolve_buffer_extensions(ctx);
- Q_ASSERT(success);
- Q_UNUSED(success);
-#endif
}
void QSGTextMaskMaterial::populate(const QPointF &p,
@@ -260,9 +253,9 @@ QSGMaterialType *QSGTextMaskMaterial::type() const
return &type;
}
-QGLTextureGlyphCache *QSGTextMaskMaterial::glyphCache() const
+QOpenGLTextureGlyphCache *QSGTextMaskMaterial::glyphCache() const
{
- return static_cast<QGLTextureGlyphCache*>(m_glyphCache.data());
+ return static_cast<QOpenGLTextureGlyphCache*>(m_glyphCache.data());
}
QSGMaterialShader *QSGTextMaskMaterial::createShader() const
diff --git a/src/declarative/scenegraph/qsgdefaultglyphnode_p_p.h b/src/declarative/scenegraph/qsgdefaultglyphnode_p_p.h
index 19d5f9e6a6..d22bc33fea 100644
--- a/src/declarative/scenegraph/qsgdefaultglyphnode_p_p.h
+++ b/src/declarative/scenegraph/qsgdefaultglyphnode_p_p.h
@@ -42,6 +42,7 @@
#ifndef TEXTMASKMATERIAL_H
#define TEXTMASKMATERIAL_H
+#include <qcolor.h>
#include <qsgmaterial.h>
#include <qsgtexture.h>
#include <qsggeometry.h>
@@ -52,7 +53,7 @@
QT_BEGIN_NAMESPACE
class QFontEngineGlyphCache;
-class QGLTextureGlyphCache;
+class QOpenGLTextureGlyphCache;
class QFontEngine;
class Geometry;
class QSGTextMaskMaterial: public QSGMaterial
@@ -75,7 +76,7 @@ public:
bool ensureUpToDate();
- QGLTextureGlyphCache *glyphCache() const;
+ QOpenGLTextureGlyphCache *glyphCache() const;
void populate(const QPointF &position,
const QVector<quint32> &glyphIndexes, const QVector<QPointF> &glyphPositions,
QSGGeometry *geometry, QRectF *boundingRect, QPointF *baseLine);
diff --git a/src/declarative/scenegraph/qsgdefaultimagenode.cpp b/src/declarative/scenegraph/qsgdefaultimagenode.cpp
index e60ebf2b84..657f8d0e7c 100644
--- a/src/declarative/scenegraph/qsgdefaultimagenode.cpp
+++ b/src/declarative/scenegraph/qsgdefaultimagenode.cpp
@@ -45,7 +45,7 @@
#include <QtCore/qvarlengtharray.h>
#include <QtCore/qmath.h>
-#include <QtOpenGL/qglfunctions.h>
+#include <QtGui/qopenglfunctions.h>
QT_BEGIN_NAMESPACE
@@ -194,8 +194,8 @@ void QSGDefaultImageNode::updateGeometry()
bool isRepeating = hCells > 1 || vCells > 1;
#ifdef QT_OPENGL_ES_2
- const QGLContext *ctx = QGLContext::currentContext();
- bool npotSupported = ctx->functions()->hasOpenGLFeature(QGLFunctions::NPOTTextures);
+ QOpenGLContext *ctx = QOpenGLContext::currentContext();
+ bool npotSupported = ctx->functions()->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures);
QSize size = t->textureSize();
bool isNpot = !isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height());
diff --git a/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp b/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp
index ff4913a7b5..13fe62a27a 100644
--- a/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp
+++ b/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp
@@ -44,14 +44,15 @@
#include <qmath.h>
#include <private/qsgpathsimplifier_p.h>
#include <private/qdeclarativeglobal_p.h>
-#include <qglshaderprogram.h>
-#include <private/qglengineshadersource_p.h>
+#include <qopenglshaderprogram.h>
+#include <QtGui/private/qopenglengineshadersource_p.h>
#include <private/qsgcontext_p.h>
#include <private/qrawfont_p.h>
-#include <qglfunctions.h>
+#include <qopenglfunctions.h>
#include <qglyphrun.h>
#include <qrawfont.h>
#include <qdir.h>
+#include <QtGui/qguiapplication.h>
QT_BEGIN_NAMESPACE
@@ -797,7 +798,7 @@ static bool fontHasNarrowOutlines(const QRawFont &f)
return minHThick == 1 || minVThick == 1;
}
-QSGDistanceFieldGlyphCacheManager::QSGDistanceFieldGlyphCacheManager(const QGLContext *c)
+QSGDistanceFieldGlyphCacheManager::QSGDistanceFieldGlyphCacheManager(QOpenGLContext *c)
: ctx(c)
, m_threshold_func(defaultThresholdFunc)
, m_antialiasingSpread_func(defaultAntialiasingSpreadFunc)
@@ -827,23 +828,23 @@ QSGDistanceFieldGlyphCacheManager::QSGDistanceFieldGlyphCacheManager(const QGLCo
m_textureCoordinateArray[6] = 0.0f;
m_textureCoordinateArray[7] = 1.0f;
- m_blitProgram = new QGLShaderProgram;
+ m_blitProgram = new QOpenGLShaderProgram;
{
QString source;
- source.append(QLatin1String(qglslMainWithTexCoordsVertexShader));
- source.append(QLatin1String(qglslUntransformedPositionVertexShader));
+ source.append(QLatin1String(qopenglslMainWithTexCoordsVertexShader));
+ source.append(QLatin1String(qopenglslUntransformedPositionVertexShader));
- QGLShader *vertexShader = new QGLShader(QGLShader::Vertex, m_blitProgram);
+ QOpenGLShader *vertexShader = new QOpenGLShader(QOpenGLShader::Vertex, m_blitProgram);
vertexShader->compileSourceCode(source);
m_blitProgram->addShader(vertexShader);
}
{
QString source;
- source.append(QLatin1String(qglslMainFragmentShader));
- source.append(QLatin1String(qglslImageSrcFragmentShader));
+ source.append(QLatin1String(qopenglslMainFragmentShader));
+ source.append(QLatin1String(qopenglslImageSrcFragmentShader));
- QGLShader *fragmentShader = new QGLShader(QGLShader::Fragment, m_blitProgram);
+ QOpenGLShader *fragmentShader = new QOpenGLShader(QOpenGLShader::Fragment, m_blitProgram);
fragmentShader->compileSourceCode(source);
m_blitProgram->addShader(fragmentShader);
@@ -876,7 +877,7 @@ int QSGDistanceFieldGlyphCacheManager::maxTextureSize() const
}
-QHash<QString, QGLContextGroupResource<QSGDistanceFieldGlyphCache::DistanceFieldTextureData> > QSGDistanceFieldGlyphCache::m_textures_data;
+QHash<QString, QOpenGLMultiGroupSharedResource> QSGDistanceFieldGlyphCache::m_textures_data;
QSGDistanceFieldGlyphCache::DistanceFieldTextureData *QSGDistanceFieldGlyphCache::textureData()
{
@@ -885,10 +886,10 @@ QSGDistanceFieldGlyphCache::DistanceFieldTextureData *QSGDistanceFieldGlyphCache
.arg(m_font.styleName())
.arg(m_font.weight())
.arg(m_font.style());
- return m_textures_data[key].value(ctx);
+ return m_textures_data[key].value<QSGDistanceFieldGlyphCache::DistanceFieldTextureData>(QOpenGLContext::currentContext());
}
-QSGDistanceFieldGlyphCache::QSGDistanceFieldGlyphCache(QSGDistanceFieldGlyphCacheManager *man, const QGLContext *c, const QRawFont &font)
+QSGDistanceFieldGlyphCache::QSGDistanceFieldGlyphCache(QSGDistanceFieldGlyphCacheManager *man, QOpenGLContext *c, const QRawFont &font)
: m_manager(man)
, ctx(c)
{
@@ -1045,7 +1046,7 @@ void QSGDistanceFieldGlyphCache::derefGlyphs(int count, const glyph_t *glyphs)
void QSGDistanceFieldGlyphCache::createTexture(int width, int height)
{
- if (ctx->d_ptr->workaround_brokenFBOReadBack && m_textureData->image.isNull())
+ if (ctx->d_func()->workaround_brokenFBOReadBack && m_textureData->image.isNull())
m_textureData->image = QImage(width, height, QImage::Format_Indexed8);
while (glGetError() != GL_NO_ERROR) { }
@@ -1083,7 +1084,7 @@ void QSGDistanceFieldGlyphCache::resizeTexture(int width, int height)
if (!oldTexture)
return;
- if (ctx->d_ptr->workaround_brokenFBOReadBack) {
+ if (ctx->d_func()->workaround_brokenFBOReadBack) {
m_textureData->image = m_textureData->image.copy(0, 0, width, height);
QImage copy = m_textureData->image.copy(0, 0, oldWidth, oldHeight);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, copy.constBits());
@@ -1093,7 +1094,7 @@ void QSGDistanceFieldGlyphCache::resizeTexture(int width, int height)
if (!m_textureData->fbo)
ctx->functions()->glGenFramebuffers(1, &m_textureData->fbo);
- ctx->functions()->glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_textureData->fbo);
+ ctx->functions()->glBindFramebuffer(GL_FRAMEBUFFER, m_textureData->fbo);
GLuint tmp_texture;
glGenTextures(1, &tmp_texture);
@@ -1105,7 +1106,7 @@ void QSGDistanceFieldGlyphCache::resizeTexture(int width, int height)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_2D, 0);
- ctx->functions()->glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ ctx->functions()->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, tmp_texture, 0);
ctx->functions()->glActiveTexture(GL_TEXTURE0);
@@ -1145,12 +1146,12 @@ void QSGDistanceFieldGlyphCache::resizeTexture(int width, int height)
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, oldWidth, oldHeight);
- ctx->functions()->glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_RENDERBUFFER_EXT, 0);
+ ctx->functions()->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_RENDERBUFFER, 0);
glDeleteTextures(1, &tmp_texture);
glDeleteTextures(1, &oldTexture);
- ctx->functions()->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
+ ctx->functions()->glBindFramebuffer(GL_FRAMEBUFFER, 0);
// restore render states
if (stencilTestEnabled)
@@ -1177,7 +1178,7 @@ void QSGDistanceFieldGlyphCache::updateCache()
glBindTexture(GL_TEXTURE_2D, m_textureData->texture);
// ### Remove before final release
- static bool cacheDistanceFields = QApplication::arguments().contains("--cache-distance-fields");
+ static bool cacheDistanceFields = QGuiApplication::arguments().contains("--cache-distance-fields");
// #define QSGDISTANCEFIELDS_TIME_CREATION
#ifdef QSGDISTANCEFIELDS_TIME_CREATION
@@ -1214,7 +1215,7 @@ void QSGDistanceFieldGlyphCache::updateCache()
QImage glyph = renderDistanceFieldGlyph(glyphIndex);
- if (ctx->d_ptr->workaround_brokenFBOReadBack) {
+ if (ctx->d_func()->workaround_brokenFBOReadBack) {
uchar *inBits = glyph.scanLine(0);
uchar *outBits = m_textureData->image.scanLine(int(c.y)) + int(c.x);
for (int y = 0; y < glyph.height(); ++y) {
@@ -1245,7 +1246,7 @@ void QSGDistanceFieldGlyphCache::updateCache()
bool QSGDistanceFieldGlyphCache::useWorkaroundBrokenFBOReadback() const
{
- return ctx->d_ptr->workaround_brokenFBOReadBack;
+ return ctx->d_func()->workaround_brokenFBOReadBack;
}
int QSGDistanceFieldGlyphCache::glyphCount() const
diff --git a/src/declarative/scenegraph/qsgdistancefieldglyphcache_p.h b/src/declarative/scenegraph/qsgdistancefieldglyphcache_p.h
index c4dd97bab5..aea7c5952f 100644
--- a/src/declarative/scenegraph/qsgdistancefieldglyphcache_p.h
+++ b/src/declarative/scenegraph/qsgdistancefieldglyphcache_p.h
@@ -42,9 +42,10 @@
#ifndef DISTANCEFIELDGLYPHCACHE_H
#define DISTANCEFIELDGLYPHCACHE_H
-#include <qgl.h>
+#include <qopengl.h>
#include <qrawfont.h>
-#include <private/qgl_p.h>
+#include <private/qopenglcontext_p.h>
+#include <QtGui/qopenglfunctions.h>
#include <private/qfont_p.h>
#include <private/qfontengine_p.h>
#include <QtGui/private/qdatabuffer_p.h>
@@ -55,13 +56,13 @@ QT_BEGIN_NAMESPACE
typedef float (*ThresholdFunc)(float glyphScale);
typedef float (*AntialiasingSpreadFunc)(float glyphScale);
-class QGLShaderProgram;
+class QOpenGLShaderProgram;
class QSGDistanceFieldGlyphCache;
class Q_DECLARATIVE_EXPORT QSGDistanceFieldGlyphCacheManager
{
public:
- QSGDistanceFieldGlyphCacheManager(const QGLContext *c);
+ QSGDistanceFieldGlyphCacheManager(QOpenGLContext *c);
~QSGDistanceFieldGlyphCacheManager();
QSGDistanceFieldGlyphCache *cache(const QRawFont &font);
@@ -75,7 +76,7 @@ public:
AntialiasingSpreadFunc antialiasingSpreadFunc() const { return m_antialiasingSpread_func; }
void setAntialiasingSpreadFunc(AntialiasingSpreadFunc func) { m_antialiasingSpread_func = func; }
- QGLShaderProgram *blitProgram() { return m_blitProgram; }
+ QOpenGLShaderProgram *blitProgram() { return m_blitProgram; }
const GLfloat *blitVertexArray() const { return &m_vertexCoordinateArray[0]; }
const GLfloat *blitTextureArray() const { return &m_textureCoordinateArray[0]; }
@@ -84,7 +85,7 @@ public:
private:
QHash<QFontEngine *, QSGDistanceFieldGlyphCache *> m_caches;
- const QGLContext *ctx;
+ QOpenGLContext *ctx;
QSGGlyphNode::AntialiasingMode m_defaultAntialiasingMode;
ThresholdFunc m_threshold_func;
@@ -92,7 +93,7 @@ private:
mutable int m_maxTextureSize;
- QGLShaderProgram *m_blitProgram;
+ QOpenGLShaderProgram *m_blitProgram;
GLfloat m_vertexCoordinateArray[8];
GLfloat m_textureCoordinateArray[8];
};
@@ -145,20 +146,22 @@ public:
bool useWorkaroundBrokenFBOReadback() const;
private:
- QSGDistanceFieldGlyphCache(QSGDistanceFieldGlyphCacheManager *man, const QGLContext *c, const QRawFont &font);
+ QSGDistanceFieldGlyphCache(QSGDistanceFieldGlyphCacheManager *man, QOpenGLContext *c, const QRawFont &font);
void createTexture(int width, int height);
void resizeTexture(int width, int height);
QSGDistanceFieldGlyphCacheManager *m_manager;
+ QOpenGLContext *ctx;
+
QRawFont m_font;
QRawFont m_referenceFont;
int m_glyphCount;
QHash<glyph_t, Metrics> m_metrics;
- struct DistanceFieldTextureData {
+ struct DistanceFieldTextureData : public QOpenGLSharedResource {
GLuint texture;
GLuint fbo;
QSize size;
@@ -171,20 +174,33 @@ private:
QImage image;
bool doubleGlyphResolution;
- DistanceFieldTextureData(const QGLContext *)
- : texture(0)
+ DistanceFieldTextureData(QOpenGLContext *ctx)
+ : QOpenGLSharedResource(ctx->shareGroup())
+ , texture(0)
, fbo(0)
, pendingGlyphs(64)
, currX(0)
, currY(0)
, doubleGlyphResolution(false)
- { }
+ {}
+
+ void invalidateResource()
+ {
+ texture = 0;
+ fbo = 0;
+ size = QSize();
+ }
+
+ void freeResource(QOpenGLContext *ctx)
+ {
+ glDeleteTextures(1, &texture);
+ ctx->functions()->glDeleteFramebuffers(1, &fbo);
+ }
};
+
DistanceFieldTextureData *textureData();
DistanceFieldTextureData *m_textureData;
- static QHash<QString, QGLContextGroupResource<DistanceFieldTextureData> > m_textures_data;
-
- const QGLContext *ctx;
+ static QHash<QString, QOpenGLMultiGroupSharedResource> m_textures_data;
friend class QSGDistanceFieldGlyphCacheManager;
};
diff --git a/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.cpp
index c81113f4dc..72c53a2ce7 100644
--- a/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.cpp
+++ b/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.cpp
@@ -42,7 +42,7 @@
#include "qsgdistancefieldglyphnode_p_p.h"
#include "qsgdistancefieldglyphcache_p.h"
#include <private/qsgtexture_p.h>
-#include <QtOpenGL/qglfunctions.h>
+#include <QtGui/qopenglfunctions.h>
#include <qmath.h>
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/scenegraph/qsgpathsimplifier.cpp b/src/declarative/scenegraph/qsgpathsimplifier.cpp
index 5fac564e21..9e851bf434 100644
--- a/src/declarative/scenegraph/qsgpathsimplifier.cpp
+++ b/src/declarative/scenegraph/qsgpathsimplifier.cpp
@@ -48,7 +48,7 @@
#include <math.h>
-#include <private/qgl_p.h>
+#include <private/qopengl_p.h>
#include <private/qrbtree_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/scenegraph/scenegraph.pri b/src/declarative/scenegraph/scenegraph.pri
index aa9d2bc6b2..b628a4708d 100644
--- a/src/declarative/scenegraph/scenegraph.pri
+++ b/src/declarative/scenegraph/scenegraph.pri
@@ -1,9 +1,6 @@
INCLUDEPATH += $$PWD/coreapi $$PWD/convenience $$PWD/3d
!contains(QT_CONFIG, egl):DEFINES += QT_NO_EGL
-QT += opengl
-
-
# Core API
HEADERS += \
$$PWD/coreapi/qsgdefaultrenderer_p.h \
@@ -11,7 +8,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/qsgflatcolormaterial.cpp b/src/declarative/scenegraph/util/qsgflatcolormaterial.cpp
index d954f196ab..06ca28aff5 100644
--- a/src/declarative/scenegraph/util/qsgflatcolormaterial.cpp
+++ b/src/declarative/scenegraph/util/qsgflatcolormaterial.cpp
@@ -41,7 +41,7 @@
#include "qsgflatcolormaterial.h"
-#include <qglshaderprogram.h>
+#include <qopenglshaderprogram.h>
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/scenegraph/util/qsgflatcolormaterial.h b/src/declarative/scenegraph/util/qsgflatcolormaterial.h
index ffff7941a3..fb0411089a 100644
--- a/src/declarative/scenegraph/util/qsgflatcolormaterial.h
+++ b/src/declarative/scenegraph/util/qsgflatcolormaterial.h
@@ -43,6 +43,7 @@
#define FLATCOLORMATERIAL_H
#include <qsgmaterial.h>
+#include <qcolor.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/scenegraph/util/qsgpainternode.cpp b/src/declarative/scenegraph/util/qsgpainternode.cpp
index ab96591b76..9a02d8bedd 100644
--- a/src/declarative/scenegraph/util/qsgpainternode.cpp
+++ b/src/declarative/scenegraph/util/qsgpainternode.cpp
@@ -43,9 +43,10 @@
#include "qsgpainteditem.h"
#include <private/qsgcontext_p.h>
-#include <qglframebufferobject.h>
-#include <qglfunctions.h>
+#include <qopenglframebufferobject.h>
+#include <qopenglfunctions.h>
#include <qmath.h>
+#include <qpainter.h>
QT_BEGIN_NAMESPACE
@@ -90,7 +91,7 @@ void QSGPainterTexture::bind()
#endif
if (m_has_mipmaps && !m_mipmaps_generated) {
- const QGLContext *ctx = QGLContext::currentContext();
+ QOpenGLContext *ctx = QOpenGLContext::currentContext();
ctx->functions()->glGenerateMipmap(GL_TEXTURE_2D);
m_mipmaps_generated = true;
}
@@ -174,7 +175,7 @@ void QSGPainterNode::paint()
m_texture->setImage(m_image);
m_texture->setDirtyRect(dirtyRect);
} else if (m_multisampledFbo) {
- QGLFramebufferObject::blitFramebuffer(m_fbo, dirtyRect, m_multisampledFbo, dirtyRect);
+ QOpenGLFramebufferObject::blitFramebuffer(m_fbo, dirtyRect, m_multisampledFbo, dirtyRect);
}
m_dirtyRect = QRect();
@@ -249,8 +250,8 @@ void QSGPainterNode::updateRenderTarget()
}
if (m_actualRenderTarget == QSGPaintedItem::FramebufferObject) {
- const QGLContext *ctx = QGLContext::currentContext();
- if (m_fbo && !m_dirtyGeometry && (!ctx->format().sampleBuffers() || !m_multisamplingSupported))
+ QOpenGLContext *ctx = QOpenGLContext::currentContext();
+ if (m_fbo && !m_dirtyGeometry && (!ctx->format().samples() || !m_multisamplingSupported))
return;
if (m_fboSize.isEmpty())
@@ -260,22 +261,22 @@ void QSGPainterNode::updateRenderTarget()
delete m_multisampledFbo;
m_fbo = m_multisampledFbo = 0;
- if (m_smoothPainting && ctx->format().sampleBuffers() && m_multisamplingSupported) {
+ if (m_smoothPainting && ctx->format().samples() && m_multisamplingSupported) {
{
- QGLFramebufferObjectFormat format;
- format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
+ QOpenGLFramebufferObjectFormat format;
+ format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setSamples(ctx->format().samples());
- m_multisampledFbo = new QGLFramebufferObject(m_fboSize, format);
+ m_multisampledFbo = new QOpenGLFramebufferObject(m_fboSize, format);
}
{
- QGLFramebufferObjectFormat format;
- format.setAttachment(QGLFramebufferObject::NoAttachment);
- m_fbo = new QGLFramebufferObject(m_fboSize, format);
+ QOpenGLFramebufferObjectFormat format;
+ format.setAttachment(QOpenGLFramebufferObject::NoAttachment);
+ m_fbo = new QOpenGLFramebufferObject(m_fboSize, format);
}
} else {
- QGLFramebufferObjectFormat format;
- format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
- m_fbo = new QGLFramebufferObject(m_fboSize, format);
+ QOpenGLFramebufferObjectFormat format;
+ format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
+ m_fbo = new QOpenGLFramebufferObject(m_fboSize, format);
}
} else {
if (!m_image.isNull() && !m_dirtyGeometry)
diff --git a/src/declarative/scenegraph/util/qsgpainternode_p.h b/src/declarative/scenegraph/util/qsgpainternode_p.h
index 5b0e9cef2c..50fb521405 100644
--- a/src/declarative/scenegraph/util/qsgpainternode_p.h
+++ b/src/declarative/scenegraph/util/qsgpainternode_p.h
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QGLFramebufferObject;
+class QOpenGLFramebufferObject;
class Q_DECLARATIVE_EXPORT QSGPainterTexture : public QSGPlainTexture
{
@@ -115,8 +115,8 @@ private:
QSGPaintedItem *m_item;
- QGLFramebufferObject *m_fbo;
- QGLFramebufferObject *m_multisampledFbo;
+ QOpenGLFramebufferObject *m_fbo;
+ QOpenGLFramebufferObject *m_multisampledFbo;
QImage m_image;
QSGOpaqueTextureMaterial m_material;
diff --git a/src/declarative/scenegraph/util/qsgtexture.cpp b/src/declarative/scenegraph/util/qsgtexture.cpp
index 536ac8d7fe..bec325f3bb 100644
--- a/src/declarative/scenegraph/util/qsgtexture.cpp
+++ b/src/declarative/scenegraph/util/qsgtexture.cpp
@@ -42,9 +42,15 @@
#define GL_GLEXT_PROTOTYPES
#include <private/qsgtexture_p.h>
-#include <qglfunctions.h>
+#include <qopenglfunctions.h>
#include <private/qsgcontext_p.h>
#include <qthread.h>
+#include <private/qdeclarativedebugtrace_p.h>
+
+#if !defined(QT_NO_DEBUG) && (defined(Q_OS_LINUX) || defined(Q_OS_MAC))
+#include <execinfo.h>
+#include <QHash>
+#endif
QT_BEGIN_NAMESPACE
@@ -65,36 +71,108 @@ QSGTexturePrivate::QSGTexturePrivate()
}
#ifndef QT_NO_DEBUG
-static int qt_texture_count = 0;
-static void qt_print_texture_count()
+static int qt_debug_texture_count = 0;
+
+#if defined(Q_OS_LINUX) || defined (Q_OS_MAC)
+DEFINE_BOOL_CONFIG_OPTION(qmlDebugLeakBacktrace, QML_DEBUG_LEAK_BACKTRACE)
+
+#define BACKTRACE_SIZE 20
+class SGTextureTraceItem
{
- qDebug("Number of leaked textures: %i", qt_texture_count);
- qt_texture_count = -1;
-}
+public:
+ void *backTrace[BACKTRACE_SIZE];
+ size_t backTraceSize;
+};
+
+static QHash<QSGTexture*, SGTextureTraceItem*> qt_debug_allocated_textures;
#endif
+inline static void qt_debug_print_texture_count()
+{
+ qDebug("Number of leaked textures: %i", qt_debug_texture_count);
+ qt_debug_texture_count = -1;
+#if defined(Q_OS_LINUX) || defined (Q_OS_MAC)
+ if (qmlDebugLeakBacktrace()) {
+ while (!qt_debug_allocated_textures.isEmpty()) {
+ QHash<QSGTexture*, SGTextureTraceItem*>::Iterator it = qt_debug_allocated_textures.begin();
+ QSGTexture* texture = it.key();
+ SGTextureTraceItem* item = it.value();
-QSGTexture::QSGTexture()
- : QObject(*(new QSGTexturePrivate))
+ qt_debug_allocated_textures.erase(it);
+
+ qDebug() << "------";
+ qDebug() << "Leaked" << texture << "backtrace:";
+
+ char** symbols = backtrace_symbols(item->backTrace, item->backTraceSize);
+
+ if (symbols) {
+ for (int i=0; i<(int) item->backTraceSize; i++)
+ qDebug("Backtrace <%02d>: %s", i, symbols[i]);
+ free(symbols);
+ }
+
+ qDebug() << "------";
+
+ delete item;
+ }
+ }
+#endif
+}
+
+inline static void qt_debug_add_texture(QSGTexture* texture)
{
-#ifndef QT_NO_DEBUG
- ++qt_texture_count;
+#if defined(Q_OS_LINUX) || defined (Q_OS_MAC)
+ if (qmlDebugLeakBacktrace()) {
+ SGTextureTraceItem* item = new SGTextureTraceItem;
+ item->backTraceSize = backtrace(item->backTrace, BACKTRACE_SIZE);
+ qt_debug_allocated_textures.insert(texture, item);
+ }
+#endif // Q_OS_LINUX
+
+ ++qt_debug_texture_count;
+
static bool atexit_registered = false;
if (!atexit_registered) {
- atexit(qt_print_texture_count);
+ atexit(qt_debug_print_texture_count);
atexit_registered = true;
}
+}
+
+static void qt_debug_remove_texture(QSGTexture* texture)
+{
+#if defined(Q_OS_LINUX) || defined (Q_OS_MAC)
+ if (qmlDebugLeakBacktrace()) {
+ SGTextureTraceItem* item = qt_debug_allocated_textures.value(texture, 0);
+ if (item) {
+ qt_debug_allocated_textures.remove(texture);
+ delete item;
+ }
+ }
+#endif
+
+ --qt_debug_texture_count;
+
+ if (qt_debug_texture_count < 0)
+ qDebug("Material destroyed after qt_debug_print_texture_count() was called.");
+}
+
+#endif // QT_NO_DEBUG
+
+
+QSGTexture::QSGTexture()
+ : QObject(*(new QSGTexturePrivate))
+{
+#ifndef QT_NO_DEBUG
+ qt_debug_add_texture(this);
#endif
}
QSGTexture::~QSGTexture()
{
#ifndef QT_NO_DEBUG
- --qt_texture_count;
- if (qt_texture_count < 0)
- qDebug("Material destroyed after qt_print_texture_count() was called.");
+ qt_debug_remove_texture(this);
#endif
}
@@ -260,7 +338,7 @@ void QSGTexture::updateBindOptions(bool force)
if (force || d->wrapChanged) {
#if !defined(QT_NO_DEBUG) && defined(QT_OPENGL_ES_2)
if (d->horizontalWrap == Repeat || d->verticalWrap == Repeat) {
- bool npotSupported = QGLContext::currentContext()->functions()->hasOpenGLFeature(QGLFunctions::NPOTTextures);
+ bool npotSupported = QOpenGLFunctions(QOpenGLContext::currentContext()).hasOpenGLFeature(QOpenGLFunctions::NPOTTextures);
QSize size = textureSize();
bool isNpot = !isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height());
if (!npotSupported && isNpot)
@@ -341,7 +419,7 @@ void QSGPlainTexture::bind()
if (!m_dirty_texture) {
glBindTexture(GL_TEXTURE_2D, m_texture_id);
if (m_has_mipmaps && !m_mipmaps_generated) {
- const QGLContext *ctx = QGLContext::currentContext();
+ QOpenGLContext *ctx = QOpenGLContext::currentContext();
ctx->functions()->glGenerateMipmap(GL_TEXTURE_2D);
m_mipmaps_generated = true;
}
@@ -377,7 +455,7 @@ void QSGPlainTexture::bind()
#endif
if (m_has_mipmaps) {
- const QGLContext *ctx = QGLContext::currentContext();
+ QOpenGLContext *ctx = QOpenGLContext::currentContext();
ctx->functions()->glGenerateMipmap(GL_TEXTURE_2D);
m_mipmaps_generated = true;
}
diff --git a/src/declarative/scenegraph/util/qsgtexture_p.h b/src/declarative/scenegraph/util/qsgtexture_p.h
index 971e5e686c..22812f8640 100644
--- a/src/declarative/scenegraph/util/qsgtexture_p.h
+++ b/src/declarative/scenegraph/util/qsgtexture_p.h
@@ -44,7 +44,7 @@
#include <private/qobject_p.h>
-#include <QtOpenGL/qgl.h>
+#include <QtGui/qopengl.h>
#include "qsgtexture.h"
#include <private/qsgcontext_p.h>
diff --git a/src/declarative/scenegraph/util/qsgtexturematerial.cpp b/src/declarative/scenegraph/util/qsgtexturematerial.cpp
index 7a7050e073..43bfbcad57 100644
--- a/src/declarative/scenegraph/util/qsgtexturematerial.cpp
+++ b/src/declarative/scenegraph/util/qsgtexturematerial.cpp
@@ -41,8 +41,8 @@
#include "qsgtexturematerial_p.h"
-#include <QtOpenGL/qglshaderprogram.h>
-#include <QtOpenGL/qglfunctions.h>
+#include <QtGui/qopenglshaderprogram.h>
+#include <QtGui/qopenglfunctions.h>
QT_BEGIN_NAMESPACE
@@ -103,7 +103,7 @@ void QSGOpaqueTextureMaterialShader::updateState(const RenderState &state, QSGMa
t->setFiltering(tx->filtering());
#ifdef QT_OPENGL_ES_2
- bool npotSupported = state.context()->functions()->hasOpenGLFeature(QGLFunctions::NPOTTextures);
+ bool npotSupported = QOpenGLFunctions(const_cast<QOpenGLContext *>(state.context())).hasOpenGLFeature(QOpenGLFunctions::NPOTTextures);
QSize size = t->textureSize();
bool isNpot = !isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height());
if (!npotSupported && isNpot) {
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/scenegraph/util/qsgvertexcolormaterial.cpp b/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp
index 910d7a53f8..c31e9dc936 100644
--- a/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp
+++ b/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp
@@ -41,7 +41,7 @@
#include "qsgvertexcolormaterial_p.h"
-#include <qglshaderprogram.h>
+#include <qopenglshaderprogram.h>
QT_BEGIN_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/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp
index 108d2579ac..276219eb45 100644
--- a/src/declarative/util/qdeclarativepixmapcache.cpp
+++ b/src/declarative/util/qdeclarativepixmapcache.cpp
@@ -66,6 +66,7 @@
#include <QtCore/qdebug.h>
#include <private/qobject_p.h>
#include <QSslError>
+#include <QOpenGLContext>
#define IMAGEREQUEST_MAX_REQUEST_COUNT 8
#define IMAGEREQUEST_MAX_REDIRECT_RECURSION 16
@@ -724,7 +725,7 @@ QDeclarativePixmapStore::QDeclarativePixmapStore()
void QDeclarativePixmapStore::cleanTextureForContext(QDeclarativePixmapData *data)
{
if (data->context) {
- Q_ASSERT(QGLContext::currentContext());
+ Q_ASSERT(QOpenGLContext::currentContext());
delete data->texture;
data->context = 0;
data->texture = 0;
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index 98f437d9a3..4f198a537e 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/etcprovider/qetcprovider.cpp b/src/imports/etcprovider/qetcprovider.cpp
index 3e76c017a4..053258a794 100644
--- a/src/imports/etcprovider/qetcprovider.cpp
+++ b/src/imports/etcprovider/qetcprovider.cpp
@@ -44,7 +44,8 @@
#include <QtDebug>
#include <QFile>
-#include <qglfunctions.h>
+#include <qopenglfunctions.h>
+#include <qopenglcontext.h>
QT_BEGIN_NAMESPACE
@@ -118,7 +119,7 @@ void EtcTexture::bind()
"paddedWidth: " << m_paddedSize.width() << "paddedHeight: " << m_paddedSize.height();
#endif
- const QGLContext *ctx = QGLContext::currentContext();
+ QOpenGLContext *ctx = QOpenGLContext::currentContext();
Q_ASSERT(ctx != 0);
ctx->functions()->glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_ETC1_RGB8_OES,
m_size.width(), m_size.height(), 0,
diff --git a/src/imports/etcprovider/qetcprovider.h b/src/imports/etcprovider/qetcprovider.h
index a34b458b70..46ec421162 100644
--- a/src/imports/etcprovider/qetcprovider.h
+++ b/src/imports/etcprovider/qetcprovider.h
@@ -42,7 +42,7 @@
#ifndef QETCPROVIDER_H
#define QETCPROVIDER_H
-#include <qgl.h>
+#include <qopengl.h>
#include <QDeclarativeImageProvider>
#include <QSGTexture>
#include <QDeclarativeEngine>
diff --git a/src/imports/gestures/gestures.pro b/src/imports/gestures/gestures.pro
index 45483fc810..e7095956b2 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 v8-private declarative-private qtquick1 qtquick1-private
+QT += core-private gui-private declarative-private qtquick1 qtquick1-private widgets-private v8-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 e054796d25..74dab8dcf3 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 v8-private 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 v8-private
OTHER_FILES += \
qmldir
diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp
index 03cd7947f9..8dcc076630 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp
@@ -50,7 +50,7 @@
#include <QtCore/private/qabstractanimation_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 3af872d4ac..c165832013 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 v8-private opengl-private qtquick1
+QT += declarative-private core-private gui-private opengl-private qtquick1 widgets widgets-private v8-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.cpp b/src/qmltest/quicktest.cpp
index 7c207084c5..c7d9747a3e 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -54,7 +54,7 @@
#endif
#include <QtDeclarative/qjsvalue.h>
#include <QtDeclarative/qjsengine.h>
-#include <QtOpenGL/qgl.h>
+#include <QtGui/qopengl.h>
#include <QtCore/qurl.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qdir.h>
diff --git a/src/qmltest/quicktest.h b/src/qmltest/quicktest.h
index ebf7ce6cb3..a83d176cfa 100644
--- a/src/qmltest/quicktest.h
+++ b/src/qmltest/quicktest.h
@@ -43,9 +43,9 @@
#define QUICKTEST_H
#include <QtQuickTest/quicktestglobal.h>
-#include <QtGui/qwidget.h>
+#include <QtWidgets/qwidget.h>
#ifdef QT_OPENGL_LIB
-#include <QtOpenGL/qgl.h>
+#include <QtGui/qopengl.h>
#endif
QT_BEGIN_NAMESPACE
@@ -65,7 +65,7 @@ Q_QUICK_TEST_EXPORT int quick_test_main(int argc, char **argv, const char *name,
#define QUICK_TEST_OPENGL_MAIN(name) \
static QWidget *name##_create_viewport() \
{ \
- return new QGLWidget(); \
+ return new QOpenGLWidget(); \
} \
int main(int argc, char **argv) \
{ \
@@ -83,7 +83,7 @@ Q_QUICK_TEST_EXPORT int quick_test_main(int argc, char **argv, const char *name,
#define QUICK_TEST_OPENGL_MAIN(name) \
static QWidget *name##_create_viewport() \
{ \
- return new QGLWidget(); \
+ return new QOpenGLWidget(); \
} \
int main(int argc, char **argv) \
{ \
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 a480cb28fe..c719067e2e 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 8e44d9c0ef..66f2c848f2 100644
--- a/src/qtquick1/qtquick1.pro
+++ b/src/qtquick1/qtquick1.pro
@@ -7,7 +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 v8-private
+QT += testlib-private declarative testlib declarative-private core-private gui-private network widgets-private v8-private
DEFINES += QT_NO_URL_CAST_FROM_STRING
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 a19700cb8e..75adbb53ba 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 v8-private declarative-private qtquick1-private
+QT += core-private gui-private declarative-private qtquick1-private widgets-private v8-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 4f1b0e1fa9..4c781887ce 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 v8-private declarative-private
+QT += core-private gui-private declarative-private widgets widgets-private v8-private
QT += opengl-private
diff --git a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp
index 45a32da768..1eecd58278 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 20d154a217..67be35f510 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 v8-private declarative-private qtquick1-private
+QT += core-private gui-private declarative-private qtquick1-private widgets-private v8-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 1fdfb2e83d..c53fd3c7fd 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 ed2512c1f4..cd40ea5f8c 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
@@ -502,7 +465,7 @@ int main(int argc, char ** argv)
displayFileDialog(&options);
#endif
- QWidget *view = 0;
+ QWindow *window = 0;
QDeclarativeEngine *engine = 0;
int exitCode = 0;
@@ -523,54 +486,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