return m_framebuffers;
}
+ApiFramebuffer ApiTraceState::colorBuffer() const
+{
+ foreach (ApiFramebuffer fbo, m_framebuffers) {
+ if (fbo.type() == QLatin1String("GL_BACK")) {
+ return fbo;
+ }
+ }
+ foreach (ApiFramebuffer fbo, m_framebuffers) {
+ if (fbo.type() == QLatin1String("GL_FRONT")) {
+ return fbo;
+ }
+ }
+ return ApiFramebuffer();
+}
+
+
ApiTraceCallSignature::ApiTraceCallSignature(const QString &name,
const QStringList &argNames)
: m_name(name),
const QList<ApiTexture> & textures() const;
const QList<ApiFramebuffer> & framebuffers() const;
+ ApiFramebuffer colorBuffer() const;
private:
QVariantMap m_parameters;
QMap<QString, QString> m_shaderSources;
#include "traceloader.h"
#include "trace_parser.hpp"
+#include <QBuffer>
#include <QDebug>
#include <QImage>
#include <QVariant>
.arg(call->name())
.arg(stateText);
} else {
+ const char *htmlTempl =
+ "<div>\n"
+ "<div>\n"
+ "%1"
+ "<span style=\"font-weight:bold; font-size:large; vertical-align:center; padding-bottom: 30px \">\n"
+ "Frame %2</span>\n"
+ "</div>\n"
+ "<div >%3 calls%4</div>\n"
+ "</div>\n";
+
+
ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(itm);
- QString text = QObject::tr("%1) Frame ")
- .arg(frame->number);
- int binaryDataSize = frame->binaryDataSize() / 1024;
- if (!frame->hasState())
- return QObject::tr(
- "<b>%1 </b>(binary data size = %2kB)")
- .arg(text)
- .arg(binaryDataSize);
- else
- return QObject::tr(
- "<b>%1 (binary data size = %2kB)</b>"
- "<br/>%3")
- .arg(text)
- .arg(binaryDataSize)
- .arg(stateText);
+ QString thumbStr, sizeStr;
+
+ if (frame->hasState()) {
+ static const char *imgTempl =
+ "<img style=\"float:left;\" "
+ "src=\"data:image/png;base64,%1\"/>\n";
+ static const char *sizeTempl =
+ ", %1kb";
+
+ ApiFramebuffer fbo = frame->state()->colorBuffer();
+ QImage thumb = fbo.thumb();
+ if (!thumb.isNull()) {
+ QByteArray ba;
+ QBuffer buffer(&ba);
+ buffer.open(QIODevice::WriteOnly);
+ thumb.save(&buffer, "PNG");
+ thumbStr = tr(imgTempl).arg(
+ QString(buffer.data().toBase64()));
+ }
+
+ int binaryDataSize = frame->binaryDataSize() / 1024;
+ if (binaryDataSize > 0) {
+ sizeStr = tr(sizeTempl).arg(binaryDataSize);
+ }
+ }
+
+ int numCalls = frame->loaded()
+ ? frame->numChildren()
+ : frame->numChildrenToLoad();
+
+ return tr(htmlTempl)
+ .arg(thumbStr)
+ .arg(frame->number)
+ .arg(numCalls)
+ .arg(sizeStr);
}
}
case ApiTraceModel::EventRole: