source: trunk/doc/html/qgfx_qws-h.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 15.5 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/include/qgfx_qws.h:1 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>qgfx_qws.h Include File</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>qgfx_qws.h</h1>
33
34<p>This is the verbatim text of the qgfx_qws.h include file. It is provided only for illustration; the copyright remains with Trolltech.
35<hr>
36<pre>
37/****************************************************************************
38** $Id: qgfx_qws-h.html 2051 2007-02-21 10:04:20Z chehrlic $
39**
40** Definition of QGfx (graphics context) class
41**
42** Created : 940721
43**
44** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
45**
46** This file is part of the kernel module of the Qt GUI Toolkit.
47**
48** This file may be distributed and/or modified under the terms of the
49** GNU General Public License version 2 as published by the Free Software
50** Foundation and appearing in the file LICENSE.GPL included in the
51** packaging of this file.
52**
53** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
54** licenses for Qt/Embedded may use this file in accordance with the
55** Qt Embedded Commercial License Agreement provided with the Software.
56**
57** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
58** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
59**
60** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
61** information about Qt Commercial License Agreements.
62** See http://www.trolltech.com/gpl/ for GPL licensing information.
63**
64** Contact info@trolltech.com if any conditions of this licensing are
65** not clear to you.
66**
67**********************************************************************/
68
69#ifndef QGFX_QWS_H
70#define QGFX_QWS_H
71
72#ifndef QT_H
73#include "qwidget.h"
74#include "qnamespace.h"
75#include "qimage.h"
76#include "qfontmanager_qws.h"
77#include "qmemorymanager_qws.h"
78#include "qpoint.h"
79#endif // QT_H
80
81#include &lt;private/qtextengine_p.h&gt;
82
83class QScreenCursor;
84
85#if !defined( QT_NO_IMAGE_16_BIT ) || !defined( QT_NO_QWS_DEPTH_16 )
86# ifndef QT_QWS_DEPTH16_RGB
87# define QT_QWS_DEPTH16_RGB 565
88# endif
89static const int qt_rbits = (QT_QWS_DEPTH16_RGB/100);
90static const int qt_gbits = (QT_QWS_DEPTH16_RGB/10%10);
91static const int qt_bbits = (QT_QWS_DEPTH16_RGB%10);
92static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits);
93static const int qt_green_shift = qt_bbits-(8-qt_gbits);
94static const int qt_neg_blue_shift = 8-qt_bbits;
95static const int qt_blue_mask = (1&lt;&lt;qt_bbits)-1;
96static const int qt_green_mask = (1&lt;&lt;(qt_gbits+qt_bbits))-((1&lt;&lt;qt_bbits)-1);
97static const int qt_red_mask = (1&lt;&lt;(qt_rbits+qt_gbits+qt_bbits))-(1&lt;&lt;(qt_gbits+qt_bbits));
98
99inline ushort qt_convRgbTo16( const int r, const int g, const int b )
100{
101 const int tr = r &lt;&lt; qt_red_shift;
102 const int tg = g &lt;&lt; qt_green_shift;
103 const int tb = b &gt;&gt; qt_neg_blue_shift;
104
105 return (tb &amp; qt_blue_mask) | (tg &amp; qt_green_mask) | (tr &amp; qt_red_mask);
106}
107
108inline ushort qt_convRgbTo16( QRgb c )
109{
110 const int tr = qRed(c) &lt;&lt; qt_red_shift;
111 const int tg = qGreen(c) &lt;&lt; qt_green_shift;
112 const int tb = qBlue(c) &gt;&gt; qt_neg_blue_shift;
113
114 return (tb &amp; qt_blue_mask) | (tg &amp; qt_green_mask) | (tr &amp; qt_red_mask);
115}
116
117inline QRgb qt_conv16ToRgb( ushort c )
118{
119 const int r=(c &amp; qt_red_mask);
120 const int g=(c &amp; qt_green_mask);
121 const int b=(c &amp; qt_blue_mask);
122 const int tr = r &gt;&gt; qt_red_shift;
123 const int tg = g &gt;&gt; qt_green_shift;
124 const int tb = b &lt;&lt; qt_neg_blue_shift;
125
126 return qRgb(tr,tg,tb);
127}
128
129inline void qt_conv16ToRgb( ushort c, int&amp; r, int&amp; g, int&amp; b )
130{
131 const int tr=(c &amp; qt_red_mask);
132 const int tg=(c &amp; qt_green_mask);
133 const int tb=(c &amp; qt_blue_mask);
134 r = tr &gt;&gt; qt_red_shift;
135 g = tg &gt;&gt; qt_green_shift;
136 b = tb &lt;&lt; qt_neg_blue_shift;
137}
138#endif
139
140
141const int SourceSolid=0;
142const int SourcePixmap=1;
143
144#ifndef QT_NO_QWS_CURSOR
145
146extern bool qt_sw_cursor;
147
148class QGfxRasterBase;
149
150#define SW_CURSOR_DATA_SIZE 4096 // 64x64 8-bit cursor
151
152struct SWCursorData {
153 unsigned char cursor[SW_CURSOR_DATA_SIZE];
154 unsigned char under[SW_CURSOR_DATA_SIZE*4]; // room for 32bpp display
155 QRgb clut[256];
156 unsigned char translut[256];
157 int colors;
158 int width;
159 int height;
160 int x;
161 int y;
162 int hotx;
163 int hoty;
164 bool enable;
165 QRect bound;
166};
167
168
169class QScreenCursor
170{
171public:
172 QScreenCursor( );
173 virtual ~QScreenCursor();
174
175 virtual void init(SWCursorData *da, bool init = FALSE);
176
177 virtual void set( const QImage &amp;image, int hotx, int hoty );
178 virtual void move( int x, int y );
179 virtual void show();
180 virtual void hide();
181
182 virtual bool restoreUnder( const QRect &amp;r, QGfxRasterBase *g = 0 );
183 virtual void saveUnder();
184 virtual void drawCursor();
185 //void draw();
186 virtual bool supportsAlphaCursor();
187
188 static bool enabled() { return qt_sw_cursor; }
189
190protected:
191 QGfxRasterBase *gfx;
192 QGfxRasterBase *gfxunder;
193
194 QImage *imgunder;
195 QImage *cursor;
196
197 uchar *fb_start;
198 uchar *fb_end;
199 bool save_under;
200 SWCursorData *data;
201
202 int clipWidth;
203 int clipHeight;
204 int myoffset;
205
206};
207
208extern QScreenCursor * qt_screencursor;
209
210#endif // QT_NO_QWS_CURSOR
211
212struct fb_cmap;
213
214// A (used) chunk of offscreen memory
215
216class QPoolEntry
217{
218public:
219 unsigned int start;
220 unsigned int end;
221 int clientId;
222};
223
224class QScreen;
225typedef void(*ClearCacheFunc)(QScreen *obj, int);
226
227class QScreen {
228
229public:
230
231 QScreen( int display_id );
232 virtual ~QScreen();
233 virtual bool initDevice() = 0;
234 virtual bool connect( const QString &amp;displaySpec ) = 0;
235 virtual void disconnect() = 0;
236 virtual int initCursor(void *, bool=FALSE);
237 virtual void shutdownDevice();
238 virtual void setMode(int,int,int) = 0;
239 virtual bool supportsDepth(int) const;
240 virtual QGfx * createGfx(unsigned char *,int,int,int,int);
241 virtual QGfx * screenGfx();
242 virtual void save();
243 virtual void restore();
244 virtual void blank(bool on);
245
246 virtual int pixmapOffsetAlignment() { return 64; }
247 virtual int pixmapLinestepAlignment() { return 64; }
248 virtual int sharedRamSize(void *) { return 0; }
249
250 virtual bool onCard(unsigned char *) const;
251 virtual bool onCard(unsigned char *, ulong&amp; out_offset) const;
252
253 // sets a single color in the colormap
254 virtual void set(unsigned int,unsigned int,unsigned int,unsigned int);
255 // allocates a color
256 virtual int alloc(unsigned int,unsigned int,unsigned int);
257
258 int width() const { return w; }
259 int height() const { return h; }
260 int depth() const { return d; }
261 virtual int pixmapDepth() const;
262 int pixelType() const { return pixeltype; }
263 int linestep() const { return lstep; }
264 int deviceWidth() const { return dw; }
265 int deviceHeight() const { return dh; }
266 uchar * base() const { return data; }
267 // Ask for memory from card cache with alignment
268 virtual uchar * cache(int,int) { return 0; }
269 virtual void uncache(uchar *) {}
270
271 int screenSize() const { return size; }
272 int totalSize() const { return mapsize; }
273
274 QRgb * clut() { return screenclut; }
275 int numCols() { return screencols; }
276
277 virtual QSize mapToDevice( const QSize &amp; ) const;
278 virtual QSize mapFromDevice( const QSize &amp; ) const;
279 virtual QPoint mapToDevice( const QPoint &amp;, const QSize &amp; ) const;
280 virtual QPoint mapFromDevice( const QPoint &amp;, const QSize &amp; ) const;
281 virtual QRect mapToDevice( const QRect &amp;, const QSize &amp; ) const;
282 virtual QRect mapFromDevice( const QRect &amp;, const QSize &amp; ) const;
283 virtual QImage mapToDevice( const QImage &amp; ) const;
284 virtual QImage mapFromDevice( const QImage &amp; ) const;
285 virtual QRegion mapToDevice( const QRegion &amp;, const QSize &amp; ) const;
286 virtual QRegion mapFromDevice( const QRegion &amp;, const QSize &amp; ) const;
287 virtual int transformOrientation() const;
288 virtual bool isTransformed() const;
289 virtual bool isInterlaced() const;
290
291 virtual void setDirty( const QRect&amp; );
292
293 virtual int memoryNeeded(const QString&amp;);
294
295 int * opType() { return screen_optype; }
296 int * lastOp() { return screen_lastop; }
297
298 virtual void haltUpdates();
299 virtual void resumeUpdates();
300
301protected:
302
303 // Only used without QT_NO_QWS_REPEATER, but included so that
304 // it's binary compatible regardless.
305 int * screen_optype;
306 int * screen_lastop;
307
308 QRgb screenclut[256];
309 int screencols;
310
311 bool initted;
312
313 uchar * data;
314
315 // Table of allocated lumps, kept in sorted highest-to-lowest order
316 // The table itself is allocated at the bottom of offscreen memory
317 // i.e. it's similar to having a stack (the table) and a heap
318 // (the allocated blocks). Freed space is implicitly described
319 // by the gaps between the allocated lumps (this saves entries and
320 // means we don't need to worry about coalescing freed lumps)
321
322 QPoolEntry * entries;
323 int * entryp;
324 unsigned int * lowest;
325
326 int w;
327 int lstep;
328 int h;
329 int d;
330 int pixeltype;
331 bool grayscale;
332
333 int dw;
334 int dh;
335
336 int hotx;
337 int hoty;
338 QImage cursor;
339
340 int size; // Screen size
341 int mapsize; // Total mapped memory
342
343 int displayId;
344
345 friend class QWSServer;
346 static ClearCacheFunc clearCacheFunc;
347};
348
349extern QScreen * qt_screen;
350
351class Q_EXPORT QGfx : public Qt {
352public:
353 // With loadable drivers, do probe here
354 static QGfx *createGfx( int depth, unsigned char *buffer,
355 int w, int h, int linestep );
356
357 virtual ~QGfx() {}
358
359 virtual void setPen( const QPen &amp; )=0;
360 virtual void setBrush( const QBrush &amp; )=0;
361 virtual void setBrushPixmap( const QPixmap * )=0;
362 virtual void setBrushOffset( int, int ) = 0;
363 virtual void setClipRect( int,int,int,int )=0;
364 virtual void setClipRegion( const QRegion &amp; )=0;
365 virtual void setClipDeviceRegion( const QRegion &amp; )=0;
366 virtual void setClipping (bool)=0;
367 // These will be called from qwidget_qws or qwidget_mac
368 // to update the drawing area when a widget is moved
369 virtual void setOffset( int,int )=0;
370 virtual void setWidgetRect( int,int,int,int )=0;
371 virtual void setWidgetRegion( const QRegion &amp; )=0;
372 virtual void setWidgetDeviceRegion( const QRegion &amp; )=0;
373 virtual void setSourceWidgetOffset(int x, int y) = 0;
374 virtual void setGlobalRegionIndex( int idx ) = 0;
375
376 virtual void setDashedLines(bool d) = 0;
377 virtual void setDashes(char *, int) = 0;
378
379 virtual void setOpaqueBackground(bool b)=0;
380 virtual void setBackgroundColor(QColor c)=0;
381
382 // Drawing operations
383 virtual void drawPoint( int,int )=0;
384 virtual void drawPoints( const QPointArray &amp;,int,int )=0;
385 virtual void moveTo( int,int )=0;
386 virtual void lineTo( int,int )=0;
387 virtual void drawLine( int,int,int,int )=0;
388 virtual void drawPolyline( const QPointArray &amp;,int,int )=0;
389
390 // current position
391 virtual QPoint pos() const = 0;
392
393 // Fill operations - these use the current source (pixmap,
394 // color, etc), and draws outline
395 virtual void fillRect( int,int,int,int )=0;
396 virtual void drawPolygon( const QPointArray &amp;,bool,int,int )=0;
397
398 virtual void setLineStep(int)=0;
399
400 // Special case of rect-with-pixmap-fill for speed/hardware acceleration
401 virtual void blt( int,int,int,int,int,int )=0;
402 virtual void scroll( int,int,int,int,int,int )=0;
403
404#if !defined(QT_NO_MOVIE) || !defined(QT_NO_TRANSFORMATIONS) || !defined(QT_NO_PIXMAP_TRANSFORMATION)
405 virtual void stretchBlt( int,int,int,int,int,int )=0;
406#endif
407 virtual void tiledBlt( int,int,int,int )=0;
408
409 enum SourceType { SourcePen, SourceImage, SourceAccel };
410 enum PixelType { NormalPixel, BGRPixel };
411
412 // Setting up source data - can be solid color or pixmap data
413 virtual void setSource(const QPaintDevice *)=0;
414 virtual void setSource(const QImage *)=0;
415 virtual void setSource(unsigned char *,int,int,int,int,QRgb *,int);
416 // This one is pen
417 virtual void setSourcePen()=0;
418
419 virtual void drawAlpha(int,int,int,int,int,int,int,int) {}
420
421 virtual void hsync(int) {}
422
423 // These apply only to blt's. For alpha values for general
424 // drawing operations we should probably have a separate QGfx
425 // class. It's not a high priority though.
426
427 // Enum values: Ignore alpha information, alpha information encoded in
428 // 32-bit rgba along with colors, alpha information in 8bpp
429 // format in alphabits
430
431 enum AlphaType { IgnoreAlpha, InlineAlpha, SeparateAlpha,
432 LittleEndianMask, BigEndianMask, SolidAlpha };
433
434 // Can be no alpha, inline (32bit data), separate (for images),
435 // LittleEndianMask/BigEndianMask 1bpp masks, constant alpha
436 // value
437 virtual void setAlphaType(AlphaType)=0;
438 // Pointer to data, linestep
439 virtual void setAlphaSource(unsigned char *,int)=0;
440 virtual void setAlphaSource(int,int=-1,int=-1,int=-1)=0;
441
442 virtual void drawGlyphs( QMemoryManager::FontID font, glyph_t *glyphs, QPoint *positions, int num_glyphs ) = 0;
443
444 virtual void setClut(QRgb *,int)=0;
445
446 // Save and restore pen and brush state - necessary when setting
447 // up a bitBlt for example
448 virtual void save()=0;
449 virtual void restore()=0;
450
451 virtual void setRop(RasterOp)=0;
452 virtual void setScreen(QScreen *,QScreenCursor *,bool,int *,int *);
453 void setShared(void * v) { shared_data=v; }
454 bool isScreenGfx() { return is_screen_gfx; } //for cursor..
455
456protected:
457 bool is_screen_gfx;
458 void * shared_data;
459
460};
461
462
463// This lives in loadable modules
464
465#ifndef QT_LOADABLE_MODULES
466extern "C" QScreen * qt_get_screen( int display_id, const char* spec );
467#endif
468
469// This is in main lib, loads the right module, calls qt_get_screen
470// In non-loadable cases just aliases to qt_get_screen
471
472const unsigned char * qt_probe_bus();
473
474#endif // QGFX_QWS_H
475
476
477
478
479</pre>
480<!-- eof -->
481<p><address><hr><div align=center>
482<table width=100% cellspacing=0 border=0><tr>
483<td>Copyright &copy; 2007
484<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
485<td align=right><div align=right>Qt 3.3.8</div>
486</table></div></address></body>
487</html>
Note: See TracBrowser for help on using the repository browser.