]> git.cworth.org Git - apitrace/blobdiff - gui/timelinewidget.h
Combine timeline and histogram tabs.
[apitrace] / gui / timelinewidget.h
index be8f92aa0733e16584004c37de3f835bc17df41c..ba42a101eb018a34fac2d5716f21f840dfd98bca 100644 (file)
@@ -6,12 +6,6 @@
 #include <QPen>
 #include "trace_profiler.hpp"
 
-struct VisibleItem {
-    QRect rect;
-    const trace::Profile::Frame* frame;
-    const trace::Profile::Call* call;
-};
-
 class TimelineWidget : public QWidget
 {
     Q_OBJECT
@@ -23,11 +17,21 @@ class TimelineWidget : public QWidget
         RulerSelect
     };
 
+    enum SelectType {
+        SelectNone,
+        SelectTime,
+        SelectProgram
+    };
+
 public:
     TimelineWidget(QWidget *parent = 0);
 
     void setProfile(trace::Profile* profile);
 
+    void selectNone(bool notify = false);
+    void selectProgram(unsigned program, bool notify = false);
+    void selectTime(int64_t start, int64_t end, bool notify = false);
+
 protected:
     virtual void wheelEvent(QWheelEvent *e);
     virtual void mousePressEvent(QMouseEvent *e);
@@ -51,27 +55,31 @@ signals:
 
     void jumpToCall(int call);
 
-    void selectionChanged(int64_t start, int64_t end);
+    void selectedNone();
+    void selectedProgram(unsigned program);
+    void selectedTime(int64_t start, int64_t end);
 
 private:
-    void setSelection(int64_t start, int64_t end, bool notify = false);
     void setRowScroll(int position, bool notify = true);
     void setTimeScroll(int64_t time, bool notify = true);
 
-    void paintHeatmapColumn(int x, QPainter& painter, QVector<uint64_t>& rows);
+    bool drawCall(QPainter& painter, const trace::Profile::Call& call, int &lastX, int64_t &heat, bool gpu);
+    void drawHeat(QPainter& painter, int x, int64_t heat, bool gpu, bool selected);
 
     double timeToPosition(int64_t time);
     int64_t positionToTime(int pos);
 
-    const VisibleItem* itemAtPosition(const QPoint& pos);
-
     void calculateRows();
 
+    const trace::Profile::Frame* frameAtTime(int64_t time);
+    const trace::Profile::Call* cpuCallAtTime(int64_t time);
+    const trace::Profile::Call* drawCallAtTime(int64_t time);
+    const trace::Profile::Call* drawCallAtTime(int64_t time, int program);
+
 private:
     /* Data */
     trace::Profile* m_profile;
-    QList<int> m_programRowMap;
-    QList<VisibleItem> m_visibleItems;
+    std::vector<int> m_rowPrograms;
 
     /* Scrollbars */
     int m_scrollX;
@@ -85,13 +93,15 @@ private:
 
     /* Visible Times */
     int64_t m_time;
+    int64_t m_timeEnd;
     int64_t m_timeMin;
     int64_t m_timeMax;
     int64_t m_timeWidth;
     int64_t m_timeWidthMin;
     int64_t m_timeWidthMax;
-    int64_t m_timeSelectionStart;
-    int64_t m_timeSelectionEnd;
+
+    int m_selectionLeft;
+    int m_selectionRight;
 
     /* Visible Rows */
     int m_row;
@@ -108,15 +118,31 @@ private:
     int m_rowHeight;
     int m_axisWidth;
     int m_axisHeight;
+    QPen m_axisLine;
     QPen m_axisBorder;
+    QPen m_axisForeground;
     QBrush m_axisBackground;
     QPen m_itemBorder;
-    QPen m_itemForeground;
-    QBrush m_itemBackground;
+    QPen m_itemGpuForeground;
+    QBrush m_itemGpuBackground;
+    QPen m_itemCpuForeground;
+    QBrush m_itemCpuBackground;
+    QPen m_itemDeselectedForeground;
+    QBrush m_itemDeselectedBackground;
     QPen m_selectionBorder;
     QBrush m_selectionBackground;
     QPen m_zoomBorder;
     QBrush m_zoomBackground;
+
+    /* Selection */
+    struct {
+        SelectType type;
+
+        unsigned program;
+
+        int64_t timeStart;
+        int64_t timeEnd;
+    } m_selection;
 };
 
 #endif // TIMELINEWIDGET_H