Commit 8b21fd90 authored by Qt Forward Merge Bot's avatar Qt Forward Merge Bot
Browse files

Merge remote-tracking branch 'origin/5.15' into dev

Change-Id: I0a9fdfe15c620b8a0d58137ca22bab5e246aab2a
parents b7593bcb b0bbbfbe
......@@ -125,6 +125,11 @@ QAbstractClipAnimator::QAbstractClipAnimator(QAbstractClipAnimatorPrivate &dd, Q
QAbstractClipAnimator::~QAbstractClipAnimator()
{
}
/*!
\qmlproperty bool Qt3DAnimation::AbstractClipAnimator::running
This property holds a boolean indicating whether the animation is currently running.
*/
/*!
\property Qt3DAnimation::QAbstractClipAnimator::running
......@@ -141,6 +146,13 @@ bool QAbstractClipAnimator::isRunning() const
return d->m_running;
}
/*!
\qmlproperty ChannelMapper Qt3DAnimation::AbstractClipAnimator::channelMapper
This property holds the ChannelMapper that controls how the channels in
the animation clip map onto the properties of the target objects.
*/
/*!
\property Qt3DAnimation::QAbstractClipAnimator::channelMapper
......@@ -198,6 +210,12 @@ int QAbstractClipAnimator::loopCount() const
Q_D(const QAbstractClipAnimator);
return d->m_loops;
}
/*!
\qmlproperty Clock Qt3DAnimation::AbstractClipAnimator::clock
The clock controls the speed with which an animation is played.
*/
/*!
\property Qt3DAnimation::QAbstractClipAnimator::clock
......@@ -208,7 +226,11 @@ QClock *QAbstractClipAnimator::clock() const
Q_D(const QAbstractClipAnimator);
return d->m_clock;
}
/*!
\qmlproperty real Qt3DAnimation::AbstractClipAnimator::normalizedTime
This property holds the clips normalized time.
*/
/*!
\property Qt3DAnimation::QAbstractClipAnimator::normalizedTime
......
......@@ -56,6 +56,7 @@ QBlendedClipAnimatorPrivate::QBlendedClipAnimatorPrivate()
\qmltype BlendedClipAnimator
\instantiates Qt3DAnimation::QBlendedClipAnimator
\inqmlmodule Qt3D.Animation
\inherits AbstractClipAnimator
\since 5.9
\brief BlendedClipAnimator is a component providing animation playback capabilities of a tree
......
......@@ -36,6 +36,7 @@
#include "qchannelmapper.h"
#include "qchannelmapper_p.h"
#include <Qt3DCore/qscenechange.h>
#include <Qt3DAnimation/qchannelmapping.h>
QT_BEGIN_NAMESPACE
......@@ -85,7 +86,7 @@ void QChannelMapper::addMapping(QAbstractChannelMapping *mapping)
if (!mapping->parent())
mapping->setParent(this);
d->update();
d->updateNode(mapping, "mappings", Qt3DCore::PropertyValueAdded);
}
}
......@@ -94,7 +95,7 @@ void QChannelMapper::removeMapping(QAbstractChannelMapping *mapping)
Q_ASSERT(mapping);
Q_D(QChannelMapper);
d->m_mappings.removeOne(mapping);
d->update();
d->updateNode(mapping, "mappings", Qt3DCore::PropertyValueRemoved);
// Remove bookkeeping connection
d->unregisterDestructionHelper(mapping);
}
......
......@@ -66,6 +66,7 @@ bool QClipAnimatorPrivate::canPlay() const
\qmltype ClipAnimator
\instantiates Qt3DAnimation::QClipAnimator
\inqmlmodule Qt3D.Animation
\inherits AbstractClipAnimator
\since 5.9
\brief ClipAnimator is a component providing simple animation playback capabilities.
......
......@@ -81,6 +81,7 @@ protected:
template<class Frontend, bool supportsSyncing>
void registerBackendType(const QBackendNodeMapperPtr &functor);
void registerBackendType(const QMetaObject &obj, const QBackendNodeMapperPtr &functor);
void registerBackendType(const QMetaObject &obj, const QBackendNodeMapperPtr &functor, bool supportsSyncing);
template<class Frontend>
void unregisterBackendType();
void unregisterBackendType(const QMetaObject &);
......@@ -88,7 +89,6 @@ protected:
private:
void syncDirtyFrontEndNodes(const QVector<QNode *> &nodes);
void syncDirtyFrontEndSubNodes(const QVector<NodeRelationshipChange> &nodes);
void registerBackendType(const QMetaObject &obj, const QBackendNodeMapperPtr &functor, bool supportsSyncing);
virtual QVariant executeCommand(const QStringList &args);
......
......@@ -165,7 +165,7 @@ void QAbstractPhysicalDevice::addAxisSetting(QAxisSetting *axisSetting)
{
Q_D(QAbstractPhysicalDevice);
if (axisSetting && !d->m_axisSettings.contains(axisSetting)) {
d->update();
d->updateNode(axisSetting, "axisSettings", Qt3DCore::PropertyValueAdded);
d->m_axisSettings.push_back(axisSetting);
}
}
......@@ -177,7 +177,7 @@ void QAbstractPhysicalDevice::removeAxisSetting(QAxisSetting *axisSetting)
{
Q_D(QAbstractPhysicalDevice);
if (axisSetting && d->m_axisSettings.contains(axisSetting)) {
d->update();
d->updateNode(axisSetting, "axisSettings", Qt3DCore::PropertyValueRemoved);
d->m_axisSettings.removeOne(axisSetting);
}
}
......
......@@ -119,7 +119,7 @@ void QAction::addInput(QAbstractActionInput *input)
// Ensures proper bookkeeping
d->registerDestructionHelper(input, &QAction::removeInput, d->m_inputs);
d->update();
d->updateNode(input, "inputs", Qt3DCore::PropertyValueAdded);
}
}
......@@ -131,7 +131,7 @@ void QAction::removeInput(QAbstractActionInput *input)
Q_D(QAction);
if (d->m_inputs.contains(input)) {
d->update();
d->updateNode(input, "inputs", Qt3DCore::PropertyValueRemoved);
d->m_inputs.removeOne(input);
......
......@@ -115,7 +115,7 @@ void QAxis::addInput(QAbstractAxisInput *input)
// Ensures proper bookkeeping
d->registerDestructionHelper(input, &QAxis::removeInput, d->m_inputs);
d->update();
d->updateNode(input, "input", Qt3DCore::PropertyValueAdded);
}
}
......@@ -137,7 +137,7 @@ void QAxis::removeInput(QAbstractAxisInput *input)
Q_D(QAxis);
if (d->m_inputs.contains(input)) {
d->update();
d->updateNode(input, "input", Qt3DCore::PropertyValueRemoved);
d->m_inputs.removeOne(input);
......
......@@ -154,7 +154,7 @@ void QInputChord::addChord(QAbstractActionInput *input)
if (!input->parent())
input->setParent(this);
d->update();
d->updateNode(input, "input", Qt3DCore::PropertyValueAdded);
}
}
......@@ -167,7 +167,7 @@ void QInputChord::removeChord(QAbstractActionInput *input)
{
Q_D(QInputChord);
if (d->m_chords.contains(input)) {
d->update();
d->updateNode(input, "input", Qt3DCore::PropertyValueRemoved);
d->m_chords.removeOne(input);
......
......@@ -207,7 +207,7 @@ void QInputSequence::addSequence(QAbstractActionInput *input)
if (!input->parent())
input->setParent(this);
d->update();
d->updateNode(input, "input", Qt3DCore::PropertyValueAdded);
}
}
......@@ -220,7 +220,7 @@ void QInputSequence::removeSequence(QAbstractActionInput *input)
{
Q_D(QInputSequence);
if (d->m_sequences.contains(input)) {
d->update();
d->updateNode(input, "input", Qt3DCore::PropertyValueRemoved);
d->m_sequences.removeOne(input);
......
......@@ -173,7 +173,7 @@ void QLogicalDevice::addAction(QAction *action)
// Ensures proper bookkeeping
d->registerDestructionHelper(action, &QLogicalDevice::removeAction, d->m_actions);
d->update();
d->updateNode(action, "action", Qt3DCore::PropertyValueAdded);
}
}
......@@ -184,7 +184,7 @@ void QLogicalDevice::removeAction(QAction *action)
{
Q_D(QLogicalDevice);
if (d->m_actions.contains(action)) {
d->update();
d->updateNode(action, "action", Qt3DCore::PropertyValueRemoved);
d->m_actions.removeOne(action);
......@@ -224,7 +224,7 @@ void QLogicalDevice::addAxis(QAxis *axis)
// Ensures proper bookkeeping
d->registerDestructionHelper(axis, &QLogicalDevice::removeAxis, d->m_axes);
d->update();
d->updateNode(axis, "axis", Qt3DCore::PropertyValueAdded);
}
}
......@@ -235,7 +235,7 @@ void QLogicalDevice::removeAxis(QAxis *axis)
{
Q_D(QLogicalDevice);
if (d->m_axes.contains(axis)) {
d->update();
d->updateNode(axis, "axis", Qt3DCore::PropertyValueRemoved);
d->m_axes.removeOne(axis);
......
......@@ -96,7 +96,7 @@ bool Scene2DPlugin::registerBackendTypes(QRenderAspect *aspect,
{
registerBackendType(aspect, Qt3DRender::Quick::QScene2D::staticMetaObject,
QSharedPointer<Scene2DBackendNodeMapper<Render::Quick::Scene2D> >
::create(renderer, m_scene2dNodeManager));
::create(renderer, m_scene2dNodeManager), true);
return true;
}
bool Scene2DPlugin::unregisterBackendTypes(QRenderAspect *aspect)
......
......@@ -2,7 +2,7 @@ TEMPLATE = subdirs
# QNX is not supported, and Linux GCC 4.9 on ARM chokes on the assimp
# sources (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66964).
QT_FOR_CONFIG += 3dcore-private
qtConfig(assimp):if(qtConfig(system-assimp)|android-clang|gcc:greaterThan(QT_GCC_MAJOR_VERSION, 4)): {
!ios:!tvos:!qcc:qtConfig(assimp):if(qtConfig(system-assimp)|android-clang|clang|win32-msvc)|if(gcc:greaterThan(QT_GCC_MAJOR_VERSION, 4)) {
SUBDIRS += assimp
}
SUBDIRS += gltf
......
......@@ -500,10 +500,16 @@ void Scene3DItem::onBeforeSync()
// make Qt3D enter a locked state
m_renderer->allowRender();
// Request refresh for next frame
// Note: it's too early to request an update at this point as
// beforeSync() triggered by afterAnimating is considered
// to be as being part of the current frame update
}
void Scene3DItem::requestUpdate()
{
// When using the FBO mode, only the QQuickItem needs to be updated
// When using the Underlay mode, the whole windows needs updating
const bool usesFBO = m_compositingMode == FBO;
if (usesFBO) {
QQuickItem::update();
for (Scene3DView *view : m_views)
......@@ -529,6 +535,7 @@ void Scene3DItem::setWindowSurface(QObject *rootObject)
m_dummySurface = new QOffscreenSurface;
m_dummySurface->setParent(qGuiApp); // parent to something suitably long-living
m_dummySurface->setFormat(rw->format());
m_dummySurface->setScreen(rw->screen());
m_dummySurface->create();
surfaceSelector->setSurface(m_dummySurface);
} else {
......@@ -616,6 +623,9 @@ QSGNode *Scene3DItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNode
// If the render aspect wasn't created yet, do so now
if (m_renderAspect == nullptr) {
m_renderAspect = new QRenderAspect(QRenderAspect::Synchronous);
auto *rw = QQuickRenderControl::renderWindowFor(window());
static_cast<Qt3DRender::QRenderAspectPrivate *>(Qt3DRender::QRenderAspectPrivate::get(m_renderAspect))->m_screen =
(rw ? rw->screen() : window()->screen());
m_aspectEngine->registerAspect(m_renderAspect);
// Before Synchronizing is in the SG Thread, we want beforeSync to be triggered
......@@ -625,8 +635,6 @@ QSGNode *Scene3DItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNode
auto renderAspectPriv = static_cast<QRenderAspectPrivate*>(QRenderAspectPrivate::get(m_renderAspect));
QObject::connect(renderAspectPriv->m_aspectManager->changeArbiter(), &Qt3DCore::QChangeArbiter::receivedChange,
this, [this] { m_dirty = true; }, Qt::DirectConnection);
QObject::connect(renderAspectPriv->m_aspectManager->changeArbiter(), &Qt3DCore::QChangeArbiter::receivedChange,
this, &QQuickItem::update, Qt::AutoConnection);
}
if (m_renderer == nullptr) {
......@@ -668,6 +676,12 @@ QSGNode *Scene3DItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNode
window()->setClearBeforeRendering(false);
}
// Request update for next frame so that we can check whether we need to
// render again or not
static int requestUpdateMethodIdx = Scene3DItem::staticMetaObject.indexOfMethod("requestUpdate()");
static QMetaMethod requestUpdateMethod =Scene3DItem::staticMetaObject.method(requestUpdateMethodIdx);
requestUpdateMethod.invoke(this, Qt::QueuedConnection);
return fboNode;
}
......
......@@ -129,6 +129,7 @@ Q_SIGNALS:
private Q_SLOTS:
void applyRootEntityChange();
void onBeforeSync();
void requestUpdate();
private:
QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *nodeData) override;
......
......@@ -419,6 +419,10 @@ void Scene3DRenderer::render()
// Restore QtQuick FBO
QOpenGLFramebufferObject::bindDefault();
// Only show the node once Qt3D has rendered to it
// Avoids showing garbage on the first frame
m_node->show();
}
// Reset the state used by the Qt Quick scenegraph to avoid any
......
......@@ -60,6 +60,7 @@ namespace Qt3DRender {
Scene3DSGMaterial::Scene3DSGMaterial()
: QSGMaterial()
, m_texture(nullptr)
, m_visible(false)
{
}
......
......@@ -75,8 +75,12 @@ public:
QSGMaterialType *type() const final { return &Scene3DSGMaterialShader::type; }
QSGMaterialShader *createShader() const final { return new Scene3DSGMaterialShader(); }
void show() { m_visible = true; }
bool visible() const { return m_visible; }
private:
QSGTexture *m_texture;
bool m_visible;
};
} // namespace Qt3DRender
......
......@@ -118,21 +118,25 @@ const char *Scene3DSGMaterialShader::fragmentShader() const
if (ctx->format().version() >= qMakePair(3, 2) && ctx->format().profile() == QSurfaceFormat::CoreProfile) {
return ""
"#version 150 core \n"
"uniform bool visible; \n"
"uniform sampler2D source; \n"
"uniform float qt_Opacity; \n"
"in vec2 qt_TexCoord; \n"
"out vec4 fragColor; \n"
"void main() { \n"
" vec4 p = texture(source, qt_TexCoord); \n"
" if (!visible) discard; \n"
" vec4 p = texture(source, qt_TexCoord); \n"
" float a = qt_Opacity * p.a; \n"
" fragColor = vec4(p.rgb * a, a); \n"
"}";
} else {
return ""
"uniform bool visible; \n"
"uniform highp sampler2D source; \n"
"uniform highp float qt_Opacity; \n"
"varying highp vec2 qt_TexCoord; \n"
"void main() { \n"
" if (!visible) discard; \n"
" highp vec4 p = texture2D(source, qt_TexCoord); \n"
" highp float a = qt_Opacity * p.a; \n"
" gl_FragColor = vec4(p.rgb * a, a); \n"
......@@ -144,6 +148,7 @@ void Scene3DSGMaterialShader::initialize()
{
m_matrixId = program()->uniformLocation("qt_Matrix");
m_opacityId = program()->uniformLocation("qt_Opacity");
m_visibleId = program()->uniformLocation("visible");
}
void Scene3DSGMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
......@@ -172,6 +177,9 @@ void Scene3DSGMaterialShader::updateState(const RenderState &state, QSGMaterial
t->updateBindOptions();
}
if (oldTx == nullptr || oldTx->visible() != tx->visible())
program()->setUniformValue(m_visibleId, tx->visible());
if (state.isMatrixDirty())
program()->setUniformValue(m_matrixId, state.combinedMatrix());
......
......@@ -74,6 +74,7 @@ protected:
private:
int m_matrixId;
int m_opacityId;
int m_visibleId;
};
} // namespace Qt3DRender
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment