QGraphicsFrameCapture : Add getters for frames names

Save captured frames names and add getters for them

Change-Id: I429e1512d6610ade9414f59fee3d081548cbb2ab
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
(cherry picked from commit 564efa3741ccd21b03d95a778e7a37d5bd902e53)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Hatem ElKharashy 2023-10-16 11:23:24 +03:00 committed by Qt Cherry-pick Bot
parent 83df3a8138
commit bf77adf1b0
5 changed files with 41 additions and 3 deletions

View File

@ -82,6 +82,22 @@ void QGraphicsFrameCapture::setCapturePrefix(const QString &prefix)
d->setCapturePrefix(prefix);
}
QString QGraphicsFrameCapture::capturedFileName()
{
if (!d.isNull())
return d->capturedFileName();
return QString();
}
QStringList QGraphicsFrameCapture::capturedFilesNames()
{
if (!d.isNull())
return d->capturedFilesNames();
return QStringList();
}
bool QGraphicsFrameCapture::isLoaded() const
{
if (!d.isNull())

View File

@ -39,6 +39,9 @@ public:
QString capturePrefix() const;
void setCapturePrefix(const QString &prefix);
QString capturedFileName();
QStringList capturedFilesNames();
bool isLoaded() const;
bool isCapturing() const;
void openCapture() const;

View File

@ -18,8 +18,7 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qstring.h>
#include <QtCore/qloggingcategory.h>
class QRhi;
#include <QtCore/qstringlist.h>
QT_BEGIN_NAMESPACE
@ -27,6 +26,7 @@ Q_DECLARE_LOGGING_CATEGORY(lcGraphicsFrameCapture)
class QRhi;
struct QRhiNativeHandles;
class QGraphicsFrameCapturePrivate
{
public:
@ -43,6 +43,12 @@ public:
QString capturePrefix() const { return m_capturePrefix; }
virtual void setCapturePrefix(const QString &prefix) { m_capturePrefix = prefix; }
virtual QString capturedFileName() const
{
return !m_capturedFilesNames.isEmpty() ? m_capturedFilesNames.last() : QString();
}
virtual QStringList capturedFilesNames() const { return m_capturedFilesNames; }
virtual bool initialized() const = 0;
virtual bool isCapturing() const = 0;
virtual void openCapture() = 0;
@ -53,6 +59,7 @@ protected:
void *m_nativeHandle = nullptr;
QString m_capturePath;
QString m_capturePrefix;
QStringList m_capturedFilesNames;
};
QT_END_NAMESPACE

View File

@ -111,6 +111,7 @@ void QGraphicsFrameCaptureMetal::endCaptureFrame()
}
[m_captureManager stopCapture];
m_capturedFilesNames.append(QString::fromNSString(m_traceURL.path));
frameNumber++;
}

View File

@ -213,7 +213,18 @@ void QGraphicsFrameCaptureRenderDoc::endCaptureFrame()
}
qCInfo(lcGraphicsFrameCapture) << "A frame capture is going to end.";
s_rdocApi->EndFrameCapture(m_nativeHandle, nullptr);
uint32_t result = s_rdocApi->EndFrameCapture(m_nativeHandle, nullptr);
if (result) {
uint32_t count = s_rdocApi->GetNumCaptures();
uint32_t pathLength = 0;
s_rdocApi->GetCapture(count - 1, nullptr, &pathLength, nullptr);
if (pathLength > 0) {
QVarLengthArray<char> name(pathLength, 0);
s_rdocApi->GetCapture(count - 1, name.data(), &pathLength, nullptr);
m_capturedFilesNames.append(QString::fromUtf8(name.data(), -1));
}
}
}
void QGraphicsFrameCaptureRenderDoc::updateCapturePathAndTemplate()