Upgrade QWidgetPrivate::DrawWidgetFlag to QFlags

Allows for easier debugging of the paint cycle.

Change-Id: Iab85bccb99198a02f33c0beeccd4e3914375358d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Tor Arne Vestbø 2019-08-14 14:32:56 +02:00
parent 6d9d4e6817
commit 14fc3f4b0d
3 changed files with 20 additions and 13 deletions

View File

@ -2353,7 +2353,7 @@ bool QWidgetPrivate::updateBrushOrigin(QPainter *painter, const QBrush &brush) c
return true;
}
void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int flags) const
void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, DrawWidgetFlags flags) const
{
Q_Q(const QWidget);
@ -5410,7 +5410,7 @@ void QWidgetPrivate::render_helper(QPainter *painter, const QPoint &targetOffset
#endif
}
void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags,
void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, DrawWidgetFlags flags,
QPainter *sharedPainter, QWidgetRepaintManager *repaintManager)
{
if (rgn.isEmpty())
@ -5508,7 +5508,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
beginBackingStorePainting();
#endif
QPainter p(q);
paintBackground(&p, toBePainted, (asRoot || onScreen) ? flags | DrawAsRoot : 0);
paintBackground(&p, toBePainted, (asRoot || onScreen) ? (flags | DrawAsRoot) : DrawWidgetFlags());
#ifndef QT_NO_OPENGL
endBackingStorePainting();
#endif
@ -5691,7 +5691,7 @@ void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset,
}
// Set backingstore flags.
int flags = DrawPaintOnScreen | DrawInvisible;
DrawWidgetFlags flags = DrawPaintOnScreen | DrawInvisible;
if (renderFlags & QWidget::DrawWindowBackground)
flags |= DrawAsRoot;
@ -5711,7 +5711,7 @@ void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset,
}
void QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& siblings, int index, const QRegion &rgn,
const QPoint &offset, int flags
const QPoint &offset, DrawWidgetFlags flags
, QPainter *sharedPainter, QWidgetRepaintManager *repaintManager)
{
QWidget *w = 0;

View File

@ -266,10 +266,11 @@ static inline bool bypassGraphicsProxyWidget(const QWidget *p)
class Q_WIDGETS_EXPORT QWidgetPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QWidget)
Q_GADGET
public:
// *************************** Cross-platform ***************************************
enum DrawWidgetFlags {
enum DrawWidgetFlag {
DrawAsRoot = 0x01,
DrawPaintOnScreen = 0x02,
DrawRecursive = 0x04,
@ -279,12 +280,15 @@ public:
DontDrawNativeChildren = 0x40,
DontSetCompositionMode = 0x80
};
Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
Q_FLAG(DrawWidgetFlags)
enum CloseMode {
CloseNoEvent,
CloseWithEvent,
CloseWithSpontaneousEvent
};
Q_ENUM(CloseMode)
enum Direction {
DirectionNorth = 0x01,
@ -292,6 +296,7 @@ public:
DirectionSouth = 0x02,
DirectionWest = 0x20
};
Q_ENUM(Direction)
// Functions.
explicit QWidgetPrivate(int version = QObjectPrivateVersion);
@ -376,20 +381,20 @@ public:
void setUpdatesEnabled_helper(bool );
bool updateBrushOrigin(QPainter *, const QBrush &brush) const;
void paintBackground(QPainter *, const QRegion &, int flags = DrawAsRoot) const;
void paintBackground(QPainter *, const QRegion &, DrawWidgetFlags flags = DrawAsRoot) const;
bool isAboutToShow() const;
QRegion prepareToRender(const QRegion &region, QWidget::RenderFlags renderFlags);
void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion,
QWidget::RenderFlags renderFlags);
void render(QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion,
QWidget::RenderFlags renderFlags);
void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags,
void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, DrawWidgetFlags flags,
QPainter *sharedPainter = nullptr, QWidgetRepaintManager *repaintManager = nullptr);
void sendPaintEvent(const QRegion &toBePainted);
void paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& children, int index,
const QRegion &rgn, const QPoint &offset, int flags,
const QRegion &rgn, const QPoint &offset, DrawWidgetFlags flags,
QPainter *sharedPainter, QWidgetRepaintManager *repaintManager);
#if QT_CONFIG(graphicsview)
@ -873,16 +878,18 @@ public:
bool stealMouseGrab(bool grab);
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QWidgetPrivate::DrawWidgetFlags)
struct QWidgetPaintContext
{
inline QWidgetPaintContext(QPaintDevice *d, const QRegion &r, const QPoint &o, int f,
inline QWidgetPaintContext(QPaintDevice *d, const QRegion &r, const QPoint &o, QWidgetPrivate::DrawWidgetFlags f,
QPainter *p, QWidgetRepaintManager *rpm)
: pdev(d), rgn(r), offset(o), flags(f), sharedPainter(p), repaintManager(rpm), painter(nullptr) {}
QPaintDevice *pdev;
QRegion rgn;
QPoint offset;
int flags;
QWidgetPrivate::DrawWidgetFlags flags;
QPainter *sharedPainter;
QWidgetRepaintManager *repaintManager;
QPainter *painter;

View File

@ -1335,7 +1335,7 @@ void QWidgetRepaintManager::doSync()
QWidget *w = opaqueNonOverlappedWidgets[i];
QWidgetPrivate *wd = w->d_func();
int flags = QWidgetPrivate::DrawRecursive;
QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawRecursive;
// Scrolled and moved widgets must draw all children.
if (!wd->isScrolled && !wd->isMoved)
flags |= QWidgetPrivate::DontDrawOpaqueChildren;
@ -1353,7 +1353,7 @@ void QWidgetRepaintManager::doSync()
// Paint the rest with composition.
if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
const int flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, 0, this);
}