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 textures = QVideoTextureHelper::createTextures(m_currentFrame, rhi, rub, std::move(textures));
23 m_currentSlot = textures ? currentSlot : std::optional<int>{};
24
25 return textures.get();
26}
27
28void QVideoFrameTexturePool::onFrameEndInvoked()
29{
30 if (m_currentSlot && m_textureSlots[*m_currentSlot])
31 m_textureSlots[*m_currentSlot]->onFrameEndInvoked();
32}
33
34void QVideoFrameTexturePool::clearTextures()
35{
36 std::fill(std::begin(m_textureSlots), std::end(m_textureSlots), nullptr);
37 m_currentSlot.reset();
38 m_texturesDirty = m_currentFrame.isValid();
39}
40
41QT_END_NAMESPACE
Combined button and popup list for selecting options.