Qt 4.8
qwindowsurface_qws_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 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 
64 
65 class QScreen;
67 
69 {
70 public:
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 
131 protected:
132  void setSurfaceFlags(SurfaceFlags type);
133  void setWinId(int id);
134 
135 private:
136  friend class QWidgetPrivate;
137 
138  void invalidateBuffer();
139 
141 };
142 
143 Q_DECLARE_OPERATORS_FOR_FLAGS(QWSWindowSurface::SurfaceFlags)
144 
146 {
147 public:
148  QWSWindowSurfacePrivate();
149 
150  void setWinId(int id);
151 
152  QWSWindowSurface::SurfaceFlags flags;
154 #ifdef QT_QWS_CLIENTBLIT
155  QRegion direct;
156  int directId;
157 #endif
158 
159  int winId;
160 };
161 
162 class QWSLock;
163 
165 {
166 public:
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 
184 protected:
185  QImage::Format preferredImageFormat(const QWidget *widget) const;
186 
187 #ifndef QT_NO_QWS_MULTIPROCESS
188  void setLock(int lockId);
190 #endif
191 #ifndef QT_NO_THREAD
193 #endif
194 
196 };
197 
199 {
200 public:
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();
212 protected:
214  int memsize;
215 };
216 
217 #ifndef QT_NO_QWS_MULTIPROCESS
219 {
220 public:
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 
238 private:
239  bool setMemory(int memId);
240 
242 };
243 #endif // QT_NO_QWS_MULTIPROCESS
244 
245 #ifndef QT_NO_PAINTONSCREEN
247 {
248 public:
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 
261 private:
262  void attachToScreen(const QScreen *screen);
263 
264  const QScreen *screen;
265 };
266 #endif // QT_NO_PAINTONSCREEN
267 
268 #ifndef QT_NO_PAINT_DEBUG
270 {
271 public:
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 
289 private:
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 
298 class QScreen;
299 
301 {
302 public:
303  QWSDirectPainterSurface(bool isClient = false,
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 
339 private:
341 #ifndef QT_NO_THREAD
343 #endif
344 
345  friend void qt_directpainter_region(QDirectPainter*, const QRegion&, int);
348  bool doLocking;
349 };
350 
351 #endif // QT_NO_DIRECTPAINTER
352 
354 
355 #endif // QWINDOWSURFACE_QWS_P_H
The QWSWindowSurface class provides the drawing area for top-level windows in Qt for Embedded Linux...
Format
The following image formats are available in Qt.
Definition: qimage.h:91
unsigned long WId
Definition: qwindowdefs.h:119
int type
Definition: qmetatype.cpp:239
QImage image() const
Implement this function to return an image of the top-level window.
bool isValid() const
Implement this function to return true if the surface is a valid surface for the given top-level wind...
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
const QRegion clipRegion() const
Returns the region currently visible on the screen.
The QMutex class provides access serialization between threads.
Definition: qmutex.h:60
QPointer< QWidget > widget
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
virtual QByteArray permanentState() const
Implement this function to return the data required for creating a server-side representation of the ...
void qt_directpainter_region(QDirectPainter *dp, const QRegion &alloc, int type)
QString key() const
Implement this function to return a string that uniquely identifies the class of this surface...
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
virtual void setGeometry(const QRect &rect)
Sets the currently allocated area to be the given rect.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QPaintDevice * paintDevice()
Implement this function to return the appropriate paint device.
virtual void beginPaint(const QRegion &)
This function is called before painting onto the surface begins, with the region in which the paintin...
SurfaceFlag
This enum is used to describe the window surface&#39;s contents.
bool isBuffered() const
Returns true if the QWSWindowSurface::Buffered is set; otherwise returns false.
void setSurfaceFlags(SurfaceFlags type)
Sets the surface flags describing the contents of this surface, to be the given flags.
The QDirectPainter class provides direct access to the underlying hardware in Qt for Embedded Linux...
The QString class provides a Unicode character string.
Definition: qstring.h:83
QPaintDevice * paintDevice()
Implement this function to return the appropriate paint device.
QWSWindowSurface::SurfaceFlags flags
virtual bool lock(int timeout=-1)
QWSWindowSurfacePrivate * d_ptr
virtual void beginPaint(const QRegion &)
This function is called before painting onto the surface begins, with the region in which the paintin...
virtual void releaseSurface()
bool isValid() const
Implement this function to return true if the surface is a valid surface for the given top-level wind...
unsigned char uchar
Definition: qglobal.h:994
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QString key() const
Implement this function to return a string that uniquely identifies the class of this surface...
void setDelay(int msec)
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
Definition: qglobal.h:2355
virtual void flush(QWidget *widget, const QRegion &region, const QPoint &offset)=0
Flushes the given region from the specified widget onto the screen.
QImage image() const
Implement this function to return an image of the top-level window.
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
static const char * data(const QByteArray &arr)
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QImage image() const
Implement this function to return an image of the top-level window.
QPoint painterOffset() const
Returns the offset to be used when painting.
The QWindowSurface class provides the drawing area for top-level windows.
virtual bool isValid() const =0
Implement this function to return true if the surface is a valid surface for the given top-level wind...
void invalidateBuffer(const QRegion &)
Invalidates the rgn (in widget&#39;s coordinates) of the backing store, i.e.
QString key() const
Implement this function to return a string that uniquely identifies the class of this surface...
virtual QPoint painterOffset() const
Returns the offset to be used when painting.
virtual void endPaint(const QRegion &)
This function is called after painting onto the surface has ended, with the region in which the paint...
bool isOpaque() const
Returns true if the QWSWindowSurface::Opaque is set; otherwise returns false.
QPaintDevice * paintDevice()
Implement this function to return the appropriate paint device.
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
bool isRegionReserved() const
Returns true if the QWSWindowSurface::RegionReserved is set; otherwise returns false.
static QReadWriteLock lock
Definition: proxyconf.cpp:399
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QString key() const
Implement this function to return a string that uniquely identifies the class of this surface...
SurfaceFlag
This enum describes the behavior of the region reserved by this QDirectPainter object.
The QScreen class is a base class for screen drivers in Qt for Embedded Linux.
Definition: qscreen_qws.h:191
virtual void flush(QWidget *widget, const QRegion &region, const QPoint &offset)
Flushes the given region from the specified widget onto the screen.
void setWinId(WId)
Definition: qwidget.cpp:1726
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
virtual void setPermanentState(const QByteArray &state)
Implement this function to attach a server-side surface instance to the corresponding client side ins...
#define class
bool isValid() const
Implement this function to return true if the surface is a valid surface for the given top-level wind...
QString key() const
Implement this function to return a string that uniquely identifies the class of this surface...
void setGeometry(const QRect &rect)
Sets the currently allocated area to be the given rect.
virtual bool scroll(const QRegion &area, int dx, int dy)
Scrolls the given area dx pixels to the right and dy downward; both dx and dy may be negative...
virtual void setGeometry(const QRect &rect)
Sets the currently allocated area to be the given rect.
virtual QPaintDevice * paintDevice()=0
Implement this function to return the appropriate paint device.
static int area(const QSize &s)
Definition: qicon.cpp:155