Skip to content

Commit

Permalink
Attemp to remove garbage rendering on large samples
Browse files Browse the repository at this point in the history
  • Loading branch information
khoidauminh committed Feb 7, 2025
1 parent 2984f82 commit b016de8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions include/SampleClipView.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#ifndef LMMS_GUI_SAMPLE_CLIP_VIEW_H
#define LMMS_GUI_SAMPLE_CLIP_VIEW_H

#include <qpoint.h>
#include "ClipView.h"

#include "SampleThumbnail.h"
Expand Down Expand Up @@ -67,6 +68,7 @@ public slots:
SampleClip * m_clip;
SampleThumbnail m_sampleThumbnail;
QPixmap m_paintPixmap;
QPoint m_paintPixmapPosition;
bool splitClip( const TimePos pos ) override;
} ;

Expand Down
16 changes: 9 additions & 7 deletions src/gui/clips/SampleClipView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ namespace lmms::gui
SampleClipView::SampleClipView( SampleClip * _clip, TrackView * _tv ) :
ClipView( _clip, _tv ),
m_clip( _clip ),
m_paintPixmap()
m_paintPixmap(),
m_paintPixmapPosition()
{
// update UI and tooltip
updateSample();
Expand Down Expand Up @@ -210,15 +211,15 @@ void SampleClipView::paintEvent( QPaintEvent * pe )

if( !needsUpdate() )
{
painter.drawPixmap( 0, 0, m_paintPixmap );
painter.drawPixmap(m_paintPixmapPosition, m_paintPixmap);
return;
}

setNeedsUpdate( false );

if (m_paintPixmap.isNull() || m_paintPixmap.size() != size())
{
m_paintPixmap = QPixmap(size());
m_paintPixmap = QPixmap(pe->rect().size());
}

QPainter p( &m_paintPixmap );
Expand Down Expand Up @@ -277,9 +278,8 @@ void SampleClipView::paintEvent( QPaintEvent * pe )
if (sample.sampleSize() > 0)
{
const auto param = SampleThumbnail::VisualizeParameters{
.sampleRect = QRect(offsetStart, spacing, sampleLength, height() - spacing),
.drawRect = QRect(0, spacing, width(), height() - spacing),
.viewportRect = pe->rect(),
.sampleRect = QRect(offsetStart-pe->rect().x(), spacing, sampleLength, height() - spacing),
.viewportRect = QRect(0, 0, pe->rect().width(), pe->rect().height()),
.amplification = sample.amplification(),
.reversed = sample.reversed()
};
Expand Down Expand Up @@ -331,8 +331,10 @@ void SampleClipView::paintEvent( QPaintEvent * pe )
}*/

p.end();

m_paintPixmapPosition = pe->rect().topLeft();

painter.drawPixmap( 0, 0, m_paintPixmap );
painter.drawPixmap(m_paintPixmapPosition.x(), 0, m_paintPixmap);
}


Expand Down

0 comments on commit b016de8

Please sign in to comment.