Qt 4.8
Functions
qbackingstore.cpp File Reference
#include "qplatformdefs.h"
#include "qbackingstore_p.h"
#include <QtCore/qglobal.h>
#include <QtCore/qdebug.h>
#include <QtCore/qvarlengtharray.h>
#include <QtGui/qevent.h>
#include <QtGui/qapplication.h>
#include <QtGui/qpaintengine.h>
#include <QtGui/qgraphicsproxywidget.h>
#include <private/qwidget_p.h>
#include <private/qwindowsurface_raster_p.h>
#include <private/qapplication_p.h>
#include <private/qpaintengine_raster_p.h>
#include <private/qgraphicseffect_p.h>
#include "qgraphicssystem_p.h"
#include <QtGui/qwsmanager_qws.h>
#include <private/qwsmanager_p.h>

Go to the source code of this file.

Functions

static bool discardInvalidateBufferRequest (QWidget *widget, QTLWExtra *tlwExtra)
 
static bool discardSyncRequest (QWidget *tlw, QTLWExtra *tlwExtra)
 
static bool qRectIntersects (const QRect &r1, const QRect &r2)
 
QRegion qt_dirtyRegion (QWidget *)
 
static void qt_flush (QWidget *widget, const QRegion &region, QWindowSurface *windowSurface, QWidget *tlw, const QPoint &tlwOffset)
 
static void sendUpdateRequest (QWidget *widget, bool updateImmediately)
 
static void showYellowThing_win (QWidget *widget, const QRegion &region, int msec)
 

Function Documentation

◆ discardInvalidateBufferRequest()

static bool discardInvalidateBufferRequest ( QWidget widget,
QTLWExtra tlwExtra 
)
inlinestatic

Definition at line 1451 of file qbackingstore.cpp.

Referenced by QWidgetPrivate::invalidateBuffer().

1452 {
1453  Q_ASSERT(widget);
1455  return true;
1456 
1457  if (!tlwExtra || tlwExtra->inTopLevelResize || !tlwExtra->backingStore)
1458  return true;
1459 
1460  if (!widget->isVisible() || !widget->updatesEnabled())
1461  return true;
1462 
1463  return false;
1464 }
bool isVisible() const
Definition: qwidget.h:1005
uint inTopLevelResize
Definition: qwidget_p.h:188
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool updatesEnabled
whether updates are enabled
Definition: qwidget.h:190
static bool closingDown()
Returns true if the application objects are being destroyed; otherwise returns false.
QWidgetBackingStoreTracker backingStore
Definition: qwidget_p.h:166

◆ discardSyncRequest()

static bool discardSyncRequest ( QWidget tlw,
QTLWExtra tlwExtra 
)
inlinestatic

Definition at line 1098 of file qbackingstore.cpp.

Referenced by QWidgetBackingStore::sync().

1099 {
1100  if (!tlw || !tlwExtra)
1101  return true;
1102 
1103 #ifdef Q_WS_X11
1104  // Delay the sync until we get an Expose event from X11 (initial show).
1105  // Qt::WA_Mapped is set to true, but the actual mapping has not yet occurred.
1106  // However, we must repaint immediately regardless of the state if someone calls repaint().
1107  if (tlwExtra->waitingForMapNotify && !tlwExtra->inRepaint)
1108  return true;
1109 #endif
1110 
1111  if (!tlw->testAttribute(Qt::WA_Mapped))
1112  return true;
1113 
1114  if (!tlw->isVisible()
1115 #ifndef Q_WS_X11
1116  // If we're minimized on X11, WA_Mapped will be false and we
1117  // will return in the case above. Some window managers on X11
1118  // sends us the PropertyNotify to change the minimized state
1119  // *AFTER* we've received the expose event, which is baaad.
1120  || tlw->isMinimized()
1121 #endif
1122  )
1123  return true;
1124 
1125  return false;
1126 }
bool isVisible() const
Definition: qwidget.h:1005
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
uint inRepaint
Definition: qwidget_p.h:189
bool isMinimized() const
Definition: qwidget.cpp:3027
uint waitingForMapNotify
Definition: qwidget_p.h:197

◆ qRectIntersects()

static bool qRectIntersects ( const QRect r1,
const QRect r2 
)
inlinestatic

Definition at line 75 of file qbackingstore.cpp.

Referenced by QWidgetBackingStore::sync().

76 {
77  return (qMax(r1.left(), r2.left()) <= qMin(r1.right(), r2.right())
78  && qMax(r1.top(), r2.top()) <= qMin(r1.bottom(), r2.bottom()));
79 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246

◆ qt_dirtyRegion()

QRegion qt_dirtyRegion ( QWidget )

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 }
QPointer< QWidget > widget
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

◆ qt_flush()

static void qt_flush ( QWidget widget,
const QRegion region,
QWindowSurface windowSurface,
QWidget tlw,
const QPoint tlwOffset 
)
inlinestatic

Flushes the contents of the windowSurface into the screen area of widget. tlwOffset is the position of the top level widget relative to the window surface. region is the region to be updated in widget coordinates.

Definition at line 86 of file qbackingstore.cpp.

Referenced by QWidgetBackingStore::flush(), QWidgetBackingStore::sync(), and QWidgetBackingStore::unflushPaint().

88 {
89  Q_ASSERT(widget);
90  Q_ASSERT(!region.isEmpty());
91  Q_ASSERT(windowSurface);
92  Q_ASSERT(tlw);
93 
94 #if !defined(QT_NO_PAINT_DEBUG) && !defined(Q_WS_QWS)
95  // QWS does flush update in QWindowSurface::flush (because it needs to lock the surface etc).
96  static int flushUpdate = qgetenv("QT_FLUSH_UPDATE").toInt();
97  if (flushUpdate > 0)
98  QWidgetBackingStore::showYellowThing(widget, region, flushUpdate * 10, false);
99 #endif
100 
101  //The performance hit by doing this should be negligible. However, be aware that
102  //using this FPS when you have > 1 windowsurface can give you inaccurate FPS
103  static bool fpsDebug = qgetenv("QT_DEBUG_FPS").toInt();
104  if (fpsDebug) {
105  static QTime time = QTime::currentTime();
106  static int frames = 0;
107 
108  frames++;
109 
110  if(time.elapsed() > 5000) {
111  double fps = double(frames * 1000) /time.restart();
112  fprintf(stderr,"FPS: %.1f\n",fps);
113  frames = 0;
114  }
115  }
116  if (widget != tlw)
117  windowSurface->flush(widget, region, tlwOffset + widget->mapTo(tlw, QPoint()));
118  else
119  windowSurface->flush(widget, region, tlwOffset);
120 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int restart()
Sets this time to the current time and returns the number of milliseconds that have elapsed since the...
Definition: qdatetime.cpp:2095
The QTime class provides clock time functions.
Definition: qdatetime.h:148
virtual void flush(QWidget *widget, const QRegion &region, const QPoint &offset)=0
Flushes the given region from the specified widget onto the screen.
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
static void showYellowThing(QWidget *widget, const QRegion &rgn, int msec, bool)
int elapsed() const
Returns the number of milliseconds that have elapsed since the last time start() or restart() was cal...
Definition: qdatetime.cpp:2123
static QTime currentTime()
Returns the current time as reported by the system clock.
Definition: qdatetime.cpp:3125
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...
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
static void flushUpdate(QWidget *widget, const QRegion &region, const QPoint &offset)

◆ sendUpdateRequest()

static void sendUpdateRequest ( QWidget widget,
bool  updateImmediately 
)
inlinestatic

Definition at line 527 of file qbackingstore.cpp.

Referenced by QWidgetBackingStore::markDirty().

528 {
529  if (!widget)
530  return;
531 
532  if (updateImmediately) {
534  QApplication::sendEvent(widget, &event);
535  } else {
537  }
538 }
EventRef event
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

◆ showYellowThing_win()

static void showYellowThing_win ( QWidget widget,
const QRegion region,
int  msec 
)
static

Definition at line 124 of file qbackingstore.cpp.

Referenced by QWidgetBackingStore::showYellowThing().

125 {
126  HBRUSH brush;
127  static int i = 0;
128  switch (i) {
129  case 0:
130  brush = CreateSolidBrush(RGB(255, 255, 0));
131  break;
132  case 1:
133  brush = CreateSolidBrush(RGB(255, 200, 55));
134  break;
135  case 2:
136  brush = CreateSolidBrush(RGB(200, 255, 55));
137  break;
138  case 3:
139  brush = CreateSolidBrush(RGB(200, 200, 0));
140  break;
141  }
142  i = (i + 1) & 3;
143 
144  HDC hdc = widget->getDC();
145 
146  const QVector<QRect> &rects = region.rects();
147  foreach (QRect rect, rects) {
148  RECT winRect;
149  SetRect(&winRect, rect.left(), rect.top(), rect.right(), rect.bottom());
150  FillRect(hdc, &winRect, brush);
151  }
152 
153  widget->releaseDC(hdc);
154  ::Sleep(msec);
155 }
void releaseDC(HDC) const
Releases the HDC hdc acquired by a previous call to getDC().
Definition: qwidget.cpp:11862
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
HDC getDC() const
Returns the window system handle of the widget, for low-level access.
Definition: qwidget.cpp:11849