About
Contact
QtCreator
KDevelop
Solarized
1
// Copyright (C) 2024 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#include
"qvideoframetexturepool_p.h"
5
#include
"qvideotexturehelper_p.h"
6
7
#include <rhi/qrhi.h>
8
9
QT_BEGIN_NAMESPACE
10
11
void
QVideoFrameTexturePool
::
setCurrentFrame
(
QVideoFrame
frame
) {
12
m_texturesDirty
=
true
;
13
m_currentFrame
=
std::
move
(
frame
);
14
}
15
16
QVideoFrameTextures
*
QVideoFrameTexturePool
::
updateTextures
(
QRhi
&
rhi
,
QRhiResourceUpdateBatch
&
rub
) {
17
const
int
currentSlot
=
rhi
.
currentFrameSlot
();
18
Q_ASSERT
(
size_t
(
currentSlot
) <
MaxSlotsCount
);
19
20
m_texturesDirty
=
false
;
21
QVideoFrameTexturesUPtr
&
textures
=
m_textureSlots
[
currentSlot
];
22
Q_ASSERT
(!
m_oldTextures
);
23
m_oldTextures
=
std::
move
(
textures
);
24
textures
=
QVideoTextureHelper::
createTextures
(
frame:
m_currentFrame
,
rhi
,
rub
,
oldTextures&:
m_oldTextures
);
25
26
m_currentSlot
=
textures
?
currentSlot
:
std::
optional
<
int
>
{
};
27
28
return
textures
.
get
();
29
}
30
31
void
QVideoFrameTexturePool
::
onFrameEndInvoked
()
32
{
33
m_oldTextures
.
reset
();
34
if
(
m_currentSlot
&&
m_textureSlots
[
*
m_currentSlot
])
35
m_textureSlots
[
*
m_currentSlot
]
->
onFrameEndInvoked
();
36
}
37
38
void
QVideoFrameTexturePool
::
clearTextures
()
39
{
40
std::
fill
(
first:
std::
begin
(
cont&:
m_textureSlots
),
last:
std::
end
(
cont&:
m_textureSlots
),
value:
nullptr
);
41
m_currentSlot
.
reset
();
42
m_texturesDirty
=
m_currentFrame
.
isValid
();
43
}
44
45
QT_END_NAMESPACE
46