From d82c1b5d05407a5ea8f29d23be316c84d4e1082e Mon Sep 17 00:00:00 2001 From: VaL Doroshchuk Date: Sat, 29 Aug 2020 15:20:03 +0200 Subject: Quick: Always create sg textures in ctor() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since compare() can be called before updateUniformData() Change-Id: I7a1e0a08926cbf6d5629468b8bf64dcd7602b399 Reviewed-by: Tor Arne Vestbø --- src/qtmultimediaquicktools/qsgvideonode_rgb.cpp | 3 +-- src/qtmultimediaquicktools/qsgvideonode_texture.cpp | 3 +-- src/qtmultimediaquicktools/qsgvideonode_yuv.cpp | 12 ++++-------- 3 files changed, 6 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp b/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp index 4b6d61f16..c9f27869c 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp +++ b/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp @@ -91,6 +91,7 @@ public: m_opacity(1.0) { setFlag(Blending, false); + m_texture.reset(new QSGVideoTexture); } QSGMaterialType *type() const override { @@ -159,8 +160,6 @@ void QSGVideoMaterialRhiShader_RGB::updateSampledImage(RenderState &state, int b return; auto m = static_cast(newMaterial); - if (!m->m_texture) - m->m_texture.reset(new QSGVideoTexture); m->m_frameMutex.lock(); auto frame = m->m_frame; diff --git a/src/qtmultimediaquicktools/qsgvideonode_texture.cpp b/src/qtmultimediaquicktools/qsgvideonode_texture.cpp index 33deef8c2..68e0d2d1a 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_texture.cpp +++ b/src/qtmultimediaquicktools/qsgvideonode_texture.cpp @@ -116,6 +116,7 @@ public: m_opacity(1.0) { setFlag(Blending, false); + m_texture.reset(new QSGVideoTexture); } ~QSGVideoMaterial_Texture() @@ -195,8 +196,6 @@ void QSGVideoMaterialRhiShader_Texture::updateSampledImage(RenderState &state, i return; auto m = static_cast(newMaterial); - if (!m->m_texture) - m->m_texture.reset(new QSGVideoTexture); m->m_frameMutex.lock(); auto size = m->m_frame.size(); diff --git a/src/qtmultimediaquicktools/qsgvideonode_yuv.cpp b/src/qtmultimediaquicktools/qsgvideonode_yuv.cpp index e825838ba..40eed8fbb 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_yuv.cpp +++ b/src/qtmultimediaquicktools/qsgvideonode_yuv.cpp @@ -231,11 +231,6 @@ bool QSGVideoMaterialRhiShader_YUV::updateUniformData(RenderState &state, QSGMat changed = true; } - if (!m->m_textures[0]) { - m->m_textures[0].reset(new QSGVideoTexture); - m->m_textures[1].reset(new QSGVideoTexture); - } - m->m_frameMutex.lock(); mapFrame(m); m->m_frameMutex.unlock(); @@ -294,9 +289,6 @@ void QSGVideoMaterialRhiShader_YUV_YV::mapFrame(QSGVideoMaterial_YUV *m) if (!m->m_frame.isValid() || !m->m_frame.map(QAbstractVideoBuffer::ReadOnly)) return; - if (!m->m_textures[2]) - m->m_textures[2].reset(new QSGVideoTexture); - int y = 0; int u = m->m_frame.pixelFormat() == QVideoFrame::Format_YV12 ? 2 : 1; int v = m->m_frame.pixelFormat() == QVideoFrame::Format_YV12 ? 1 : 2; @@ -341,6 +333,10 @@ QSGVideoMaterial_YUV::QSGVideoMaterial_YUV(const QVideoSurfaceFormat &format) : m_format(format), m_opacity(1.0) { + m_textures[0].reset(new QSGVideoTexture); + m_textures[1].reset(new QSGVideoTexture); + m_textures[2].reset(new QSGVideoTexture); + switch (format.yCbCrColorSpace()) { case QVideoSurfaceFormat::YCbCr_JPEG: m_colorMatrix = QMatrix4x4( -- cgit v1.2.1