Commit d6c1f38b authored by Marco Bubke's avatar Marco Bubke

QmlDesigner.NodeInstances: Add render only puppet

Improves the interaction responsibility.
parent a6dd51c7
......@@ -3,6 +3,7 @@ INCLUDEPATH += $$PWD/../include
HEADERS += $$PWD/behaviornodeinstance.h
HEADERS += $$PWD/rendernodeinstanceserver.h
HEADERS += $$PWD/synchronizecommand.h
HEADERS += $$PWD/addimportcontainer.h
HEADERS += $$PWD/previewnodeinstanceserver.h
......@@ -50,6 +51,7 @@ HEADERS += $$PWD/../include/nodeinstanceserverinterface.h
SOURCES += $$PWD/behaviornodeinstance.cpp
SOURCES += $$PWD/rendernodeinstanceserver.cpp
SOURCES += $$PWD/synchronizecommand.cpp
SOURCES += $$PWD/addimportcontainer.cpp
SOURCES += $$PWD/previewnodeinstanceserver.cpp
......
......@@ -7,6 +7,7 @@
#include "nodeinstanceserver.h"
#include "previewnodeinstanceserver.h"
#include "rendernodeinstanceserver.h"
#include "propertyabstractcontainer.h"
#include "propertyvaluecontainer.h"
......@@ -47,6 +48,8 @@ NodeInstanceClientProxy::NodeInstanceClientProxy(QObject *parent)
m_nodeInstanceServer = new PreviewNodeInstanceServer(this);
} else if (QCoreApplication::arguments().at(2) == QLatin1String("editormode")) {
m_nodeInstanceServer = new NodeInstanceServer(this);
} else if (QCoreApplication::arguments().at(2) == QLatin1String("rendermode")) {
m_nodeInstanceServer = new RenderNodeInstanceServer(this);
}
m_socket = new QLocalSocket(this);
......
......@@ -383,6 +383,21 @@ QDeclarativeEngine *NodeInstanceServer::engine() const
return 0;
}
QDeclarativeView *NodeInstanceServer::delcarativeView() const
{
return m_declarativeView.data();
}
const QVector<NodeInstanceServer::InstancePropertyPair> NodeInstanceServer::changedPropertyList() const
{
return m_changedPropertyList;
}
void NodeInstanceServer::clearChangedPropertyList()
{
m_changedPropertyList.clear();
}
void NodeInstanceServer::removeAllInstanceRelationships()
{
// prevent destroyed() signals calling back
......@@ -983,9 +998,6 @@ void NodeInstanceServer::findItemChangesAndSendChangeCommands()
if (d->dirtySceneTransform || d->geometryChanged || d->dirty)
informationChangedInstanceSet.insert(instance);
if((d->dirty && d->notifyBoundingRectChanged)|| (d->dirty && !d->dirtySceneTransform) || nonInstanceChildIsDirty(graphicsObject))
m_dirtyInstanceSet.insert(instance);
if (d->geometryChanged) {
if (instance.isRootNodeInstance())
m_declarativeView->scene()->setSceneRect(item->boundingRect());
......@@ -1004,9 +1016,6 @@ void NodeInstanceServer::findItemChangesAndSendChangeCommands()
if (propertyName.contains("anchors") && informationChangedInstanceSet.contains(instance))
informationChangedInstanceSet.insert(instance);
if (propertyName == "width" || propertyName == "height")
m_dirtyInstanceSet.insert(instance);
if (propertyName == "parent") {
informationChangedInstanceSet.insert(instance);
parentChangedSet.insert(instance);
......@@ -1027,11 +1036,6 @@ void NodeInstanceServer::findItemChangesAndSendChangeCommands()
if (!parentChangedSet.isEmpty())
sendChildrenChangedCommand(parentChangedSet.toList());
if (!m_dirtyInstanceSet.isEmpty() && nodeInstanceClient()->bytesToWrite() < 10000) {
nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(m_dirtyInstanceSet.toList()));
m_dirtyInstanceSet.clear();
}
if (adjustSceneRect) {
QRectF boundingRect = m_rootNodeInstance.boundingRect();
if (boundingRect.isValid()) {
......
......@@ -137,6 +137,10 @@ protected:
void setTimerId(int timerId);
int timerId() const;
QDeclarativeView *delcarativeView() const;
const QVector<InstancePropertyPair> changedPropertyList() const;
void clearChangedPropertyList();
private:
ServerNodeInstance m_rootNodeInstance;
ServerNodeInstance m_activeStateInstance;
......@@ -155,7 +159,6 @@ private:
int m_slowRenderTimerInterval;
QVector<InstancePropertyPair> m_changedPropertyList;
QStringList m_importList;
QSet<ServerNodeInstance> m_dirtyInstanceSet;
QList<ServerNodeInstance> m_completedComponentList;
};
......
......@@ -45,13 +45,14 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
m_nodeInstanceView(nodeInstanceView),
m_firstBlockSize(0),
m_secondBlockSize(0),
m_thirdBlockSize(0),
m_runModus(runModus),
m_synchronizeId(-1)
{
QString socketToken(QUuid::createUuid().toString());
m_localServer->listen(socketToken);
m_localServer->setMaxPendingConnections(2);
m_localServer->setMaxPendingConnections(3);
QString applicationPath = QCoreApplication::applicationDirPath();
if (runModus == TestModus)
......@@ -76,6 +77,14 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
if (fowardQmlpuppetOutput)
m_qmlPuppetPreviewProcess->setProcessChannelMode(QProcess::ForwardedChannels);
m_qmlPuppetPreviewProcess->start(applicationPath, QStringList() << socketToken << "previewmode" << "-graphicssystem raster");
m_qmlPuppetRenderProcess = new QProcess;
connect(m_qmlPuppetRenderProcess.data(), SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)));
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), m_qmlPuppetRenderProcess.data(), SLOT(kill()));
if (fowardQmlpuppetOutput)
m_qmlPuppetRenderProcess->setProcessChannelMode(QProcess::ForwardedChannels);
m_qmlPuppetRenderProcess->start(applicationPath, QStringList() << socketToken << "rendermode" << "-graphicssystem raster");
}
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(deleteLater()));
......@@ -87,6 +96,9 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
if (runModus == NormalModus) {
m_qmlPuppetPreviewProcess->waitForStarted();
connect(m_qmlPuppetPreviewProcess.data(), SIGNAL(finished(int)), m_qmlPuppetPreviewProcess.data(),SLOT(deleteLater()));
m_qmlPuppetRenderProcess->waitForStarted();
connect(m_qmlPuppetRenderProcess.data(), SIGNAL(finished(int)), m_qmlPuppetRenderProcess.data(),SLOT(deleteLater()));
}
if (!m_localServer->hasPendingConnections())
......@@ -101,6 +113,13 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
m_secondSocket = m_localServer->nextPendingConnection();
connect(m_secondSocket.data(), SIGNAL(readyRead()), this, SLOT(readSecondDataStream()));
if (!m_localServer->hasPendingConnections())
m_localServer->waitForNewConnection(-1);
m_thirdSocket = m_localServer->nextPendingConnection();
connect(m_thirdSocket.data(), SIGNAL(readyRead()), this, SLOT(readThirdDataStream()));
}
m_localServer->close();
......@@ -116,12 +135,18 @@ NodeInstanceServerProxy::~NodeInstanceServerProxy()
if (m_secondSocket)
m_secondSocket->close();
if(m_thirdSocket)
m_thirdSocket->close();
if (m_qmlPuppetEditorProcess)
m_qmlPuppetEditorProcess->kill();
if (m_qmlPuppetPreviewProcess)
m_qmlPuppetPreviewProcess->kill();
if (m_qmlPuppetRenderProcess)
m_qmlPuppetRenderProcess->kill();
}
void NodeInstanceServerProxy::dispatchCommand(const QVariant &command)
......@@ -176,6 +201,7 @@ void NodeInstanceServerProxy::writeCommand(const QVariant &command)
{
writeCommandToSocket(command, m_firstSocket.data());
writeCommandToSocket(command, m_secondSocket.data());
writeCommandToSocket(command, m_thirdSocket.data());
if (m_runModus == TestModus) {
static int synchronizeId = 0;
......@@ -198,6 +224,9 @@ void NodeInstanceServerProxy::processFinished(int /*exitCode*/, QProcess::ExitSt
m_firstSocket->close();
if (m_secondSocket)
m_secondSocket->close();
if (m_thirdSocket)
m_thirdSocket->close();
if (exitStatus == QProcess::CrashExit)
emit processCrashed();
}
......@@ -261,6 +290,36 @@ void NodeInstanceServerProxy::readSecondDataStream()
}
}
void NodeInstanceServerProxy::readThirdDataStream()
{
QList<QVariant> commandList;
while (!m_thirdSocket->atEnd()) {
if (m_thirdSocket->bytesAvailable() < int(sizeof(quint32)))
break;
QDataStream in(m_thirdSocket.data());
if (m_thirdBlockSize == 0) {
in >> m_thirdBlockSize;
}
if (m_thirdSocket->bytesAvailable() < m_thirdBlockSize)
break;
QVariant command;
in >> command;
m_thirdBlockSize = 0;
commandList.append(command);
}
foreach (const QVariant &command, commandList) {
dispatchCommand(command);
}
}
void NodeInstanceServerProxy::createInstances(const CreateInstancesCommand &command)
{
writeCommand(QVariant::fromValue(command));
......
......@@ -51,16 +51,20 @@ private slots:
void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
void readFirstDataStream();
void readSecondDataStream();
void readThirdDataStream();
private:
QWeakPointer<QLocalServer> m_localServer;
QWeakPointer<QLocalSocket> m_firstSocket;
QWeakPointer<QLocalSocket> m_secondSocket;
QWeakPointer<QLocalSocket> m_thirdSocket;
QWeakPointer<NodeInstanceView> m_nodeInstanceView;
QWeakPointer<QProcess> m_qmlPuppetEditorProcess;
QWeakPointer<QProcess> m_qmlPuppetPreviewProcess;
QWeakPointer<QProcess> m_qmlPuppetRenderProcess;
quint32 m_firstBlockSize;
quint32 m_secondBlockSize;
quint32 m_thirdBlockSize;
RunModus m_runModus;
int m_synchronizeId;
};
......
#include "rendernodeinstanceserver.h"
#include "nodeinstanceclientinterface.h"
#include "pixmapchangedcommand.h"
#include <QDeclarativeView>
#include <QGraphicsItem>
#include <private/qgraphicsitem_p.h>
namespace QmlDesigner {
RenderNodeInstanceServer::RenderNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) :
NodeInstanceServer(nodeInstanceClient)
{
}
void RenderNodeInstanceServer::findItemChangesAndSendChangeCommands()
{
static bool inFunction = false;
if (!inFunction) {
inFunction = true;
bool adjustSceneRect = false;
if (delcarativeView()) {
foreach (QGraphicsItem *item, delcarativeView()->items()) {
QGraphicsObject *graphicsObject = item->toGraphicsObject();
if (graphicsObject && hasInstanceForObject(graphicsObject)) {
ServerNodeInstance instance = instanceForObject(graphicsObject);
QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(item);
if((d->dirty && d->notifyBoundingRectChanged)|| (d->dirty && !d->dirtySceneTransform) || nonInstanceChildIsDirty(graphicsObject))
m_dirtyInstanceSet.insert(instance);
if (d->geometryChanged) {
if (instance.isRootNodeInstance())
delcarativeView()->scene()->setSceneRect(item->boundingRect());
}
}
}
foreach (const InstancePropertyPair& property, changedPropertyList()) {
const ServerNodeInstance instance = property.first;
const QString propertyName = property.second;
if (instance.isRootNodeInstance() && (propertyName == "width" || propertyName == "height"))
adjustSceneRect = true;
if (propertyName == "width" || propertyName == "height")
m_dirtyInstanceSet.insert(instance);
}
clearChangedPropertyList();
resetAllItems();
if (!m_dirtyInstanceSet.isEmpty() && nodeInstanceClient()->bytesToWrite() < 10000) {
nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(m_dirtyInstanceSet.toList()));
m_dirtyInstanceSet.clear();
}
if (adjustSceneRect) {
QRectF boundingRect = rootNodeInstance().boundingRect();
if (boundingRect.isValid()) {
delcarativeView()->setSceneRect(boundingRect);
}
}
slowDownRenderTimer();
nodeInstanceClient()->flush();
nodeInstanceClient()->synchronizeWithClientProcess();
}
inFunction = false;
}
}
} // namespace QmlDesigner
#ifndef RENDERNODEINSTANCESERVER_H
#define RENDERNODEINSTANCESERVER_H
#include "nodeinstanceserver.h"
namespace QmlDesigner {
class RenderNodeInstanceServer : public NodeInstanceServer
{
Q_OBJECT
public:
explicit RenderNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient);
protected:
void findItemChangesAndSendChangeCommands();
private:
QSet<ServerNodeInstance> m_dirtyInstanceSet;
};
} // namespace QmlDesigner
#endif // RENDERNODEINSTANCESERVER_H
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