Do not use QPainter::setOpacity because, as explained in http://techbase.kde.org/Development/Tutorials/Graphics/Performance#QPainter::setOpacity.28.29 this deactivate hardware acceleration and make Clementine use 100% CPU when using a custom image as background.

This commit is contained in:
Arnaud Bienner 2012-02-19 21:43:55 +01:00
parent b32444dce7
commit 7912caa115
1 changed files with 12 additions and 1 deletions

View File

@ -801,10 +801,21 @@ void PlaylistView::paintEvent(QPaintEvent* event) {
width(), height(),
Qt::KeepAspectRatioByExpanding,
Qt::SmoothTransformation);
QPixmap temp(cached_scaled_background_image_.size());
temp.fill(Qt::transparent);
QPainter p(&temp);
p.setCompositionMode(QPainter::CompositionMode_Source);
p.drawPixmap(0, 0, cached_scaled_background_image_);
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
p.fillRect(temp.rect(), QColor(0, 0, 0, 127*kBackgroundOpacity));
p.end();
cached_scaled_background_image_ = temp;
last_height_ = height();
last_width_ = width();
}
background_painter.setOpacity(kBackgroundOpacity);
background_painter.drawPixmap((width() - cached_scaled_background_image_.width()) / 2,
(height() - cached_scaled_background_image_.height()) / 2,
cached_scaled_background_image_);