aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-06-13 23:10:03 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2014-06-13 23:10:03 +0200
commit9932617582470d717c97f8161a65133293c185c5 (patch)
tree1df48d67c6e5ca4aa8b7810fc9e717083b4199e3 /src
parent7fde8a8d20da7fa00d974286fa903b3fee76d466 (diff)
parent17ee404f2678684674b9c5c0c523602953146e37 (diff)
Merge remote-tracking branch 'origin/5.3' into dev
Conflicts: src/quickwidgets/qquickwidget.cpp Change-Id: Id4b080aea713df68608847bb82570231e37ce536
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/masm/yarr/YarrJIT.cpp2
-rw-r--r--src/particles/qquickellipseextruder.cpp8
-rw-r--r--src/qml/doc/src/cppintegration/exposecppattributes.qdoc2
-rw-r--r--src/qml/doc/src/javascript/expressions.qdoc85
-rw-r--r--src/qml/doc/src/javascript/hostenvironment.qdoc4
-rw-r--r--src/qml/doc/src/javascript/qmlglobalobject.qdoc7
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp8
-rw-r--r--src/qml/qml/qqmlengine.cpp1
-rw-r--r--src/quick/doc/src/examples.qdoc8
-rw-r--r--src/quick/items/qquickgridview.cpp2
-rw-r--r--src/quick/items/qquickitem.cpp2
-rw-r--r--src/quick/items/qquickitemview.cpp4
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp4
-rw-r--r--src/quick/scenegraph/coreapi/qsgshaderrewriter.cpp4
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp2
-rw-r--r--src/quick/scenegraph/shaders/visualization.vert2
-rw-r--r--src/quick/scenegraph/util/qsgpainternode.cpp5
-rw-r--r--src/quickwidgets/qquickwidget.cpp73
-rw-r--r--src/quickwidgets/qquickwidget_p.h2
19 files changed, 134 insertions, 91 deletions
diff --git a/src/3rdparty/masm/yarr/YarrJIT.cpp b/src/3rdparty/masm/yarr/YarrJIT.cpp
index 783a869b5a..94a72a57c7 100644
--- a/src/3rdparty/masm/yarr/YarrJIT.cpp
+++ b/src/3rdparty/masm/yarr/YarrJIT.cpp
@@ -2561,6 +2561,7 @@ class YarrGenerator : private MacroAssembler {
#if CPU(ARM_TRADITIONAL)
push(ARMRegisters::r8); // scratch register
#endif
+ push(addressTempRegister);
if (compileMode == IncludeSubpatterns)
move(ARMRegisters::r3, output);
#elif CPU(SH4)
@@ -2588,6 +2589,7 @@ class YarrGenerator : private MacroAssembler {
pop(X86Registers::ebx);
pop(X86Registers::ebp);
#elif CPU(ARM)
+ pop(addressTempRegister);
#if CPU(ARM_TRADITIONAL)
pop(ARMRegisters::r8); // scratch register
#endif
diff --git a/src/particles/qquickellipseextruder.cpp b/src/particles/qquickellipseextruder.cpp
index f4374d8013..6016d5966b 100644
--- a/src/particles/qquickellipseextruder.cpp
+++ b/src/particles/qquickellipseextruder.cpp
@@ -82,7 +82,13 @@ QPointF QQuickEllipseExtruder::extrude(const QRectF & r)
bool QQuickEllipseExtruder::contains(const QRectF &bounds, const QPointF &point)
{
- return bounds.contains(point);//TODO: Ellipse
+ if (!bounds.contains(point))
+ return false;
+
+ QPointF relPoint(bounds.center() - point);
+ qreal xa = relPoint.x()/bounds.width();
+ qreal yb = relPoint.y()/bounds.height();
+ return (xa * xa + yb * yb) < 0.25;
}
QT_END_NAMESPACE
diff --git a/src/qml/doc/src/cppintegration/exposecppattributes.qdoc b/src/qml/doc/src/cppintegration/exposecppattributes.qdoc
index f02c3da6af..8f883d9f42 100644
--- a/src/qml/doc/src/cppintegration/exposecppattributes.qdoc
+++ b/src/qml/doc/src/cppintegration/exposecppattributes.qdoc
@@ -106,6 +106,8 @@ public:
QString author() const {
return m_author;
}
+signals:
+ void authorChanged();
private:
QString m_author;
};
diff --git a/src/qml/doc/src/javascript/expressions.qdoc b/src/qml/doc/src/javascript/expressions.qdoc
index 79c11b3ac5..37baa49c52 100644
--- a/src/qml/doc/src/javascript/expressions.qdoc
+++ b/src/qml/doc/src/javascript/expressions.qdoc
@@ -37,44 +37,36 @@ Object} includes a number of helper methods that simplify building UIs and
interacting with the QML environment.
The JavaScript environment provided by QML is stricter than that in a web
-browser. For example, in QML you cannot add, or modify, members of the
+browser. For example, in QML you cannot add to, or modify, members of the
JavaScript global object. In regular JavaScript, it is possible to do this
accidentally by using a variable without declaring it. In QML this will throw
-an exception, so all local variables should be explicitly declared. See
+an exception, so all local variables must be explicitly declared. See
\l{JavaScript Environment Restrictions} for a complete description of the
restrictions on JavaScript code executed from QML.
-There are various ways in which JavaScript expressions may be defined and used
-in QML, including property bindings, signal handlers, custom methods and
-JavaScript imports.
-
-
-
-
-\section1 JavaScript Expressions in QML Objects
-
-QML \l{QML Object Types}{object types} defined in \l{QML Documents}
-{QML documents} can make use of JavaScript expressions which implement program
-logic. There are four ways that JavaScript can be used in a QML document:
+Various parts of \l{QML Documents}{QML documents} can contain JavaScript code:
\list 1
- \li Relationships between \l{Property Attributes}{properties} are described
- using JavaScript expressions in \l{Property Binding}{property bindings}.
- When any of a property's \e dependencies change, the property is
- automatically updated too, according to the specified relationship.
- \li \l{Signal Attributes}{Signal handlers} can be defined
- which are automatically evaluated when the object emits the associated
- signal.
- \li \l{Method Attributes}{Custom methods} can be defined
- in QML files as JavaScript functions.
- \li JavaScript files providing functions and variables can be
- \l{Importing JavaScript Resources in QML}{imported} in a QML
- document.
+ \li The body of \l{Property Binding}{property bindings}. These JavaScript
+ expressions describe relationships between QML object \l{Property Attributes}
+ {properties}. When any of a property's \e dependencies change, the property
+ is automatically updated too, according to the specified relationship.
+ \li The body of \l{Signal Attributes}{Signal handlers}. These JavaScript
+ statements are automatically evaluated whenever a QML object emits the
+ associated signal.
+ \li The definition of \l{Method Attributes}{custom methods}. JavaScript functions
+ that are defined within the body of a QML object become methods of that
+ object.
+ \li Standalone \l{Importing JavaScript Resources in QML}{JavaScript resource
+ (.js) files}. These files are actually separate from QML documents, but
+ they can be imported into QML documents. Functions and variables that are
+ defined within the imported files can be used in property bindings, signal
+ handlers, and custom methods.
\endlist
-\section2 Property Bindings
+\section1 JavaScript in Property Bindings
In the following example, the \l Rectangle's \c color depends on the
\l MouseArea's \c pressed property. This relationship is described using a
@@ -136,7 +128,7 @@ bindings differ from value assignments.
-\section2 Signal Handlers
+\section1 JavaScript in Signal Handlers
QML object types can emit signals in reaction to certain events occurring.
Those signals can be handled by signal handler functions, which can be defined
@@ -188,7 +180,7 @@ to define the implementation of signal handlers in QML with JavaScript.
-\section2 JavaScript Expressions in Functions
+\section1 JavaScript in Standalone Functions
Program logic can also be defined in JavaScript functions. These functions can
be defined inline in QML documents (as custom methods) or externally in
@@ -196,12 +188,12 @@ imported JavaScript files.
-\section3 Custom Methods
+\section2 JavaScript in Custom Object Methods
Custom methods can be defined in QML documents and may be called from signal
handlers, property bindings, or functions in other QML objects. Methods
-defined in this way are often referred to as "inline JavaScript functions" as
-their implementation is included in the QML object type definition
+defined in this way are often referred to as \e{inline JavaScript functions}
+because their implementation is included in the QML object type definition
(QML document), as opposed to an external JavaScript file.
An example of an inline custom method is as follows:
@@ -225,7 +217,7 @@ Item {
}
\endqml
-The factorial function will run whenever the MouseArea detects a clicked signal.
+The factorial function will run whenever the MouseArea detects a \c clicked signal.
Importantly, custom methods defined inline in a QML document are exposed to
other objects, and therefore inline functions on the root object in a QML
@@ -238,7 +230,7 @@ to define custom methods in QML with JavaScript code implementations.
-\section3 Functions in Imported JavaScript Files
+\section2 Functions in Imported JavaScript Files
Non-trivial program logic is best separated into external JavaScript files.
These files can be imported into QML files using an \c import statement, in
@@ -263,7 +255,7 @@ the section about \l{Importing JavaScript Resources in QML}.
-\section3 Connecting Signals to JavaScript Functions
+\section2 Connecting Signals to JavaScript Functions
QML object types which emit signals also provide default signal handlers for
their signals, as described in a previous section. Sometimes, however, a
@@ -292,23 +284,26 @@ See \l{qtqml-syntax-signals.html}
-\section1 Running JavaScript at Startup
+\section1 JavaScript in Application Startup Code
It is occasionally necessary to run some imperative code at application (or
component instance) startup. While it is tempting to just include the startup
script as \e {global code} in an external script file, this can have severe
limitations as the QML environment may not have been fully established. For
example, some objects might not have been created or some
-\l {Property Binding}{property bindings} may not have been run.
-\l {JavaScript Environment Restrictions} covers the exact limitations of global
+\l {Property Binding}{property bindings} may not have been established. See
+\l {JavaScript Environment Restrictions} for the exact limitations of global
script code.
-Every QML object has an \e attached \l Component property that references the
-component within which the object was instantiated. Every \l Component
-will emit a \c completed signal, and thus every object can define an
-implementation for the \c onCompleted() handler which can be used to trigger the
-execution of script code at startup after the QML environment has been
-completely established. For example:
+A QML object will emit the \c{Component.completed} \l{Signal and Handler Event
+System#Attached Signal Handlers}{attached signal} when its instantiation is
+complete. JavaScript code in the corresponding \c{Component.onCompleted} handler
+runs after the object is instantiated. Thus, the best place to write application
+startup code is in the \c{Component.onCompleted} handler of the top-level level
+object, because this object emits \c{Component.completed} when the QML environment
+is fully established.
+
+For example:
\qml
import QtQuick 2.0
@@ -346,7 +341,7 @@ signal just before being destroyed.
\section1 Scarce Resources in JavaScript
As described in the documentation for \l{QML Basic Types}, a \c var type
-property may hold a "scarce resource" (image or pixmap). There are several
+property may hold a \e{scarce resource} (image or pixmap). There are several
important semantics of scarce resources which should be noted:
\list
diff --git a/src/qml/doc/src/javascript/hostenvironment.qdoc b/src/qml/doc/src/javascript/hostenvironment.qdoc
index a63ef617c0..bd3ff63bf8 100644
--- a/src/qml/doc/src/javascript/hostenvironment.qdoc
+++ b/src/qml/doc/src/javascript/hostenvironment.qdoc
@@ -135,8 +135,8 @@ var initialPosition = { rootObject.x, rootObject.y }
\endcode
This restriction exists as the QML environment is not yet fully established.
-To run code after the environment setup has completed, refer to
-\l {Running JavaScript at Startup}.
+To run code after the environment setup has completed, see
+\l {JavaScript in Application Startup Code}.
\li The value of \c this is currently undefined in QML in the majority of contexts.
diff --git a/src/qml/doc/src/javascript/qmlglobalobject.qdoc b/src/qml/doc/src/javascript/qmlglobalobject.qdoc
index 4329bbb351..e89e49822e 100644
--- a/src/qml/doc/src/javascript/qmlglobalobject.qdoc
+++ b/src/qml/doc/src/javascript/qmlglobalobject.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
@@ -122,7 +122,8 @@ browser. The following objects and properties are supported by the QML implemen
\endtable
-The \l{qml/xmlhttprequest}{XMLHttpRequest example} demonstrates how to
-use the XMLHttpRequest object to make a request and read the response headers.
+The \l{Qt Quick Examples - XMLHttpRequest}{XMLHttpRequest example} demonstrates
+how to use the XMLHttpRequest object to make a request and read the response
+headers.
*/
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index b61be913a6..a02424a3dc 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -1407,7 +1407,7 @@ static QV4::ReturnedValue CallOverloaded(QObject *object, const QQmlPropertyData
{
int argumentCount = callArgs->argc;
- const QQmlPropertyData *best = 0;
+ QQmlPropertyData best;
int bestParameterScore = INT_MAX;
int bestMatchScore = INT_MAX;
@@ -1453,7 +1453,7 @@ static QV4::ReturnedValue CallOverloaded(QObject *object, const QQmlPropertyData
methodMatchScore += MatchScore((v = callArgs->args[ii]), methodArgTypes[ii]);
if (bestParameterScore > methodParameterScore || bestMatchScore > methodMatchScore) {
- best = attempt;
+ best = *attempt;
bestParameterScore = methodParameterScore;
bestMatchScore = methodMatchScore;
}
@@ -1463,10 +1463,10 @@ static QV4::ReturnedValue CallOverloaded(QObject *object, const QQmlPropertyData
} while((attempt = RelatedMethod(object, attempt, dummy)) != 0);
- if (best) {
+ if (best.isValid()) {
if (valueTypeObject)
valueTypeObject->setValue(valueTypeValue);
- return CallPrecise(object, *best, engine, callArgs);
+ return CallPrecise(object, best, engine, callArgs);
} else {
QString error = QLatin1String("Unable to determine callable overload. Candidates are:");
const QQmlPropertyData *candidate = &data;
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index f78cdbb970..61246b92d8 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -809,6 +809,7 @@ void QQmlEnginePrivate::init()
qRegisterMetaType<QList<QObject*> >();
qRegisterMetaType<QList<int> >();
qRegisterMetaType<QQmlV4Handle>();
+ qRegisterMetaType<QQmlBinding*>();
v8engine()->setEngine(q);
diff --git a/src/quick/doc/src/examples.qdoc b/src/quick/doc/src/examples.qdoc
index 22c9786fda..3669a31de0 100644
--- a/src/quick/doc/src/examples.qdoc
+++ b/src/quick/doc/src/examples.qdoc
@@ -109,9 +109,8 @@ steps such as use cases and introductory material. For more information about Qt
\section2 Extending QML
The following tutorials show how a QML-based application can be combined with
-C++ code using the \l{Qt QML} module. The \l{Running the Examples} section
-has more information about opening the examples from within Qt Creator. For
-information about extending QML, visit the \l{Integrating QML and C++} page.
+C++ code using the \l{Qt QML} module. For information about extending QML, visit
+the \l{Integrating QML and C++} page.
\annotatedlist{qmlextendingexamples}
@@ -119,8 +118,7 @@ information about extending QML, visit the \l{Integrating QML and C++} page.
Examples are small applications which show how to implement various Qt Quick
features. The examples run on various platforms and are opened from within Qt
-Creator. The \l{Running the Examples} section has more information about opening
-the examples from within Qt Creator.
+Creator.
\div {class="landingicons"}
\div {class="icons1of3"}
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index 2c03903f36..d5ca3a128e 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -640,8 +640,8 @@ void QQuickGridViewPrivate::layoutVisibleItems(int fromModelIndex)
if (colPos != col * colSize()) {
colPos = col * colSize();
firstItem->setPosition(colPos, rowPos);
- firstItem->setVisible(firstItem->rowPos() + rowSize() >= from && firstItem->rowPos() <= to);
}
+ firstItem->setVisible(firstItem->rowPos() + rowSize() >= from && firstItem->rowPos() <= to);
for (int i = 1; i < visibleItems.count(); ++i) {
FxGridItemSG *item = static_cast<FxGridItemSG*>(visibleItems.at(i));
if (++col >= columns) {
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index da8ca9fd5d..73047add5d 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -1334,6 +1334,7 @@ void QQuickKeysAttached::keyPressed(QKeyEvent *event, bool post)
for (int ii = 0; ii < d->targets.count(); ++ii) {
QQuickItem *i = d->targets.at(ii);
if (i && i->isVisible()) {
+ event->accept();
QCoreApplication::sendEvent(i, event);
if (event->isAccepted()) {
d->inPress = false;
@@ -1376,6 +1377,7 @@ void QQuickKeysAttached::keyReleased(QKeyEvent *event, bool post)
for (int ii = 0; ii < d->targets.count(); ++ii) {
QQuickItem *i = d->targets.at(ii);
if (i && i->isVisible()) {
+ event->accept();
QCoreApplication::sendEvent(i, event);
if (event->isAccepted()) {
d->inRelease = false;
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index 87e6728f86..94abbd0954 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -481,7 +481,7 @@ void QQuickItemView::setDisplayMarginBeginning(int margin)
if (d->displayMarginBeginning != margin) {
d->displayMarginBeginning = margin;
if (isComponentComplete()) {
- d->refillOrLayout();
+ d->forceLayoutPolish();
}
emit displayMarginBeginningChanged();
}
@@ -499,7 +499,7 @@ void QQuickItemView::setDisplayMarginEnd(int margin)
if (d->displayMarginEnd != margin) {
d->displayMarginEnd = margin;
if (isComponentComplete()) {
- d->refillOrLayout();
+ d->forceLayoutPolish();
}
emit displayMarginEndChanged();
}
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index d6e2487a89..b3342be5ce 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -418,7 +418,7 @@ void Updater::visitTransformNode(Node *n)
// The only change in this subtree is ourselves and we are a batch root, so
// only update subroots and return, saving tons of child-processing (flickable-panning)
- if (!n->becameBatchRoot && m_added == 0 && m_force_update == 0 && dirty && (n->dirtyState & ~QSGNode::DirtyMatrix) == 0) {
+ if (!n->becameBatchRoot && m_added == 0 && m_force_update == 0 && m_opacityChange == 0 && dirty && (n->dirtyState & ~QSGNode::DirtyMatrix) == 0) {
BatchRootInfo *info = renderer->batchRootInfo(n);
for (QSet<Node *>::const_iterator it = info->subRoots.constBegin();
it != info->subRoots.constEnd(); ++it) {
@@ -2020,6 +2020,8 @@ void Renderer::renderMergedBatch(const Batch *batch)
<< " root:" << batch->root;
if (batch->drawSets.size() > 1)
debug << "sets:" << batch->drawSets.size();
+ if (!batch->isOpaque)
+ debug << "opacity:" << e->node->inheritedOpacity();
batch->uploadedThisFrame = false;
}
diff --git a/src/quick/scenegraph/coreapi/qsgshaderrewriter.cpp b/src/quick/scenegraph/coreapi/qsgshaderrewriter.cpp
index 9ff0971774..bffdf40bc1 100644
--- a/src/quick/scenegraph/coreapi/qsgshaderrewriter.cpp
+++ b/src/quick/scenegraph/coreapi/qsgshaderrewriter.cpp
@@ -52,7 +52,6 @@ namespace QSGShaderRewriter {
struct Tokenizer {
enum Token {
- Token_Invalid,
Token_Void,
Token_OpenBrace,
Token_CloseBrace,
@@ -75,7 +74,6 @@ struct Tokenizer {
};
const char *Tokenizer::NAMES[] = {
- "Invalid",
"Void",
"OpenBrace",
"CloseBrace",
@@ -167,7 +165,7 @@ Tokenizer::Token Tokenizer::next()
}
}
- return Token_Invalid;
+ return Token_EOF;
}
}
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index 1ba54ea19e..e4d61eb0ae 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -1199,6 +1199,8 @@ bool QSGThreadedRenderLoop::event(QEvent *e)
Window *w = windowForTimer(te->timerId());
if (w)
polishAndSync(w);
+ else
+ killTimer(te->timerId());
}
return true;
}
diff --git a/src/quick/scenegraph/shaders/visualization.vert b/src/quick/scenegraph/shaders/visualization.vert
index f1892b71da..591eb12ed6 100644
--- a/src/quick/scenegraph/shaders/visualization.vert
+++ b/src/quick/scenegraph/shaders/visualization.vert
@@ -3,7 +3,7 @@ uniform highp mat4 matrix;
uniform highp mat4 rotation;
// w -> apply 3d rotation and projection
-uniform lowp vec4 tweak;
+uniform mediump vec4 tweak;
varying mediump vec2 pos;
diff --git a/src/quick/scenegraph/util/qsgpainternode.cpp b/src/quick/scenegraph/util/qsgpainternode.cpp
index b454f666ac..8ccb9d2ffb 100644
--- a/src/quick/scenegraph/util/qsgpainternode.cpp
+++ b/src/quick/scenegraph/util/qsgpainternode.cpp
@@ -96,7 +96,6 @@ QSGPainterNode::QSGPainterNode(QQuickPaintedItem *item)
, m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
, m_texture(0)
, m_gl_device(0)
- , m_size(1, 1)
, m_dirtyContents(false)
, m_opaquePainting(false)
, m_linear_filtering(false)
@@ -116,6 +115,10 @@ QSGPainterNode::QSGPainterNode(QQuickPaintedItem *item)
setMaterial(&m_materialO);
setOpaqueMaterial(&m_material);
setGeometry(&m_geometry);
+
+#ifdef QSG_RUNTIME_DESCRIPTION
+ qsgnode_set_description(this, QString::fromLatin1("QQuickPaintedItem(%1):%2").arg(QString::fromLatin1(item->metaObject()->className())).arg(item->objectName()));
+#endif
}
QSGPainterNode::~QSGPainterNode()
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index a8a33c07c8..f91d512ab0 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -89,7 +89,6 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
offscreenWindow = renderControl->createOffscreenWindow();
offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
// Do not call create() on offscreenWindow.
- createOffscreenSurface();
if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface))
setRenderToTexture();
@@ -144,6 +143,7 @@ QQuickWidgetPrivate::QQuickWidgetPrivate()
, offscreenSurface(0)
, renderControl(0)
, fbo(0)
+ , resolvedFbo(0)
, context(0)
, resizeMode(QQuickWidget::SizeViewToRootObject)
, initialSize(0,0)
@@ -164,21 +164,12 @@ QQuickWidgetPrivate::~QQuickWidgetPrivate()
Q_ASSERT(!context || (QOpenGLContext::currentContext() == context && context->surface() == offscreenSurface));
delete offscreenWindow;
delete renderControl;
+ delete resolvedFbo;
delete fbo;
- delete offscreenSurface;
destroyContext();
}
-void QQuickWidgetPrivate::createOffscreenSurface()
-{
- delete offscreenSurface;
- offscreenSurface = 0;
- offscreenSurface = new QOffscreenSurface;
- offscreenSurface->setFormat(offscreenWindow->requestedFormat());
- offscreenSurface->create();
-}
-
void QQuickWidgetPrivate::execute()
{
Q_Q(QQuickWidget);
@@ -237,6 +228,12 @@ void QQuickWidgetPrivate::renderSceneGraph()
renderControl->sync();
renderControl->render();
context->functions()->glFlush();
+
+ if (resolvedFbo) {
+ QRect rect(QPoint(0, 0), fbo->size());
+ QOpenGLFramebufferObject::blitFramebuffer(resolvedFbo, rect, fbo, rect);
+ }
+
context->doneCurrent();
q->update();
}
@@ -313,6 +310,7 @@ QQuickWidget::QQuickWidget(QWidget *parent)
: QWidget(*(new QQuickWidgetPrivate), parent, 0)
{
setMouseTracking(true);
+ setFocusPolicy(Qt::StrongFocus);
d_func()->init();
}
@@ -325,6 +323,7 @@ QQuickWidget::QQuickWidget(const QUrl &source, QWidget *parent)
: QWidget(*(new QQuickWidgetPrivate), parent, 0)
{
setMouseTracking(true);
+ setFocusPolicy(Qt::StrongFocus);
d_func()->init();
setSource(source);
}
@@ -342,6 +341,7 @@ QQuickWidget::QQuickWidget(QQmlEngine* engine, QWidget *parent)
: QWidget(*(new QQuickWidgetPrivate), parent, 0)
{
setMouseTracking(true);
+ setFocusPolicy(Qt::StrongFocus);
Q_ASSERT(engine);
d_func()->init(engine);
}
@@ -641,6 +641,13 @@ void QQuickWidgetPrivate::createContext()
return;
}
+ offscreenSurface = new QOffscreenSurface;
+ // Pass the context's format(), which, now that the underlying platform context is created,
+ // contains a QSurfaceFormat representing the _actual_ format of the underlying
+ // configuration. This is essential to get a surface that is compatible with the context.
+ offscreenSurface->setFormat(context->format());
+ offscreenSurface->create();
+
if (context->makeCurrent(offscreenSurface))
renderControl->initialize(context);
else
@@ -649,6 +656,8 @@ void QQuickWidgetPrivate::createContext()
void QQuickWidgetPrivate::destroyContext()
{
+ delete offscreenSurface;
+ offscreenSurface = 0;
delete context;
context = 0;
}
@@ -671,11 +680,23 @@ void QQuickWidget::createFramebufferObject()
context->makeCurrent(d->offscreenSurface);
+ int samples = d->offscreenWindow->requestedFormat().samples();
+ if (!QOpenGLExtensions(context).hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample))
+ samples = 0;
+
+ QOpenGLFramebufferObjectFormat format;
+ format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
+ format.setSamples(samples);
+
+ QSize fboSize = size() * window()->devicePixelRatio();
+
delete d->fbo;
- d->fbo = new QOpenGLFramebufferObject(size() * window()->devicePixelRatio());
- d->fbo->setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
+ d->fbo = new QOpenGLFramebufferObject(fboSize, format);
d->offscreenWindow->setRenderTarget(d->fbo);
+ if (samples > 0)
+ d->resolvedFbo = new QOpenGLFramebufferObject(fboSize);
+
// Sanity check: The window must not have an underlying platform window.
// Having one would mean create() was called and platforms that only support
// a single native window were in trouble.
@@ -685,9 +706,10 @@ void QQuickWidget::createFramebufferObject()
void QQuickWidget::destroyFramebufferObject()
{
Q_D(QQuickWidget);
- if (d->fbo)
- delete d->fbo;
+ delete d->fbo;
d->fbo = 0;
+ delete d->resolvedFbo;
+ d->resolvedFbo = 0;
}
QQuickWidget::ResizeMode QQuickWidget::resizeMode() const
@@ -766,7 +788,14 @@ void QQuickWidgetPrivate::setRootObject(QObject *obj)
GLuint QQuickWidgetPrivate::textureId() const
{
- return fbo ? fbo->texture() : 0;
+ Q_Q(const QQuickWidget);
+ if (!q->isWindow() && q->internalWinId()) {
+ qWarning() << "QQuickWidget cannot be used as a native child widget."
+ << "Consider setting Qt::AA_DontCreateNativeWidgetSiblings";
+ return 0;
+ }
+ return resolvedFbo ? resolvedFbo->texture()
+ : (fbo ? fbo->texture() : 0);
}
/*!
@@ -980,13 +1009,18 @@ bool QQuickWidget::event(QEvent *e)
switch (e->type()) {
#ifndef QT_NO_DRAGANDDROP
case QEvent::Drop:
- case QEvent::DragEnter:
case QEvent::DragMove:
case QEvent::DragLeave:
// Drag/drop events only have local pos, so no need to map,
// but QQuickWindow::event() does not return true
d->offscreenWindow->event(e);
return e->isAccepted();
+ case QEvent::DragEnter:
+ // Don't reject drag events for the entire widget when one
+ // item rejects the drag enter
+ d->offscreenWindow->event(e);
+ e->accept();
+ return true;
#endif
case QEvent::TouchBegin:
case QEvent::TouchEnd:
@@ -1038,10 +1072,7 @@ void QQuickWidget::setFormat(const QSurfaceFormat &format)
newFormat.setDepthBufferSize(qMax(newFormat.depthBufferSize(), currentFormat.depthBufferSize()));
newFormat.setStencilBufferSize(qMax(newFormat.stencilBufferSize(), currentFormat.stencilBufferSize()));
newFormat.setAlphaBufferSize(qMax(newFormat.alphaBufferSize(), currentFormat.alphaBufferSize()));
- if (currentFormat != newFormat) {
- d->offscreenWindow->setFormat(newFormat);
- d->createOffscreenSurface();
- }
+ d->offscreenWindow->setFormat(newFormat);
}
/*!
diff --git a/src/quickwidgets/qquickwidget_p.h b/src/quickwidgets/qquickwidget_p.h
index 8efe32b3ce..356c34e7f5 100644
--- a/src/quickwidgets/qquickwidget_p.h
+++ b/src/quickwidgets/qquickwidget_p.h
@@ -87,7 +87,6 @@ public:
void createContext();
void destroyContext();
void handleContextCreationFailure(const QSurfaceFormat &format, bool isEs);
- void createOffscreenSurface();
GLuint textureId() const Q_DECL_OVERRIDE;
@@ -108,6 +107,7 @@ public:
QOffscreenSurface *offscreenSurface;
QQuickRenderControl *renderControl;
QOpenGLFramebufferObject *fbo;
+ QOpenGLFramebufferObject *resolvedFbo;
QOpenGLContext *context;
QQuickWidget::ResizeMode resizeMode;