Skip to content

Commit

Permalink
Avoid to manipulate m_texture via pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Apr 5, 2024
1 parent a0a0ddb commit a0ef420
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
10 changes: 4 additions & 6 deletions src/waveform/renderers/allshader/waveformrendererpreroll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -54,7 +53,7 @@ void generateTexture(OpenGLTexture2D* pTexture,
painter.drawPath(path);
painter.end();

pTexture->setData(image);
return image;
}
} // anonymous namespace

Expand Down Expand Up @@ -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()) {
Expand Down
9 changes: 4 additions & 5 deletions src/waveform/renderers/allshader/waveformrendermark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

class TextureGraphics : public WaveformMark::Graphics {
public:
TextureGraphics() = default;

TextureGraphics(const QImage& image) {
m_texture.setData(image);
}
QOpenGLTexture* texture() {
return &m_texture;
}
Expand Down Expand Up @@ -321,8 +322,6 @@ void allshader::WaveformRenderMark::resizeGL(int, int) {
}

void allshader::WaveformRenderMark::updateMarkImage(WaveformMarkPointer pMark) {
auto pTextureGraphics = std::make_unique<TextureGraphics>();
pTextureGraphics->texture()->setData(
pMark->m_pGraphics = std::make_unique<TextureGraphics>(
pMark->generateImage(m_waveformRenderer->getDevicePixelRatio()));
pMark->m_pGraphics = std::move(pTextureGraphics);
}

0 comments on commit a0ef420

Please sign in to comment.