diff options
-rw-r--r-- | gui/apisurface.cpp | 24 | ||||
-rw-r--r-- | gui/apisurface.h | 8 | ||||
-rw-r--r-- | gui/apitracemodel.cpp | 2 | ||||
-rw-r--r-- | gui/imageviewer.cpp | 8 | ||||
-rw-r--r-- | gui/imageviewer.h | 2 | ||||
-rw-r--r-- | gui/mainwindow.cpp | 64 | ||||
-rw-r--r-- | gui/mainwindow.h | 3 | ||||
-rw-r--r-- | gui/ui/mainwindow.ui | 18 |
8 files changed, 89 insertions, 40 deletions
diff --git a/gui/apisurface.cpp b/gui/apisurface.cpp index 4f0a9173..e1ce2a1f 100644 --- a/gui/apisurface.cpp +++ b/gui/apisurface.cpp @@ -2,6 +2,7 @@ #include "thumbnail.h" #include <sstream> +#include <memory> #include <QDebug> #include <QSysInfo> @@ -31,28 +32,31 @@ struct ByteArrayBuf : public std::streambuf } }; -void ApiSurface::setData(const QByteArray &data) +QImage ApiSurface::calculateThumbnail(bool opaque, bool alpha) const { - m_data = data; + return m_data.isEmpty() ? QImage{} : calculateThumbnail(m_data, opaque, alpha); +} +QImage ApiSurface::calculateThumbnail(const QByteArray &data, bool opaque, + bool alpha) const +{ /* * We need to do the conversion to create the thumbnail */ - image::Image *image = imageFromData(data); + std::unique_ptr<image::Image> image{imageFromData(data)}; Q_ASSERT(image); - QImage img = qimageFromRawImage(image); - m_thumb = thumbnail(img); - delete image; + QImage img = qimageFromRawImage(image.get(), 0.0f, 1.0f, opaque, alpha); + return thumbnail(img); } -QByteArray ApiSurface::data() const +void ApiSurface::setData(const QByteArray &data) { - return m_data; + m_data = data; } -QImage ApiSurface::thumb() const +QByteArray ApiSurface::data() const { - return m_thumb; + return m_data; } int ApiSurface::depth() const diff --git a/gui/apisurface.h b/gui/apisurface.h index de5f531d..aa5eec15 100644 --- a/gui/apisurface.h +++ b/gui/apisurface.h @@ -23,9 +23,9 @@ public: void setFormatName(const QString &str); void setData(const QByteArray &data); + QImage calculateThumbnail(bool opaque, bool alpha) const; QByteArray data() const; - QImage thumb() const; static image::Image *imageFromData(const QByteArray &data); static QImage qimageFromRawImage(const image::Image *img, @@ -35,13 +35,15 @@ public: bool alpha = false); private: + QSize m_size; QByteArray m_data; - QImage m_thumb; int m_depth; QString m_formatName; -}; + QImage calculateThumbnail(const QByteArray &data, bool opaque, + bool alpha) const; +}; class ApiTexture : public ApiSurface { diff --git a/gui/apitracemodel.cpp b/gui/apitracemodel.cpp index 51908dea..ee43dd7f 100644 --- a/gui/apitracemodel.cpp +++ b/gui/apitracemodel.cpp @@ -75,7 +75,7 @@ QVariant ApiTraceModel::data(const QModelIndex &index, int role) const ", %1kb"; ApiFramebuffer fbo = frame->state()->colorBuffer(); - QImage thumb = fbo.thumb(); + QImage thumb = fbo.calculateThumbnail(false, false); if (!thumb.isNull()) { QByteArray ba; QBuffer buffer(&ba); diff --git a/gui/imageviewer.cpp b/gui/imageviewer.cpp index 6953c009..560b477f 100644 --- a/gui/imageviewer.cpp +++ b/gui/imageviewer.cpp @@ -10,11 +10,13 @@ #include <QPixmap> #include <QScrollBar> -ImageViewer::ImageViewer(QWidget *parent) +ImageViewer::ImageViewer(QWidget *parent, bool opaque, bool alpha) : QDialog(parent), m_image(0) { setupUi(this); + opaqueCheckBox->setChecked(opaque); + alphaCheckBox->setChecked(alpha); connect(lowerSpinBox, SIGNAL(valueChanged(double)), SLOT(slotUpdate())); @@ -65,9 +67,7 @@ void ImageViewer::setData(const QByteArray &data) { delete m_image; m_image = ApiSurface::imageFromData(data); - m_convertedImage = ApiSurface::qimageFromRawImage(m_image); - m_pixelWidget->setSurface(m_convertedImage); - updateGeometry(); + slotUpdate(); } void ImageViewer::slotUpdate() diff --git a/gui/imageviewer.h b/gui/imageviewer.h index d5d83a43..e0cbce0c 100644 --- a/gui/imageviewer.h +++ b/gui/imageviewer.h @@ -14,7 +14,7 @@ class ImageViewer : public QDialog, public Ui_ImageViewer { Q_OBJECT public: - ImageViewer(QWidget *parent = 0); + ImageViewer(QWidget *parent = 0, bool opaque = false, bool alpha = false); ~ImageViewer(); void setData(const QByteArray &data); diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 510bb21a..63305663 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -753,9 +753,10 @@ variantToItem(const QString &key, const QVariant &var, static void addSurfaceItem(const ApiSurface &surface, const QString &label, QTreeWidgetItem *parent, - QTreeWidget *tree) + QTreeWidget *tree, + bool opaque, bool alpha) { - QIcon icon(QPixmap::fromImage(surface.thumb())); + QIcon icon(QPixmap::fromImage(surface.calculateThumbnail(opaque, alpha))); QTreeWidgetItem *item = new QTreeWidgetItem(parent); item->setIcon(0, icon); @@ -785,11 +786,19 @@ static void addSurfaceItem(const ApiSurface &surface, } void MainWindow::addSurface(const ApiTexture &image, QTreeWidgetItem *parent) { - addSurfaceItem(image, image.label(), parent, m_ui.surfacesTreeWidget); + addSurface(image, image.label(), parent); } void MainWindow::addSurface(const ApiFramebuffer &fbo, QTreeWidgetItem *parent) { - addSurfaceItem(fbo, fbo.type(), parent, m_ui.surfacesTreeWidget); + addSurface(fbo, fbo.type(), parent); +} + +void MainWindow::addSurface(const ApiSurface &surface, const QString &label, + QTreeWidgetItem *parent) +{ + addSurfaceItem(surface, label, parent, + m_ui.surfacesTreeWidget, m_ui.surfacesOpaqueCB->isChecked(), + m_ui.surfacesAlphaCB->isChecked()); } template <typename Surface> @@ -884,6 +893,29 @@ static void setValueOfSSBBItem(const ApiTraceState &state, } } +void MainWindow::updateSurfacesView() +{ + updateSurfacesView(*m_selectedEvent->state()); +} + +void MainWindow::updateSurfacesView(const ApiTraceState &state) +{ + const QList<ApiTexture> &textures = + state.textures(); + const QList<ApiFramebuffer> &fbos = + state.framebuffers(); + + m_ui.surfacesTreeWidget->clear(); + if (textures.isEmpty() && fbos.isEmpty()) { + m_ui.surfacesTab->setDisabled(false); + } else { + m_ui.surfacesTreeWidget->setIconSize(QSize(THUMBNAIL_SIZE, THUMBNAIL_SIZE)); + addSurfaces(textures, "Textures"); + addSurfaces(fbos, "Framebuffers"); + m_ui.surfacesTab->setEnabled(true); + } +} + void MainWindow::fillStateForFrame() { if (!m_selectedEvent || !m_selectedEvent->hasState()) { @@ -926,20 +958,7 @@ void MainWindow::fillStateForFrame() variantMapToItems(state.buffers(), QVariantMap(), buffersItems); m_ui.buffersTreeWidget->insertTopLevelItems(0, buffersItems); - const QList<ApiTexture> &textures = - state.textures(); - const QList<ApiFramebuffer> &fbos = - state.framebuffers(); - - m_ui.surfacesTreeWidget->clear(); - if (textures.isEmpty() && fbos.isEmpty()) { - m_ui.surfacesTab->setDisabled(false); - } else { - m_ui.surfacesTreeWidget->setIconSize(QSize(THUMBNAIL_SIZE, THUMBNAIL_SIZE)); - addSurfaces(textures, "Textures"); - addSurfaces(fbos, "Framebuffers"); - m_ui.surfacesTab->setEnabled(true); - } + updateSurfacesView(state); m_ui.stateDock->show(); { @@ -1021,7 +1040,9 @@ void MainWindow::showSelectedSurface() return; } - ImageViewer *viewer = new ImageViewer(this); + ImageViewer *viewer = + new ImageViewer(this, m_ui.surfacesOpaqueCB->isChecked(), + m_ui.surfacesAlphaCB->isChecked()); QString title; if (selectedCall()) { @@ -1247,6 +1268,11 @@ void MainWindow::initConnections() m_profileDialog, SLOT(show())); connect(m_profileDialog, SIGNAL(jumpToCall(int)), this, SLOT(slotJumpTo(int))); + + connect(m_ui.surfacesOpaqueCB, SIGNAL(stateChanged(int)), this, + SLOT(updateSurfacesView())); + connect(m_ui.surfacesAlphaCB, SIGNAL(stateChanged(int)), this, + SLOT(updateSurfacesView())); } void MainWindow::initRetraceConnections() diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 1f1e5797..15b534cc 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -104,6 +104,7 @@ private slots: void slotFoundFrameEnd(ApiTraceFrame *frame); void slotJumpToResult(ApiTraceCall *call); void replayTrace(bool dumpState, bool dumpThumbnails); + void updateSurfacesView(); private: void initObjects(); @@ -113,6 +114,7 @@ private: void updateActionsState(bool traceLoaded, bool stopped = true); void newTraceFile(const QString &fileName); void trimEvent(); + void updateSurfacesView(const ApiTraceState &state); void fillStateForFrame(); /* there's a difference between selected frame/call and @@ -130,6 +132,7 @@ private: QString linkedAndroidTrace(const QString &localFile); void addSurface(const ApiTexture &image, QTreeWidgetItem *parent); void addSurface(const ApiFramebuffer &image, QTreeWidgetItem *parent); + void addSurface(const ApiSurface &surface, const QString &label, QTreeWidgetItem *parent); template <typename Surface> void addSurfaces(const QList<Surface> &images, const char *label); diff --git a/gui/ui/mainwindow.ui b/gui/ui/mainwindow.ui index 238920ad..1bc4c741 100644 --- a/gui/ui/mainwindow.ui +++ b/gui/ui/mainwindow.ui @@ -215,8 +215,22 @@ <attribute name="title"> <string>Surfaces</string> </attribute> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="1" column="0"> + <widget class="QCheckBox" name="surfacesOpaqueCB"> + <property name="text"> + <string>Opaque</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="surfacesAlphaCB"> + <property name="text"> + <string>Alpha</string> + </property> + </widget> + </item> + <item row="0" column="0" colspan="2"> <widget class="QTreeWidget" name="surfacesTreeWidget"> <column> <property name="text"> |