Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qvideoframetexturepool.cpp
Go to the documentation of this file.
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
6
7#include <rhi/qrhi.h>
8
10
11void QVideoFrameTexturePool::setCurrentFrame(QVideoFrame frame) {
12 m_texturesDirty = true;
13 m_currentFrame = std::move(frame);
14}
15
16QVideoFrameTextures* 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(m_currentFrame, rhi, rub, m_oldTextures);
25
26 m_currentSlot = textures ? currentSlot : std::optional<int>{};
27
28 return textures.get();
29}
30
31void QVideoFrameTexturePool::onFrameEndInvoked()
32{
33 m_oldTextures.reset();
34 if (m_currentSlot && m_textureSlots[*m_currentSlot])
35 m_textureSlots[*m_currentSlot]->onFrameEndInvoked();
36}
37
38void QVideoFrameTexturePool::clearTextures()
39{
40 std::fill(std::begin(m_textureSlots), std::end(m_textureSlots), nullptr);
41 m_currentSlot.reset();
42 m_texturesDirty = m_currentFrame.isValid();
43}
44
45QT_END_NAMESPACE