Skip to content

Commit

Permalink
refactor: optimization background
Browse files Browse the repository at this point in the history
Change-Id: I3e2303eab2705e91fe4169b4972bf4e12a1ecff7
  • Loading branch information
haruyukilxz committed Sep 12, 2018
1 parent 4c77610 commit 146148c
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions widgets/fullscreenbackground.cpp
Expand Up @@ -240,19 +240,15 @@ const QScreen *FullscreenBackground::screenForGeometry(const QRect &rect) const

const QPixmap FullscreenBackground::pixmapHandle(const QPixmap &pixmap, const QScreen *screen)
{
QPixmap pix = pixmap.scaled(screen->size(),
const QSize trueSize { screen->size() * screen->devicePixelRatio() };
QPixmap pix = pixmap.scaled(trueSize,
Qt::KeepAspectRatioByExpanding,
Qt::SmoothTransformation);

pix = pix.copy(QRect((pix.width() - screen->size().width()) / 2,
(pix.height() - screen->size().height()) / 2,
screen->size().width(),
screen->size().height()));

// s->size() is scaled value, Avoid losing information after zooming
pix = pix.scaled(screen->size() * screen->devicePixelRatio(),
Qt::KeepAspectRatioByExpanding,
Qt::SmoothTransformation);
pix = pix.copy(QRect((pix.width() - trueSize.width()) / 2,
(pix.height() - trueSize.height()) / 2,
trueSize.width(),
trueSize.height()));

// draw pix to widget, so pix need set pixel ratio from qwidget devicepixelratioF
pix.setDevicePixelRatio(devicePixelRatioF());
Expand Down

0 comments on commit 146148c

Please sign in to comment.