1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtGui module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QWINDOWSURFACE_QWS_P_H
43 #define QWINDOWSURFACE_QWS_P_H
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.
56 #include "qwindowsurface_p.h"
59 #include <qdirectpainter_qws.h>
61 #include <private/qwssharedmemory_p.h>
66 class QWSWindowSurfacePrivate;
68 class Q_GUI_EXPORT QWSWindowSurface : public QWindowSurface
72 QWSWindowSurface(QWidget *widget);
75 virtual bool isValid() const = 0;
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 ®ion,
80 const QPoint &offset);
82 virtual bool move(const QPoint &offset);
83 virtual QRegion move(const QPoint &offset, const QRegion &newClip);
85 virtual QPoint painterOffset() const; // remove!!!
87 virtual void beginPaint(const QRegion &);
88 virtual void endPaint(const QRegion &);
90 virtual bool lock(int timeout = -1);
91 virtual void unlock();
93 virtual QString key() const = 0;
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);
101 virtual QImage image() const = 0;
102 virtual QPaintDevice *paintDevice() = 0;
104 const QRegion clipRegion() const;
105 void setClipRegion(const QRegion &);
107 #ifdef QT_QWS_CLIENTBLIT
108 virtual const QRegion directRegion() const;
109 virtual int directRegionId() const;
110 virtual void setDirectRegion(const QRegion &, int);
114 RegionReserved = 0x1,
118 Q_DECLARE_FLAGS(SurfaceFlags, SurfaceFlag)
120 SurfaceFlags surfaceFlags() const;
122 inline bool isRegionReserved() const {
123 return surfaceFlags() & RegionReserved;
125 inline bool isBuffered() const { return surfaceFlags() & Buffered; }
126 inline bool isOpaque() const { return surfaceFlags() & Opaque; }
129 virtual void releaseSurface();
132 void setSurfaceFlags(SurfaceFlags type);
133 void setWinId(int id);
136 friend class QWidgetPrivate;
138 void invalidateBuffer();
140 QWSWindowSurfacePrivate *d_ptr;
143 Q_DECLARE_OPERATORS_FOR_FLAGS(QWSWindowSurface::SurfaceFlags)
145 class QWSWindowSurfacePrivate
148 QWSWindowSurfacePrivate();
150 void setWinId(int id);
152 QWSWindowSurface::SurfaceFlags flags;
154 #ifdef QT_QWS_CLIENTBLIT
164 class Q_GUI_EXPORT QWSMemorySurface : public QWSWindowSurface
168 QWSMemorySurface(QWidget *widget);
171 bool isValid() const;
173 QPaintDevice *paintDevice() { return &img; }
174 bool scroll(const QRegion &area, int dx, int dy);
176 QImage image() const { return img; }
177 QPoint painterOffset() const;
179 void beginPaint(const QRegion &rgn);
181 bool lock(int timeout = -1);
185 QImage::Format preferredImageFormat(const QWidget *widget) const;
187 #ifndef QT_NO_QWS_MULTIPROCESS
188 void setLock(int lockId);
198 class Q_GUI_EXPORT QWSLocalMemSurface : public QWSMemorySurface
201 QWSLocalMemSurface();
202 QWSLocalMemSurface(QWidget *widget);
203 ~QWSLocalMemSurface();
205 void setGeometry(const QRect &rect);
207 QString key() const { return QLatin1String("mem"); }
208 QByteArray permanentState() const;
210 void setPermanentState(const QByteArray &data);
211 virtual void releaseSurface();
217 #ifndef QT_NO_QWS_MULTIPROCESS
218 class Q_GUI_EXPORT QWSSharedMemSurface : public QWSMemorySurface
221 QWSSharedMemSurface();
222 QWSSharedMemSurface(QWidget *widget);
223 ~QWSSharedMemSurface();
225 void setGeometry(const QRect &rect);
227 QString key() const { return QLatin1String("shm"); }
228 QByteArray permanentState() const;
230 void setPermanentState(const QByteArray &data);
232 #ifdef QT_QWS_CLIENTBLIT
233 virtual void setDirectRegion(const QRegion &, int);
234 virtual const QRegion directRegion() const;
236 virtual void releaseSurface();
239 bool setMemory(int memId);
243 #endif // QT_NO_QWS_MULTIPROCESS
245 #ifndef QT_NO_PAINTONSCREEN
246 class Q_GUI_EXPORT QWSOnScreenSurface : public QWSMemorySurface
249 QWSOnScreenSurface();
250 QWSOnScreenSurface(QWidget *widget);
251 ~QWSOnScreenSurface();
253 bool isValid() const;
254 QPoint painterOffset() const;
256 QString key() const { return QLatin1String("OnScreen"); }
257 QByteArray permanentState() const;
259 void setPermanentState(const QByteArray &data);
262 void attachToScreen(const QScreen *screen);
264 const QScreen *screen;
266 #endif // QT_NO_PAINTONSCREEN
268 #ifndef QT_NO_PAINT_DEBUG
269 class Q_GUI_EXPORT QWSYellowSurface : public QWSWindowSurface
272 QWSYellowSurface(bool isClient = false);
275 void setDelay(int msec) { delay = msec; }
277 bool isValid() const { return true; }
279 void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset);
281 QString key() const { return QLatin1String("Yellow"); }
282 QByteArray permanentState() const;
284 void setPermanentState(const QByteArray &data);
286 QPaintDevice *paintDevice() { return &img; }
287 QImage image() const { return img; }
291 QSize surfaceSize; // client side
292 QImage img; // server side
294 #endif // QT_NO_PAINT_DEBUG
296 #ifndef QT_NO_DIRECTPAINTER
300 class Q_GUI_EXPORT QWSDirectPainterSurface : public QWSWindowSurface
303 QWSDirectPainterSurface(bool isClient = false,
304 QDirectPainter::SurfaceFlag flags = QDirectPainter::NonReserved);
305 ~QWSDirectPainterSurface();
307 void setReserved() { setSurfaceFlags(RegionReserved); }
309 void setGeometry(const QRect &rect) { setRegion(rect); }
311 void setRegion(const QRegion ®ion);
312 QRegion region() const { return clipRegion(); }
314 void flush(QWidget*, const QRegion &, const QPoint &);
316 bool isValid() const { return false; }
318 QString key() const { return QLatin1String("DirectPainter"); }
319 QByteArray permanentState() const;
321 void setPermanentState(const QByteArray &);
323 QImage image() const { return QImage(); }
324 QPaintDevice *paintDevice() { return 0; }
326 // hw: get rid of this
327 WId windowId() const { return static_cast<WId>(winId()); }
329 QScreen *screen() const { return _screen; }
331 void beginPaint(const QRegion &);
332 bool lock(int timeout = -1);
335 void setLocking(bool b) { doLocking = b; }
337 bool hasPendingRegionEvents() const;
345 friend void qt_directpainter_region(QDirectPainter*, const QRegion&, int);
346 bool flushingRegionEvents;
351 #endif // QT_NO_DIRECTPAINTER
355 #endif // QWINDOWSURFACE_QWS_P_H