diff options
author | Liang Qi <liang.qi@qt.io> | 2018-01-06 20:21:19 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-01-06 20:21:19 +0100 |
commit | 82621148de82d63a562163a72598e15ed98797a8 (patch) | |
tree | 030d345ad4a4ae612995949bbbeec66b36e69854 /src/qtmultimediaquicktools | |
parent | 2fc515ea1eaa0f7ffb56c4dadee560095c3374bd (diff) | |
parent | 7a3b8907060123fe5d487d4c9ba3a1e222f468bb (diff) |
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts:
.qmake.conf
Change-Id: I5acdc7e0bd3729b80522dfff0f388cf2507fb111
Diffstat (limited to 'src/qtmultimediaquicktools')
4 files changed, 29 insertions, 9 deletions
diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp index 7030b3357..c51aec088 100644 --- a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp +++ b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp @@ -382,9 +382,9 @@ QAbstractVideoSurface *QDeclarativeVideoRendererBackend::videoSurface() const QRectF QDeclarativeVideoRendererBackend::adjustedViewport() const { const QRectF viewport = m_surface->surfaceFormat().viewport(); - const QSize pixelAspectRatio = m_surface->surfaceFormat().pixelAspectRatio(); + const QSizeF pixelAspectRatio = m_surface->surfaceFormat().pixelAspectRatio(); - if (pixelAspectRatio.height() != 0) { + if (pixelAspectRatio.isValid()) { const qreal ratio = pixelAspectRatio.width() / pixelAspectRatio.height(); QRectF result = viewport; result.setX(result.x() * ratio); diff --git a/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp b/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp index 0dfa11ab9..d039e1e0b 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp +++ b/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp @@ -113,11 +113,19 @@ protected: class QSGVideoMaterialShader_RGB_swizzle : public QSGVideoMaterialShader_RGB { public: - QSGVideoMaterialShader_RGB_swizzle() - : QSGVideoMaterialShader_RGB() + QSGVideoMaterialShader_RGB_swizzle(bool hasAlpha) + : m_hasAlpha(hasAlpha) { setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qtmultimediaquicktools/shaders/rgbvideo_swizzle.frag")); } + +protected: + void initialize() override { + QSGVideoMaterialShader_RGB::initialize(); + program()->setUniformValue(program()->uniformLocation("hasAlpha"), GLboolean(m_hasAlpha)); + } + + bool m_hasAlpha; }; @@ -145,7 +153,8 @@ public: } QSGMaterialShader *createShader() const override { - return needsSwizzling() ? new QSGVideoMaterialShader_RGB_swizzle + const bool hasAlpha = m_format.pixelFormat() == QVideoFrame::Format_ARGB32; + return needsSwizzling() ? new QSGVideoMaterialShader_RGB_swizzle(hasAlpha) : new QSGVideoMaterialShader_RGB; } 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; } diff --git a/src/qtmultimediaquicktools/shaders/rgbvideo_swizzle.frag b/src/qtmultimediaquicktools/shaders/rgbvideo_swizzle.frag index f01dc86a0..df66bde63 100644 --- a/src/qtmultimediaquicktools/shaders/rgbvideo_swizzle.frag +++ b/src/qtmultimediaquicktools/shaders/rgbvideo_swizzle.frag @@ -1,8 +1,10 @@ uniform sampler2D rgbTexture; uniform lowp float opacity; varying highp vec2 qt_TexCoord; +uniform bool hasAlpha; void main() { - gl_FragColor = vec4(texture2D(rgbTexture, qt_TexCoord).bgr, 1.0) * opacity; + vec4 v = texture2D(rgbTexture, qt_TexCoord); + gl_FragColor = vec4(v.bgr, hasAlpha ? v.a : 1.0) * opacity; } |