summaryrefslogtreecommitdiffstats
path: root/src/gui/util/qgraphicsframecapture.cpp
blob: e49fb83008acea7735e3e205920e0cb9147ebca6 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// 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)) && QT_CONFIG(library)
#include "qgraphicsframecapturerenderdoc_p_p.h"
#elif QT_CONFIG(metal)
#include "qgraphicsframecapturemetal_p_p.h"
#else
#include "qgraphicsframecapture_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)) && QT_CONFIG(library)
    d.reset(new QGraphicsFrameCaptureRenderDoc);
#elif QT_CONFIG(metal)
    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();
}

QString QGraphicsFrameCapture::capturePath() const
{
    if (!d.isNull())
        return d->capturePath();
    return QString();
}

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

QString QGraphicsFrameCapture::capturePrefix() const
{
    if (!d.isNull())
        return d->capturePrefix();
    return QString();
}

void QGraphicsFrameCapture::setCapturePrefix(const QString &prefix)
{
    if (!d.isNull())
        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())
        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