source: trunk/src/gui/painting/qwindowsurface_qws_p.h

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 9.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 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** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
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** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QWINDOWSURFACE_QWS_P_H
43#define QWINDOWSURFACE_QWS_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 "qwindowsurface_p.h"
57#include <qregion.h>
58#include <qimage.h>
59#include <qdirectpainter_qws.h>
60#include <qmutex.h>
61#include <private/qwssharedmemory_p.h>
62
63QT_BEGIN_NAMESPACE
64
65class QScreen;
66class QWSWindowSurfacePrivate;
67
68class Q_GUI_EXPORT QWSWindowSurface : public QWindowSurface
69{
70public:
71 QWSWindowSurface();
72 QWSWindowSurface(QWidget *widget);
73 ~QWSWindowSurface();
74
75 virtual bool isValid() const = 0;
76
77 virtual void setGeometry(const QRect &rect);
78 virtual void setGeometry(const QRect &rect, const QRegion &mask);
79 virtual void flush(QWidget *widget, const QRegion &region,
80 const QPoint &offset);
81
82 virtual bool move(const QPoint &offset);
83 virtual QRegion move(const QPoint &offset, const QRegion &newClip);
84
85 virtual QPoint painterOffset() const; // remove!!!
86
87 virtual void beginPaint(const QRegion &);
88 virtual void endPaint(const QRegion &);
89
90 virtual bool lock(int timeout = -1);
91 virtual void unlock();
92
93 virtual QString key() const = 0;
94
95 // XXX: not good enough
96 virtual QByteArray transientState() const;
97 virtual QByteArray permanentState() const;
98 virtual void setTransientState(const QByteArray &state);
99 virtual void setPermanentState(const QByteArray &state);
100
101 virtual QImage image() const = 0;
102 virtual QPaintDevice *paintDevice() = 0;
103
104 const QRegion clipRegion() const;
105 void setClipRegion(const QRegion &);
106
107#ifdef QT_QWS_CLIENTBLIT
108 virtual const QRegion directRegion() const;
109 virtual int directRegionId() const;
110 virtual void setDirectRegion(const QRegion &, int);
111#endif
112
113 enum SurfaceFlag {
114 RegionReserved = 0x1,
115 Buffered = 0x2,
116 Opaque = 0x4
117 };
118 Q_DECLARE_FLAGS(SurfaceFlags, SurfaceFlag)
119
120 SurfaceFlags surfaceFlags() const;
121
122 inline bool isRegionReserved() const {
123 return surfaceFlags() & RegionReserved;
124 }
125 inline bool isBuffered() const { return surfaceFlags() & Buffered; }
126 inline bool isOpaque() const { return surfaceFlags() & Opaque; }
127
128 int winId() const;
129 virtual void releaseSurface();
130
131protected:
132 void setSurfaceFlags(SurfaceFlags type);
133 void setWinId(int id);
134
135private:
136 friend class QWidgetPrivate;
137
138 void invalidateBuffer();
139
140 QWSWindowSurfacePrivate *d_ptr;
141};
142
143Q_DECLARE_OPERATORS_FOR_FLAGS(QWSWindowSurface::SurfaceFlags)
144
145class QWSWindowSurfacePrivate
146{
147public:
148 QWSWindowSurfacePrivate();
149
150 void setWinId(int id);
151
152 QWSWindowSurface::SurfaceFlags flags;
153 QRegion clip;
154#ifdef QT_QWS_CLIENTBLIT
155 QRegion direct;
156 int directId;
157#endif
158
159 int winId;
160};
161
162class QWSLock;
163
164class Q_GUI_EXPORT QWSMemorySurface : public QWSWindowSurface
165{
166public:
167 QWSMemorySurface();
168 QWSMemorySurface(QWidget *widget);
169 ~QWSMemorySurface();
170
171 bool isValid() const;
172
173 QPaintDevice *paintDevice() { return &img; }
174 bool scroll(const QRegion &area, int dx, int dy);
175
176 QImage image() const { return img; }
177 QPoint painterOffset() const;
178
179 void beginPaint(const QRegion &rgn);
180
181 bool lock(int timeout = -1);
182 void unlock();
183
184protected:
185 QImage::Format preferredImageFormat(const QWidget *widget) const;
186
187#ifndef QT_NO_QWS_MULTIPROCESS
188 void setLock(int lockId);
189 QWSLock *memlock;
190#endif
191#ifndef QT_NO_THREAD
192 QMutex threadLock;
193#endif
194
195 QImage img;
196};
197
198class Q_GUI_EXPORT QWSLocalMemSurface : public QWSMemorySurface
199{
200public:
201 QWSLocalMemSurface();
202 QWSLocalMemSurface(QWidget *widget);
203 ~QWSLocalMemSurface();
204
205 void setGeometry(const QRect &rect);
206
207 QString key() const { return QLatin1String("mem"); }
208 QByteArray permanentState() const;
209
210 void setPermanentState(const QByteArray &data);
211 virtual void releaseSurface();
212protected:
213 uchar *mem;
214 int memsize;
215};
216
217#ifndef QT_NO_QWS_MULTIPROCESS
218class Q_GUI_EXPORT QWSSharedMemSurface : public QWSMemorySurface
219{
220public:
221 QWSSharedMemSurface();
222 QWSSharedMemSurface(QWidget *widget);
223 ~QWSSharedMemSurface();
224
225 void setGeometry(const QRect &rect);
226
227 QString key() const { return QLatin1String("shm"); }
228 QByteArray permanentState() const;
229
230 void setPermanentState(const QByteArray &data);
231
232#ifdef QT_QWS_CLIENTBLIT
233 virtual void setDirectRegion(const QRegion &, int);
234 virtual const QRegion directRegion() const;
235#endif
236 virtual void releaseSurface();
237
238private:
239 bool setMemory(int memId);
240
241 QWSSharedMemory mem;
242};
243#endif // QT_NO_QWS_MULTIPROCESS
244
245#ifndef QT_NO_PAINTONSCREEN
246class Q_GUI_EXPORT QWSOnScreenSurface : public QWSMemorySurface
247{
248public:
249 QWSOnScreenSurface();
250 QWSOnScreenSurface(QWidget *widget);
251 ~QWSOnScreenSurface();
252
253 bool isValid() const;
254 QPoint painterOffset() const;
255
256 QString key() const { return QLatin1String("OnScreen"); }
257 QByteArray permanentState() const;
258
259 void setPermanentState(const QByteArray &data);
260
261private:
262 void attachToScreen(const QScreen *screen);
263
264 const QScreen *screen;
265};
266#endif // QT_NO_PAINTONSCREEN
267
268#ifndef QT_NO_PAINT_DEBUG
269class Q_GUI_EXPORT QWSYellowSurface : public QWSWindowSurface
270{
271public:
272 QWSYellowSurface(bool isClient = false);
273 ~QWSYellowSurface();
274
275 void setDelay(int msec) { delay = msec; }
276
277 bool isValid() const { return true; }
278
279 void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
280
281 QString key() const { return QLatin1String("Yellow"); }
282 QByteArray permanentState() const;
283
284 void setPermanentState(const QByteArray &data);
285
286 QPaintDevice *paintDevice() { return &img; }
287 QImage image() const { return img; }
288
289private:
290 int delay;
291 QSize surfaceSize; // client side
292 QImage img; // server side
293};
294#endif // QT_NO_PAINT_DEBUG
295
296#ifndef QT_NO_DIRECTPAINTER
297
298class QScreen;
299
300class Q_GUI_EXPORT QWSDirectPainterSurface : public QWSWindowSurface
301{
302public:
303 QWSDirectPainterSurface(bool isClient = false,
304 QDirectPainter::SurfaceFlag flags = QDirectPainter::NonReserved);
305 ~QWSDirectPainterSurface();
306
307 void setReserved() { setSurfaceFlags(RegionReserved); }
308
309 void setGeometry(const QRect &rect) { setRegion(rect); }
310
311 void setRegion(const QRegion &region);
312 QRegion region() const { return clipRegion(); }
313
314 void flush(QWidget*, const QRegion &, const QPoint &);
315
316 bool isValid() const { return false; }
317
318 QString key() const { return QLatin1String("DirectPainter"); }
319 QByteArray permanentState() const;
320
321 void setPermanentState(const QByteArray &);
322
323 QImage image() const { return QImage(); }
324 QPaintDevice *paintDevice() { return 0; }
325
326 // hw: get rid of this
327 WId windowId() const { return static_cast<WId>(winId()); }
328
329 QScreen *screen() const { return _screen; }
330
331 void beginPaint(const QRegion &);
332 bool lock(int timeout = -1);
333 void unlock();
334
335 void setLocking(bool b) { doLocking = b; }
336
337 bool hasPendingRegionEvents() const;
338
339private:
340 QScreen *_screen;
341#ifndef QT_NO_THREAD
342 QMutex threadLock;
343#endif
344
345 friend void qt_directpainter_region(QDirectPainter*, const QRegion&, int);
346 bool flushingRegionEvents;
347 bool synchronous;
348 bool doLocking;
349};
350
351#endif // QT_NO_DIRECTPAINTER
352
353QT_END_NAMESPACE
354
355#endif // QWINDOWSURFACE_QWS_P_H
Note: See TracBrowser for help on using the repository browser.