Qt 4.8
qbackingstore_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QBACKINGSTORE_P_H
43 #define QBACKINGSTORE_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include <QDebug>
57 #include <QtGui/qwidget.h>
58 #include <private/qwidget_p.h>
59 #include <private/qwindowsurface_p.h>
60 #ifdef Q_WS_QWS
61 #include <private/qwindowsurface_qws_p.h>
62 #endif
63 
65 
66 class QWindowSurface;
67 
73 };
74 
76 {
77 public:
80 
81  static void showYellowThing(QWidget *widget, const QRegion &rgn, int msec, bool);
82 
83  void sync(QWidget *exposedWidget, const QRegion &exposedRegion);
84  void sync();
85  void flush(QWidget *widget = 0, QWindowSurface *surface = 0);
86 
87  inline QPoint topLevelOffset() const { return tlwOffset; }
88 
89  QWindowSurface *surface() const { return windowSurface; }
90 
91  inline bool isDirty() const
92  {
93  return !(dirtyWidgets.isEmpty() && dirty.isEmpty() && !hasDirtyFromPreviousSync
94  && !fullUpdatePending
95 #if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
96  && !hasDirtyWindowDecoration()
97 #endif
98  );
99  }
100 
101  // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
102  void markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately = false,
103  bool invalidateBuffer = false);
104  void markDirty(const QRect &rect, QWidget *widget, bool updateImmediately = false,
105  bool invalidateBuffer = false);
106 
107 private:
109  QRegion dirtyOnScreen; // needsFlush
110  QRegion dirty; // needsRepaint
116 #ifdef Q_BACKINGSTORE_SUBSURFACES
117  QList<QWindowSurface*> subSurfaces;
118 #endif
121 
123 
124  static bool flushPaint(QWidget *widget, const QRegion &rgn);
125  static void unflushPaint(QWidget *widget, const QRegion &rgn);
126 
127  bool bltRect(const QRect &rect, int dx, int dy, QWidget *widget);
128  void releaseBuffer();
129 
130  void beginPaint(QRegion &toClean, QWidget *widget, QWindowSurface *windowSurface,
131  BeginPaintInfo *returnInfo, bool toCleanIsInTopLevelCoordinates = true);
132  void endPaint(const QRegion &cleaned, QWindowSurface *windowSurface, BeginPaintInfo *beginPaintInfo);
133 
134  QRegion dirtyRegion(QWidget *widget = 0) const;
135  QRegion staticContents(QWidget *widget = 0, const QRect &withinClipRect = QRect()) const;
136 
137  void markDirtyOnScreen(const QRegion &dirtyOnScreen, QWidget *widget, const QPoint &topLevelOffset);
138 
139  void removeDirtyWidget(QWidget *w);
140 
141 #if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
142  bool hasDirtyWindowDecoration() const;
143  void paintWindowDecoration();
144 #endif
145  void updateLists(QWidget *widget);
146 
147  inline void addDirtyWidget(QWidget *widget, const QRegion &rgn)
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  }
161 
162  inline void dirtyWidgetsRemoveAll(QWidget *widget)
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  }
172 
173  inline void addStaticWidget(QWidget *widget)
174  {
175  if (!widget)
176  return;
177 
179  if (!staticWidgets.contains(widget))
180  staticWidgets.append(widget);
181  }
182 
183  inline void removeStaticWidget(QWidget *widget)
184  { staticWidgets.removeAll(widget); }
185 
186  // Move the reparented widget and all its static children from this backing store
187  // to the new backing store if reparented into another top-level / backing store.
188  inline void moveStaticWidgets(QWidget *reparented)
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)) {
199  staticWidgets.removeAt(i);
200  if (newBs)
201  newBs->addStaticWidget(w);
202  } else {
203  ++i;
204  }
205  }
206  }
207 
208  inline QRect topLevelRect() const
209  {
210 #ifdef Q_WS_QWS
211  return tlw->frameGeometry();
212 #else
213  return tlw->data->crect;
214 #endif
215  }
216 
217  inline void appendDirtyOnScreenWidget(QWidget *widget)
218  {
219  if (!widget)
220  return;
221 
222  if (!dirtyOnScreenWidgets) {
223  dirtyOnScreenWidgets = new QVector<QWidget *>;
224  dirtyOnScreenWidgets->append(widget);
225  } else if (!dirtyOnScreenWidgets->contains(widget)) {
226  dirtyOnScreenWidgets->append(widget);
227  }
228  }
229 
231  {
232  if (!widget || !dirtyOnScreenWidgets)
233  return;
234 
235  int i = 0;
236  while (i < dirtyOnScreenWidgets->size()) {
237  if (dirtyOnScreenWidgets->at(i) == widget)
238  dirtyOnScreenWidgets->remove(i);
239  else
240  ++i;
241  }
242  }
243 
244  inline void resetWidget(QWidget *widget)
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  }
253 
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  }
263 
264  inline bool hasStaticContents() const
265  { return !staticWidgets.isEmpty() && windowSurface->hasFeature(QWindowSurface::StaticContents); }
266 
267  friend QRegion qt_dirtyRegion(QWidget *);
268  friend class QWidgetPrivate;
269  friend class QWidget;
270  friend class QWSManagerPrivate;
271  friend class QETWidget;
272  friend class QWindowSurface;
273  friend class QWSWindowSurface;
274 };
275 
277 
278 #endif // QBACKINGSTORE_P_H
The QWSWindowSurface class provides the drawing area for top-level windows in Qt for Embedded Linux...
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPointer< QWidget > widget
QRegion dirty
Definition: qwidget_p.h:726
void remove(int i)
Removes the element at index position i.
Definition: qvector.h:374
QRect crect
Definition: qwidget.h:131
QWindowSurface * windowSurface
QRegion qt_dirtyRegion(QWidget *)
Definition: qwidget.cpp:1111
bool isDirty() const
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QRect frameGeometry
geometry of the widget relative to its parent including any window frame
Definition: qwidget.h:159
void addStaticWidget(QWidget *widget)
void resetWidget(QWidget *widget)
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
QList< QWidget * > staticWidgets
QRect topLevelRect() const
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QWidgetData data
Definition: qwidget_p.h:755
QVector< QWidget * > dirtyWidgets
QWindowSurface * surface() const
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
void createExtra()
Creates the widget extra data.
Definition: qwidget.cpp:1802
QGraphicsEffect * graphicsEffect
Definition: qwidget_p.h:710
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
uint windowSurfaceRecreated
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
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
QWidgetData * data
Definition: qwidget.h:815
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
unsigned int uint
Definition: qglobal.h:996
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
bool hasStaticContents() const
void appendDirtyOnScreenWidget(QWidget *widget)
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
uint inDirtyList
Definition: qwidget_p.h:772
QPoint topLevelOffset() const
void moveStaticWidgets(QWidget *reparented)
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
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
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
QWExtra * extra
Definition: qwidget_p.h:700
void dirtyOnScreenWidgetsRemoveAll(QWidget *widget)
bool contains(const T &t) const
Returns true if the vector contains an occurrence of value; otherwise returns false.
Definition: qvector.h:731
void removeStaticWidget(QWidget *widget)
bool hasFeature(WindowSurfaceFeature feature) const
Q_CORE_EXPORT QTextStream & flush(QTextStream &s)
uint in_destructor
Definition: qwidget.h:129
void dirtyWidgetsRemoveAll(QWidget *widget)
QVector< QWidget * > * dirtyOnScreenWidgets
void addDirtyWidget(QWidget *widget, const QRegion &rgn)
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QRect effectiveRectFor(const QRect &rect) const
Definition: qwidget_p.h:658
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480