forked from qt-creator/qt-creator
QmlProfiler: rendering optimizations
Reviewed-by: Kai Koehne
This commit is contained in:
@@ -49,6 +49,7 @@ TiledCanvas::TiledCanvas()
|
|||||||
{
|
{
|
||||||
setFlag(QGraphicsItem::ItemHasNoContents, false);
|
setFlag(QGraphicsItem::ItemHasNoContents, false);
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
|
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF TiledCanvas::canvasSize() const
|
QSizeF TiledCanvas::canvasSize() const
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ function drawData(canvas, ctxt, region)
|
|||||||
var sumValue = ranges[ranges.length - 1].start + ranges[ranges.length - 1].duration - ranges[0].start;
|
var sumValue = ranges[ranges.length - 1].start + ranges[ranges.length - 1].duration - ranges[0].start;
|
||||||
var spacing = width / sumValue;
|
var spacing = width / sumValue;
|
||||||
|
|
||||||
|
ctxt.fillStyle = "rgba(0,0,0,1)";
|
||||||
|
var highest = [0,0,0,0,0];
|
||||||
|
|
||||||
//### only draw those in range
|
//### only draw those in range
|
||||||
for (var ii = 0; ii < ranges.length; ++ii) {
|
for (var ii = 0; ii < ranges.length; ++ii) {
|
||||||
|
|
||||||
@@ -103,8 +106,11 @@ function drawData(canvas, ctxt, region)
|
|||||||
if (size < 0.5)
|
if (size < 0.5)
|
||||||
size = 0.5;
|
size = 0.5;
|
||||||
|
|
||||||
ctxt.fillStyle = "rgba(0,0,0,1)" //colors[ranges[ii].type];
|
xx = Math.round(xx);
|
||||||
ctxt.fillRect(xx, ranges[ii].type*10, size, 10);
|
if (xx + size > highest[ranges[ii].type]) {
|
||||||
|
ctxt.fillRect(xx, ranges[ii].type*10, size, 10);
|
||||||
|
highest[ranges[ii].type] = xx+size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw fps overlay
|
//draw fps overlay
|
||||||
|
|||||||
@@ -81,6 +81,16 @@ void TimelineView::setRanges(const QScriptValue &value)
|
|||||||
|
|
||||||
for (int i = 0; i < m_rangeList.count(); ++i)
|
for (int i = 0; i < m_rangeList.count(); ++i)
|
||||||
m_prevLimits << PrevLimits(0, 0);
|
m_prevLimits << PrevLimits(0, 0);
|
||||||
|
|
||||||
|
qreal startValue = m_ranges.property(0).property("start").toNumber();
|
||||||
|
m_starts.clear();
|
||||||
|
m_starts.reserve(length);
|
||||||
|
m_ends.clear();
|
||||||
|
m_ends.reserve(length);
|
||||||
|
for (int i = 0; i < length; ++i) {
|
||||||
|
m_starts.append(m_ranges.property(i).property("start").toNumber() - startValue);
|
||||||
|
m_ends.append(m_ranges.property(i).property("start").toNumber() + m_ranges.property(i).property("duration").toNumber() - startValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineView::setStartX(qreal arg)
|
void TimelineView::setStartX(qreal arg)
|
||||||
@@ -127,32 +137,25 @@ void TimelineView::updateTimeline(bool updateStartX)
|
|||||||
qreal oldtw = m_totalWidth;
|
qreal oldtw = m_totalWidth;
|
||||||
m_totalWidth = totalRange * spacing;
|
m_totalWidth = totalRange * spacing;
|
||||||
|
|
||||||
qreal offsets[length][2];
|
|
||||||
|
|
||||||
for (int i = 0; i < length; ++i) {
|
|
||||||
offsets[i][0] = (m_ranges.property(i).property("start").toNumber() - startValue);
|
|
||||||
offsets[i][1] = (m_ranges.property(i).property("start").toNumber() + m_ranges.property(i).property("duration").toNumber() - startValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find region samples
|
// Find region samples
|
||||||
int minsample = 0;
|
int minsample = 0;
|
||||||
int maxsample = 0;
|
int maxsample = 0;
|
||||||
|
|
||||||
for (int i = 0; i < length; ++i) {
|
for (int i = 0; i < length; ++i) {
|
||||||
if (offsets[i][1] >= m_startTime)
|
if (m_ends.at(i) >= m_startTime)
|
||||||
break;
|
break;
|
||||||
minsample = i;
|
minsample = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = minsample + 1; i < length; ++i) {
|
for (int i = minsample + 1; i < length; ++i) {
|
||||||
maxsample = i;
|
maxsample = i;
|
||||||
if (offsets[i][0] > m_endTime)
|
if (m_starts.at(i) > m_endTime)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//### overkill (if we can expose whether or not data is nested)
|
//### overkill (if we can expose whether or not data is nested)
|
||||||
for (int i = maxsample + 1; i < length; ++i) {
|
for (int i = maxsample + 1; i < length; ++i) {
|
||||||
if (offsets[i][0] < m_endTime)
|
if (m_starts.at(i) < m_endTime)
|
||||||
maxsample = i;
|
maxsample = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,8 +225,8 @@ void TimelineView::updateTimeline(bool updateStartX)
|
|||||||
item->setParentItem(this);
|
item->setParentItem(this);
|
||||||
}
|
}
|
||||||
if (item) {
|
if (item) {
|
||||||
item->setX(offsets[i][0]*spacing);
|
item->setX(m_starts.at(i)*spacing);
|
||||||
item->setWidth(m_ranges.property(i).property("duration").toNumber() * spacing);
|
item->setWidth((m_ends.at(i)-m_starts.at(i)) * spacing);
|
||||||
item->setZValue(++z);
|
item->setZValue(++z);
|
||||||
}
|
}
|
||||||
if (creating)
|
if (creating)
|
||||||
|
|||||||
@@ -129,6 +129,8 @@ private:
|
|||||||
qreal m_startX;
|
qreal m_startX;
|
||||||
int prevMin;
|
int prevMin;
|
||||||
int prevMax;
|
int prevMax;
|
||||||
|
QList<qreal> m_starts;
|
||||||
|
QList<qreal> m_ends;
|
||||||
|
|
||||||
struct PrevLimits {
|
struct PrevLimits {
|
||||||
PrevLimits(int _min, int _max) : min(_min), max(_max) {}
|
PrevLimits(int _min, int _max) : min(_min), max(_max) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user