QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GstHwFrameTexturesBase Class Reference

#include <GstHwFrameTexturesBase.h>

Inheritance diagram for GstHwFrameTexturesBase:
Collaboration diagram for GstHwFrameTexturesBase:

Public Member Functions

 ~GstHwFrameTexturesBase () override
QRhiTexture * texture (uint plane) const override
bool allPlanesValid () const noexcept
 True when the bundle has planes and every one of them wrapped its native handle.
void setSourceSample (GstSample *s) noexcept
 Transfers a ref into the bundle. Caller must have a fresh ref.
template<class Handles>
bool matchesImport (const QRhi *rhi, QSize size, QVideoFrameFormat::PixelFormat pixelFormat, const Handles &handles) const noexcept

Static Public Member Functions

template<class FT>
static FT * reusableBundle (QVideoFrameTexturesUPtr &old)
template<class FT, class Reuse, class Make>
static QVideoFrameTexturesUPtr finishMap (GstHwVideoBuffer &source, QRhi &rhi, QVideoFrameTexturesUPtr &old, const GstHwMapTail &tail, Reuse &&reuse, Make &&make)

Protected Member Functions

template<class Handles>
void wrapPlanes (QRhi *rhi, QSize size, QVideoFrameFormat::PixelFormat pixelFormat, const Handles &handles, int layout=0, QRhiTexture::Flags flags={})

Protected Attributes

QRhi * _rhi = nullptr
int _count = 0
std::unique_ptr< QRhiTexture > _textures [GstHw::kMaxPlanes]
GstSample * _srcSample = nullptr

Detailed Description

Common base for per-platform FrameTextures : QVideoFrameTextures from *VideoBuffer::mapTextures(). Qt invokes onFrameEndInvoked() on the current bundle after every window frame and keeps sampling it until its pool slot is reused, so the source sample and every native resource must live until destruction — never release them from onFrameEndInvoked().

Definition at line 44 of file GstHwFrameTexturesBase.h.

Constructor & Destructor Documentation

◆ ~GstHwFrameTexturesBase()

GstHwFrameTexturesBase::~GstHwFrameTexturesBase ( )
inlineoverride

Definition at line 47 of file GstHwFrameTexturesBase.h.

References _srcSample.

Member Function Documentation

◆ allPlanesValid()

bool GstHwFrameTexturesBase::allPlanesValid ( ) const
inlinenoexcept

True when the bundle has planes and every one of them wrapped its native handle.

Definition at line 55 of file GstHwFrameTexturesBase.h.

References _count, and _textures.

Referenced by matchesImport().

◆ finishMap()

template<class FT, class Reuse, class Make>
QVideoFrameTexturesUPtr GstHwFrameTexturesBase::finishMap ( GstHwVideoBuffer & source,
QRhi & rhi,
QVideoFrameTexturesUPtr & old,
const GstHwMapTail & tail,
Reuse && reuse,
Make && make )
inlinestatic

Shared mapTextures() tail: hands source's sample to old when it is an FT bundle that reuse accepts (typically through matchesImport(); reuse may refresh per-frame state on it; pass nullptr for paths without reuse). Otherwise preflights the format, builds a bundle with make and keeps it only when every plane wrapped.

Definition at line 98 of file GstHwFrameTexturesBase.h.

References GstHwMapTail::diag, GstHwPathTelemetry::fail(), GstHwMapTail::frameSize, GstHwMapTail::log, GstHw::MapDiagnostics::loggedFirstSuccess, GstHw::MapDiagnostics::loggedTextureCreateFail, GstHwPathTelemetry::MapFailed, GstHwMapTail::path, GstHwMapTail::pixelFormat, GstHwMapTail::preflight, GstHwImportPreflight::preflightOrRecord(), QGC_HW_WARN_ONCE, GstHwPathTelemetry::record(), GstHwPathTelemetry::recordFallbackReason(), GstHwVideoBuffer::refSample(), reusableBundle(), GstHwMapTail::successTag, GstHwMapTail::textureFlags, and GstHwPathTelemetry::TextureReuse.

◆ matchesImport()

template<class Handles>
bool GstHwFrameTexturesBase::matchesImport ( const QRhi * rhi,
QSize size,
QVideoFrameFormat::PixelFormat pixelFormat,
const Handles & handles ) const
inlinenoexcept

True when this bundle wrapped handles for the same QRhi, size and format and every plane wrapped: its QRhiTexture views then sample a recycled native resource's new contents unchanged.

Definition at line 70 of file GstHwFrameTexturesBase.h.

References _count, _rhi, and allPlanesValid().

◆ reusableBundle()

template<class FT>
FT * GstHwFrameTexturesBase::reusableBundle ( QVideoFrameTexturesUPtr & old)
inlinestatic

old as an FT bundle, else nullptr. Each path's bundle type is distinct, and Qt's texture pool can also pass CPU-fallback or Qt-owned bundles here.

Definition at line 88 of file GstHwFrameTexturesBase.h.

Referenced by finishMap().

◆ setSourceSample()

void GstHwFrameTexturesBase::setSourceSample ( GstSample * s)
inlinenoexcept

Transfers a ref into the bundle. Caller must have a fresh ref.

Definition at line 61 of file GstHwFrameTexturesBase.h.

References _srcSample.

◆ texture()

QRhiTexture * GstHwFrameTexturesBase::texture ( uint plane) const
inlineoverride

Definition at line 49 of file GstHwFrameTexturesBase.h.

References _count, and _textures.

◆ wrapPlanes()

template<class Handles>
void GstHwFrameTexturesBase::wrapPlanes ( QRhi * rhi,
QSize size,
QVideoFrameFormat::PixelFormat pixelFormat,
const Handles & handles,
int layout = 0,
QRhiTexture::Flags flags = {} )
inlineprotected

Wraps one native handle per plane (GL name, VkImage, ID3D1x resource, MTLTexture) as a QRhiTexture and records the import for matchesImport(). Fallback formats are disabled: a substituted format would misread the native layout. Planes QRhi rejects stay null, as do zero handles (a plane the source never produced), whatever the QRhi backend's createFrom() accepts.

Definition at line 135 of file GstHwFrameTexturesBase.h.

Member Data Documentation

◆ _count

int GstHwFrameTexturesBase::_count = 0
protected

Definition at line 164 of file GstHwFrameTexturesBase.h.

Referenced by allPlanesValid(), matchesImport(), and texture().

◆ _rhi

QRhi* GstHwFrameTexturesBase::_rhi = nullptr
protected

Definition at line 163 of file GstHwFrameTexturesBase.h.

Referenced by matchesImport().

◆ _srcSample

GstSample* GstHwFrameTexturesBase::_srcSample = nullptr
protected

Definition at line 166 of file GstHwFrameTexturesBase.h.

Referenced by setSourceSample(), and ~GstHwFrameTexturesBase().

◆ _textures

std::unique_ptr<QRhiTexture> GstHwFrameTexturesBase::_textures[GstHw::kMaxPlanes]
protected

Definition at line 165 of file GstHwFrameTexturesBase.h.

Referenced by allPlanesValid(), and texture().


The documentation for this class was generated from the following file: