mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 10:22:55 +00:00
optimize widget background painting for the case of multiple region rectangles
essentially saving multiple painter state changes and whatnot, performance for single region rectangle remains the same Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
f638484d11
commit
1ac3daf78c
2 changed files with 20 additions and 16 deletions
|
@ -1687,9 +1687,13 @@ static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrus
|
|||
painter->fillRect(0, 0, painter->device()->width(), painter->device()->height(), brush);
|
||||
painter->restore();
|
||||
} else {
|
||||
const QVector<QRect> &rects = rgn.rects();
|
||||
for (int i = 0; i < rects.size(); ++i)
|
||||
painter->fillRect(rects.at(i), brush);
|
||||
QPen oldPen = painter->pen();
|
||||
QBrush oldBrush = painter->brush();
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setBrush(brush);
|
||||
painter->drawRects(rgn.rects());
|
||||
painter->setBrush(oldBrush);
|
||||
painter->setPen(oldPen);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1715,8 +1719,7 @@ void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int
|
|||
const QBrush autoFillBrush = q->palette().brush(q->backgroundRole());
|
||||
|
||||
if ((flags & DrawAsRoot) && !(q->autoFillBackground() && autoFillBrush.isOpaque())) {
|
||||
const QBrush bg = q->palette().brush(QPalette::Window);
|
||||
fillRegion(painter, rgn, bg);
|
||||
fillRegion(painter, rgn, q->palette().brush(QPalette::Window));
|
||||
}
|
||||
|
||||
if (q->autoFillBackground())
|
||||
|
|
|
@ -1256,28 +1256,29 @@ void QWidgetPrivate::updateSystemBackground()
|
|||
|| q->testAttribute(Qt::WA_NoSystemBackground)
|
||||
|| q->testAttribute(Qt::WA_UpdatesDisabled)
|
||||
|| type == Qt::Popup || type == Qt::ToolTip) {
|
||||
if (QX11Info::isCompositingManagerRunning()
|
||||
&& q->testAttribute(Qt::WA_TranslucentBackground)
|
||||
&& !(q->parent()))
|
||||
XSetWindowBackground(qt_x11Data->display, q->internalWinId(),
|
||||
QX11Data::XColorPixel(xinfo.screen(), Qt::transparent));
|
||||
else
|
||||
XSetWindowBackgroundPixmap(qt_x11Data->display, q->internalWinId(), XNone);
|
||||
if (QX11Info::isCompositingManagerRunning()
|
||||
&& q->testAttribute(Qt::WA_TranslucentBackground)
|
||||
&& !(q->parent())) {
|
||||
XSetWindowBackground(qt_x11Data->display, q->internalWinId(),
|
||||
QX11Data::XColorPixel(xinfo.screen(), Qt::transparent));
|
||||
} else {
|
||||
XSetWindowBackgroundPixmap(qt_x11Data->display, q->internalWinId(), XNone);
|
||||
}
|
||||
else if (brush.style() == Qt::SolidPattern && brush.isOpaque())
|
||||
} else if (brush.style() == Qt::SolidPattern && brush.isOpaque()) {
|
||||
XSetWindowBackground(qt_x11Data->display, q->internalWinId(),
|
||||
QX11Data::XColorPixel(xinfo.screen(), brush.color()));
|
||||
else if (isBackgroundInherited())
|
||||
} else if (isBackgroundInherited()) {
|
||||
XSetWindowBackgroundPixmap(qt_x11Data->display, q->internalWinId(), ParentRelative);
|
||||
else if (brush.style() == Qt::TexturePattern) {
|
||||
} else if (brush.style() == Qt::TexturePattern) {
|
||||
const Qt::HANDLE bgpixmap = brush.texture().toX11Pixmap();
|
||||
XSetWindowBackgroundPixmap(qt_x11Data->display, q->internalWinId(), bgpixmap);
|
||||
if (bgpixmap) {
|
||||
XFreePixmap(qt_x11Data->display, bgpixmap);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
XSetWindowBackground(qt_x11Data->display, q->internalWinId(),
|
||||
QX11Data::XColorPixel(xinfo.screen(), brush.color()));
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
|
|
Loading…
Add table
Reference in a new issue