]> git.cworth.org Git - apitrace/blobdiff - gui/profiletablemodel.cpp
Use skiplist-based FastCallSet within trace::CallSet
[apitrace] / gui / profiletablemodel.cpp
index 649dae08e3fa9d72e23382a865c8ede52bd9552b..11a0d0c10901e299b271dfabad75e4948fb0c5f7 100644 (file)
@@ -1,9 +1,12 @@
 #include "profiletablemodel.h"
+#include "profiledialog.h"
+#include "profiling.h"
 
+#include <QLocale>
+
+typedef trace::Profile::Call Call;
 typedef trace::Profile::Frame Frame;
 typedef trace::Profile::Program Program;
-typedef trace::Profile::CpuCall CpuCall;
-typedef trace::Profile::DrawCall DrawCall;
 
 enum {
     COLUMN_PROGRAM,
@@ -46,10 +49,35 @@ void ProfileTableModel::setProfile(trace::Profile* profile)
 }
 
 
-void ProfileTableModel::setTimeSelection(int64_t start, int64_t end)
+/**
+ * Set selection to nothing
+ */
+void ProfileTableModel::selectNone()
+{
+    m_timeMin = m_timeMax = 0;
+    updateModel();
+    sort(m_sortColumn, m_sortOrder);
+}
+
+
+/**
+ * Set selection to program
+ */
+void ProfileTableModel::selectProgram(unsigned /*program*/)
+{
+    /* We have no program based selection for table */
+    selectNone();
+}
+
+
+/**
+ * Set selection to a period of time
+ */
+void ProfileTableModel::selectTime(int64_t start, int64_t end)
 {
     m_timeMin = start;
     m_timeMax = end;
+
     updateModel();
     sort(m_sortColumn, m_sortOrder);
 }
@@ -78,11 +106,11 @@ void ProfileTableModel::updateModel()
     }
 
     for (std::vector<Program>::const_iterator itr = m_profile->programs.begin(); itr != m_profile->programs.end(); ++itr) {
-        ProfileTableRow* row = getRow(itr - m_profile->programs.begin());
+        ProfileTableRow* row = NULL;
         const Program& program = *itr;
 
-        for (std::vector<DrawCall>::const_iterator jtr = program.drawCalls.begin(); jtr != program.drawCalls.end(); ++jtr) {
-            const DrawCall& call = *jtr;
+        for (std::vector<unsigned>::const_iterator jtr = program.calls.begin(); jtr != program.calls.end(); ++jtr) {
+            const Call& call = m_profile->calls[*jtr];
 
             if (call.cpuStart > m_timeMax) {
                 break;
@@ -92,6 +120,10 @@ void ProfileTableModel::updateModel()
                 continue;
             }
 
+            if (!row) {
+                row = getRow(itr - m_profile->programs.begin());
+            }
+
             row->uses++;
             row->pixels  += call.pixels;
             row->gpuTime += call.gpuDuration;
@@ -116,7 +148,7 @@ void ProfileTableModel::updateModel()
 /**
  * Get the appropriate call associated with an item in the table
  */
-const DrawCall* ProfileTableModel::getJumpCall(const QModelIndex & index) const {
+const trace::Profile::Call *ProfileTableModel::getJumpCall(const QModelIndex & index) const {
     const ProfileTableRow& row = m_rowData[index.row()];
 
     switch(index.column()) {
@@ -135,6 +167,33 @@ const DrawCall* ProfileTableModel::getJumpCall(const QModelIndex & index) const
 }
 
 
+/**
+ * Get the shader program associated with an item in the table
+ */
+unsigned ProfileTableModel::getProgram(const QModelIndex & index) const
+{
+    const ProfileTableRow& row = m_rowData[index.row()];
+    return row.program;
+}
+
+
+/**
+ * Get the row index for a shader program
+ */
+int ProfileTableModel::getRowIndex(unsigned program) const
+{
+    for (int i = 0; i < m_rowData.size(); ++i) {
+        if (m_rowData[i].program == program)
+            return i;
+    }
+
+    return -1;
+}
+
+
+/**
+ * Get the row data for a shader program
+ */
 ProfileTableRow* ProfileTableModel::getRow(unsigned program) {
     for (QList<ProfileTableRow>::iterator itr = m_rowData.begin(); itr != m_rowData.end(); ++itr) {
         if (itr->program == program)
@@ -175,19 +234,19 @@ QVariant ProfileTableModel::data(const QModelIndex &index, int role) const
         case COLUMN_PROGRAM:
             return row.program;
         case COLUMN_USAGES:
-            return row.uses;
+            return QLocale::system().toString(row.uses);
         case COLUMN_GPU_TIME:
-            return row.gpuTime;
+            return Profiling::getTimeString(row.gpuTime);
         case COLUMN_CPU_TIME:
-            return row.cpuTime;
+            return Profiling::getTimeString(row.cpuTime);
         case COLUMN_PIXELS_DRAWN:
-            return row.pixels;
+            return QLocale::system().toString((qlonglong)row.pixels);
         case COLUMN_GPU_AVERAGE:
-            return (row.uses <= 0) ? 0 : (row.gpuTime / row.uses);
+            return Profiling::getTimeString((row.uses <= 0) ? 0 : (row.gpuTime / row.uses));
         case COLUMN_CPU_AVERAGE:
-            return (row.uses <= 0) ? 0 : (row.cpuTime / row.uses);
+            return Profiling::getTimeString((row.uses <= 0) ? 0 : (row.cpuTime / row.uses));
         case COLUMN_PIXELS_AVERAGE:
-            return (row.uses <= 0) ? 0 : (row.pixels / row.uses);
+            return QLocale::system().toString((row.uses <= 0) ? 0 : (row.pixels / row.uses));
         }
     } else if (role == Qt::TextAlignmentRole) {
         return Qt::AlignRight;