source: trunk/src/gui/embedded/qscreen_qws.h@ 855

Last change on this file since 855 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: 12.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
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 [email protected].
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/qlist.h>
48#include <QtGui/qrgb.h>
49#include <QtCore/qrect.h>
50#include <QtGui/qimage.h>
51#include <QtGui/qregion.h>
52
53struct fb_cmap;
54
55QT_BEGIN_HEADER
56
57QT_BEGIN_NAMESPACE
58
59QT_MODULE(Gui)
60
61class QScreenCursor;
62class QBrush;
63class QWSWindow;
64class QWSWindowSurface;
65class QGraphicsSystem;
66class QPixmapData;
67
68#ifndef QT_QWS_DEPTH16_RGB
69#define QT_QWS_DEPTH16_RGB 565
70#endif
71static const int qt_rbits = (QT_QWS_DEPTH16_RGB/100);
72static const int qt_gbits = (QT_QWS_DEPTH16_RGB/10%10);
73static const int qt_bbits = (QT_QWS_DEPTH16_RGB%10);
74static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits);
75static const int qt_green_shift = qt_bbits-(8-qt_gbits);
76static const int qt_neg_blue_shift = 8-qt_bbits;
77static const int qt_blue_mask = (1<<qt_bbits)-1;
78static const int qt_green_mask = (1<<(qt_gbits+qt_bbits))-(1<<qt_bbits);
79static const int qt_red_mask = (1<<(qt_rbits+qt_gbits+qt_bbits))-(1<<(qt_gbits+qt_bbits));
80
81static const int qt_red_rounding_shift = qt_red_shift + qt_rbits;
82static const int qt_green_rounding_shift = qt_green_shift + qt_gbits;
83static const int qt_blue_rounding_shift = qt_bbits - qt_neg_blue_shift;
84
85
86inline 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
95inline ushort qt_convRgbTo16(QRgb c)
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
104inline QRgb qt_conv16ToRgb(ushort c)
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
116inline 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
126const int SourceSolid=0;
127const int SourcePixmap=1;
128
129#ifndef QT_NO_QWS_CURSOR
130
131class QScreenCursor;
132extern QScreenCursor *qt_screencursor;
133extern bool qt_sw_cursor;
134
135class Q_GUI_EXPORT QScreenCursor
136{
137public:
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 qt_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
158protected:
159 QImage cursor;
160
161 QSize size;
162 QPoint pos;
163 QPoint hotspot;
164 uint enable : 1;
165 uint hwaccel : 1;
166 uint supportsAlpha : 1;
167
168private:
169 friend class QProxyScreenCursor;
170};
171
172#endif // QT_NO_QWS_CURSOR
173
174// A (used) chunk of offscreen memory
175
176class QPoolEntry
177{
178public:
179 unsigned int start;
180 unsigned int end;
181 int clientId;
182};
183
184class QScreen;
185class QScreenPrivate;
186class QPixmapDataFactory;
187
188extern Q_GUI_EXPORT QScreen *qt_screen;
189typedef void(*ClearCacheFunc)(QScreen *obj, int);
190
191class Q_GUI_EXPORT QScreen {
192
193public:
194 enum ClassId { LinuxFBClass, TransformedClass, VNCClass, MultiClass,
195 VFbClass, DirectFBClass, SvgalibClass, ProxyClass,
196 GLClass, 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
303protected:
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];
309 int screencols;
310
311 uchar * data;
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
320 QPoolEntry * entries;
321 int * entryp;
322 unsigned int * lowest;
323
324 int w;
325 int lstep;
326 int h;
327 int d;
328 PixelType pixeltype;
329 bool grayscale;
330
331 int dw;
332 int dh;
333
334 int size; // Screen size
335 int mapsize; // Total mapped memory
336
337 int displayId;
338
339 int physWidth;
340 int physHeight;
341
342 friend class QWSServer;
343 friend class QWSServerPrivate;
344 static ClearCacheFunc clearCacheFunc;
345
346private:
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 QProxyScreen;
361#endif
362 friend void qt_solidFill_setup(QScreen*, const QColor&, const QRegion&);
363 friend void qt_blit_setup(QScreen *screen, const QImage &image,
364 const QPoint &topLeft, const QRegion &region);
365#ifdef QT_QWS_DEPTH_GENERIC
366 friend void qt_set_generic_blit(QScreen *screen, int bpp,
367 int len_red, int len_green, int len_blue,
368 int len_alpha, int off_red, int off_green,
369 int off_blue, int off_alpha);
370#endif
371
372 QScreenPrivate *d_ptr;
373};
374
375// This lives in loadable modules
376
377#ifndef QT_LOADABLE_MODULES
378extern "C" QScreen * qt_get_screen(int display_id, const char* spec);
379#endif
380
381// This is in main lib, loads the right module, calls qt_get_screen
382// In non-loadable cases just aliases to qt_get_screen
383
384const unsigned char * qt_probe_bus();
385
386QT_END_NAMESPACE
387
388QT_END_HEADER
389
390#endif // QSCREEN_QWS_H
Note: See TracBrowser for help on using the repository browser.