From 804d0bd42a23488a6bbd8090ee2590871ddeb64e Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Mon, 9 Apr 2018 22:58:37 +0100 Subject: [PATCH] Fix rubber band selection drawing contents misaligned with scaling Summary: in drawPixmap(source, sourceRect) the source rect is in native pixels. In this code the size was scaled by the DPR, but the location was not. blendRect is the contents of a selection rectangle, offset from the bounding darker blue rectangle. Hence we haven't really noticed. This completely fixes the rectangle when the scale == 2.0/3.0 Some smaller artifacts remain on fractional scale factors, which is a separate code bug with the same symptoms. CCBUG: 386111 Reviewers: aacid, rkflx Reviewed By: rkflx Subscribers: sander, rkflx, anthonyfieroni, #okular Tags: #okular Differential Revision: https://phabricator.kde.org/D8980 --- ui/pageview.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/pageview.cpp b/ui/pageview.cpp index 87aed00cd..50179167f 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -1746,8 +1746,9 @@ void PageView::paintEvent(QPaintEvent *pe) QPixmap blendedPixmap( blendRect.width() * devicePixelRatioF(), blendRect.height() * devicePixelRatioF() ); blendedPixmap.setDevicePixelRatio(devicePixelRatioF()); QPainter p( &blendedPixmap ); + p.drawPixmap( 0, 0, doubleBuffer, - blendRect.left() - contentsRect.left(), blendRect.top() - contentsRect.top(), + (blendRect.left() - contentsRect.left()) * devicePixelRatioF(), (blendRect.top() - contentsRect.top()) * devicePixelRatioF(), blendRect.width() * devicePixelRatioF(), blendRect.height() * devicePixelRatioF() ); QColor blCol = selBlendColor.dark( 140 ); @@ -1779,7 +1780,7 @@ void PageView::paintEvent(QPaintEvent *pe) blendedPixmap.setDevicePixelRatio(devicePixelRatioF()); QPainter p( &blendedPixmap ); p.drawPixmap( 0, 0, doubleBuffer, - blendRect.left() - contentsRect.left(), blendRect.top() - contentsRect.top(), + (blendRect.left() - contentsRect.left()) * devicePixelRatioF(), (blendRect.top() - contentsRect.top()) * devicePixelRatioF(), blendRect.width() * devicePixelRatioF(), blendRect.height() * devicePixelRatioF() ); QColor blCol = d->mouseSelectionColor.dark( 140 );