summaryrefslogtreecommitdiffstats
path: root/doc/html/qgfx_qws-h.html
blob: c3e3009ea173fce41a1becb5313888a4b310ab9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/include/qgfx_qws.h:1 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>qgfx_qws.h Include File</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<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>

<p>This is the verbatim text of the qgfx_qws.h include file. It is provided only for illustration; the copyright remains with Trolltech.
<hr>
<pre>
/****************************************************************************
** $Id: qt/qgfx_qws.h   3.3.8   edited Jan 11 14:38 $
**
** Definition of TQGfx (graphics context) class
**
** Created : 940721
**
** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
**
** This file is part of the kernel module of the TQt GUI Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Alternatively you may (at your option) use any
** later version of the GNU General Public License if such license has
** been publicly approved by Trolltech ASA (or its successors, if any)
** and the KDE Free TQt Foundation.
**
** Please review the following information to ensure GNU General
** Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/.
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** Licensees holding valid TQt Commercial licenses may use this file in
** accordance with the TQt Commercial License Agreement provided with
** the Software.
**
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
** herein.
**
**********************************************************************/

#ifndef TQGFX_QWS_H
#define TQGFX_QWS_H

#ifndef QT_H
#include "ntqwidget.h"
#include "ntqnamespace.h"
#include "ntqimage.h"
#include "qfontmanager_qws.h"
#include "qmemorymanager_qws.h"
#include "ntqpoint.h"
#endif // QT_H

#include &lt;private/qtextengine_p.h&gt;

class TQScreenCursor;

#if !defined( TQT_NO_IMAGE_16_BIT ) || !defined( TQT_NO_QWS_DEPTH_16 )
# ifndef QT_QWS_DEPTH16_RGB
#  define QT_QWS_DEPTH16_RGB 565
# endif
static const int qt_rbits = (QT_QWS_DEPTH16_RGB/100);
static const int qt_gbits = (QT_QWS_DEPTH16_RGB/10%10);
static const int qt_bbits = (QT_QWS_DEPTH16_RGB%10);
static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits);
static const int qt_green_shift = qt_bbits-(8-qt_gbits);
static const int qt_neg_blue_shift = 8-qt_bbits;
static const int qt_blue_mask = (1&lt;&lt;qt_bbits)-1;
static const int qt_green_mask = (1&lt;&lt;(qt_gbits+qt_bbits))-((1&lt;&lt;qt_bbits)-1);
static const int qt_red_mask = (1&lt;&lt;(qt_rbits+qt_gbits+qt_bbits))-(1&lt;&lt;(qt_gbits+qt_bbits));

inline ushort qt_convRgbTo16( const int r, const int g, const int b )
{
    const int tr = r &lt;&lt; qt_red_shift;
    const int tg = g &lt;&lt; qt_green_shift;
    const int tb = b &gt;&gt; qt_neg_blue_shift;

    return (tb &amp; qt_blue_mask) | (tg &amp; qt_green_mask) | (tr &amp; qt_red_mask);
}

inline ushort qt_convRgbTo16( TQRgb c )
{
    const int tr = tqRed(c) &lt;&lt; qt_red_shift;
    const int tg = tqGreen(c) &lt;&lt; qt_green_shift;
    const int tb = tqBlue(c) &gt;&gt; qt_neg_blue_shift;

    return (tb &amp; qt_blue_mask) | (tg &amp; qt_green_mask) | (tr &amp; qt_red_mask);
}

inline TQRgb qt_conv16ToRgb( ushort c )
{
    const int r=(c &amp; qt_red_mask);
    const int g=(c &amp; qt_green_mask);
    const int b=(c &amp; qt_blue_mask);
    const int tr = r &gt;&gt; qt_red_shift;
    const int tg = g &gt;&gt; qt_green_shift;
    const int tb = b &lt;&lt; qt_neg_blue_shift;

    return tqRgb(tr,tg,tb);
}

inline void qt_conv16ToRgb( ushort c, int&amp; r, int&amp; g, int&amp; b )
{
    const int tr=(c &amp; qt_red_mask);
    const int tg=(c &amp; qt_green_mask);
    const int tb=(c &amp; qt_blue_mask);
    r = tr &gt;&gt; qt_red_shift;
    g = tg &gt;&gt; qt_green_shift;
    b = tb &lt;&lt; qt_neg_blue_shift;
}
#endif


const int SourceSolid=0;
const int SourcePixmap=1;

#ifndef TQT_NO_QWS_CURSOR

extern bool qt_sw_cursor;

class TQGfxRasterBase;

#define SW_CURSOR_DATA_SIZE	4096  // 64x64 8-bit cursor

struct SWCursorData {
    unsigned char cursor[SW_CURSOR_DATA_SIZE];
    unsigned char under[SW_CURSOR_DATA_SIZE*4]; // room for 32bpp display
    TQRgb clut[256];
    unsigned char translut[256];
    int colors;
    int width;
    int height;
    int x;
    int y;
    int hotx;
    int hoty;
    bool enable;
    TQRect bound;
};


class TQScreenCursor
{
public:
    TQScreenCursor( );
    virtual ~TQScreenCursor();

    virtual void init(SWCursorData *da, bool init = FALSE);

    virtual void set( const TQImage &amp;image, int hotx, int hoty );
    virtual void move( int x, int y );
    virtual void show();
    virtual void hide();

    virtual bool restoreUnder( const TQRect &amp;r, TQGfxRasterBase *g = 0 );
    virtual void saveUnder();
    virtual void drawCursor();
    //void draw();
    virtual bool supportsAlphaCursor();

    static bool enabled() { return qt_sw_cursor; }

protected:
    TQGfxRasterBase *gfx;
    TQGfxRasterBase *gfxunder;

    TQImage *imgunder;
    TQImage *cursor;

    uchar *fb_start;
    uchar *fb_end;
    bool save_under;
    SWCursorData *data;

    int clipWidth;
    int clipHeight;
    int myoffset;

};

extern TQScreenCursor * qt_screencursor;

#endif // TQT_NO_QWS_CURSOR

struct fb_cmap;

// A (used) chunk of offscreen memory

class TQPoolEntry
{
public:
    unsigned int start;
    unsigned int end;
    int clientId;
};

class TQScreen;
typedef void(*ClearCacheFunc)(TQScreen *obj, int);

class TQScreen {

public:

    TQScreen( int display_id );
    virtual ~TQScreen();
    virtual bool initDevice() = 0;
    virtual bool connect( const TQString &amp;displaySpec ) = 0;
    virtual void disconnect() = 0;
    virtual int initCursor(void *, bool=FALSE);
    virtual void shutdownDevice();
    virtual void setMode(int,int,int) = 0;
    virtual bool supportsDepth(int) const;
    virtual TQGfx * createGfx(unsigned char *,int,int,int,int);
    virtual TQGfx * screenGfx();
    virtual void save();
    virtual void restore();
    virtual void blank(bool on);

    virtual int pixmapOffsetAlignment() { return 64; }
    virtual int pixmapLinestepAlignment() { return 64; }
    virtual int sharedRamSize(void *) { return 0; }

    virtual bool onCard(unsigned char *) const;
    virtual bool onCard(unsigned char *, ulong&amp; out_offset) const;

    // sets a single color in the colormap
    virtual void set(unsigned int,unsigned int,unsigned int,unsigned int);
    // allocates a color
    virtual int alloc(unsigned int,unsigned int,unsigned int);

    int width() const { return w; }
    int height() const { return h; }
    int depth() const { return d; }
    virtual int pixmapDepth() const;
    int pixelType() const { return pixeltype; }
    int linestep() const { return lstep; }
    int deviceWidth() const { return dw; }
    int deviceHeight() const { return dh; }
    uchar * base() const { return data; }
    // Ask for memory from card cache with alignment
    virtual uchar * cache(int,int) { return 0; }
    virtual void uncache(uchar *) {}

    int screenSize() const { return size; }
    int totalSize() const { return mapsize; }

    TQRgb * clut() { return screenclut; }
    int numCols() { return screencols; }

    virtual TQSize mapToDevice( const TQSize &amp; ) const;
    virtual TQSize mapFromDevice( const TQSize &amp; ) const;
    virtual TQPoint mapToDevice( const TQPoint &amp;, const TQSize &amp; ) const;
    virtual TQPoint mapFromDevice( const TQPoint &amp;, const TQSize &amp; ) const;
    virtual TQRect mapToDevice( const TQRect &amp;, const TQSize &amp; ) const;
    virtual TQRect mapFromDevice( const TQRect &amp;, const TQSize &amp; ) const;
    virtual TQImage mapToDevice( const TQImage &amp; ) const;
    virtual TQImage mapFromDevice( const TQImage &amp; ) const;
    virtual TQRegion mapToDevice( const TQRegion &amp;, const TQSize &amp; ) const;
    virtual TQRegion mapFromDevice( const TQRegion &amp;, const TQSize &amp; ) const;
    virtual int transformOrientation() const;
    virtual bool isTransformed() const;
    virtual bool isInterlaced() const;

    virtual void setDirty( const TQRect&amp; );

    virtual int memoryNeeded(const TQString&amp;);

    int * opType() { return screen_optype; }
    int * lastOp() { return screen_lastop; }

    virtual void haltUpdates();
    virtual void resumeUpdates();

protected:

    // Only used without TQT_NO_QWS_REPEATER, but included so that
    // it's binary compatible regardless.
    int * screen_optype;
    int * screen_lastop;

    TQRgb screenclut[256];
    int screencols;

    bool initted;

    uchar * data;

    // Table of allocated lumps, kept in sorted highest-to-lowest order
    // The table itself is allocated at the bottom of offscreen memory
    // i.e. it's similar to having a stack (the table) and a heap
    // (the allocated blocks). Freed space is implicitly described
    // by the gaps between the allocated lumps (this saves entries and
    // means we don't need to worry about coalescing freed lumps)

    TQPoolEntry * entries;
    int * entryp;
    unsigned int * lowest;

    int w;
    int lstep;
    int h;
    int d;
    int pixeltype;
    bool grayscale;

    int dw;
    int dh;

    int hotx;
    int hoty;
    TQImage cursor;

    int size;	       // Screen size
    int mapsize;       // Total mapped memory

    int displayId;

    friend class TQWSServer;
    static ClearCacheFunc clearCacheFunc;
};

extern TQScreen * qt_screen;

class Q_EXPORT TQGfx : public TQt {
public:
    // With loadable drivers, do probe here
    static TQGfx *createGfx( int depth, unsigned char *buffer,
			    int w, int h, int linestep );

    virtual ~TQGfx() {}

    virtual void setPen( const TQPen &amp; )=0;
    virtual void setBrush( const TQBrush &amp; )=0;
    virtual void setBrushPixmap( const TQPixmap * )=0;
    virtual void setBrushOffset( int, int ) = 0;
    virtual void setClipRect( int,int,int,int )=0;
    virtual void setClipRegion( const TQRegion &amp; )=0;
    virtual void setClipDeviceRegion( const TQRegion &amp; )=0;
    virtual void setClipping (bool)=0;
    // These will be called from qwidget_qws or qwidget_mac
    // to update the drawing area when a widget is moved
    virtual void setOffset( int,int )=0;
    virtual void setWidgetRect( int,int,int,int )=0;
    virtual void setWidgetRegion( const TQRegion &amp; )=0;
    virtual void setWidgetDeviceRegion( const TQRegion &amp; )=0;
    virtual void setSourceWidgetOffset(int x, int y) = 0;
    virtual void setGlobalRegionIndex( int idx ) = 0;

    virtual void setDashedLines(bool d) = 0;
    virtual void setDashes(char *, int) = 0;

    virtual void setOpaqueBackground(bool b)=0;
    virtual void setBackgroundColor(TQColor c)=0;

    // Drawing operations
    virtual void drawPoint( int,int )=0;
    virtual void drawPoints( const TQPointArray &amp;,int,int )=0;
    virtual void moveTo( int,int )=0;
    virtual void lineTo( int,int )=0;
    virtual void drawLine( int,int,int,int )=0;
    virtual void drawPolyline( const TQPointArray &amp;,int,int )=0;

    // current position
    virtual TQPoint pos() const = 0;

    // Fill operations - these use the current source (pixmap,
    // color, etc), and draws outline
    virtual void fillRect( int,int,int,int )=0;
    virtual void drawPolygon( const TQPointArray &amp;,bool,int,int )=0;

    virtual void setLineStep(int)=0;

    // Special case of rect-with-pixmap-fill for speed/hardware acceleration
    virtual void blt( int,int,int,int,int,int )=0;
    virtual void scroll( int,int,int,int,int,int )=0;

#if !defined(TQT_NO_MOVIE) || !defined(TQT_NO_TRANSFORMATIONS) || !defined(TQT_NO_PIXMAP_TRANSFORMATION)
    virtual void stretchBlt( int,int,int,int,int,int )=0;
#endif
    virtual void tiledBlt( int,int,int,int )=0;

    enum SourceType { SourcePen, SourceImage, SourceAccel };
    enum PixelType { NormalPixel, BGRPixel };

    // Setting up source data - can be solid color or pixmap data
    virtual void setSource(const TQPaintDevice *)=0;
    virtual void setSource(const TQImage *)=0;
    virtual void setSource(unsigned char *,int,int,int,int,TQRgb *,int);
    // This one is pen
    virtual void setSourcePen()=0;

    virtual void drawAlpha(int,int,int,int,int,int,int,int) {}

    virtual void hsync(int) {}

    // These apply only to blt's. For alpha values for general
    // drawing operations we should probably have a separate TQGfx
    // class. It's not a high priority though.

    // Enum values: Ignore alpha information, alpha information encoded in
    // 32-bit rgba along with colors, alpha information in 8bpp
    // format in alphabits

    enum AlphaType { IgnoreAlpha, InlineAlpha, SeparateAlpha,
                     LittleEndianMask, BigEndianMask, SolidAlpha };

    // Can be no alpha, inline (32bit data), separate (for images),
    // LittleEndianMask/BigEndianMask 1bpp masks, constant alpha
    // value
    virtual void setAlphaType(AlphaType)=0;
    // Pointer to data, linestep
    virtual void setAlphaSource(unsigned char *,int)=0;
    virtual void setAlphaSource(int,int=-1,int=-1,int=-1)=0;

    virtual void drawGlyphs( TQMemoryManager::FontID font, glyph_t *glyphs, TQPoint *positions, int num_glyphs ) = 0;

    virtual void setClut(TQRgb *,int)=0;

    // Save and restore pen and brush state - necessary when setting
    // up a bitBlt for example
    virtual void save()=0;
    virtual void restore()=0;

    virtual void setRop(RasterOp)=0;
    virtual void setScreen(TQScreen *,TQScreenCursor *,bool,int *,int *);
    void setShared(void * v) { shared_data=v; }
    bool isScreenGfx() { return is_screen_gfx; } //for cursor..

protected:
    bool is_screen_gfx;
    void * shared_data;

};


// This lives in loadable modules

#ifndef QT_LOADABLE_MODULES
extern "C" TQScreen * qt_get_screen( int display_id, const char* spec );
#endif

// This is in main lib, loads the right module, calls qt_get_screen
// In non-loadable cases just aliases to qt_get_screen

const unsigned char * qt_probe_bus();

#endif // TQGFX_QWS_H




</pre>
<!-- eof -->
<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>