0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the QtGui module of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
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 |
|
|
64 |
QT_BEGIN_NAMESPACE
|
|
65 |
|
|
66 |
class QWindowSurface;
|
|
67 |
|
|
68 |
struct BeginPaintInfo {
|
|
69 |
inline BeginPaintInfo() : wasFlushed(0), nothingToPaint(0), windowSurfaceRecreated(0) {}
|
|
70 |
uint wasFlushed : 1;
|
|
71 |
uint nothingToPaint : 1;
|
|
72 |
uint windowSurfaceRecreated : 1;
|
|
73 |
};
|
|
74 |
|
|
75 |
class Q_AUTOTEST_EXPORT QWidgetBackingStore
|
|
76 |
{
|
|
77 |
public:
|
|
78 |
QWidgetBackingStore(QWidget *t);
|
|
79 |
~QWidgetBackingStore();
|
|
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 |
#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
|
|
95 |
&& !hasDirtyWindowDecoration()
|
|
96 |
#endif
|
|
97 |
);
|
|
98 |
}
|
|
99 |
|
|
100 |
// ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
|
|
101 |
void markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately = false,
|
|
102 |
bool invalidateBuffer = false);
|
|
103 |
void markDirty(const QRect &rect, QWidget *widget, bool updateImmediately = false,
|
|
104 |
bool invalidateBuffer = false);
|
|
105 |
|
|
106 |
private:
|
|
107 |
QWidget *tlw;
|
|
108 |
QRegion dirtyOnScreen; // needsFlush
|
|
109 |
QRegion dirty; // needsRepaint
|
|
110 |
QRegion dirtyFromPreviousSync;
|
|
111 |
QVector<QWidget *> dirtyWidgets;
|
|
112 |
QVector<QWidget *> *dirtyOnScreenWidgets;
|
|
113 |
QList<QWidget *> staticWidgets;
|
|
114 |
QWindowSurface *windowSurface;
|
|
115 |
#ifdef Q_BACKINGSTORE_SUBSURFACES
|
|
116 |
QList<QWindowSurface*> subSurfaces;
|
|
117 |
#endif
|
|
118 |
bool hasDirtyFromPreviousSync;
|
|
119 |
|
|
120 |
QPoint tlwOffset;
|
|
121 |
|
|
122 |
static bool flushPaint(QWidget *widget, const QRegion &rgn);
|
|
123 |
static void unflushPaint(QWidget *widget, const QRegion &rgn);
|
|
124 |
|
|
125 |
bool bltRect(const QRect &rect, int dx, int dy, QWidget *widget);
|
|
126 |
void releaseBuffer();
|
|
127 |
|
|
128 |
void beginPaint(QRegion &toClean, QWidget *widget, QWindowSurface *windowSurface,
|
|
129 |
BeginPaintInfo *returnInfo, bool toCleanIsInTopLevelCoordinates = true);
|
|
130 |
void endPaint(const QRegion &cleaned, QWindowSurface *windowSurface, BeginPaintInfo *beginPaintInfo);
|
|
131 |
|
|
132 |
QRegion dirtyRegion(QWidget *widget = 0) const;
|
|
133 |
QRegion staticContents(QWidget *widget = 0, const QRect &withinClipRect = QRect()) const;
|
|
134 |
|
|
135 |
void markDirtyOnScreen(const QRegion &dirtyOnScreen, QWidget *widget, const QPoint &topLevelOffset);
|
|
136 |
|
|
137 |
void removeDirtyWidget(QWidget *w);
|
|
138 |
|
|
139 |
#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
|
|
140 |
bool hasDirtyWindowDecoration() const;
|
|
141 |
void paintWindowDecoration();
|
|
142 |
#endif
|
|
143 |
void updateLists(QWidget *widget);
|
|
144 |
|
|
145 |
inline void addDirtyWidget(QWidget *widget, const QRegion &rgn)
|
|
146 |
{
|
|
147 |
if (widget && !widget->d_func()->inDirtyList && !widget->data->in_destructor) {
|
|
148 |
QWidgetPrivate *widgetPrivate = widget->d_func();
|
|
149 |
if (widgetPrivate->graphicsEffect)
|
|
150 |
widgetPrivate->dirty = widgetPrivate->effectiveRectFor(rgn.boundingRect());
|
|
151 |
else
|
|
152 |
widgetPrivate->dirty = rgn;
|
|
153 |
dirtyWidgets.append(widget);
|
|
154 |
widgetPrivate->inDirtyList = true;
|
|
155 |
}
|
|
156 |
}
|
|
157 |
|
|
158 |
inline void dirtyWidgetsRemoveAll(QWidget *widget)
|
|
159 |
{
|
|
160 |
int i = 0;
|
|
161 |
while (i < dirtyWidgets.size()) {
|
|
162 |
if (dirtyWidgets.at(i) == widget)
|
|
163 |
dirtyWidgets.remove(i);
|
|
164 |
else
|
|
165 |
++i;
|
|
166 |
}
|
|
167 |
}
|
|
168 |
|
|
169 |
inline void addStaticWidget(QWidget *widget)
|
|
170 |
{
|
|
171 |
if (!widget)
|
|
172 |
return;
|
|
173 |
|
|
174 |
Q_ASSERT(widget->testAttribute(Qt::WA_StaticContents));
|
|
175 |
if (!staticWidgets.contains(widget))
|
|
176 |
staticWidgets.append(widget);
|
|
177 |
}
|
|
178 |
|
|
179 |
inline void removeStaticWidget(QWidget *widget)
|
|
180 |
{ staticWidgets.removeAll(widget); }
|
|
181 |
|
|
182 |
// Move the reparented widget and all its static children from this backing store
|
|
183 |
// to the new backing store if reparented into another top-level / backing store.
|
|
184 |
inline void moveStaticWidgets(QWidget *reparented)
|
|
185 |
{
|
|
186 |
Q_ASSERT(reparented);
|
|
187 |
QWidgetBackingStore *newBs = reparented->d_func()->maybeBackingStore();
|
|
188 |
if (newBs == this)
|
|
189 |
return;
|
|
190 |
|
|
191 |
int i = 0;
|
|
192 |
while (i < staticWidgets.size()) {
|
|
193 |
QWidget *w = staticWidgets.at(i);
|
|
194 |
if (reparented == w || reparented->isAncestorOf(w)) {
|
|
195 |
staticWidgets.removeAt(i);
|
|
196 |
if (newBs)
|
|
197 |
newBs->addStaticWidget(w);
|
|
198 |
} else {
|
|
199 |
++i;
|
|
200 |
}
|
|
201 |
}
|
|
202 |
}
|
|
203 |
|
|
204 |
inline QRect topLevelRect() const
|
|
205 |
{
|
|
206 |
#ifdef Q_WS_QWS
|
|
207 |
return tlw->frameGeometry();
|
|
208 |
#endif
|
|
209 |
return tlw->data->crect;
|
|
210 |
}
|
|
211 |
|
|
212 |
inline void appendDirtyOnScreenWidget(QWidget *widget)
|
|
213 |
{
|
|
214 |
if (!widget)
|
|
215 |
return;
|
|
216 |
|
|
217 |
if (!dirtyOnScreenWidgets) {
|
|
218 |
dirtyOnScreenWidgets = new QVector<QWidget *>;
|
|
219 |
dirtyOnScreenWidgets->append(widget);
|
|
220 |
} else if (!dirtyOnScreenWidgets->contains(widget)) {
|
|
221 |
dirtyOnScreenWidgets->append(widget);
|
|
222 |
}
|
|
223 |
}
|
|
224 |
|
|
225 |
inline void dirtyOnScreenWidgetsRemoveAll(QWidget *widget)
|
|
226 |
{
|
|
227 |
if (!widget || !dirtyOnScreenWidgets)
|
|
228 |
return;
|
|
229 |
|
|
230 |
int i = 0;
|
|
231 |
while (i < dirtyOnScreenWidgets->size()) {
|
|
232 |
if (dirtyOnScreenWidgets->at(i) == widget)
|
|
233 |
dirtyOnScreenWidgets->remove(i);
|
|
234 |
else
|
|
235 |
++i;
|
|
236 |
}
|
|
237 |
}
|
|
238 |
|
|
239 |
inline void resetWidget(QWidget *widget)
|
|
240 |
{
|
|
241 |
if (widget) {
|
|
242 |
widget->d_func()->inDirtyList = false;
|
|
243 |
widget->d_func()->isScrolled = false;
|
|
244 |
widget->d_func()->isMoved = false;
|
|
245 |
widget->d_func()->dirty = QRegion();
|
|
246 |
}
|
|
247 |
}
|
|
248 |
|
|
249 |
inline void updateStaticContentsSize()
|
|
250 |
{
|
|
251 |
for (int i = 0; i < staticWidgets.size(); ++i) {
|
|
252 |
QWidgetPrivate *wd = staticWidgets.at(i)->d_func();
|
|
253 |
if (!wd->extra)
|
|
254 |
wd->createExtra();
|
|
255 |
wd->extra->staticContentsSize = wd->data.crect.size();
|
|
256 |
}
|
|
257 |
}
|
|
258 |
|
|
259 |
inline bool hasStaticContents() const
|
|
260 |
{ return !staticWidgets.isEmpty() && windowSurface->hasStaticContentsSupport(); }
|
|
261 |
|
|
262 |
friend QRegion qt_dirtyRegion(QWidget *);
|
|
263 |
friend class QWidgetPrivate;
|
|
264 |
friend class QWidget;
|
|
265 |
friend class QWSManagerPrivate;
|
|
266 |
friend class QETWidget;
|
|
267 |
friend class QWindowSurface;
|
|
268 |
friend class QWSWindowSurface;
|
|
269 |
};
|
|
270 |
|
|
271 |
QT_END_NAMESPACE
|
|
272 |
|
|
273 |
#endif // QBACKINGSTORE_P_H
|