Skip to content

Commit

Permalink
Code tidies: improve variable naming and add const where possible
Browse files Browse the repository at this point in the history
Remove obsolete check for valid sourceRect, we never get into the
accelerated code path if it's not.

Pick-to: 6.2
Change-Id: I872685fca8cba3a09ed856d727d5baafddee161b
Reviewed-by: Tor Arne Vestbø <[email protected]>
  • Loading branch information
vohi committed Dec 8, 2021
1 parent 5cdc82e commit b393370
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions src/widgets/kernel/qwidgetrepaintmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,14 +423,13 @@ void QWidgetPrivate::moveRect(const QRect &rect, int dx, int dy)
return;

QWidget *tlw = q->window();
QTLWExtra* x = tlw->d_func()->topData();

static const bool accelEnv = qEnvironmentVariableIntValue("QT_NO_FAST_MOVE") == 0;

QWidget *pw = q->parentWidget();
QPoint toplevelOffset = pw->mapTo(tlw, QPoint());
QWidgetPrivate *pd = pw->d_func();
QRect clipR(pd->clipRect());
QWidget *parentWidget = q->parentWidget();
QPoint toplevelOffset = parentWidget->mapTo(tlw, QPoint());
QWidgetPrivate *parentPrivate = parentWidget->d_func();
const QRect clipR(parentPrivate->clipRect());
const QRect newRect(rect.translated(dx, dy));
QRect destRect = rect.intersected(clipR);
if (destRect.isValid())
Expand All @@ -447,24 +446,24 @@ void QWidgetPrivate::moveRect(const QRect &rect, int dx, int dy)
&& !isOverlapped(sourceRect) && !isOverlapped(destRect);

if (!accelerateMove) {
QRegion parentR(effectiveRectFor(parentRect));
QRegion parentRegion(effectiveRectFor(parentRect));
if (!extra || !extra->hasMask) {
parentR -= newRect;
parentRegion -= newRect;
} else {
// invalidateBackingStore() excludes anything outside the mask
parentR += newRect & clipR;
parentRegion += newRect & clipR;
}
pd->invalidateBackingStore(parentR);
parentPrivate->invalidateBackingStore(parentRegion);
invalidateBackingStore((newRect & clipR).translated(-data.crect.topLeft()));
} else {

QWidgetRepaintManager *repaintManager = x->repaintManager.get();
QWidgetRepaintManager *repaintManager = QWidgetPrivate::get(tlw)->maybeRepaintManager();
Q_ASSERT(repaintManager);
QRegion childExpose(newRect & clipR);

if (sourceRect.isValid() && repaintManager->bltRect(sourceRect, dx, dy, pw))
if (repaintManager->bltRect(sourceRect, dx, dy, parentWidget))
childExpose -= destRect;

if (!pw->updatesEnabled())
if (!parentWidget->updatesEnabled())
return;

const bool childUpdatesEnabled = q->updatesEnabled();
Expand All @@ -481,14 +480,14 @@ void QWidgetPrivate::moveRect(const QRect &rect, int dx, int dy)
parentExpose += QRegion(newRect) - extra->mask.translated(data.crect.topLeft());

if (!parentExpose.isEmpty()) {
repaintManager->markDirty(parentExpose, pw);
pd->isMoved = true;
repaintManager->markDirty(parentExpose, parentWidget);
parentPrivate->isMoved = true;
}

if (childUpdatesEnabled) {
QRegion needsFlush(sourceRect);
needsFlush += destRect;
repaintManager->markNeedsFlush(pw, needsFlush, toplevelOffset);
repaintManager->markNeedsFlush(parentWidget, needsFlush, toplevelOffset);
}
}
}
Expand All @@ -498,15 +497,14 @@ void QWidgetPrivate::scrollRect(const QRect &rect, int dx, int dy)
{
Q_Q(QWidget);
QWidget *tlw = q->window();
QTLWExtra* x = tlw->d_func()->topData();

QWidgetRepaintManager *repaintManager = x->repaintManager.get();
QWidgetRepaintManager *repaintManager = QWidgetPrivate::get(tlw)->maybeRepaintManager();
if (!repaintManager)
return;

static const bool accelEnv = qEnvironmentVariableIntValue("QT_NO_FAST_SCROLL") == 0;

QRect scrollRect = rect & clipRect();
const QRect scrollRect = rect & clipRect();
bool overlapped = false;
bool accelerateScroll = accelEnv && isOpaque && !q_func()->testAttribute(Qt::WA_WState_InPaintEvent)
&& !(overlapped = isOverlapped(scrollRect.translated(data.crect.topLeft())));
Expand Down

0 comments on commit b393370

Please sign in to comment.