summaryrefslogtreecommitdiffstats
path: root/src/gui/util/qgraphicsframecapture.cpp
blob: 2ae59b64102f3cba70a537d312629876c676c3b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "qgraphicsframecapture_p.h"
#if defined (Q_OS_WIN) || defined(Q_OS_LINUX)
#include "qgraphicsframecapturerenderdoc_p_p.h"
#elif defined(Q_OS_MACOS) || defined(Q_OS_IOS)
#include "qgraphicsframecapturemetal_p_p.h"
#endif

#include <QtCore/qstandardpaths.h>
#include <QtCore/qcoreapplication.h>

QT_BEGIN_NAMESPACE

QGraphicsFrameCapturePrivate::QGraphicsFrameCapturePrivate()
    : m_capturePath(QStandardPaths::writableLocation(QStandardPaths::TempLocation) +
                    QStringLiteral("/") + QCoreApplication::applicationName() +
                    QStringLiteral("/captures")),
      m_capturePrefix(QCoreApplication::applicationName())
{

}

QGraphicsFrameCapture::QGraphicsFrameCapture()
{
#if defined (Q_OS_WIN) || defined(Q_OS_LINUX)
    d.reset(new QGraphicsFrameCaptureRenderDoc);
#elif defined(Q_OS_MACOS) || defined(Q_OS_IOS)
    d.reset(new QGraphicsFrameCaptureMetal);
#endif
}

QGraphicsFrameCapture::~QGraphicsFrameCapture()
{

}

void QGraphicsFrameCapture::setRhi(QRhi *rhi)
{
    if (!d.isNull())
        d->setRhi(rhi);
}

void QGraphicsFrameCapture::startCaptureFrame()
{
    if (!d.isNull())
        d->startCaptureFrame();
}

void QGraphicsFrameCapture::endCaptureFrame()
{
    if (!d.isNull())
        d->endCaptureFrame();
}

void QGraphicsFrameCapture::setCapturePath(const QString &path)
{
    if (!d.isNull())
        d->setCapturePath(path);
}

void QGraphicsFrameCapture::setCapturePrefix(const QString &prefix)
{
    if (!d.isNull())
        d->setCapturePrefix(prefix);
}

bool QGraphicsFrameCapture::isLoaded() const
{
    if (!d.isNull())
        return d->initialized();

    return false;
}

bool QGraphicsFrameCapture::isCapturing() const
{
    if (!d.isNull())
        return d->isCapturing();

    return false;
}

void QGraphicsFrameCapture::openCapture() const
{
    if (!d.isNull())
        d->openCapture();
}

QT_END_NAMESPACE