From e5bdf9a244c6e1ec0fc419f3c7b9fdb1e5dd8346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 5 Apr 2024 07:43:00 +0200 Subject: [PATCH] Avoid to manipulate m_texture via pointer --- .../renderers/allshader/waveformrendererpreroll.cpp | 10 ++++------ .../renderers/allshader/waveformrendermark.cpp | 11 +++++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/waveform/renderers/allshader/waveformrendererpreroll.cpp b/src/waveform/renderers/allshader/waveformrendererpreroll.cpp index b28d4cc353bd..89c657a156ac 100644 --- a/src/waveform/renderers/allshader/waveformrendererpreroll.cpp +++ b/src/waveform/renderers/allshader/waveformrendererpreroll.cpp @@ -11,8 +11,7 @@ #include "widget/wskincolor.h" namespace { -void generateTexture(OpenGLTexture2D* pTexture, - float markerLength, +QImage drawPrerollImage(float markerLength, float markerBreadth, float devicePixelRatio, QColor color) { @@ -54,7 +53,7 @@ void generateTexture(OpenGLTexture2D* pTexture, painter.drawPath(path); painter.end(); - pTexture->setData(image); + return image; } } // anonymous namespace @@ -120,11 +119,10 @@ void WaveformRendererPreroll::paintGL() { // has changed size last time. m_markerLength = markerLength; m_markerBreadth = markerBreadth; - generateTexture(&m_texture, - m_markerLength, + m_texture.setData(drawPrerollImage(m_markerLength, m_markerBreadth, m_waveformRenderer->getDevicePixelRatio(), - m_color); + m_color)); } if (!m_texture.isStorageAllocated()) { diff --git a/src/waveform/renderers/allshader/waveformrendermark.cpp b/src/waveform/renderers/allshader/waveformrendermark.cpp index bc98b5edf886..52c1346b9e9e 100644 --- a/src/waveform/renderers/allshader/waveformrendermark.cpp +++ b/src/waveform/renderers/allshader/waveformrendermark.cpp @@ -20,9 +20,10 @@ class TextureGraphics : public WaveformMark::Graphics { public: - TextureGraphics() = default; - - QOpenGLTexture* texture() { + TextureGraphics(const QImage& image) { + m_texture.setData(image); + } + QOpenGLTexture* texture() const { return &m_texture; } @@ -321,8 +322,6 @@ void allshader::WaveformRenderMark::resizeGL(int, int) { } void allshader::WaveformRenderMark::updateMarkImage(WaveformMarkPointer pMark) { - auto pTextureGraphics = std::make_unique(); - pTextureGraphics->texture()->setData( + pMark->m_pGraphics = std::make_unique( pMark->generateImage(m_waveformRenderer->getDevicePixelRatio())); - pMark->m_pGraphics = std::move(pTextureGraphics); }