QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCVideoNodeItem.cc
Go to the documentation of this file.
1#include "QGCVideoNodeItem.h"
2
3#include <QtQuick/QQuickWindow>
4#include <rhi/qrhi.h>
5
6QGCVideoNodeItem::QGCVideoNodeItem(QQuickItem* parent) : QQuickItem(parent)
7{
8 setFlag(ItemHasContents, true);
9}
10
12
13void QGCVideoNodeItem::setCurrentTexture(QRhiTexture* texture, const QSize& frameSize,
14 QVideoFrameFormat::PixelFormat pixelFormat,
15 const QMatrix4x4& externalTextureMatrix)
16{
17 _pendingTexture = texture;
18 _frameSize = frameSize;
19 _pixelFormat = pixelFormat;
20 _externalTextureMatrix = externalTextureMatrix;
21 _dirty = true;
22 update();
23}
24
25QSGNode* QGCVideoNodeItem::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*)
26{
27 auto* node = static_cast<QGCVideoRenderNode*>(oldNode);
28 if (!node) {
29 node = new QGCVideoRenderNode;
30 }
31 if (_dirty) {
32 node->setFrame(_pendingTexture, _frameSize, _pixelFormat, _externalTextureMatrix);
33 _dirty = false;
34 }
35 node->markDirty(QSGNode::DirtyMaterial);
36 return node;
37}
38
40
42
43void QGCVideoRenderNode::setFrame(QRhiTexture* texture, const QSize& frameSize,
44 QVideoFrameFormat::PixelFormat pixelFormat,
45 const QMatrix4x4& externalTextureMatrix)
46{
47 _texture = texture;
48 _frameSize = frameSize;
49 _pixelFormat = pixelFormat;
50 _externalTextureMatrix = externalTextureMatrix;
51}
52
53QSGRenderNode::StateFlags QGCVideoRenderNode::changedStates() const
54{
55 return {BlendState, ScissorState, ViewportState};
56}
57
58QSGRenderNode::RenderingFlags QGCVideoRenderNode::flags() const
59{
60 return {BoundedRectRendering, OpaqueRendering};
61}
62
64{
65 return QRectF(QPointF(0, 0), QSizeF(_frameSize));
66}
67
71
72void QGCVideoRenderNode::render(const RenderState* /*state*/)
73{
74}
75
77{
78 _texture = nullptr;
79}
QSGNode * updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override
~QGCVideoNodeItem() override
QGCVideoNodeItem(QQuickItem *parent=nullptr)
void setCurrentTexture(QRhiTexture *texture, const QSize &frameSize, QVideoFrameFormat::PixelFormat pixelFormat, const QMatrix4x4 &externalTextureMatrix)
void prepare() override
void setFrame(QRhiTexture *texture, const QSize &frameSize, QVideoFrameFormat::PixelFormat pixelFormat, const QMatrix4x4 &externalTextureMatrix)
~QGCVideoRenderNode() override
QRectF rect() const override
StateFlags changedStates() const override
RenderingFlags flags() const override
void releaseResources() override
void render(const RenderState *state) override