QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GstGlFrameTextures.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QSize>
4#include <QtGui/qopengl.h>
5#include <QtMultimedia/QVideoFrameFormat>
6#include <array>
7#include <private/qvideotexturehelper_p.h>
8#include <rhi/qrhi.h>
9
11#include "GstHwVideoBuffer.h"
12
15{
16public:
17 using FallbackPolicy = QVideoTextureHelper::TextureDescription::FallbackPolicy;
18
19 GstGlFrameTextures(QRhi* rhi, QSize size, QVideoFrameFormat::PixelFormat pixelFormat,
20 std::array<GLuint, GstHw::kMaxPlanes> names, int count,
21 FallbackPolicy fallback = FallbackPolicy::Enable)
22 : _rhi(rhi), _size(size), _pixelFormat(pixelFormat), _names(names)
23 {
24 _count = count;
25 const auto* desc = QVideoTextureHelper::textureDescription(pixelFormat);
26 if (!desc)
27 return;
28 for (int i = 0; i < _count; ++i) {
29 // GL_NONE (0) is silently accepted by createFrom but samples as black; gst-gl can hand us 0 if a plane
30 // wasn't uploaded yet.
31 if (_names[i] == 0)
32 continue;
33 const QSize planeSize = desc->rhiPlaneSize(size, i, rhi);
34 _textures[i].reset(rhi->newTexture(desc->rhiTextureFormat(i, rhi, fallback), planeSize, 1, {}));
35 if (_textures[i] && !_textures[i]->createFrom({_names[i], 0})) {
36 _textures[i].reset();
37 }
38 }
39 }
40
41protected:
42 QRhi* _rhi = nullptr;
43 QSize _size;
44 QVideoFrameFormat::PixelFormat _pixelFormat = QVideoFrameFormat::Format_Invalid;
45 std::array<GLuint, GstHw::kMaxPlanes> _names{};
46};
Shared base for GL-texture-backed QVideoFrameTextures wrappers (GLMemory and DMABuf-via-EGLImage).
std::array< GLuint, GstHw::kMaxPlanes > _names
GstGlFrameTextures(QRhi *rhi, QSize size, QVideoFrameFormat::PixelFormat pixelFormat, std::array< GLuint, GstHw::kMaxPlanes > names, int count, FallbackPolicy fallback=FallbackPolicy::Enable)
QVideoTextureHelper::TextureDescription::FallbackPolicy FallbackPolicy
QVideoFrameFormat::PixelFormat _pixelFormat
Common base for per-platform FrameTextures : QVideoFrameTextures from *VideoBuffer::mapTextures().
std::unique_ptr< QRhiTexture > _textures[GstHw::kMaxPlanes]