summaryrefslogtreecommitdiffstats
path: root/src/qtmultimediaquicktools/qsgvideonode_texture.cpp
diff options
context:
space:
mode:
authorVaL Doroshchuk <valentyn.doroshchuk@qt.io>2017-12-19 10:42:39 +0100
committerVaL Doroshchuk <valentyn.doroshchuk@qt.io>2017-12-22 09:59:45 +0000
commit4a6f459d193b621a77e002944eb28e4e96f2e2c7 (patch)
treed63109c7eafeb3b21e7ef78f1864d82743d6debb /src/qtmultimediaquicktools/qsgvideonode_texture.cpp
parentbfebd23f150fa660177fff6aa372ae46e42038c3 (diff)
QML: Use alpha channel for ARGB32 video frames
Added a fix to use alpha channel for ARGB32 video frames. Previously alpha component was always ignored and used 1.0 instead. To see transparent videos it is still needed to enable blending by adjusting an opacity property of qml element. Task-number: QTBUG-43098 Change-Id: If3aaf8ab695021b3a49a1790d900366e9c336b33 Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'src/qtmultimediaquicktools/qsgvideonode_texture.cpp')
-rw-r--r--src/qtmultimediaquicktools/qsgvideonode_texture.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/qtmultimediaquicktools/qsgvideonode_texture.cpp b/src/qtmultimediaquicktools/qsgvideonode_texture.cpp
index a26d59532..f5545afc7 100644
--- a/src/qtmultimediaquicktools/qsgvideonode_texture.cpp
+++ b/src/qtmultimediaquicktools/qsgvideonode_texture.cpp
@@ -108,11 +108,19 @@ protected:
class QSGVideoMaterialShader_Texture_swizzle : public QSGVideoMaterialShader_Texture
{
public:
- QSGVideoMaterialShader_Texture_swizzle()
- : QSGVideoMaterialShader_Texture()
+ QSGVideoMaterialShader_Texture_swizzle(bool hasAlpha)
+ : m_hasAlpha(hasAlpha)
{
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qtmultimediaquicktools/shaders/rgbvideo_swizzle.frag"));
}
+
+protected:
+ void initialize() override {
+ QSGVideoMaterialShader_Texture::initialize();
+ program()->setUniformValue(program()->uniformLocation("hasAlpha"), GLboolean(m_hasAlpha));
+ }
+
+ int m_hasAlpha;
};
@@ -138,7 +146,8 @@ public:
}
QSGMaterialShader *createShader() const override {
- return needsSwizzling() ? new QSGVideoMaterialShader_Texture_swizzle
+ const bool hasAlpha = m_format.pixelFormat() == QVideoFrame::Format_ARGB32;
+ return needsSwizzling() ? new QSGVideoMaterialShader_Texture_swizzle(hasAlpha)
: new QSGVideoMaterialShader_Texture;
}