]> git.cworth.org Git - apitrace/commitdiff
Show the size of binary data uploaded in a frame.
authorZack Rusin <zack@kde.org>
Wed, 27 Apr 2011 03:03:42 +0000 (23:03 -0400)
committerZack Rusin <zack@kde.org>
Wed, 27 Apr 2011 03:03:42 +0000 (23:03 -0400)
By default only mark frames that make the gpu download more than 1MB
in the listview, for all others just show the size in the tooltip.

gui/apitracecall.cpp
gui/apitracecall.h
gui/apitracemodel.cpp

index 5901811d15e8af0d52feb0a559ec0cd12378ae9f..e26570528574d54a2f0bbe207ec29421d5cd3406 100644 (file)
@@ -4,6 +4,7 @@
 #include "trace_model.hpp"
 
 #include <QDebug>
+#include <QLocale>
 #include <QObject>
 #define QT_USE_FAST_OPERATOR_PLUS
 #include <QStringBuilder>
@@ -495,8 +496,24 @@ QStaticText ApiTraceFrame::staticText() const
     if (m_staticText && !m_staticText->text().isEmpty())
         return *m_staticText;
 
-    QString richText =
-        QString::fromLatin1("<span style=\"font-weight:bold\">Frame %1</span>").arg(number);
+    QString richText;
+
+    //mark the frame if it uploads more than a meg a frame
+    if (m_binaryDataSize > (1024*1024)) {
+        richText =
+            QObject::tr(
+                "<span style=\"font-weight:bold;\">"
+                "Frame&nbsp;%1</span>"
+                "<span style=\"font-style:italic;\">"
+                "&nbsp;&nbsp;&nbsp;&nbsp;(%2MB)</span>")
+            .arg(number)
+            .arg(double(m_binaryDataSize / (1024.*1024.)), 0, 'g', 2);
+    } else {
+        richText =
+            QObject::tr(
+                "<span style=\"font-weight:bold\">Frame %1</span>")
+            .arg(number);
+    }
 
     if (!m_staticText)
         m_staticText = new QStaticText(richText);
@@ -898,6 +915,11 @@ ApiTrace * ApiTraceCall::parentTrace() const
 void ApiTraceFrame::addCall(ApiTraceCall *call)
 {
     m_calls.append(call);
+    if (call->hasBinaryData()) {
+        QByteArray data =
+            call->arguments()[call->binaryDataIndex()].toByteArray();
+        m_binaryDataSize += data.size();
+    }
 }
 
 QList<ApiTraceCall*> ApiTraceFrame::calls() const
@@ -920,3 +942,8 @@ bool ApiTraceFrame::isEmpty() const
     return m_calls.isEmpty();
 }
 
+int ApiTraceFrame::binaryDataSize() const
+{
+    return m_binaryDataSize;
+}
+
index d8005ca6d3b0b620a6bbea7e7bcfebdd85bca1b1..b7362eb521558a1a92c20948d1f58f06169be848 100644 (file)
@@ -253,6 +253,7 @@ public:
     void addCall(ApiTraceCall *call);
     QList<ApiTraceCall*> calls() const;
 
+    int binaryDataSize() const;
 private:
     ApiTrace *m_parentTrace;
     quint64 m_binaryDataSize;
index 7366ae5d025b69f6c428a402b72c3b66b368ab95..e60b176f02311387ab62d35fa25544833293e99c 100644 (file)
@@ -53,12 +53,20 @@ QVariant ApiTraceModel::data(const QModelIndex &index, int role) const
                     .arg(stateText);
         } else {
             ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(itm);
-            QString text = frame->staticText().text();
+            QString text = QObject::tr("%1)&nbsp;Frame&nbsp;")
+                           .arg(frame->number);
+            int binaryDataSize = frame->binaryDataSize() / 1024;
             if (frame->state().isEmpty())
-                return QString::fromLatin1("<b>%1</b>").arg(text);
+                return QObject::tr(
+                    "<b>%1&nbsp;</b>(binary&nbsp;data&nbsp;size&nbsp;=&nbsp;%2kB)")
+                    .arg(text)
+                    .arg(binaryDataSize);
             else
-                return QString::fromLatin1("<b>%1</b><br/>%2")
+                return QObject::tr(
+                    "<b>%1&nbsp;(binary&nbsp;data&nbsp;size&nbsp;=&nbsp;%2kB)</b>"
+                    "<br/>%3")
                     .arg(text)
+                    .arg(binaryDataSize)
                     .arg(stateText);
         }
     }