From 7912caa1155ccfafae6d5171f3256ef82a19d3ce Mon Sep 17 00:00:00 2001 From: Arnaud Bienner Date: Sun, 19 Feb 2012 21:43:55 +0100 Subject: [PATCH] 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. --- src/playlist/playlistview.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index 181cb4ef0..6366333cd 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -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_);