diff --git a/src/plugins/qmlprofiler/canvas/qdeclarativetiledcanvas.cpp b/src/plugins/qmlprofiler/canvas/qdeclarativetiledcanvas.cpp index 6cbb96f696a..9e086e141af 100644 --- a/src/plugins/qmlprofiler/canvas/qdeclarativetiledcanvas.cpp +++ b/src/plugins/qmlprofiler/canvas/qdeclarativetiledcanvas.cpp @@ -49,6 +49,7 @@ TiledCanvas::TiledCanvas() { setFlag(QGraphicsItem::ItemHasNoContents, false); setAcceptedMouseButtons(Qt::LeftButton); + setCacheMode(QGraphicsItem::DeviceCoordinateCache); } QSizeF TiledCanvas::canvasSize() const diff --git a/src/plugins/qmlprofiler/qml/MainView.js b/src/plugins/qmlprofiler/qml/MainView.js index 98d4151d487..036fdc02a4e 100644 --- a/src/plugins/qmlprofiler/qml/MainView.js +++ b/src/plugins/qmlprofiler/qml/MainView.js @@ -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 spacing = width / sumValue; + ctxt.fillStyle = "rgba(0,0,0,1)"; + var highest = [0,0,0,0,0]; + //### only draw those in range for (var ii = 0; ii < ranges.length; ++ii) { @@ -103,8 +106,11 @@ function drawData(canvas, ctxt, region) if (size < 0.5) size = 0.5; - ctxt.fillStyle = "rgba(0,0,0,1)" //colors[ranges[ii].type]; - ctxt.fillRect(xx, ranges[ii].type*10, size, 10); + xx = Math.round(xx); + 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 diff --git a/src/plugins/qmlprofiler/timelineview.cpp b/src/plugins/qmlprofiler/timelineview.cpp index 58586057829..26a09fd1c19 100644 --- a/src/plugins/qmlprofiler/timelineview.cpp +++ b/src/plugins/qmlprofiler/timelineview.cpp @@ -81,6 +81,16 @@ void TimelineView::setRanges(const QScriptValue &value) for (int i = 0; i < m_rangeList.count(); ++i) 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) @@ -127,32 +137,25 @@ void TimelineView::updateTimeline(bool updateStartX) qreal oldtw = m_totalWidth; 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 int minsample = 0; int maxsample = 0; for (int i = 0; i < length; ++i) { - if (offsets[i][1] >= m_startTime) + if (m_ends.at(i) >= m_startTime) break; minsample = i; } for (int i = minsample + 1; i < length; ++i) { maxsample = i; - if (offsets[i][0] > m_endTime) + if (m_starts.at(i) > m_endTime) break; } //### overkill (if we can expose whether or not data is nested) for (int i = maxsample + 1; i < length; ++i) { - if (offsets[i][0] < m_endTime) + if (m_starts.at(i) < m_endTime) maxsample = i; } @@ -222,8 +225,8 @@ void TimelineView::updateTimeline(bool updateStartX) item->setParentItem(this); } if (item) { - item->setX(offsets[i][0]*spacing); - item->setWidth(m_ranges.property(i).property("duration").toNumber() * spacing); + item->setX(m_starts.at(i)*spacing); + item->setWidth((m_ends.at(i)-m_starts.at(i)) * spacing); item->setZValue(++z); } if (creating) diff --git a/src/plugins/qmlprofiler/timelineview.h b/src/plugins/qmlprofiler/timelineview.h index 7e04e58a546..d52e5a8806e 100644 --- a/src/plugins/qmlprofiler/timelineview.h +++ b/src/plugins/qmlprofiler/timelineview.h @@ -129,6 +129,8 @@ private: qreal m_startX; int prevMin; int prevMax; + QList m_starts; + QList m_ends; struct PrevLimits { PrevLimits(int _min, int _max) : min(_min), max(_max) {}