forked from qt-creator/qt-creator
QmlProfiler: Apply d-pointer pattern to TimelineRenderState
It will be a public class in the timeline library. Change-Id: I77a3bedd9e63b57c199680e89da1950ed7b7e3d1 Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
@@ -87,7 +87,8 @@ HEADERS += \
|
|||||||
timelinerenderstate.h \
|
timelinerenderstate.h \
|
||||||
timelinenotesmodel.h \
|
timelinenotesmodel.h \
|
||||||
timelinenotesmodel_p.h \
|
timelinenotesmodel_p.h \
|
||||||
timelinerenderer_p.h
|
timelinerenderer_p.h \
|
||||||
|
timelinerenderstate_p.h
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
qml/qmlprofiler.qrc
|
qml/qmlprofiler.qrc
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ QtcPlugin {
|
|||||||
"timelinenotesrenderpass.cpp", "timelinenotesrenderpass.h",
|
"timelinenotesrenderpass.cpp", "timelinenotesrenderpass.h",
|
||||||
"timelinerenderer.cpp", "timelinerenderer.h", "timelinerenderer_p.h",
|
"timelinerenderer.cpp", "timelinerenderer.h", "timelinerenderer_p.h",
|
||||||
"timelinerenderpass.cpp", "timelinerenderpass.h",
|
"timelinerenderpass.cpp", "timelinerenderpass.h",
|
||||||
"timelinerenderstate.cpp", "timelinerenderstate.h",
|
"timelinerenderstate.cpp", "timelinerenderstate.h", "timelinerenderstate_p.h",
|
||||||
"timelineselectionrenderpass.cpp", "timelineselectionrenderpass.h",
|
"timelineselectionrenderpass.cpp", "timelineselectionrenderpass.h",
|
||||||
"timelinezoomcontrol.cpp", "timelinezoomcontrol.h"
|
"timelinezoomcontrol.cpp", "timelinezoomcontrol.h"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -28,83 +28,128 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "timelinerenderstate.h"
|
#include "timelinerenderstate_p.h"
|
||||||
|
|
||||||
namespace Timeline {
|
namespace Timeline {
|
||||||
|
|
||||||
TimelineRenderState::TimelineRenderState(qint64 start, qint64 end, qreal scale, int numPasses) :
|
TimelineRenderState::TimelineRenderState(qint64 start, qint64 end, qreal scale, int numPasses) :
|
||||||
m_expandedRowRoot(new QSGNode), m_collapsedRowRoot(new QSGNode),
|
d_ptr(new TimelineRenderStatePrivate)
|
||||||
m_expandedOverlayRoot(new QSGNode), m_collapsedOverlayRoot(new QSGNode),
|
|
||||||
m_start(start), m_end(end), m_scale(scale), m_passes(numPasses)
|
|
||||||
{
|
{
|
||||||
m_expandedRowRoot->setFlag(QSGNode::OwnedByParent, false);
|
Q_D(TimelineRenderState);
|
||||||
m_collapsedRowRoot->setFlag(QSGNode::OwnedByParent, false);
|
d->expandedRowRoot = new QSGNode;
|
||||||
m_expandedOverlayRoot->setFlag(QSGNode::OwnedByParent, false);
|
d->collapsedRowRoot = new QSGNode;
|
||||||
m_collapsedOverlayRoot->setFlag(QSGNode::OwnedByParent, false);
|
d->expandedOverlayRoot = new QSGNode;
|
||||||
|
d->collapsedOverlayRoot = new QSGNode;
|
||||||
|
d->start = start;
|
||||||
|
d->end = end;
|
||||||
|
d->scale = scale;
|
||||||
|
d->passes.resize(numPasses);
|
||||||
|
|
||||||
|
d->expandedRowRoot->setFlag(QSGNode::OwnedByParent, false);
|
||||||
|
d->collapsedRowRoot->setFlag(QSGNode::OwnedByParent, false);
|
||||||
|
d->expandedOverlayRoot->setFlag(QSGNode::OwnedByParent, false);
|
||||||
|
d->collapsedOverlayRoot->setFlag(QSGNode::OwnedByParent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimelineRenderState::~TimelineRenderState()
|
TimelineRenderState::~TimelineRenderState()
|
||||||
{
|
{
|
||||||
delete m_expandedRowRoot;
|
Q_D(TimelineRenderState);
|
||||||
delete m_collapsedRowRoot;
|
delete d->expandedRowRoot;
|
||||||
delete m_expandedOverlayRoot;
|
delete d->collapsedRowRoot;
|
||||||
delete m_collapsedOverlayRoot;
|
delete d->expandedOverlayRoot;
|
||||||
|
delete d->collapsedOverlayRoot;
|
||||||
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 TimelineRenderState::start() const
|
qint64 TimelineRenderState::start() const
|
||||||
{
|
{
|
||||||
return m_start;
|
Q_D(const TimelineRenderState);
|
||||||
|
return d->start;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 TimelineRenderState::end() const
|
qint64 TimelineRenderState::end() const
|
||||||
{
|
{
|
||||||
return m_end;
|
Q_D(const TimelineRenderState);
|
||||||
|
return d->end;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal TimelineRenderState::scale() const
|
qreal TimelineRenderState::scale() const
|
||||||
{
|
{
|
||||||
return m_scale;
|
Q_D(const TimelineRenderState);
|
||||||
|
return d->scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode *TimelineRenderState::expandedRowRoot() const
|
const QSGNode *TimelineRenderState::expandedRowRoot() const
|
||||||
{
|
{
|
||||||
return m_expandedRowRoot;
|
Q_D(const TimelineRenderState);
|
||||||
|
return d->expandedRowRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode *TimelineRenderState::collapsedRowRoot() const
|
const QSGNode *TimelineRenderState::collapsedRowRoot() const
|
||||||
{
|
{
|
||||||
return m_collapsedRowRoot;
|
Q_D(const TimelineRenderState);
|
||||||
|
return d->collapsedRowRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode *TimelineRenderState::expandedOverlayRoot() const
|
const QSGNode *TimelineRenderState::expandedOverlayRoot() const
|
||||||
{
|
{
|
||||||
return m_expandedOverlayRoot;
|
Q_D(const TimelineRenderState);
|
||||||
|
return d->expandedOverlayRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode *TimelineRenderState::collapsedOverlayRoot() const
|
const QSGNode *TimelineRenderState::collapsedOverlayRoot() const
|
||||||
{
|
{
|
||||||
return m_collapsedOverlayRoot;
|
Q_D(const TimelineRenderState);
|
||||||
|
return d->collapsedOverlayRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSGNode *TimelineRenderState::expandedRowRoot()
|
||||||
|
{
|
||||||
|
Q_D(TimelineRenderState);
|
||||||
|
return d->expandedRowRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSGNode *TimelineRenderState::collapsedRowRoot()
|
||||||
|
{
|
||||||
|
Q_D(TimelineRenderState);
|
||||||
|
return d->collapsedRowRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSGNode *TimelineRenderState::expandedOverlayRoot()
|
||||||
|
{
|
||||||
|
Q_D(TimelineRenderState);
|
||||||
|
return d->expandedOverlayRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSGNode *TimelineRenderState::collapsedOverlayRoot()
|
||||||
|
{
|
||||||
|
Q_D(TimelineRenderState);
|
||||||
|
return d->collapsedOverlayRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TimelineRenderState::isEmpty() const
|
bool TimelineRenderState::isEmpty() const
|
||||||
{
|
{
|
||||||
return m_collapsedRowRoot->childCount() == 0 && m_expandedRowRoot->childCount() == 0 &&
|
Q_D(const TimelineRenderState);
|
||||||
m_collapsedOverlayRoot->childCount() == 0 && m_expandedOverlayRoot->childCount() == 0;
|
return d->collapsedRowRoot->childCount() == 0 && d->expandedRowRoot->childCount() == 0 &&
|
||||||
|
d->collapsedOverlayRoot->childCount() == 0 && d->expandedOverlayRoot->childCount() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TimelineRenderPass::State *TimelineRenderState::passState(int i)
|
TimelineRenderPass::State *TimelineRenderState::passState(int i)
|
||||||
{
|
{
|
||||||
return m_passes[i];
|
Q_D(TimelineRenderState);
|
||||||
|
return d->passes[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
const TimelineRenderPass::State *TimelineRenderState::passState(int i) const
|
const TimelineRenderPass::State *TimelineRenderState::passState(int i) const
|
||||||
{
|
{
|
||||||
return m_passes[i];
|
Q_D(const TimelineRenderState);
|
||||||
|
return d->passes[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineRenderState::setPassState(int i, TimelineRenderPass::State *state)
|
void TimelineRenderState::setPassState(int i, TimelineRenderPass::State *state)
|
||||||
{
|
{
|
||||||
m_passes[i] = state;
|
Q_D(TimelineRenderState);
|
||||||
|
d->passes[i] = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Timeline
|
} // namespace Timeline
|
||||||
|
|||||||
@@ -49,25 +49,22 @@ public:
|
|||||||
const TimelineRenderPass::State *passState(int i) const;
|
const TimelineRenderPass::State *passState(int i) const;
|
||||||
void setPassState(int i, TimelineRenderPass::State *state);
|
void setPassState(int i, TimelineRenderPass::State *state);
|
||||||
|
|
||||||
QSGNode *expandedRowRoot() const;
|
const QSGNode *expandedRowRoot() const;
|
||||||
QSGNode *collapsedRowRoot() const;
|
const QSGNode *collapsedRowRoot() const;
|
||||||
QSGNode *expandedOverlayRoot() const;
|
const QSGNode *expandedOverlayRoot() const;
|
||||||
QSGNode *collapsedOverlayRoot() const;
|
const QSGNode *collapsedOverlayRoot() const;
|
||||||
|
|
||||||
|
QSGNode *expandedRowRoot();
|
||||||
|
QSGNode *collapsedRowRoot();
|
||||||
|
QSGNode *expandedOverlayRoot();
|
||||||
|
QSGNode *collapsedOverlayRoot();
|
||||||
|
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSGNode *m_expandedRowRoot;
|
class TimelineRenderStatePrivate;
|
||||||
QSGNode *m_collapsedRowRoot;
|
TimelineRenderStatePrivate *d_ptr;
|
||||||
QSGNode *m_expandedOverlayRoot;
|
Q_DECLARE_PRIVATE(TimelineRenderState)
|
||||||
QSGNode *m_collapsedOverlayRoot;
|
|
||||||
|
|
||||||
qint64 m_start;
|
|
||||||
qint64 m_end;
|
|
||||||
|
|
||||||
qreal m_scale; // "native" scale, this stays the same through the life time of a state
|
|
||||||
|
|
||||||
QVector<TimelineRenderPass::State *> m_passes;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Timeline
|
} // namespace Timeline
|
||||||
|
|||||||
56
src/plugins/qmlprofiler/timelinerenderstate_p.h
Normal file
56
src/plugins/qmlprofiler/timelinerenderstate_p.h
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TIMELINERENDERSTATE_P_H
|
||||||
|
#define TIMELINERENDERSTATE_P_H
|
||||||
|
|
||||||
|
#include "timelinerenderstate.h"
|
||||||
|
|
||||||
|
namespace Timeline {
|
||||||
|
|
||||||
|
class TimelineRenderState::TimelineRenderStatePrivate {
|
||||||
|
public:
|
||||||
|
QSGNode *expandedRowRoot;
|
||||||
|
QSGNode *collapsedRowRoot;
|
||||||
|
QSGNode *expandedOverlayRoot;
|
||||||
|
QSGNode *collapsedOverlayRoot;
|
||||||
|
|
||||||
|
qint64 start;
|
||||||
|
qint64 end;
|
||||||
|
|
||||||
|
qreal scale; // "native" scale, this stays the same through the life time of a state
|
||||||
|
|
||||||
|
QVector<TimelineRenderPass::State *> passes;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Timeline
|
||||||
|
|
||||||
|
#endif // TIMELINERENDERSTATE_P_H
|
||||||
|
|
||||||
Reference in New Issue
Block a user