Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsgvivantevideomaterialshader.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 Pelagicore AG
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
7#include "private/qsgvideotexture_p.h"
8
10 mUScale(1),
11 mVScale(1),
12 mNewUVScale(true)
13{
14 setShaderFileName(VertexStage, QStringLiteral(":/imx6/shaders/rgba.vert.qsb"));
15 setShaderFileName(FragmentStage, QStringLiteral(":/imx6/shaders/rgba.frag.qsb"));
16}
17
19 QSGMaterial *oldMaterial)
20{
21 Q_UNUSED(oldMaterial);
22
23 bool changed = false;
24 QByteArray *buf = state.uniformData();
25
26 if (state.isMatrixDirty()) {
27 memcpy(buf->data(), state.combinedMatrix().constData(), 64);
28 changed = true;
29 }
30
31 if (state.isOpacityDirty()) {
32 auto m = static_cast<QSGVivanteVideoMaterial *>(newMaterial);
33 m->mOpacity = state.opacity();
34 memcpy(buf->data() + 64, &m->mOpacity, 4);
35 changed = true;
36 }
37
38 if (mNewUVScale) {
39 memcpy(buf->data() + 64 + 4, &mUScale, 4);
40 memcpy(buf->data() + 64 + 4 + 4, &mVScale, 4);
41 changed = true;
42 mNewUVScale = false;
43 }
44
45 return changed;
46}
47
49 QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
50{
51 Q_UNUSED(oldMaterial);
52
53 if (binding < 1)
54 return;
55
56 auto m = static_cast<QSGVivanteVideoMaterial *>(newMaterial);
57 if (!m->mTexture)
58 m->mTexture.reset(new QSGVideoTexture);
59
60 m->bind();
61 m->mTexture->setNativeObject(m->mCurrentTexture, m->mCurrentFrame.size());
62 m->mTexture->commitTextureOperations(state.rhi(), state.resourceUpdateBatch());
63 *texture = m->mTexture.data();
64}
65
66void QSGVivanteVideoMaterialShader::setUVScale(float uScale, float vScale)
67{
68 mUScale = uScale;
69 mVScale = vScale;
70 mNewUVScale = true;
71}
\inmodule QtCore
Definition qbytearray.h:57
Encapsulates the current rendering state during a call to QSGMaterialShader::updateUniformData() and ...
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.
Definition qsgmaterial.h:15
\inmodule QtQuick
Definition qsgtexture.h:20
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,...
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...
void setUVScale(float uScale, float vScale)
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
else opt state
[0]
const GLfloat * m
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLuint texture
#define QStringLiteral(str)
#define Q_UNUSED(x)