Qt 4.8
Public Functions | Static Public Functions | Private Functions | Static Private Functions | Properties | Friends | List of all members
QWidgetBackingStore Class Reference

#include <qbackingstore_p.h>

Public Functions

void flush (QWidget *widget=0, QWindowSurface *surface=0)
 Flushes the contents of the backing store into the top-level widget. More...
 
bool isDirty () const
 
void markDirty (const QRegion &rgn, QWidget *widget, bool updateImmediately=false, bool invalidateBuffer=false)
 Marks the region of the widget as dirty (if not already marked as dirty) and posts an UpdateRequest event to the top-level widget (if not already posted). More...
 
void markDirty (const QRect &rect, QWidget *widget, bool updateImmediately=false, bool invalidateBuffer=false)
 This function is equivalent to calling markDirty(QRegion(rect), ...), but is more efficient as it eliminates QRegion operations/allocations and can use the rect more precisely for additional cut-offs. More...
 
 QWidgetBackingStore (QWidget *t)
 
QWindowSurfacesurface () const
 
void sync (QWidget *exposedWidget, const QRegion &exposedRegion)
 Synchronizes the exposedRegion of the exposedWidget with the backing store. More...
 
void sync ()
 Synchronizes the backing store, i.e. More...
 
QPoint topLevelOffset () const
 
 ~QWidgetBackingStore ()
 

Static Public Functions

static void showYellowThing (QWidget *widget, const QRegion &rgn, int msec, bool)
 

Private Functions

void addDirtyWidget (QWidget *widget, const QRegion &rgn)
 
void addStaticWidget (QWidget *widget)
 
void appendDirtyOnScreenWidget (QWidget *widget)
 
void beginPaint (QRegion &toClean, QWidget *widget, QWindowSurface *windowSurface, BeginPaintInfo *returnInfo, bool toCleanIsInTopLevelCoordinates=true)
 Prepares the window surface to paint a\ toClean region of the widget and updates the BeginPaintInfo struct accordingly. More...
 
bool bltRect (const QRect &rect, int dx, int dy, QWidget *widget)
 
void dirtyOnScreenWidgetsRemoveAll (QWidget *widget)
 
QRegion dirtyRegion (QWidget *widget=0) const
 Returns the region (in top-level coordinates) that needs repaint and/or flush. More...
 
void dirtyWidgetsRemoveAll (QWidget *widget)
 
void endPaint (const QRegion &cleaned, QWindowSurface *windowSurface, BeginPaintInfo *beginPaintInfo)
 
bool hasStaticContents () const
 
void markDirtyOnScreen (const QRegion &dirtyOnScreen, QWidget *widget, const QPoint &topLevelOffset)
 Marks the region of the widget as dirty on screen. More...
 
void moveStaticWidgets (QWidget *reparented)
 
void releaseBuffer ()
 
void removeDirtyWidget (QWidget *w)
 
void removeStaticWidget (QWidget *widget)
 
void resetWidget (QWidget *widget)
 
QRegion staticContents (QWidget *widget=0, const QRect &withinClipRect=QRect()) const
 Returns the static content inside the parent if non-zero; otherwise the static content for the entire backing store is returned. More...
 
QRect topLevelRect () const
 
void updateLists (QWidget *widget)
 
void updateStaticContentsSize ()
 

Static Private Functions

static bool flushPaint (QWidget *widget, const QRegion &rgn)
 
static void unflushPaint (QWidget *widget, const QRegion &rgn)
 

Properties

QRegion dirty
 
QRegion dirtyFromPreviousSync
 
QRegion dirtyOnScreen
 
QVector< QWidget * > * dirtyOnScreenWidgets
 
QVector< QWidget * > dirtyWidgets
 
uint fullUpdatePending: 1
 
uint hasDirtyFromPreviousSync: 1
 
QList< QWidget * > staticWidgets
 
QWidgettlw
 
QPoint tlwOffset
 
QWindowSurfacewindowSurface
 

Friends

class QETWidget
 
QRegion qt_dirtyRegion (QWidget *)
 
class QWidget
 
class QWidgetPrivate
 
class QWindowSurface
 
class QWSManagerPrivate
 
class QWSWindowSurface
 

Detailed Description

Definition at line 75 of file qbackingstore_p.h.

Constructors and Destructors

◆ QWidgetBackingStore()

QWidgetBackingStore::QWidgetBackingStore ( QWidget t)

Definition at line 884 of file qbackingstore.cpp.

885  : tlw(topLevel), dirtyOnScreenWidgets(0), hasDirtyFromPreviousSync(false)
886  , fullUpdatePending(0)
887 {
889  if (!windowSurface)
890  windowSurface = topLevel->d_func()->createDefaultWindowSurface();
891 
892  // The QWindowSurface constructor will call QWidget::setWindowSurface(),
893  // but automatically created surfaces should not be added to the topdata.
894 #ifdef Q_BACKINGSTORE_SUBSURFACES
895  Q_ASSERT(topLevel->d_func()->topData()->windowSurface == windowSurface);
896 #endif
897  topLevel->d_func()->topData()->windowSurface = 0;
898 
899  // Ensure all existing subsurfaces and static widgets are added to their respective lists.
900  updateLists(topLevel);
901 }
QWindowSurface * windowSurface
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void updateLists(QWidget *widget)
QWindowSurface * windowSurface() const
Returns the QWindowSurface this widget will be drawn into.
Definition: qwidget.cpp:12819
QVector< QWidget * > * dirtyOnScreenWidgets

◆ ~QWidgetBackingStore()

QWidgetBackingStore::~QWidgetBackingStore ( )

Definition at line 903 of file qbackingstore.cpp.

904 {
905  for (int c = 0; c < dirtyWidgets.size(); ++c) {
907  }
908 
909  delete windowSurface;
910  windowSurface = 0;
911  delete dirtyOnScreenWidgets;
913 }
unsigned char c[8]
Definition: qnumeric_p.h:62
QWindowSurface * windowSurface
void resetWidget(QWidget *widget)
QVector< QWidget * > dirtyWidgets
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QVector< QWidget * > * dirtyOnScreenWidgets
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

Functions

◆ addDirtyWidget()

void QWidgetBackingStore::addDirtyWidget ( QWidget widget,
const QRegion rgn 
)
inlineprivate

Definition at line 147 of file qbackingstore_p.h.

Referenced by markDirty().

148  {
149  if (widget && !widget->d_func()->inDirtyList && !widget->data->in_destructor) {
150  QWidgetPrivate *widgetPrivate = widget->d_func();
151 #ifndef QT_NO_GRAPHICSEFFECT
152  if (widgetPrivate->graphicsEffect)
153  widgetPrivate->dirty = widgetPrivate->effectiveRectFor(rgn.boundingRect());
154  else
155 #endif //QT_NO_GRAPHICSEFFECT
156  widgetPrivate->dirty = rgn;
157  dirtyWidgets.append(widget);
158  widgetPrivate->inDirtyList = true;
159  }
160  }
QRegion dirty
Definition: qwidget_p.h:726
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
QVector< QWidget * > dirtyWidgets
QGraphicsEffect * graphicsEffect
Definition: qwidget_p.h:710
QWidgetData * data
Definition: qwidget.h:815
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
uint inDirtyList
Definition: qwidget_p.h:772
uint in_destructor
Definition: qwidget.h:129
QRect effectiveRectFor(const QRect &rect) const
Definition: qwidget_p.h:658

◆ addStaticWidget()

void QWidgetBackingStore::addStaticWidget ( QWidget widget)
inlineprivate

Definition at line 173 of file qbackingstore_p.h.

Referenced by moveStaticWidgets(), and updateLists().

174  {
175  if (!widget)
176  return;
177 
179  if (!staticWidgets.contains(widget))
180  staticWidgets.append(widget);
181  }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QList< QWidget * > staticWidgets
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041

◆ appendDirtyOnScreenWidget()

void QWidgetBackingStore::appendDirtyOnScreenWidget ( QWidget widget)
inlineprivate

Definition at line 217 of file qbackingstore_p.h.

Referenced by markDirtyOnScreen().

218  {
219  if (!widget)
220  return;
221 
222  if (!dirtyOnScreenWidgets) {
224  dirtyOnScreenWidgets->append(widget);
225  } else if (!dirtyOnScreenWidgets->contains(widget)) {
226  dirtyOnScreenWidgets->append(widget);
227  }
228  }
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
bool contains(const T &t) const
Returns true if the vector contains an occurrence of value; otherwise returns false.
Definition: qvector.h:731
QVector< QWidget * > * dirtyOnScreenWidgets

◆ beginPaint()

void QWidgetBackingStore::beginPaint ( QRegion toClean,
QWidget widget,
QWindowSurface windowSurface,
BeginPaintInfo returnInfo,
bool  toCleanIsInTopLevelCoordinates = true 
)
private

Prepares the window surface to paint a\ toClean region of the widget and updates the BeginPaintInfo struct accordingly.

The toClean region might be clipped by the window surface.

Definition at line 306 of file qbackingstore.cpp.

Referenced by sync().

308 {
309 #ifdef Q_WS_QWS
311  QWidget *surfaceWidget = surface->window();
312 
313  if (!surface->isValid()) {
314  // this looks strange but it really just releases the surface
315  surface->releaseSurface();
316  // the old window surface is deleted in setWindowSurface, which is
317  // called from QWindowSurface constructor.
318  windowSurface = tlw->d_func()->createDefaultWindowSurface();
319  surface = static_cast<QWSWindowSurface *>(windowSurface);
320  // createDefaultWindowSurface() will set topdata->windowSurface on the
321  // widget to zero. However, if this is a sub-surface, it should point
322  // to the widget's sub windowSurface, so we set that here:
323  if (!surfaceWidget->isWindow())
324  surfaceWidget->d_func()->topData()->windowSurface = windowSurface;
325  surface->setGeometry(topLevelRect());
326  returnInfo->windowSurfaceRecreated = true;
327  }
328 
329  const QRegion toCleanUnclipped(toClean);
330 
331  if (surfaceWidget->isWindow())
332  tlwOffset = surface->painterOffset();
333 #ifdef Q_BACKINGSTORE_SUBSURFACES
334  else if (toCleanIsInTopLevelCoordinates)
335  toClean &= surface->clipRegion().translated(surfaceWidget->mapTo(tlw, QPoint()));
336  if (!toCleanIsInTopLevelCoordinates && windowSurface == this->windowSurface)
337  toClean &= surface->clipRegion().translated(-widget->mapTo(surfaceWidget, QPoint()));
338 #else
339  toClean &= surface->clipRegion();
340 #endif
341 
342  if (toClean.isEmpty()) {
343  if (surfaceWidget->isWindow()) {
344  dirtyFromPreviousSync += toCleanUnclipped;
346  }
347 
348  returnInfo->nothingToPaint = true;
349  // Nothing to repaint. However, we might have newly exposed areas on the
350  // screen, so we have to make sure those are flushed.
351  flush();
352  return;
353  }
354 
355  if (surfaceWidget->isWindow()) {
356  if (toCleanUnclipped != toClean) {
357  dirtyFromPreviousSync += (toCleanUnclipped - surface->clipRegion());
359  }
361  dirtyFromPreviousSync -= toClean;
363  }
364  }
365 
366 #endif // Q_WS_QWS
367 
368  Q_UNUSED(widget);
369  Q_UNUSED(toCleanIsInTopLevelCoordinates);
370 
371  // Always flush repainted areas.
372  dirtyOnScreen += toClean;
373 
374 #if defined(Q_WS_QWS) && !defined(Q_BACKINGSTORE_SUBSURFACES)
375  toClean.translate(tlwOffset);
376 #endif
377 
378 #ifdef QT_NO_PAINT_DEBUG
379  windowSurface->beginPaint(toClean);
380 #else
381  returnInfo->wasFlushed = QWidgetBackingStore::flushPaint(tlw, toClean);
382  // Avoid deadlock with QT_FLUSH_PAINT: the server will wait for
383  // the BackingStore lock, so if we hold that, the server will
384  // never release the Communication lock that we are waiting for in
385  // sendSynchronousCommand
386  if (!returnInfo->wasFlushed)
387  windowSurface->beginPaint(toClean);
388 #endif
389 
390  Q_UNUSED(returnInfo);
391 }
The QWSWindowSurface class provides the drawing area for top-level windows in Qt for Embedded Linux...
const QRegion clipRegion() const
Returns the region currently visible on the screen.
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
QWindowSurface * windowSurface
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QRect topLevelRect() const
virtual void beginPaint(const QRegion &)
This function is called before painting onto the surface begins, with the region in which the paintin...
virtual void releaseSurface()
QWindowSurface * surface() const
uint windowSurfaceRecreated
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
QWindowSurface * windowSurface() const
Returns the QWindowSurface this widget will be drawn into.
Definition: qwidget.cpp:12819
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
virtual bool isValid() const =0
Implement this function to return true if the surface is a valid surface for the given top-level wind...
void flush(QWidget *widget=0, QWindowSurface *surface=0)
Flushes the contents of the backing store into the top-level widget.
virtual QPoint painterOffset() const
Returns the offset to be used when painting.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void translate(int dx, int dy)
Translates (moves) the region dx along the X axis and dy along the Y axis.
Definition: qregion.cpp:4116
QRegion translated(int dx, int dy) const
Returns a copy of the region that is translated dx along the x axis and dy along the y axis...
Definition: qregion.cpp:743
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.
static bool flushPaint(QWidget *widget, const QRegion &rgn)
virtual void setGeometry(const QRect &rect)
Sets the currently allocated area to be the given rect.

◆ bltRect()

bool QWidgetBackingStore::bltRect ( const QRect rect,
int  dx,
int  dy,
QWidget widget 
)
private

Definition at line 277 of file qbackingstore.cpp.

Referenced by QWidgetPrivate::moveRect(), and QWidgetPrivate::scrollRect().

278 {
279  const QPoint pos(tlwOffset + widget->mapTo(tlw, rect.topLeft()));
280  const QRect tlwRect(QRect(pos, rect.size()));
281  if (fullUpdatePending || dirty.intersects(tlwRect))
282  return false; // We don't want to scroll junk.
283  return windowSurface->scroll(tlwRect, dx, dy);
284 }
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
QWindowSurface * windowSurface
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool intersects(const QRegion &r) const
Returns true if this region intersects with region, otherwise returns false.
Definition: qregion.cpp:766
virtual bool scroll(const QRegion &area, int dx, int dy)
Scrolls the given area dx pixels to the right and dy downward; both dx and dy may be negative...
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ dirtyOnScreenWidgetsRemoveAll()

void QWidgetBackingStore::dirtyOnScreenWidgetsRemoveAll ( QWidget widget)
inlineprivate

Definition at line 230 of file qbackingstore_p.h.

Referenced by removeDirtyWidget().

231  {
232  if (!widget || !dirtyOnScreenWidgets)
233  return;
234 
235  int i = 0;
236  while (i < dirtyOnScreenWidgets->size()) {
237  if (dirtyOnScreenWidgets->at(i) == widget)
239  else
240  ++i;
241  }
242  }
QPointer< QWidget > widget
void remove(int i)
Removes the element at index position i.
Definition: qvector.h:374
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QVector< QWidget * > * dirtyOnScreenWidgets

◆ dirtyRegion()

QRegion QWidgetBackingStore::dirtyRegion ( QWidget widget = 0) const
private

Returns the region (in top-level coordinates) that needs repaint and/or flush.

If the widget is non-zero, only the dirty region for the widget is returned and the region will be in widget coordinates.

Definition at line 419 of file qbackingstore.cpp.

Referenced by qt_dirtyRegion().

420 {
421  const bool widgetDirty = widget && widget != tlw;
422  const QRect tlwRect(topLevelRect());
423 #if defined(Q_WS_QPA)
424  const QRect surfaceGeometry(tlwRect.topLeft(), windowSurface->size());
425 #else
426  const QRect surfaceGeometry(windowSurface->geometry());
427 #endif
428  if (fullUpdatePending || (surfaceGeometry != tlwRect && surfaceGeometry.size() != tlwRect.size())) {
429  if (widgetDirty) {
430  const QRect dirtyTlwRect = QRect(QPoint(), tlwRect.size());
431  const QPoint offset(widget->mapTo(tlw, QPoint()));
432  const QRect dirtyWidgetRect(dirtyTlwRect & widget->rect().translated(offset));
433  return dirtyWidgetRect.translated(-offset);
434  }
435  return QRect(QPoint(), tlwRect.size());
436  }
437 
438  // Calculate the region that needs repaint.
439  QRegion r(dirty);
440  for (int i = 0; i < dirtyWidgets.size(); ++i) {
441  QWidget *w = dirtyWidgets.at(i);
442  if (widgetDirty && w != widget && !widget->isAncestorOf(w))
443  continue;
444  r += w->d_func()->dirty.translated(w->mapTo(tlw, QPoint()));
445  }
446 
447  // Append the region that needs flush.
448  r += dirtyOnScreen;
449 
450  if (dirtyOnScreenWidgets) { // Only in use with native child widgets.
451  for (int i = 0; i < dirtyOnScreenWidgets->size(); ++i) {
453  if (widgetDirty && w != widget && !widget->isAncestorOf(w))
454  continue;
455  QWidgetPrivate *wd = w->d_func();
456  Q_ASSERT(wd->needsFlush);
457  r += wd->needsFlush->translated(w->mapTo(tlw, QPoint()));
458  }
459  }
460 
461  if (widgetDirty) {
462  // Intersect with the widget geometry and translate to its coordinates.
463  const QPoint offset(widget->mapTo(tlw, QPoint()));
464  r &= widget->rect().translated(offset);
465  r.translate(-offset);
466  }
467  return r;
468 }
QRect geometry() const
Returns the currently allocated area on the screen.
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
QWindowSurface * windowSurface
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QRect topLevelRect() const
QVector< QWidget * > dirtyWidgets
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QRegion * needsFlush
Definition: qwidget_p.h:705
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
bool isAncestorOf(const QWidget *child) const
Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child...
Definition: qwidget.cpp:8573
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QRegion translated(int dx, int dy) const
Returns a copy of the region that is translated dx along the x axis and dy along the y axis...
Definition: qregion.cpp:743
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
QVector< QWidget * > * dirtyOnScreenWidgets
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ dirtyWidgetsRemoveAll()

void QWidgetBackingStore::dirtyWidgetsRemoveAll ( QWidget widget)
inlineprivate

Definition at line 162 of file qbackingstore_p.h.

Referenced by removeDirtyWidget().

163  {
164  int i = 0;
165  while (i < dirtyWidgets.size()) {
166  if (dirtyWidgets.at(i) == widget)
167  dirtyWidgets.remove(i);
168  else
169  ++i;
170  }
171  }
QPointer< QWidget > widget
void remove(int i)
Removes the element at index position i.
Definition: qvector.h:374
QVector< QWidget * > dirtyWidgets
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ endPaint()

void QWidgetBackingStore::endPaint ( const QRegion cleaned,
QWindowSurface windowSurface,
BeginPaintInfo beginPaintInfo 
)
private

Definition at line 393 of file qbackingstore.cpp.

Referenced by sync().

395 {
396 #ifndef QT_NO_PAINT_DEBUG
397  if (!beginPaintInfo->wasFlushed)
398  windowSurface->endPaint(cleaned);
399  else
401 #else
402  Q_UNUSED(beginPaintInfo);
403  windowSurface->endPaint(cleaned);
404 #endif
405 
406 #ifdef Q_BACKINGSTORE_SUBSURFACES
407  flush(static_cast<QWSWindowSurface *>(windowSurface)->window(), windowSurface);
408 #else
409  flush();
410 #endif
411 }
NSWindow * window
void flush(QWidget *widget=0, QWindowSurface *surface=0)
Flushes the contents of the backing store into the top-level widget.
virtual void endPaint(const QRegion &)
This function is called after painting onto the surface has ended, with the region in which the paint...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
static void unflushPaint(QWidget *widget, const QRegion &rgn)

◆ flush()

void QWidgetBackingStore::flush ( QWidget widget = 0,
QWindowSurface surface = 0 
)

Flushes the contents of the backing store into the top-level widget.

If the widget is non-zero, the content is flushed to the widget. If the surface is non-zero, the content of the surface is flushed.

Definition at line 1425 of file qbackingstore.cpp.

Referenced by beginPaint(), endPaint(), and sync().

1426 {
1427 #if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
1428  paintWindowDecoration();
1429 #endif
1430 
1431  if (!dirtyOnScreen.isEmpty()) {
1432  QWidget *target = widget ? widget : tlw;
1433  QWindowSurface *source = surface ? surface : windowSurface;
1434  qt_flush(target, dirtyOnScreen, source, tlw, tlwOffset);
1435  dirtyOnScreen = QRegion();
1436  }
1437 
1439  return;
1440 
1441  for (int i = 0; i < dirtyOnScreenWidgets->size(); ++i) {
1442  QWidget *w = dirtyOnScreenWidgets->at(i);
1443  QWidgetPrivate *wd = w->d_func();
1444  Q_ASSERT(wd->needsFlush);
1446  *wd->needsFlush = QRegion();
1447  }
1449 }
QPointer< QWidget > widget
QWindowSurface * windowSurface
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static void qt_flush(QWidget *widget, const QRegion &region, QWindowSurface *windowSurface, QWidget *tlw, const QPoint &tlwOffset)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QWindowSurface * surface() const
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
The QWindowSurface class provides the drawing area for top-level windows.
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QRegion * needsFlush
Definition: qwidget_p.h:705
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
QVector< QWidget * > * dirtyOnScreenWidgets
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ flushPaint()

bool QWidgetBackingStore::flushPaint ( QWidget widget,
const QRegion rgn 
)
staticprivate

Definition at line 236 of file qbackingstore.cpp.

Referenced by beginPaint(), QWidgetPrivate::drawWidget(), and QWidgetPrivate::repaint_sys().

237 {
238  if (!widget)
239  return false;
240 
241  int delay = 0;
243  static int flushPaintEvent = qgetenv("QT_FLUSH_PAINT_EVENT").toInt();
244  if (!flushPaintEvent)
245  return false;
246  delay = flushPaintEvent;
247  } else {
248  static int flushPaint = qgetenv("QT_FLUSH_PAINT").toInt();
249  if (!flushPaint)
250  return false;
251  delay = flushPaint;
252  }
253 
254  QWidgetBackingStore::showYellowThing(widget, rgn, delay * 10, true);
255  return true;
256 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
static void showYellowThing(QWidget *widget, const QRegion &rgn, int msec, bool)
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...
static bool flushPaint(QWidget *widget, const QRegion &rgn)

◆ hasStaticContents()

bool QWidgetBackingStore::hasStaticContents ( ) const
inlineprivate

Definition at line 264 of file qbackingstore_p.h.

Referenced by qt_grab_cursor(), sync(), and QETWidget::translateConfigEvent().

QWindowSurface * windowSurface
QList< QWidget * > staticWidgets
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
bool hasFeature(WindowSurfaceFeature feature) const

◆ isDirty()

bool QWidgetBackingStore::isDirty ( ) const
inline

Definition at line 91 of file qbackingstore_p.h.

Referenced by sync().

92  {
95 #if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
96  && !hasDirtyWindowDecoration()
97 #endif
98  );
99  }
QVector< QWidget * > dirtyWidgets
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139

◆ markDirty() [1/2]

void QWidgetBackingStore::markDirty ( const QRegion rgn,
QWidget widget,
bool  updateImmediately = false,
bool  invalidateBuffer = false 
)

Marks the region of the widget as dirty (if not already marked as dirty) and posts an UpdateRequest event to the top-level widget (if not already posted).

If updateImmediately is true, the event is sent immediately instead of posted.

If invalidateBuffer is true, all widgets intersecting with the region will be dirty.

If the widget paints directly on screen, the event is sent to the widget instead of the top-level widget, and invalidateBuffer is completely ignored.

Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).

Definition at line 553 of file qbackingstore.cpp.

Referenced by QETWidget::forceUpdate(), QWidgetPrivate::invalidateBuffer(), QWidgetPrivate::moveRect(), QWidget::repaint(), QWidgetPrivate::scrollRect(), and QWidget::update().

555 {
556  Q_ASSERT(tlw->d_func()->extra);
557  Q_ASSERT(tlw->d_func()->extra->topextra);
558  Q_ASSERT(!tlw->d_func()->extra->topextra->inTopLevelResize);
559  Q_ASSERT(widget->isVisible() && widget->updatesEnabled());
560  Q_ASSERT(widget->window() == tlw);
561  Q_ASSERT(!rgn.isEmpty());
562 
563 #ifndef QT_NO_GRAPHICSEFFECT
564  widget->d_func()->invalidateGraphicsEffectsRecursively();
565 #endif //QT_NO_GRAPHICSEFFECT
566 
567  if (widget->d_func()->paintOnScreen()) {
568  if (widget->d_func()->dirty.isEmpty()) {
569  widget->d_func()->dirty = rgn;
570  sendUpdateRequest(widget, updateImmediately);
571  return;
572  } else if (qt_region_strictContains(widget->d_func()->dirty, widget->rect())) {
573  if (updateImmediately)
574  sendUpdateRequest(widget, updateImmediately);
575  return; // Already dirty.
576  }
577 
578  const bool eventAlreadyPosted = !widget->d_func()->dirty.isEmpty();
579  widget->d_func()->dirty += rgn;
580  if (!eventAlreadyPosted || updateImmediately)
581  sendUpdateRequest(widget, updateImmediately);
582  return;
583  }
584 
585  if (fullUpdatePending) {
586  if (updateImmediately)
587  sendUpdateRequest(tlw, updateImmediately);
588  return;
589  }
590 
592  fullUpdatePending = true;
593  sendUpdateRequest(tlw, updateImmediately);
594  return;
595  }
596 
597  const QPoint offset = widget->mapTo(tlw, QPoint());
598  const QRect widgetRect = widget->d_func()->effectiveRectFor(widget->rect());
599  if (qt_region_strictContains(dirty, widgetRect.translated(offset))) {
600  if (updateImmediately)
601  sendUpdateRequest(tlw, updateImmediately);
602  return; // Already dirty.
603  }
604 
605  if (invalidateBuffer) {
606  const bool eventAlreadyPosted = !dirty.isEmpty();
607 #ifndef QT_NO_GRAPHICSEFFECT
608  if (widget->d_func()->graphicsEffect)
609  dirty += widget->d_func()->effectiveRectFor(rgn.boundingRect()).translated(offset);
610  else
611 #endif //QT_NO_GRAPHICSEFFECT
612  dirty += rgn.translated(offset);
613  if (!eventAlreadyPosted || updateImmediately)
614  sendUpdateRequest(tlw, updateImmediately);
615  return;
616  }
617 
618  if (dirtyWidgets.isEmpty()) {
619  addDirtyWidget(widget, rgn);
620  sendUpdateRequest(tlw, updateImmediately);
621  return;
622  }
623 
624  if (widget->d_func()->inDirtyList) {
625  if (!qt_region_strictContains(widget->d_func()->dirty, widgetRect)) {
626 #ifndef QT_NO_GRAPHICSEFFECT
627  if (widget->d_func()->graphicsEffect)
628  widget->d_func()->dirty += widget->d_func()->effectiveRectFor(rgn.boundingRect());
629  else
630 #endif //QT_NO_GRAPHICSEFFECT
631  widget->d_func()->dirty += rgn;
632  }
633  } else {
634  addDirtyWidget(widget, rgn);
635  }
636 
637  if (updateImmediately)
638  sendUpdateRequest(tlw, updateImmediately);
639 }
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
QWindowSurface * windowSurface
bool isVisible() const
Definition: qwidget.h:1005
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QVector< QWidget * > dirtyWidgets
bool updatesEnabled
whether updates are enabled
Definition: qwidget.h:190
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
QGraphicsEffect * graphicsEffect() const
The graphicsEffect function returns a pointer to the widget&#39;s graphics effect.
Definition: qwidget.cpp:5484
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
Q_GUI_EXPORT bool qt_region_strictContains(const QRegion &region, const QRect &rect)
Returns true if rect is guaranteed to be fully contained in region.
Definition: qregion.cpp:4380
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool hasFeature(WindowSurfaceFeature feature) const
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
QRegion translated(int dx, int dy) const
Returns a copy of the region that is translated dx along the x axis and dy along the y axis...
Definition: qregion.cpp:743
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
static void sendUpdateRequest(QWidget *widget, bool updateImmediately)
void addDirtyWidget(QWidget *widget, const QRegion &rgn)

◆ markDirty() [2/2]

void QWidgetBackingStore::markDirty ( const QRect rect,
QWidget widget,
bool  updateImmediately = false,
bool  invalidateBuffer = false 
)

This function is equivalent to calling markDirty(QRegion(rect), ...), but is more efficient as it eliminates QRegion operations/allocations and can use the rect more precisely for additional cut-offs.

Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).

Definition at line 648 of file qbackingstore.cpp.

650 {
651  Q_ASSERT(tlw->d_func()->extra);
652  Q_ASSERT(tlw->d_func()->extra->topextra);
653  Q_ASSERT(!tlw->d_func()->extra->topextra->inTopLevelResize);
654  Q_ASSERT(widget->isVisible() && widget->updatesEnabled());
655  Q_ASSERT(widget->window() == tlw);
656  Q_ASSERT(!rect.isEmpty());
657 
658 #ifndef QT_NO_GRAPHICSEFFECT
659  widget->d_func()->invalidateGraphicsEffectsRecursively();
660 #endif //QT_NO_GRAPHICSEFFECT
661 
662  if (widget->d_func()->paintOnScreen()) {
663  if (widget->d_func()->dirty.isEmpty()) {
664  widget->d_func()->dirty = QRegion(rect);
665  sendUpdateRequest(widget, updateImmediately);
666  return;
667  } else if (qt_region_strictContains(widget->d_func()->dirty, rect)) {
668  if (updateImmediately)
669  sendUpdateRequest(widget, updateImmediately);
670  return; // Already dirty.
671  }
672 
673  const bool eventAlreadyPosted = !widget->d_func()->dirty.isEmpty();
674  widget->d_func()->dirty += rect;
675  if (!eventAlreadyPosted || updateImmediately)
676  sendUpdateRequest(widget, updateImmediately);
677  return;
678  }
679 
680  if (fullUpdatePending) {
681  if (updateImmediately)
682  sendUpdateRequest(tlw, updateImmediately);
683  return;
684  }
685 
687  fullUpdatePending = true;
688  sendUpdateRequest(tlw, updateImmediately);
689  return;
690  }
691 
692  const QRect widgetRect = widget->d_func()->effectiveRectFor(rect);
693  const QRect translatedRect(widgetRect.translated(widget->mapTo(tlw, QPoint())));
694  if (qt_region_strictContains(dirty, translatedRect)) {
695  if (updateImmediately)
696  sendUpdateRequest(tlw, updateImmediately);
697  return; // Already dirty
698  }
699 
700  if (invalidateBuffer) {
701  const bool eventAlreadyPosted = !dirty.isEmpty();
702  dirty += translatedRect;
703  if (!eventAlreadyPosted || updateImmediately)
704  sendUpdateRequest(tlw, updateImmediately);
705  return;
706  }
707 
708  if (dirtyWidgets.isEmpty()) {
709  addDirtyWidget(widget, rect);
710  sendUpdateRequest(tlw, updateImmediately);
711  return;
712  }
713 
714  if (widget->d_func()->inDirtyList) {
715  if (!qt_region_strictContains(widget->d_func()->dirty, widgetRect))
716  widget->d_func()->dirty += widgetRect;
717  } else {
718  addDirtyWidget(widget, rect);
719  }
720 
721  if (updateImmediately)
722  sendUpdateRequest(tlw, updateImmediately);
723 }
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
QWindowSurface * windowSurface
bool isVisible() const
Definition: qwidget.h:1005
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QVector< QWidget * > dirtyWidgets
bool updatesEnabled
whether updates are enabled
Definition: qwidget.h:190
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
Q_GUI_EXPORT bool qt_region_strictContains(const QRegion &region, const QRect &rect)
Returns true if rect is guaranteed to be fully contained in region.
Definition: qregion.cpp:4380
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool hasFeature(WindowSurfaceFeature feature) const
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
static void sendUpdateRequest(QWidget *widget, bool updateImmediately)
void addDirtyWidget(QWidget *widget, const QRegion &rgn)

◆ markDirtyOnScreen()

void QWidgetBackingStore::markDirtyOnScreen ( const QRegion region,
QWidget widget,
const QPoint topLevelOffset 
)
private

Marks the region of the widget as dirty on screen.

The region will be copied from the backing store to the widget's native parent next time flush() is called.

Paint on screen widgets are ignored.

Definition at line 731 of file qbackingstore.cpp.

Referenced by QWidgetPrivate::drawWidget(), QWidgetPrivate::moveRect(), removeDirtyWidget(), QWidgetPrivate::scrollRect(), and sync().

732 {
733  if (!widget || widget->d_func()->paintOnScreen() || region.isEmpty())
734  return;
735 
736 #if defined(Q_WS_QWS) || defined(Q_WS_MAC)
738  dirtyOnScreen += region.translated(topLevelOffset);
739  return;
740 #endif
741 
742  // Top-level.
743  if (widget == tlw) {
745  dirtyOnScreen += region;
746  return;
747  }
748 
749  // Alien widgets.
750  if (!widget->internalWinId() && !widget->isWindow()) {
751  QWidget *nativeParent = widget->nativeParentWidget(); // Alien widgets with the top-level as the native parent (common case).
752  if (nativeParent == tlw) {
754  dirtyOnScreen += region.translated(topLevelOffset);
755  return;
756  }
757 
758  // Alien widgets with native parent != tlw.
759  QWidgetPrivate *nativeParentPrivate = nativeParent->d_func();
760  if (!nativeParentPrivate->needsFlush)
761  nativeParentPrivate->needsFlush = new QRegion;
762  const QPoint nativeParentOffset = widget->mapTo(nativeParent, QPoint());
763  *nativeParentPrivate->needsFlush += region.translated(nativeParentOffset);
764  appendDirtyOnScreenWidget(nativeParent);
765  return;
766  }
767 
768  // Native child widgets.
769  QWidgetPrivate *widgetPrivate = widget->d_func();
770  if (!widgetPrivate->needsFlush)
771  widgetPrivate->needsFlush = new QRegion;
772  *widgetPrivate->needsFlush += region;
774 }
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QWidget * nativeParentWidget() const
Returns the native parent for this widget, i.
Definition: qwidget.cpp:4514
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
void appendDirtyOnScreenWidget(QWidget *widget)
QRegion * needsFlush
Definition: qwidget_p.h:705
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
QRegion translated(int dx, int dy) const
Returns a copy of the region that is translated dx along the x axis and dy along the y axis...
Definition: qregion.cpp:743

◆ moveStaticWidgets()

void QWidgetBackingStore::moveStaticWidgets ( QWidget reparented)
inlineprivate

Definition at line 188 of file qbackingstore_p.h.

189  {
190  Q_ASSERT(reparented);
191  QWidgetBackingStore *newBs = reparented->d_func()->maybeBackingStore();
192  if (newBs == this)
193  return;
194 
195  int i = 0;
196  while (i < staticWidgets.size()) {
197  QWidget *w = staticWidgets.at(i);
198  if (reparented == w || reparented->isAncestorOf(w)) {
200  if (newBs)
201  newBs->addStaticWidget(w);
202  } else {
203  ++i;
204  }
205  }
206  }
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void addStaticWidget(QWidget *widget)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QList< QWidget * > staticWidgets
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
bool isAncestorOf(const QWidget *child) const
Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child...
Definition: qwidget.cpp:8573
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ releaseBuffer()

void QWidgetBackingStore::releaseBuffer ( )
private

Definition at line 286 of file qbackingstore.cpp.

Referenced by isServerProcess().

287 {
288  if (windowSurface)
289 #if defined(Q_WS_QPA)
290  windowSurface->resize(QSize());
291 #else
293 #endif
294 #ifdef Q_BACKINGSTORE_SUBSURFACES
295  for (int i = 0; i < subSurfaces.size(); ++i)
296  subSurfaces.at(i)->setGeometry(QRect());
297 #endif
298 }
QWindowSurface * windowSurface
virtual void setGeometry(const QRect &rect)
Sets the currently allocated area to be the given rect.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ removeDirtyWidget()

void QWidgetBackingStore::removeDirtyWidget ( QWidget w)
private

Definition at line 776 of file qbackingstore.cpp.

Referenced by QWidget::setParent().

777 {
778  if (!w)
779  return;
780 
783  resetWidget(w);
784 
785  QWidgetPrivate *wd = w->d_func();
786  const int n = wd->children.count();
787  for (int i = 0; i < n; ++i) {
788  if (QWidget *child = qobject_cast<QWidget*>(wd->children.at(i)))
789  removeDirtyWidget(child);
790  }
791 }
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void removeDirtyWidget(QWidget *w)
void resetWidget(QWidget *widget)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QObjectList children
Definition: qobject.h:93
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void dirtyOnScreenWidgetsRemoveAll(QWidget *widget)
void dirtyWidgetsRemoveAll(QWidget *widget)

◆ removeStaticWidget()

void QWidgetBackingStore::removeStaticWidget ( QWidget widget)
inlineprivate

Definition at line 183 of file qbackingstore_p.h.

184  { staticWidgets.removeAll(widget); }
QList< QWidget * > staticWidgets
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770

◆ resetWidget()

void QWidgetBackingStore::resetWidget ( QWidget widget)
inlineprivate

Definition at line 244 of file qbackingstore_p.h.

Referenced by removeDirtyWidget(), sync(), and ~QWidgetBackingStore().

245  {
246  if (widget) {
247  widget->d_func()->inDirtyList = false;
248  widget->d_func()->isScrolled = false;
249  widget->d_func()->isMoved = false;
250  widget->d_func()->dirty = QRegion();
251  }
252  }
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68

◆ showYellowThing()

void QWidgetBackingStore::showYellowThing ( QWidget widget,
const QRegion rgn,
int  msec,
bool  unclipped 
)
static

Definition at line 158 of file qbackingstore.cpp.

Referenced by flushPaint(), and qt_flush().

159 {
160 #ifdef Q_WS_QWS
161  Q_UNUSED(widget);
162  Q_UNUSED(unclipped);
163  static QWSYellowSurface surface(true);
164  surface.setDelay(msec);
165  surface.flush(widget, toBePainted, QPoint());
166 #else
167  QRegion paintRegion = toBePainted;
168  QRect widgetRect = widget->rect();
169 
170  if (!widget->internalWinId()) {
171  QWidget *nativeParent = widget->nativeParentWidget();
172  const QPoint offset = widget->mapTo(nativeParent, QPoint(0, 0));
173  paintRegion.translate(offset);
174  widgetRect.translate(offset);
175  widget = nativeParent;
176  }
177 
178 #ifdef Q_WS_WIN
179  Q_UNUSED(unclipped);
180  showYellowThing_win(widget, paintRegion, msec);
181 #else
182  //flags to fool painter
183  bool paintUnclipped = widget->testAttribute(Qt::WA_PaintUnclipped);
184  if (unclipped && !widget->d_func()->paintOnScreen())
186 
187  const bool setFlag = !widget->testAttribute(Qt::WA_WState_InPaintEvent);
188  if (setFlag)
190 
191  //setup the engine
192  QPaintEngine *pe = widget->paintEngine();
193  if (pe) {
194  pe->setSystemClip(paintRegion);
195  {
196  QPainter p(widget);
197  p.setClipRegion(paintRegion);
198  static int i = 0;
199  switch (i) {
200  case 0:
201  p.fillRect(widgetRect, QColor(255,255,0));
202  break;
203  case 1:
204  p.fillRect(widgetRect, QColor(255,200,55));
205  break;
206  case 2:
207  p.fillRect(widgetRect, QColor(200,255,55));
208  break;
209  case 3:
210  p.fillRect(widgetRect, QColor(200,200,0));
211  break;
212  }
213  i = (i+1) & 3;
214  p.end();
215  }
216  }
217 
218  if (setFlag)
220 
221  //restore
222  widget->setAttribute(Qt::WA_PaintUnclipped, paintUnclipped);
223 
224  if (pe)
225  pe->setSystemClip(QRegion());
226 
228 
229 #if defined(Q_OS_UNIX)
230  ::usleep(1000 * msec);
231 #endif
232 #endif // Q_WS_WIN
233 #endif // Q_WS_QWS
234 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QWindowSurface * surface() const
QWidget * nativeParentWidget() const
Returns the native parent for this widget, i.
Definition: qwidget.cpp:4514
virtual void flush(QWidget *widget, const QRegion &region, const QPoint &offset)=0
Flushes the given region from the specified widget onto the screen.
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
static void showYellowThing_win(QWidget *widget, const QRegion &region, int msec)
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
void setSystemClip(const QRegion &baseClip)
Sets the system clip for this engine.
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
QPaintEngine * paintEngine() const
Returns the widget&#39;s paint engine.
static void syncX()
Synchronizes with the X server in the X11 implementation.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
void translate(int dx, int dy)
Translates (moves) the region dx along the X axis and dy along the Y axis.
Definition: qregion.cpp:4116
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ staticContents()

QRegion QWidgetBackingStore::staticContents ( QWidget parent = 0,
const QRect withinClipRect = QRect() 
) const
private

Returns the static content inside the parent if non-zero; otherwise the static content for the entire backing store is returned.

The content will be clipped to withinClipRect if non-empty.

Definition at line 475 of file qbackingstore.cpp.

Referenced by QWidgetPrivate::invalidateBuffer_resizeHelper(), and sync().

476 {
477  if (!parent && tlw->testAttribute(Qt::WA_StaticContents)) {
478 #if defined(Q_WS_QPA)
479  const QSize surfaceGeometry(windowSurface->size());
480 #else
481  const QRect surfaceGeometry(windowSurface->geometry());
482 #endif
483  QRect surfaceRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height());
484  if (!withinClipRect.isEmpty())
485  surfaceRect &= withinClipRect;
486  return QRegion(surfaceRect);
487  }
488 
489  QRegion region;
490  if (parent && parent->d_func()->children.isEmpty())
491  return region;
492 
493  const bool clipToRect = !withinClipRect.isEmpty();
494  const int count = staticWidgets.count();
495  for (int i = 0; i < count; ++i) {
496  QWidget *w = staticWidgets.at(i);
497  QWidgetPrivate *wd = w->d_func();
498  if (!wd->isOpaque || !wd->extra || wd->extra->staticContentsSize.isEmpty()
499  || !w->isVisible() || (parent && !parent->isAncestorOf(w))) {
500  continue;
501  }
502 
504  const QPoint offset = w->mapTo(parent ? parent : tlw, QPoint());
505  if (clipToRect)
506  rect &= withinClipRect.translated(-offset);
507  if (rect.isEmpty())
508  continue;
509 
510  rect &= wd->clipRect();
511  if (rect.isEmpty())
512  continue;
513 
514  QRegion visible(rect);
515  wd->clipToEffectiveMask(visible);
516  if (visible.isEmpty())
517  continue;
518  wd->subtractOpaqueSiblings(visible, 0, /*alsoNonOpaque=*/true);
519 
520  visible.translate(offset);
521  region += visible;
522  }
523 
524  return region;
525 }
QRect geometry() const
Returns the currently allocated area on the screen.
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
QWindowSurface * windowSurface
bool isVisible() const
Definition: qwidget.h:1005
QRect clipRect() const
Definition: qwidget.cpp:1997
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QList< QWidget * > staticWidgets
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
int width() const
Returns the width.
Definition: qsize.h:126
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QSize staticContentsSize
Definition: qwidget_p.h:270
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
bool isAncestorOf(const QWidget *child) const
Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child...
Definition: qwidget.cpp:8573
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QWExtra * extra
Definition: qwidget_p.h:700
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove=0, bool alsoNonOpaque=false) const
Definition: qwidget.cpp:2139
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
Definition: qsize.h:120
void clipToEffectiveMask(QRegion &region) const
Definition: qwidget.cpp:2230

◆ surface()

QWindowSurface* QWidgetBackingStore::surface ( ) const
inline

Definition at line 89 of file qbackingstore_p.h.

Referenced by beginPaint(), flush(), QWidgetPrivate::moveRect(), QWidgetPrivate::scrollRect(), and showYellowThing().

89 { return windowSurface; }
QWindowSurface * windowSurface

◆ sync() [1/2]

void QWidgetBackingStore::sync ( QWidget exposedWidget,
const QRegion exposedRegion 
)

Synchronizes the exposedRegion of the exposedWidget with the backing store.

If there's nothing to repaint, the area is flushed and painting does not occur; otherwise the area is marked as dirty on screen and will be flushed right after we are done with all painting.

Definition at line 1135 of file qbackingstore.cpp.

1136 {
1137  QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
1138  if (discardSyncRequest(tlw, tlwExtra) || tlwExtra->inTopLevelResize)
1139  return;
1140 
1141  if (!exposedWidget || !exposedWidget->internalWinId() || !exposedWidget->isVisible()
1142  || !exposedWidget->updatesEnabled() || exposedRegion.isEmpty()) {
1143  return;
1144  }
1145 
1146  // If there's no preserved contents support we always need
1147  // to do a full repaint before flushing
1149  fullUpdatePending = true;
1150 
1151  // Nothing to repaint.
1152  if (!isDirty()) {
1153  qt_flush(exposedWidget, exposedRegion, windowSurface, tlw, tlwOffset);
1154  return;
1155  }
1156 
1157  if (exposedWidget != tlw)
1158  markDirtyOnScreen(exposedRegion, exposedWidget, exposedWidget->mapTo(tlw, QPoint()));
1159  else
1160  markDirtyOnScreen(exposedRegion, exposedWidget, QPoint());
1161  sync();
1162 }
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
QWindowSurface * windowSurface
bool isVisible() const
Definition: qwidget.h:1005
bool isDirty() const
uint inTopLevelResize
Definition: qwidget_p.h:188
void markDirtyOnScreen(const QRegion &dirtyOnScreen, QWidget *widget, const QPoint &topLevelOffset)
Marks the region of the widget as dirty on screen.
void sync()
Synchronizes the backing store, i.e.
static void qt_flush(QWidget *widget, const QRegion &region, QWindowSurface *windowSurface, QWidget *tlw, const QPoint &tlwOffset)
bool updatesEnabled
whether updates are enabled
Definition: qwidget.h:190
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
static bool discardSyncRequest(QWidget *tlw, QTLWExtra *tlwExtra)
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
bool hasFeature(WindowSurfaceFeature feature) const

◆ sync() [2/2]

void QWidgetBackingStore::sync ( )

Synchronizes the backing store, i.e.

dirty areas are repainted and flushed.

Definition at line 1167 of file qbackingstore.cpp.

Referenced by sync().

1168 {
1169  QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
1170  if (discardSyncRequest(tlw, tlwExtra)) {
1171  // If the top-level is minimized, it's not visible on the screen so we can delay the
1172  // update until it's shown again. In order to do that we must keep the dirty states.
1173  // These will be cleared when we receive the first expose after showNormal().
1174  // However, if the widget is not visible (isVisible() returns false), everything will
1175  // be invalidated once the widget is shown again, so clear all dirty states.
1176  if (!tlw->isVisible()) {
1177  dirty = QRegion();
1178  for (int i = 0; i < dirtyWidgets.size(); ++i)
1180  dirtyWidgets.clear();
1181  fullUpdatePending = false;
1182  }
1183  return;
1184  }
1185 
1186  const bool updatesDisabled = !tlw->updatesEnabled();
1187  bool repaintAllWidgets = false;
1188 
1189  const bool inTopLevelResize = tlwExtra->inTopLevelResize;
1190  const QRect tlwRect(topLevelRect());
1191 #ifdef Q_WS_QPA
1192  const QRect surfaceGeometry(tlwRect.topLeft(), windowSurface->size());
1193 #else
1194  const QRect surfaceGeometry(windowSurface->geometry());
1195 #endif
1196  if ((fullUpdatePending || inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) {
1197  if (hasStaticContents()) {
1198  // Repaint existing dirty area and newly visible area.
1199  const QRect clipRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height());
1200  const QRegion staticRegion(staticContents(0, clipRect));
1201  QRegion newVisible(0, 0, tlwRect.width(), tlwRect.height());
1202  newVisible -= staticRegion;
1203  dirty += newVisible;
1204  windowSurface->setStaticContents(staticRegion);
1205  } else {
1206  // Repaint everything.
1207  dirty = QRegion(0, 0, tlwRect.width(), tlwRect.height());
1208  for (int i = 0; i < dirtyWidgets.size(); ++i)
1210  dirtyWidgets.clear();
1211  repaintAllWidgets = true;
1212  }
1213  }
1214 
1215 #ifdef Q_WS_QPA
1216  if (inTopLevelResize || surfaceGeometry.size() != tlwRect.size())
1217  windowSurface->resize(tlwRect.size());
1218 #else
1219  if (inTopLevelResize || surfaceGeometry != tlwRect)
1220  windowSurface->setGeometry(tlwRect);
1221 #endif
1222 
1223  if (updatesDisabled)
1224  return;
1225 
1228 
1229  // Contains everything that needs repaint.
1230  QRegion toClean(dirty);
1231 
1232  // Loop through all update() widgets and remove them from the list before they are
1233  // painted (in case someone calls update() in paintEvent). If the widget is opaque
1234  // and does not have transparent overlapping siblings, append it to the
1235  // opaqueNonOverlappedWidgets list and paint it directly without composition.
1236  QVarLengthArray<QWidget *, 32> opaqueNonOverlappedWidgets;
1237  for (int i = 0; i < dirtyWidgets.size(); ++i) {
1238  QWidget *w = dirtyWidgets.at(i);
1239  QWidgetPrivate *wd = w->d_func();
1240  if (wd->data.in_destructor)
1241  continue;
1242 
1243  // Clip with mask() and clipRect().
1244  wd->dirty &= wd->clipRect();
1245  wd->clipToEffectiveMask(wd->dirty);
1246 
1247  // Subtract opaque siblings and children.
1248  bool hasDirtySiblingsAbove = false;
1249  // We know for sure that the widget isn't overlapped if 'isMoved' is true.
1250  if (!wd->isMoved)
1251  wd->subtractOpaqueSiblings(wd->dirty, &hasDirtySiblingsAbove);
1252  // Scrolled and moved widgets must draw all children.
1253  if (!wd->isScrolled && !wd->isMoved)
1254  wd->subtractOpaqueChildren(wd->dirty, w->rect());
1255 
1256  if (wd->dirty.isEmpty()) {
1257  resetWidget(w);
1258  continue;
1259  }
1260 
1261  const QRegion widgetDirty(w != tlw ? wd->dirty.translated(w->mapTo(tlw, QPoint()))
1262  : wd->dirty);
1263  toClean += widgetDirty;
1264 
1265 #ifndef QT_NO_GRAPHICSVIEW
1266  if (tlw->d_func()->extra->proxyWidget) {
1267  resetWidget(w);
1268  continue;
1269  }
1270 #endif
1271 
1272  if (!hasDirtySiblingsAbove && wd->isOpaque && !dirty.intersects(widgetDirty.boundingRect())) {
1273  opaqueNonOverlappedWidgets.append(w);
1274  } else {
1275  resetWidget(w);
1276  dirty += widgetDirty;
1277  }
1278  }
1279  dirtyWidgets.clear();
1280 
1281  fullUpdatePending = false;
1282 
1283  if (toClean.isEmpty()) {
1284  // Nothing to repaint. However, we might have newly exposed areas on the
1285  // screen if this function was called from sync(QWidget *, QRegion)), so
1286  // we have to make sure those are flushed.
1287  flush();
1288  return;
1289  }
1290 
1291 #ifndef QT_NO_GRAPHICSVIEW
1292  if (tlw->d_func()->extra->proxyWidget) {
1294  dirty = QRegion();
1295  const QVector<QRect> rects(toClean.rects());
1296  for (int i = 0; i < rects.size(); ++i)
1297  tlw->d_func()->extra->proxyWidget->update(rects.at(i));
1298  return;
1299  }
1300 #endif
1301 
1302 #ifndef Q_BACKINGSTORE_SUBSURFACES
1303  BeginPaintInfo beginPaintInfo;
1304  beginPaint(toClean, tlw, windowSurface, &beginPaintInfo);
1305  if (beginPaintInfo.nothingToPaint) {
1306  for (int i = 0; i < opaqueNonOverlappedWidgets.size(); ++i)
1307  resetWidget(opaqueNonOverlappedWidgets[i]);
1308  dirty = QRegion();
1309  return;
1310  }
1311 #endif
1312 
1313  // Must do this before sending any paint events because
1314  // the size may change in the paint event.
1316  const QRegion dirtyCopy(dirty);
1317  dirty = QRegion();
1318 
1319  // Paint opaque non overlapped widgets.
1320  for (int i = 0; i < opaqueNonOverlappedWidgets.size(); ++i) {
1321  QWidget *w = opaqueNonOverlappedWidgets[i];
1322  QWidgetPrivate *wd = w->d_func();
1323 
1324  int flags = QWidgetPrivate::DrawRecursive;
1325  // Scrolled and moved widgets must draw all children.
1326  if (!wd->isScrolled && !wd->isMoved)
1328  if (w == tlw)
1329  flags |= QWidgetPrivate::DrawAsRoot;
1330 
1331  QRegion toBePainted(wd->dirty);
1332  resetWidget(w);
1333 
1334 #ifdef Q_BACKINGSTORE_SUBSURFACES
1335  QWindowSurface *subSurface = w->windowSurface();
1336  BeginPaintInfo beginPaintInfo;
1337 
1338  QPoint off = w->mapTo(tlw, QPoint());
1339  toBePainted.translate(off);
1340  beginPaint(toBePainted, w, subSurface, &beginPaintInfo, true);
1341  toBePainted.translate(-off);
1342 
1343  if (beginPaintInfo.nothingToPaint)
1344  continue;
1345 
1346  if (beginPaintInfo.windowSurfaceRecreated) {
1347  // Eep the window surface has changed. The old one may have been
1348  // deleted, in which case we will segfault on the call to
1349  // painterOffset() below. Use the new window surface instead.
1350  subSurface = w->windowSurface();
1351  }
1352 
1353  QPoint offset(tlwOffset);
1354  if (subSurface == windowSurface)
1355  offset += w->mapTo(tlw, QPoint());
1356  else
1357  offset = static_cast<QWSWindowSurface*>(subSurface)->painterOffset();
1358  wd->drawWidget(subSurface->paintDevice(), toBePainted, offset, flags, 0, this);
1359 
1360  endPaint(toBePainted, subSurface, &beginPaintInfo);
1361 #else
1362  QPoint offset(tlwOffset);
1363  if (w != tlw)
1364  offset += w->mapTo(tlw, QPoint());
1365  wd->drawWidget(windowSurface->paintDevice(), toBePainted, offset, flags, 0, this);
1366 #endif
1367  }
1368 
1369  // Paint the rest with composition.
1370 #ifndef Q_BACKINGSTORE_SUBSURFACES
1371  if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
1373  tlw->d_func()->drawWidget(windowSurface->paintDevice(), dirtyCopy, tlwOffset, flags, 0, this);
1374  }
1375 
1376  endPaint(toClean, windowSurface, &beginPaintInfo);
1377 #else
1378  if (!repaintAllWidgets && dirtyCopy.isEmpty())
1379  return; // Nothing more to paint.
1380 
1381  QList<QWindowSurface *> surfaceList(subSurfaces);
1382  surfaceList.prepend(windowSurface);
1383  const QRect dirtyBoundingRect(dirtyCopy.boundingRect());
1384 
1385  // Loop through all window surfaces (incl. the top-level surface) and
1386  // repaint those intersecting with the bounding rect of the dirty region.
1387  for (int i = 0; i < surfaceList.size(); ++i) {
1388  QWindowSurface *subSurface = surfaceList.at(i);
1389  QWidget *w = subSurface->window();
1390  QWidgetPrivate *wd = w->d_func();
1391 
1392  const QRect clipRect = wd->clipRect().translated(w->mapTo(tlw, QPoint()));
1393  if (!qRectIntersects(dirtyBoundingRect, clipRect))
1394  continue;
1395 
1396  toClean = dirtyCopy;
1397  BeginPaintInfo beginPaintInfo;
1398  beginPaint(toClean, w, subSurface, &beginPaintInfo);
1399  if (beginPaintInfo.nothingToPaint)
1400  continue;
1401 
1402  if (beginPaintInfo.windowSurfaceRecreated) {
1403  // Eep the window surface has changed. The old one may have been
1404  // deleted, in which case we will segfault on the call to
1405  // painterOffset() below. Use the new window surface instead.
1406  subSurface = w->windowSurface();
1407  }
1408 
1409  int flags = QWidgetPrivate::DrawRecursive;
1410  if (w == tlw)
1411  flags |= QWidgetPrivate::DrawAsRoot;
1412  const QPoint painterOffset = static_cast<QWSWindowSurface*>(subSurface)->painterOffset();
1413  wd->drawWidget(subSurface->paintDevice(), toClean, painterOffset, flags, 0, this);
1414 
1415  endPaint(toClean, subSurface, &beginPaintInfo);
1416  }
1417 #endif
1418 }
QRect geometry() const
Returns the currently allocated area on the screen.
The QWSWindowSurface class provides the drawing area for top-level windows in Qt for Embedded Linux...
QRegion dirty
Definition: qwidget_p.h:726
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
QWindowSurface * windowSurface
bool isVisible() const
Definition: qwidget.h:1005
QRect clipRect() const
Definition: qwidget.cpp:1997
QRegion staticContents(QWidget *widget=0, const QRect &withinClipRect=QRect()) const
Returns the static content inside the parent if non-zero; otherwise the static content for the entire...
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
uint inTopLevelResize
Definition: qwidget_p.h:188
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
virtual void setGeometry(const QRect &rect)
Sets the currently allocated area to be the given rect.
void resetWidget(QWidget *widget)
void append(const T &t)
QRect topLevelRect() const
QWidgetData data
Definition: qwidget_p.h:755
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
QVector< QWidget * > dirtyWidgets
uint windowSurfaceRecreated
bool updatesEnabled
whether updates are enabled
Definition: qwidget.h:190
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter=0, QWidgetBackingStore *backingStore=0)
Definition: qwidget.cpp:5679
QWindowSurface * windowSurface() const
Returns the QWindowSurface this widget will be drawn into.
Definition: qwidget.cpp:12819
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
bool hasStaticContents() const
The QWindowSurface class provides the drawing area for top-level windows.
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
void flush(QWidget *widget=0, QWindowSurface *surface=0)
Flushes the contents of the backing store into the top-level widget.
static bool qRectIntersects(const QRect &r1, const QRect &r2)
void setStaticContents(const QRegion &region)
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
void beginPaint(QRegion &toClean, QWidget *widget, QWindowSurface *windowSurface, BeginPaintInfo *returnInfo, bool toCleanIsInTopLevelCoordinates=true)
Prepares the window surface to paint a\ toClean region of the widget and updates the BeginPaintInfo s...
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void subtractOpaqueChildren(QRegion &rgn, const QRect &clipRect) const
Definition: qwidget.cpp:2128
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
static bool discardSyncRequest(QWidget *tlw, QTLWExtra *tlwExtra)
bool intersects(const QRegion &r) const
Returns true if this region intersects with region, otherwise returns false.
Definition: qregion.cpp:766
uint in_destructor
Definition: qwidget.h:129
void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove=0, bool alsoNonOpaque=false) const
Definition: qwidget.cpp:2139
QRegion translated(int dx, int dy) const
Returns a copy of the region that is translated dx along the x axis and dy along the y axis...
Definition: qregion.cpp:743
void clipToEffectiveMask(QRegion &region) const
Definition: qwidget.cpp:2230
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.
void endPaint(const QRegion &cleaned, QWindowSurface *windowSurface, BeginPaintInfo *beginPaintInfo)
int size() const
virtual QPaintDevice * paintDevice()=0
Implement this function to return the appropriate paint device.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ topLevelOffset()

QPoint QWidgetBackingStore::topLevelOffset ( ) const
inline

Definition at line 87 of file qbackingstore_p.h.

87 { return tlwOffset; }

◆ topLevelRect()

QRect QWidgetBackingStore::topLevelRect ( ) const
inlineprivate

Definition at line 208 of file qbackingstore_p.h.

Referenced by beginPaint(), dirtyRegion(), and sync().

209  {
210 #ifdef Q_WS_QWS
211  return tlw->frameGeometry();
212 #else
213  return tlw->data->crect;
214 #endif
215  }
QRect crect
Definition: qwidget.h:131
QRect frameGeometry
geometry of the widget relative to its parent including any window frame
Definition: qwidget.h:159
QWidgetData * data
Definition: qwidget.h:815

◆ unflushPaint()

void QWidgetBackingStore::unflushPaint ( QWidget widget,
const QRegion rgn 
)
staticprivate

Definition at line 258 of file qbackingstore.cpp.

Referenced by QWidgetPrivate::drawWidget(), endPaint(), and QWidgetPrivate::repaint_sys().

259 {
260  if (widget->d_func()->paintOnScreen() || rgn.isEmpty())
261  return;
262 
263  QWidget *tlw = widget->window();
264  QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
265  if (!tlwExtra)
266  return;
267 
268  const QPoint offset = widget->mapTo(tlw, QPoint());
269  qt_flush(widget, rgn, tlwExtra->backingStore->windowSurface, tlw, offset);
270 }
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
QWindowSurface * windowSurface
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static void qt_flush(QWidget *widget, const QRegion &region, QWindowSurface *windowSurface, QWidget *tlw, const QPoint &tlwOffset)
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
QWidgetBackingStoreTracker backingStore
Definition: qwidget_p.h:166

◆ updateLists()

void QWidgetBackingStore::updateLists ( QWidget widget)
private

Definition at line 860 of file qbackingstore.cpp.

Referenced by QWidgetBackingStore().

861 {
862  if (!cur)
863  return;
864 
865  QList<QObject*> children = cur->children();
866  for (int i = 0; i < children.size(); ++i) {
867  QWidget *child = qobject_cast<QWidget*>(children.at(i));
868  if (!child)
869  continue;
870 
871  updateLists(child);
872  }
873 
874  if (cur->testAttribute(Qt::WA_StaticContents))
875  addStaticWidget(cur);
876 
877 #ifdef Q_BACKINGSTORE_SUBSURFACES
878  QTLWExtra *extra = cur->d_func()->maybeTopData();
879  if (extra && extra->windowSurface && cur != tlw)
880  subSurfaces.append(extra->windowSurface);
881 #endif
882 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
QWindowSurface * windowSurface
Definition: qwidget_p.h:167
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void addStaticWidget(QWidget *widget)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void updateLists(QWidget *widget)
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ updateStaticContentsSize()

void QWidgetBackingStore::updateStaticContentsSize ( )
inlineprivate

Definition at line 254 of file qbackingstore_p.h.

Referenced by sync().

255  {
256  for (int i = 0; i < staticWidgets.size(); ++i) {
257  QWidgetPrivate *wd = staticWidgets.at(i)->d_func();
258  if (!wd->extra)
259  wd->createExtra();
260  wd->extra->staticContentsSize = wd->data.crect.size();
261  }
262  }
QRect crect
Definition: qwidget.h:131
QList< QWidget * > staticWidgets
QWidgetData data
Definition: qwidget_p.h:755
void createExtra()
Creates the widget extra data.
Definition: qwidget.cpp:1802
QSize staticContentsSize
Definition: qwidget_p.h:270
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QWExtra * extra
Definition: qwidget_p.h:700

Friends and Related Functions

◆ QETWidget

friend class QETWidget
friend

Definition at line 271 of file qbackingstore_p.h.

◆ qt_dirtyRegion

QRegion qt_dirtyRegion ( QWidget )
friend

Definition at line 1111 of file qwidget.cpp.

1112 {
1113  if (!widget)
1114  return QRegion();
1115 
1117  if (!bs)
1118  return QRegion();
1119 
1120  return bs->dirtyRegion(widget);
1121 }
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
QRegion dirtyRegion(QWidget *widget=0) const
Returns the region (in top-level coordinates) that needs repaint and/or flush.
QWidgetBackingStore * maybeBackingStore() const
Definition: qwidget_p.h:1036

◆ QWidget

friend class QWidget
friend

Definition at line 269 of file qbackingstore_p.h.

◆ QWidgetPrivate

friend class QWidgetPrivate
friend

Definition at line 268 of file qbackingstore_p.h.

◆ QWindowSurface

friend class QWindowSurface
friend

Definition at line 272 of file qbackingstore_p.h.

◆ QWSManagerPrivate

friend class QWSManagerPrivate
friend

Definition at line 270 of file qbackingstore_p.h.

Referenced by removeDirtyWidget().

◆ QWSWindowSurface

friend class QWSWindowSurface
friend

Definition at line 273 of file qbackingstore_p.h.

Properties

◆ dirty

QRegion QWidgetBackingStore::dirty
private

◆ dirtyFromPreviousSync

QRegion QWidgetBackingStore::dirtyFromPreviousSync
private

Definition at line 111 of file qbackingstore_p.h.

Referenced by beginPaint(), and sync().

◆ dirtyOnScreen

QRegion QWidgetBackingStore::dirtyOnScreen
private

Definition at line 109 of file qbackingstore_p.h.

Referenced by beginPaint(), dirtyRegion(), flush(), and markDirtyOnScreen().

◆ dirtyOnScreenWidgets

QVector<QWidget *>* QWidgetBackingStore::dirtyOnScreenWidgets
private

Definition at line 113 of file qbackingstore_p.h.

Referenced by dirtyRegion(), flush(), and ~QWidgetBackingStore().

◆ dirtyWidgets

QVector<QWidget *> QWidgetBackingStore::dirtyWidgets
private

Definition at line 112 of file qbackingstore_p.h.

Referenced by dirtyRegion(), markDirty(), sync(), and ~QWidgetBackingStore().

◆ fullUpdatePending

uint QWidgetBackingStore::fullUpdatePending
private

Definition at line 120 of file qbackingstore_p.h.

Referenced by bltRect(), dirtyRegion(), markDirty(), and sync().

◆ hasDirtyFromPreviousSync

uint QWidgetBackingStore::hasDirtyFromPreviousSync
private

Definition at line 119 of file qbackingstore_p.h.

Referenced by beginPaint(), and sync().

◆ staticWidgets

QList<QWidget *> QWidgetBackingStore::staticWidgets
private

Definition at line 114 of file qbackingstore_p.h.

Referenced by staticContents().

◆ tlw

QWidget* QWidgetBackingStore::tlw
private

◆ tlwOffset

QPoint QWidgetBackingStore::tlwOffset
private

Definition at line 122 of file qbackingstore_p.h.

Referenced by beginPaint(), bltRect(), flush(), removeDirtyWidget(), and sync().

◆ windowSurface

QWindowSurface* QWidgetBackingStore::windowSurface
private

The documentation for this class was generated from the following files: