5#include "private/qmultimediautils_p.h"
6#include <QtQuick/qsgmaterial.h>
8#include <QtMultimedia/private/qvideotexturehelper_p.h>
9#include <private/qsginternaltextnode_p.h>
10#include <private/qquickitem_p.h>
11#include <private/qquickvideooutput_p.h>
12#include <private/qabstractvideobuffer_p.h>
89 diff =
m_textures[1].comparisonKey() -
m->m_textures[1].comparisonKey();
91 diff =
m_textures[2].comparisonKey() -
m->m_textures[2].comparisonKey();
93 return diff < 0 ? -1 : (diff > 0 ? 1 : 0);
146 for (
int plane = 0; plane < 3; ++plane)
159 if (!
state.isMatrixDirty() && !
state.isOpacityDirty())
162 if (
state.isOpacityDirty()) {
170 m->updateTextures(
state.rhi(),
state.resourceUpdateBatch());
175 maxNits = 100 *
m_hdrInfo.
limits.colorComponentValue.maxColorComponentValue;
181 m->m_currentFrame,
state.combinedMatrix(),
state.opacity(), maxNits);
191 if (binding < 1 || binding > 3)
199 : m_videoFormat(videoFormat)
205 : m_parent(parent), m_videoFormat(videoFormat)
215 delete m_subtitleTextNode;
222 updateSubtitle(
frame);
239 QSize subtitleFrameSize = m_rect.
size().toSize();
240 if (subtitleFrameSize.isEmpty())
245 if (!m_subtitleLayout.
update(subtitleFrameSize,
frame.subtitleText()))
248 delete m_subtitleTextNode;
249 m_subtitleTextNode =
nullptr;
250 if (
frame.subtitleText().isEmpty())
255 m_subtitleTextNode = parent_d->sceneGraphContext()->createInternalTextNode(parent_d->sceneGraphRenderContext());
262 setSubtitleGeometry();
265void QSGVideoNode::setSubtitleGeometry()
267 if (!m_subtitleTextNode)
273 float rotate = -1.f * m_orientation;
274 float yTranslate = 0;
275 float xTranslate = 0;
276 if (m_orientation == 90) {
277 yTranslate = m_rect.
height();
278 }
else if (m_orientation == 180) {
279 yTranslate = m_rect.
height();
280 xTranslate = m_rect.
width();
281 }
else if (m_orientation == 270) {
282 xTranslate = m_rect.
width();
296 const auto currentFrameOrientation = m_material ?
static_cast<int>(m_material->
m_currentFrame.
rotation()) : 0;
297 bool frameChanged =
false;
299 if (currentFrameOrientation != m_frameOrientation
304 if (
rect == m_rect && textureRect == m_textureRect && orientation == m_orientation
309 m_textureRect = textureRect;
310 m_orientation = orientation;
312 m_frameOrientation = currentFrameOrientation;
315 const int videoRotation = (orientation + currentFrameOrientation) % 360;
331 switch (videoRotation) {
334 qSetTex(
v + 0, textureRect.topLeft());
335 qSetTex(
v + 1, textureRect.bottomLeft());
336 qSetTex(
v + 2, textureRect.topRight());
337 qSetTex(
v + 3, textureRect.bottomRight());
342 qSetTex(
v + 0, textureRect.bottomLeft());
343 qSetTex(
v + 1, textureRect.bottomRight());
344 qSetTex(
v + 2, textureRect.topLeft());
345 qSetTex(
v + 3, textureRect.topRight());
350 qSetTex(
v + 0, textureRect.bottomRight());
351 qSetTex(
v + 1, textureRect.topRight());
352 qSetTex(
v + 2, textureRect.bottomLeft());
353 qSetTex(
v + 3, textureRect.topLeft());
358 qSetTex(
v + 0, textureRect.topRight());
359 qSetTex(
v + 1, textureRect.topLeft());
360 qSetTex(
v + 2, textureRect.bottomRight());
361 qSetTex(
v + 3, textureRect.bottomLeft());
375 setSubtitleGeometry();
The QColor class provides colors based on RGB, HSV or CMYK values.
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
void translate(const QVector3D &vector)
Multiplies this matrix by another that translates coordinates by the components of vector.
\inmodule QtCore\reentrant
static QQuickItemPrivate * get(QQuickItem *item)
Render video or camera viewfinder.
\inmodule QtCore\reentrant
constexpr qreal y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr qreal x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr QSizeF size() const noexcept
Returns the size of the rectangle.
Format
Describes the swapchain format.
@ HDRExtendedDisplayP3Linear
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
int resourceLimit(ResourceLimit limit) const
int currentFrameSlot() const
const QSGGeometry * geometry() const
Returns this node's geometry.
void setGeometry(QSGGeometry *geometry)
Sets the geometry of this node to geometry.
void setMaterial(QSGMaterial *material)
Sets the material of this geometry node to material.
The QSGGeometry class provides low-level storage for graphics primitives in the \l{Qt Quick Scene Gra...
static const AttributeSet & defaultAttributes_TexturedPoint2D()
Convenience function which returns attributes to be used for textured 2D drawing.
void setColor(QColor color) override
Sets the main color to use when rendering the text to color.
void addRectangleNode(const QRectF &rect, const QColor &color)
Encapsulates the current rendering state during a call to QSGMaterialShader::updateUniformData() and ...
The QSGMaterialShader class represents a graphics API independent shader program.
void setShaderFileName(Stage stage, const QString &filename)
Sets the filename for the shader for the specified stage.
The QSGMaterial class encapsulates rendering state for a shader program.
void setFlag(Flags flags, bool on=true)
Sets the flags flags on this material if on is true; otherwise clears the attribute.
void appendChildNode(QSGNode *node)
Appends node to this node's list of children.
void markDirty(DirtyState bits)
Notifies all connected renderers that the node has dirty bits.
void setFlag(Flag, bool=true)
Sets the flag f on this node if enabled is true; otherwise clears the flag.
RenderMode
\value RenderMode2D Normal 2D rendering \value RenderMode2DNoDepthBuffer Normal 2D rendering with dep...
void addTextLayout(QPointF position, QTextLayout *layout, int selectionStart=-1, int selectionCount=-1, int lineStart=0, int lineCount=-1)
Adds the contents of layout to the text node at position.
QVideoFrameFormat m_videoFormat
QRhiSwapChainHdrInfo m_hdrInfo
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
QRhiSwapChain::Format m_surfaceFormat
void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to prepare use of sampled images in the shader,...
QSGVideoMaterialRhiShader(const QVideoFrameFormat &videoFormat, const QRhiSwapChain::Format surfaceFormat, const QRhiSwapChainHdrInfo &hdrInfo)
QVideoFrame m_videoFrameSlots[NVideoFrameSlots]
QSGVideoMaterial(const QVideoFrameFormat &videoFormat)
QVideoFrame m_currentFrame
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
QSGMaterialType * type() const override
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
void updateTextures(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
void setHdrInfo(const QRhiSwapChainHdrInfo &hdrInfo)
void setCurrentFrame(const QVideoFrame &frame)
int compare(const QSGMaterial *other) const override
Compares this material to other and returns 0 if they are equal; -1 if this material should sort befo...
QRhiSwapChainHdrInfo m_hdrInfo
void setSurfaceFormat(const QRhiSwapChain::Format surfaceFormat)
std::unique_ptr< QVideoFrameTextures > m_videoFrameTextures
std::array< QSGVideoTexture, 3 > m_textures
QRhiSwapChain::Format m_surfaceFormat
QVideoFrameFormat m_videoFormat
void setHdrInfo(const QRhiSwapChainHdrInfo &hdrInfo)
void setTexturedRectGeometry(const QRectF &boundingRect, const QRectF &textureRect, int orientation)
void setSurfaceFormat(const QRhiSwapChain::Format surfaceFormat)
QSGVideoNode(QQuickVideoOutput *parent, const QVideoFrameFormat &videoFormat)
void setCurrentFrame(const QVideoFrame &frame)
The QVideoFrame class represents a frame of video data.
QtVideo::Rotation rotation() const
Returns the angle the frame should be rotated clockwise before displaying.
bool mirrored() const
Returns whether the frame should be mirrored before displaying.
QVector3D Q_QUICK3DUTILS_EXPORT rotate(const QMatrix4x4 &m, const QVector3D &v)
Combined button and popup list for selecting options.
QString vertexShaderFileName(const QVideoFrameFormat &format)
QString fragmentShaderFileName(const QVideoFrameFormat &format, QRhiSwapChain::Format surfaceFormat)
std::unique_ptr< QVideoFrameTextures > createTextures(QVideoFrame &frame, QRhi *rhi, QRhiResourceUpdateBatch *rub, std::unique_ptr< QVideoFrameTextures > &&oldTextures)
void updateUniformData(QByteArray *dst, const QVideoFrameFormat &format, const QVideoFrame &frame, const QMatrix4x4 &transform, float opacity, float maxNits)
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
GLsizei const GLfloat * v
[13]
GLuint GLenum GLenum transform
static void qSetTex(QSGGeometry::TexturedPoint2D *v, const QPointF &p)
static QT_BEGIN_NAMESPACE void qSetGeom(QSGGeometry::TexturedPoint2D *v, const QPointF &p)
static void qSwapTex(QSGGeometry::TexturedPoint2D *v0, QSGGeometry::TexturedPoint2D *v1)
union QRhiSwapChainHdrInfo::@295 limits
The QSGGeometry::TexturedPoint2D struct is a convenience struct for accessing 2D Points with texture ...
The QSGMaterialType class is used as a unique type token in combination with QSGMaterial.
bool update(const QSize &frameSize, QString text)