Qt 4.8
qscreen_qws.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 QSCREEN_QWS_H
43 #define QSCREEN_QWS_H
44 
45 #include <QtCore/qnamespace.h>
46 #include <QtCore/qpoint.h>
47 #include <QtCore/qstringlist.h>
48 #include <QtGui/qrgb.h>
49 #include <QtCore/qrect.h>
50 #include <QtGui/qimage.h>
51 #include <QtGui/qregion.h>
52 
53 struct fb_cmap;
54 
56 
58 
59 QT_MODULE(Gui)
60 
61 class QScreenCursor;
62 class QBrush;
63 class QWSWindow;
64 class QWSWindowSurface;
65 class QGraphicsSystem;
66 class QPixmapData;
67 
68 #ifndef QT_QWS_DEPTH16_RGB
69 #define QT_QWS_DEPTH16_RGB 565
70 #endif
71 static const int qt_rbits = (QT_QWS_DEPTH16_RGB/100);
72 static const int qt_gbits = (QT_QWS_DEPTH16_RGB/10%10);
73 static const int qt_bbits = (QT_QWS_DEPTH16_RGB%10);
74 static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits);
75 static const int qt_green_shift = qt_bbits-(8-qt_gbits);
76 static const int qt_neg_blue_shift = 8-qt_bbits;
77 static const int qt_blue_mask = (1<<qt_bbits)-1;
78 static const int qt_green_mask = (1<<(qt_gbits+qt_bbits))-(1<<qt_bbits);
79 static const int qt_red_mask = (1<<(qt_rbits+qt_gbits+qt_bbits))-(1<<(qt_gbits+qt_bbits));
80 
84 
85 
86 inline ushort qt_convRgbTo16(const int r, const int g, const int b)
87 {
88  const int tr = r << qt_red_shift;
89  const int tg = g << qt_green_shift;
90  const int tb = b >> qt_neg_blue_shift;
91 
92  return (tb & qt_blue_mask) | (tg & qt_green_mask) | (tr & qt_red_mask);
93 }
94 
96 {
97  const int tr = qRed(c) << qt_red_shift;
98  const int tg = qGreen(c) << qt_green_shift;
99  const int tb = qBlue(c) >> qt_neg_blue_shift;
100 
101  return (tb & qt_blue_mask) | (tg & qt_green_mask) | (tr & qt_red_mask);
102 }
103 
105 {
106  const int r=(c & qt_red_mask);
107  const int g=(c & qt_green_mask);
108  const int b=(c & qt_blue_mask);
109  const int tr = r >> qt_red_shift | r >> qt_red_rounding_shift;
110  const int tg = g >> qt_green_shift | g >> qt_green_rounding_shift;
111  const int tb = b << qt_neg_blue_shift | b >> qt_blue_rounding_shift;
112 
113  return qRgb(tr,tg,tb);
114 }
115 
116 inline void qt_conv16ToRgb(ushort c, int& r, int& g, int& b)
117 {
118  const int tr=(c & qt_red_mask);
119  const int tg=(c & qt_green_mask);
120  const int tb=(c & qt_blue_mask);
121  r = tr >> qt_red_shift | tr >> qt_red_rounding_shift;
122  g = tg >> qt_green_shift | tg >> qt_green_rounding_shift;
123  b = tb << qt_neg_blue_shift | tb >> qt_blue_rounding_shift;
124 }
125 
126 const int SourceSolid=0;
127 const int SourcePixmap=1;
128 
129 #ifndef QT_NO_QWS_CURSOR
130 
131 class QScreenCursor;
133 extern bool qws_sw_cursor;
134 
136 {
137 public:
138  QScreenCursor();
139  virtual ~QScreenCursor();
140 
141  virtual void set(const QImage &image, int hotx, int hoty);
142  virtual void move(int x, int y);
143  virtual void show();
144  virtual void hide();
145 
146  bool supportsAlphaCursor() const { return supportsAlpha; }
147 
148  static bool enabled() { return qws_sw_cursor; }
149 
150  QRect boundingRect() const { return QRect(pos - hotspot, size); }
151  QImage image() const { return cursor; }
152  bool isVisible() const { return enable; }
153  bool isAccelerated() const { return hwaccel; }
154 
155  static void initSoftwareCursor();
156  static QScreenCursor* instance() { return qt_screencursor; }
157 
158 protected:
160 
167 
168 private:
169  friend class QProxyScreenCursor;
170 };
171 
172 #endif // QT_NO_QWS_CURSOR
173 
174 // A (used) chunk of offscreen memory
175 
177 {
178 public:
179  unsigned int start;
180  unsigned int end;
181  int clientId;
182 };
183 
184 class QScreen;
185 class QScreenPrivate;
186 class QPixmapDataFactory;
187 
189 typedef void(*ClearCacheFunc)(QScreen *obj, int);
190 
192 
193 public:
194  enum ClassId { LinuxFBClass, TransformedClass, VNCClass, MultiClass,
195  VFbClass, DirectFBClass, SvgalibClass, ProxyClass,
196  GLClass, IntfbClass, CustomClass = 1024 };
197 
198  QScreen(int display_id, ClassId classId);
199  explicit QScreen(int display_id);
200  virtual ~QScreen();
201  static QScreen* instance() { return qt_screen; }
202  virtual bool initDevice() = 0;
203  virtual bool connect(const QString &displaySpec) = 0;
204  virtual void disconnect() = 0;
205  virtual void shutdownDevice();
206  virtual void setMode(int,int,int) = 0;
207  virtual bool supportsDepth(int) const;
208 
209  virtual void save();
210  virtual void restore();
211  virtual void blank(bool on);
212 
213  virtual int pixmapOffsetAlignment() { return 64; }
214  virtual int pixmapLinestepAlignment() { return 64; }
215  virtual int sharedRamSize(void *) { return 0; }
216 
217  virtual bool onCard(const unsigned char *) const;
218  virtual bool onCard(const unsigned char *, ulong& out_offset) const;
219 
220  enum PixelType { NormalPixel, BGRPixel };
221 
222  // sets a single color in the colormap
223  virtual void set(unsigned int,unsigned int,unsigned int,unsigned int);
224  // allocates a color
225  virtual int alloc(unsigned int,unsigned int,unsigned int);
226 
227  int width() const { return w; }
228  int height() const { return h; }
229  int depth() const { return d; }
230  virtual int pixmapDepth() const;
231  PixelType pixelType() const { return pixeltype; }
232  int linestep() const { return lstep; }
233  int deviceWidth() const { return dw; }
234  int deviceHeight() const { return dh; }
235  uchar * base() const { return data; }
236  // Ask for memory from card cache with alignment
237  virtual uchar * cache(int) { return 0; }
238  virtual void uncache(uchar *) {}
239 
240  QImage::Format pixelFormat() const;
241 
242  int screenSize() const { return size; }
243  int totalSize() const { return mapsize; }
244 
245  QRgb * clut() { return screenclut; }
246 #ifdef QT_DEPRECATED
247  QT_DEPRECATED int numCols() { return screencols; }
248 #endif
249  int colorCount() { return screencols; }
250 
251  virtual QSize mapToDevice(const QSize &) const;
252  virtual QSize mapFromDevice(const QSize &) const;
253  virtual QPoint mapToDevice(const QPoint &, const QSize &) const;
254  virtual QPoint mapFromDevice(const QPoint &, const QSize &) const;
255  virtual QRect mapToDevice(const QRect &, const QSize &) const;
256  virtual QRect mapFromDevice(const QRect &, const QSize &) const;
257  virtual QImage mapToDevice(const QImage &) const;
258  virtual QImage mapFromDevice(const QImage &) const;
259  virtual QRegion mapToDevice(const QRegion &, const QSize &) const;
260  virtual QRegion mapFromDevice(const QRegion &, const QSize &) const;
261  virtual int transformOrientation() const;
262  virtual bool isTransformed() const;
263  virtual bool isInterlaced() const;
264 
265  virtual void setDirty(const QRect&);
266 
267  virtual int memoryNeeded(const QString&);
268 
269  virtual void haltUpdates();
270  virtual void resumeUpdates();
271 
272  // composition manager methods
273  virtual void exposeRegion(QRegion r, int changing);
274 
275  // these work directly on the screen
276  virtual void blit(const QImage &img, const QPoint &topLeft, const QRegion &region);
277  virtual void solidFill(const QColor &color, const QRegion &region);
278  void blit(QWSWindow *bs, const QRegion &clip);
279 
280  virtual QWSWindowSurface* createSurface(QWidget *widget) const;
281  virtual QWSWindowSurface* createSurface(const QString &key) const;
282 
283  virtual QList<QScreen*> subScreens() const { return QList<QScreen*>(); }
284  virtual QRegion region() const { return QRect(offset(), QSize(w, h)); }
285  int subScreenIndexAt(const QPoint &p) const;
286 
287  void setOffset(const QPoint &p);
288  QPoint offset() const;
289 
290  int physicalWidth() const { return physWidth; } // physical display size in mm
291  int physicalHeight() const { return physHeight; } // physical display size in mm
292 
293  QPixmapDataFactory* pixmapDataFactory() const; // Deprecated, will be removed in 4.6
294  QGraphicsSystem* graphicsSystem() const;
295 
296 #ifdef QT_QWS_CLIENTBLIT
297  bool supportsBlitInClients() const;
298  void setSupportsBlitInClients(bool);
299 #endif
300 
301  ClassId classId() const;
302 
303 protected:
304  void setPixelFormat(QImage::Format format);
305  void setPixmapDataFactory(QPixmapDataFactory *factory); // Deprecated, will be removed in 4.6
306  void setGraphicsSystem(QGraphicsSystem* system);
307 
308  QRgb screenclut[256];
310 
312 
313  // Table of allocated lumps, kept in sorted highest-to-lowest order
314  // The table itself is allocated at the bottom of offscreen memory
315  // i.e. it's similar to having a stack (the table) and a heap
316  // (the allocated blocks). Freed space is implicitly described
317  // by the gaps between the allocated lumps (this saves entries and
318  // means we don't need to worry about coalescing freed lumps)
319 
321  int * entryp;
322  unsigned int * lowest;
323 
324  int w;
325  int lstep;
326  int h;
327  int d;
329  bool grayscale;
330 
331  int dw;
332  int dh;
333 
334  int size; // Screen size
335  int mapsize; // Total mapped memory
336 
338 
341 
342  friend class QWSServer;
343  friend class QWSServerPrivate;
345 
346 private:
347  void compose(int level, const QRegion &exposed, QRegion &blend,
348  QImage **blendbuffer, int changing_level);
349  void paintBackground(const QRegion &);
350 
351  friend class QWSOnScreenSurface;
352  static bool isWidgetPaintOnScreen(const QWidget *w);
353 
354 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
355  void setFrameBufferLittleEndian(bool littleEndian);
356  bool frameBufferLittleEndian() const;
357  friend class QVNCScreen;
358  friend class QLinuxFbScreen;
359  friend class QVFbScreen;
360  friend class QQnxScreen;
361  friend class QProxyScreen;
362  friend class QIntfbScreen;
363 #endif
364  friend void qt_solidFill_setup(QScreen*, const QColor&, const QRegion&);
365  friend void qt_blit_setup(QScreen *screen, const QImage &image,
366  const QPoint &topLeft, const QRegion &region);
367 #ifdef QT_QWS_DEPTH_GENERIC
368  friend void qt_set_generic_blit(QScreen *screen, int bpp,
369  int len_red, int len_green, int len_blue,
370  int len_alpha, int off_red, int off_green,
371  int off_blue, int off_alpha);
372 #endif
373 
375 };
376 
377 // This lives in loadable modules
378 
379 #ifndef QT_LOADABLE_MODULES
380 extern "C" QScreen * qt_get_screen(int display_id, const char* spec);
381 #endif
382 
383 // This is in main lib, loads the right module, calls qt_get_screen
384 // In non-loadable cases just aliases to qt_get_screen
385 
386 const unsigned char * qt_probe_bus();
387 
389 
391 
392 #endif // QSCREEN_QWS_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
The QScreenCursor class is a base class for screen cursors in Qt for Embedded Linux.
Definition: qscreen_qws.h:135
double d
Definition: qnumeric_p.h:62
int screencols
the number of entries in the color table
Definition: qscreen_qws.h:309
The QWSWindowSurface class provides the drawing area for top-level windows in Qt for Embedded Linux...
static const int qt_red_rounding_shift
Definition: qscreen_qws.h:81
Format
The following image formats are available in Qt.
Definition: qimage.h:91
unsigned int QRgb
Definition: qrgb.h:53
int * entryp
Definition: qscreen_qws.h:321
The QProxyScreenCursor class provides a generic interface to QScreenCursor implementations.
The QProxyScreen class provides a generic interface to QScreen implementations.
int height() const
Returns the logical height of the framebuffer in pixels.
Definition: qscreen_qws.h:228
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPointer< QWidget > widget
virtual int sharedRamSize(void *)
Definition: qscreen_qws.h:215
#define QT_MODULE(x)
Definition: qglobal.h:2783
int physicalHeight() const
Returns the physical height of the screen in millimeters.
Definition: qscreen_qws.h:291
const int SourcePixmap
Definition: qscreen_qws.h:127
int d
the pixel depth
Definition: qscreen_qws.h:327
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
unsigned int * lowest
Definition: qscreen_qws.h:322
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
void qt_solidFill_setup(QScreen *screen, const QColor &color, const QRegion &region)
static const int qt_bbits
Definition: qscreen_qws.h:73
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QVFbScreen class implements a screen driver for the virtual framebuffer.
void(* ClearCacheFunc)(QScreen *obj, int)
Definition: qscreen_qws.h:189
QPoint hotspot
Definition: qscreen_qws.h:163
int deviceWidth() const
Returns the physical width of the framebuffer device in pixels.
Definition: qscreen_qws.h:233
unsigned int start
Definition: qscreen_qws.h:179
QScreenPrivate * d_ptr
Definition: qscreen_qws.h:374
static ClearCacheFunc clearCacheFunc
Definition: qscreen_qws.h:344
int physHeight
the physical height of the screen in millimeters.
Definition: qscreen_qws.h:340
static const int qt_blue_mask
Definition: qscreen_qws.h:77
ushort qt_convRgbTo16(const int r, const int g, const int b)
Definition: qscreen_qws.h:86
The QString class provides a Unicode character string.
Definition: qstring.h:83
int size
the number of bytes in the visible region of the frame buffer
Definition: qscreen_qws.h:334
virtual int pixmapOffsetAlignment()
Returns the value (in bits) to which the start address of pixmaps held in the graphics card&#39;s memory...
Definition: qscreen_qws.h:213
unsigned int end
Definition: qscreen_qws.h:180
bool supportsAlphaCursor() const
Definition: qscreen_qws.h:146
int qRed(QRgb rgb)
Returns the red component of the ARGB quadruplet rgb.
Definition: qrgb.h:57
PixelType
This enum describes the pixel storage format of the screen, i.
Definition: qscreen_qws.h:220
static const int qt_red_mask
Definition: qscreen_qws.h:79
The QQnxScreen class implements a screen driver for QNX io-display based devices. ...
PixelType pixeltype
set to BGRPixel
Definition: qscreen_qws.h:328
int physWidth
the physical width of the screen in millimeters.
Definition: qscreen_qws.h:339
QImage image() const
Returns the cursor&#39;s image.
Definition: qscreen_qws.h:151
virtual int pixmapLinestepAlignment()
Returns the value (in bits) to which individual scanlines of pixmaps held in the graphics card&#39;s memo...
Definition: qscreen_qws.h:214
The QWSWindow class encapsulates a top-level window in Qt for Embedded Linux.
virtual QRegion region() const
Returns the region covered by this screen driver.
Definition: qscreen_qws.h:284
unsigned char uchar
Definition: qglobal.h:994
int width() const
Returns the logical width of the framebuffer in pixels.
Definition: qscreen_qws.h:227
bool isAccelerated() const
Returns true if the cursor is accelerated; otherwise false.
Definition: qscreen_qws.h:153
uchar * data
points to the first visible pixel in the frame buffer.
Definition: qscreen_qws.h:311
QT_DEPRECATED int numCols()
Definition: qscreen_qws.h:247
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
PixelType pixelType() const
Returns the pixel storage format of the screen.
Definition: qscreen_qws.h:231
int linestep() const
Returns the length of each scanline of the framebuffer in bytes.
Definition: qscreen_qws.h:232
The QVNCScreen class implements a screen driver for VNC servers.
virtual uchar * cache(int)
Definition: qscreen_qws.h:237
int w
the logical width of the screen.
Definition: qscreen_qws.h:324
static const int qt_gbits
Definition: qscreen_qws.h:72
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)
unsigned int uint
Definition: qglobal.h:996
The QIntfbScreen class implements a screen driver for the INTEGRITY framebuffer drivers.
static QScreen * instance()
Returns a pointer to the application&#39;s QScreen instance.
Definition: qscreen_qws.h:201
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
int displayId
Definition: qscreen_qws.h:337
unsigned long ulong
Definition: qglobal.h:997
static const int qt_green_shift
Definition: qscreen_qws.h:75
QRgb qt_conv16ToRgb(ushort c)
Definition: qscreen_qws.h:104
static const int qt_green_mask
Definition: qscreen_qws.h:78
QRgb qRgb(int r, int g, int b)
Returns the ARGB quadruplet (255, {r}, {g}, {b}).
Definition: qrgb.h:69
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
static const int qt_rbits
Definition: qscreen_qws.h:71
uchar * base() const
Returns a pointer to the beginning of the framebuffer.
Definition: qscreen_qws.h:235
int dw
the device width
Definition: qscreen_qws.h:331
#define QT_QWS_DEPTH16_RGB
Definition: qscreen_qws.h:69
QPoolEntry * entries
Definition: qscreen_qws.h:320
int dh
the device height
Definition: qscreen_qws.h:332
void qt_blit_setup(QScreen *screen, const QImage &image, const QPoint &topLeft, const QRegion &region)
static bool enabled()
Definition: qscreen_qws.h:148
The QWSServer class encapsulates a server process in Qt for Embedded Linux.
Q_GUI_EXPORT EGLSurface createSurface(QPaintDevice *device, EGLConfig cfg, const QEglProperties *surfaceAttribs=0)
Definition: qegl_x11.cpp:333
int deviceHeight() const
Returns the full height of the framebuffer device in pixels.
Definition: qscreen_qws.h:234
static const int qt_neg_blue_shift
Definition: qscreen_qws.h:76
ClassId
This enum defines the class identifiers for the known screen subclasses.
Definition: qscreen_qws.h:194
unsigned short ushort
Definition: qglobal.h:995
int colorCount()
Returns the number of entries in the screen&#39;s color lookup table (i.
Definition: qscreen_qws.h:249
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
int totalSize() const
Returns the size of the available graphics card memory (including the screen) in bytes.
Definition: qscreen_qws.h:243
const int SourceSolid
Definition: qscreen_qws.h:126
QRect boundingRect() const
Returns the cursor&#39;s bounding rectangle.
Definition: qscreen_qws.h:150
virtual QList< QScreen * > subScreens() const
Definition: qscreen_qws.h:283
QRgb * clut()
Returns a pointer to the screen&#39;s color lookup table (i.
Definition: qscreen_qws.h:245
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
static const int qt_red_shift
Definition: qscreen_qws.h:74
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool grayscale
the gray scale screen mode flag
Definition: qscreen_qws.h:329
virtual void uncache(uchar *)
Definition: qscreen_qws.h:238
The QScreen class is a base class for screen drivers in Qt for Embedded Linux.
Definition: qscreen_qws.h:191
QScreen * qt_get_screen(int display_id, const char *spec)
int lstep
the number of bytes representing a line in the frame buffer.
Definition: qscreen_qws.h:325
#define QT_DEPRECATED
Definition: qglobal.h:1094
uint supportsAlpha
Definition: qscreen_qws.h:166
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QScreenCursor * qt_screencursor
Definition: qscreen_qws.cpp:67
int h
the logical height of the screen.
Definition: qscreen_qws.h:326
bool isVisible() const
Returns true if the cursor is visible; otherwise false.
Definition: qscreen_qws.h:152
bool qws_sw_cursor
int qGreen(QRgb rgb)
Returns the green component of the ARGB quadruplet rgb.
Definition: qrgb.h:60
static const int qt_blue_rounding_shift
Definition: qscreen_qws.h:83
int qBlue(QRgb rgb)
Returns the blue component of the ARGB quadruplet rgb.
Definition: qrgb.h:63
const unsigned char * qt_probe_bus()
int mapsize
the total number of bytes in the frame buffer
Definition: qscreen_qws.h:335
The QLinuxFbScreen class implements a screen driver for the Linux framebuffer.
int physicalWidth() const
Returns the physical width of the screen in millimeters.
Definition: qscreen_qws.h:290
#define QT_END_HEADER
Definition: qglobal.h:137
static QScreenCursor * instance()
Definition: qscreen_qws.h:156
int screenSize() const
Returns the size of the screen in bytes.
Definition: qscreen_qws.h:242
static const int qt_green_rounding_shift
Definition: qscreen_qws.h:82
int depth() const
Returns the depth of the framebuffer, in bits per pixel.
Definition: qscreen_qws.h:229
The QList class is a template class that provides lists.
Definition: qdatastream.h:62