- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qscreen_qws.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QSCREEN_QWS_H
    00043 #define QSCREEN_QWS_H
    00044
    00045 #include <QtCore/qnamespace.h>
    00046 #include <QtCore/qpoint.h>
    00047 #include <QtCore/qlist.h>
    00048 #include <QtGui/qrgb.h>
    00049 #include <QtCore/qrect.h>
    00050 #include <QtGui/qimage.h>
    00051 #include <QtGui/qregion.h>
    00052
    00053 struct fb_cmap;
    00054
    00055 QT_BEGIN_HEADER
    00056
    00057 QT_BEGIN_NAMESPACE
    00058
    00059 QT_MODULE(Gui)
    00060
    00061 class QScreenCursor;
    00062 class QBrush;
    00063 class QWSWindow;
    00064 class QWSWindowSurface;
    00065 class QGraphicsSystem;
    00066 class QPixmapData;
    00067
    00068 #ifndef QT_QWS_DEPTH16_RGB
    00069 #define QT_QWS_DEPTH16_RGB 565
    00070 #endif
    00071 static const int qt_rbits = (QT_QWS_DEPTH16_RGB/100);
    00072 static const int qt_gbits = (QT_QWS_DEPTH16_RGB/10%10);
    00073 static const int qt_bbits = (QT_QWS_DEPTH16_RGB%10);
    00074 static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits);
    00075 static const int qt_green_shift = qt_bbits-(8-qt_gbits);
    00076 static const int qt_neg_blue_shift = 8-qt_bbits;
    00077 static const int qt_blue_mask = (1<<qt_bbits)-1;
    00078 static const int qt_green_mask = (1<<(qt_gbits+qt_bbits))-(1<<qt_bbits);
    00079 static const int qt_red_mask = (1<<(qt_rbits+qt_gbits+qt_bbits))-(1<<(qt_gbits+qt_bbits));
    00080
    00081 static const int qt_red_rounding_shift = qt_red_shift + qt_rbits;
    00082 static const int qt_green_rounding_shift = qt_green_shift + qt_gbits;
    00083 static const int qt_blue_rounding_shift = qt_bbits - qt_neg_blue_shift;
    00084
    00085
    00086 inline ushort qt_convRgbTo16(const int r, const int g, const int b)
    00087 {
    00088     const int tr = r << qt_red_shift;
    00089     const int tg = g << qt_green_shift;
    00090     const int tb = b >> qt_neg_blue_shift;
    00091
    00092     return (tb & qt_blue_mask) | (tg & qt_green_mask) | (tr & qt_red_mask);
    00093 }
    00094
    00095 inline ushort qt_convRgbTo16(QRgb c)
    00096 {
    00097     const int tr = qRed(c) << qt_red_shift;
    00098     const int tg = qGreen(c) << qt_green_shift;
    00099     const int tb = qBlue(c) >> qt_neg_blue_shift;
    00100
    00101     return (tb & qt_blue_mask) | (tg & qt_green_mask) | (tr & qt_red_mask);
    00102 }
    00103
    00104 inline QRgb qt_conv16ToRgb(ushort c)
    00105 {
    00106     const int r=(c & qt_red_mask);
    00107     const int g=(c & qt_green_mask);
    00108     const int b=(c & qt_blue_mask);
    00109     const int tr = r >> qt_red_shift | r >> qt_red_rounding_shift;
    00110     const int tg = g >> qt_green_shift | g >> qt_green_rounding_shift;
    00111     const int tb = b << qt_neg_blue_shift | b >> qt_blue_rounding_shift;
    00112
    00113     return qRgb(tr,tg,tb);
    00114 }
    00115
    00116 inline void qt_conv16ToRgb(ushort c, int& r, int& g, int& b)
    00117 {
    00118     const int tr=(c & qt_red_mask);
    00119     const int tg=(c & qt_green_mask);
    00120     const int tb=(c & qt_blue_mask);
    00121     r = tr >> qt_red_shift | tr >> qt_red_rounding_shift;
    00122     g = tg >> qt_green_shift | tg >> qt_green_rounding_shift;
    00123     b = tb << qt_neg_blue_shift | tb >> qt_blue_rounding_shift;
    00124 }
    00125
    00126 const int SourceSolid=0;
    00127 const int SourcePixmap=1;
    00128
    00129 #ifndef QT_NO_QWS_CURSOR
    00130
    00131 class QScreenCursor;
    00132 extern QScreenCursor *qt_screencursor;
    00133 extern bool qt_sw_cursor;
    00134
    00135 class Q_GUI_EXPORT QScreenCursor
    00136 {
    00137 public:
    00138     QScreenCursor();
    00139     virtual ~QScreenCursor();
    00140
    00141     virtual void set(const QImage &image, int hotx, int hoty);
    00142     virtual void move(int x, int y);
    00143     virtual void show();
    00144     virtual void hide();
    00145
    00146     bool supportsAlphaCursor() const { return supportsAlpha; }
    00147
    00148     static bool enabled() { return qt_sw_cursor; }
    00149
    00150     QRect boundingRect() const { return QRect(pos - hotspot, size); }
    00151     QImage image() const { return cursor; }
    00152     bool isVisible() const { return enable; }
    00153     bool isAccelerated() const { return hwaccel; }
    00154
    00155     static void initSoftwareCursor();
    00156     static QScreenCursor* instance() { return qt_screencursor; }
    00157
    00158 protected:
    00159     QImage cursor;
    00160
    00161     QSize size;
    00162     QPoint pos;
    00163     QPoint hotspot;
    00164     uint enable : 1;
    00165     uint hwaccel : 1;
    00166     uint supportsAlpha : 1;
    00167
    00168 private:
    00169     friend class QProxyScreenCursor;
    00170 };
    00171
    00172 #endif // QT_NO_QWS_CURSOR
    00173
    00174 // A (used) chunk of offscreen memory
    00175
    00176 class QPoolEntry
    00177 {
    00178 public:
    00179     unsigned int start;
    00180     unsigned int end;
    00181     int clientId;
    00182 };
    00183
    00184 class QScreen;
    00185 class QScreenPrivate;
    00186 class QPixmapDataFactory;
    00187
    00188 extern Q_GUI_EXPORT QScreen *qt_screen;
    00189 typedef void(*ClearCacheFunc)(QScreen *obj, int);
    00190
    00191 class Q_GUI_EXPORT QScreen {
    00192
    00193 public:
    00194     enum ClassId { LinuxFBClass, TransformedClass, VNCClass, MultiClass,
    00195                    VFbClass, DirectFBClass, SvgalibClass, ProxyClass,
    00196                    GLClass, CustomClass = 1024 };
    00197
    00198     QScreen(int display_id, ClassId classId);
    00199     explicit QScreen(int display_id);
    00200     virtual ~QScreen();
    00201     static QScreen* instance() { return qt_screen; }
    00202     virtual bool initDevice() = 0;
    00203     virtual bool connect(const QString &displaySpec) = 0;
    00204     virtual void disconnect() = 0;
    00205     virtual void shutdownDevice();
    00206     virtual void setMode(int,int,int) = 0;
    00207     virtual bool supportsDepth(int) const;
    00208
    00209     virtual void save();
    00210     virtual void restore();
    00211     virtual void blank(bool on);
    00212
    00213     virtual int pixmapOffsetAlignment() { return 64; }
    00214     virtual int pixmapLinestepAlignment() { return 64; }
    00215     virtual int sharedRamSize(void *) { return 0; }
    00216
    00217     virtual bool onCard(const unsigned char *) const;
    00218     virtual bool onCard(const unsigned char *, ulong& out_offset) const;
    00219
    00220     enum PixelType { NormalPixel, BGRPixel };
    00221
    00222     // sets a single color in the colormap
    00223     virtual void set(unsigned int,unsigned int,unsigned int,unsigned int);
    00224     // allocates a color
    00225     virtual int alloc(unsigned int,unsigned int,unsigned int);
    00226
    00227     int width() const { return w; }
    00228     int height() const { return h; }
    00229     int depth() const { return d; }
    00230     virtual int pixmapDepth() const;
    00231     PixelType pixelType() const { return pixeltype; }
    00232     int linestep() const { return lstep; }
    00233     int deviceWidth() const { return dw; }
    00234     int deviceHeight() const { return dh; }
    00235     uchar * base() const { return data; }
    00236     // Ask for memory from card cache with alignment
    00237     virtual uchar * cache(int) { return 0; }
    00238     virtual void uncache(uchar *) {}
    00239
    00240     QImage::Format pixelFormat() const;
    00241
    00242     int screenSize() const { return size; }
    00243     int totalSize() const { return mapsize; }
    00244
    00245     QRgb * clut() { return screenclut; }
    00246 #ifdef QT_DEPRECATED
    00247     QT_DEPRECATED int numCols() { return screencols; }
    00248 #endif
    00249     int colorCount() { return screencols; }
    00250
    00251     virtual QSize mapToDevice(const QSize &) const;
    00252     virtual QSize mapFromDevice(const QSize &) const;
    00253     virtual QPoint mapToDevice(const QPoint &, const QSize &) const;
    00254     virtual QPoint mapFromDevice(const QPoint &, const QSize &) const;
    00255     virtual QRect mapToDevice(const QRect &, const QSize &) const;
    00256     virtual QRect mapFromDevice(const QRect &, const QSize &) const;
    00257     virtual QImage mapToDevice(const QImage &) const;
    00258     virtual QImage mapFromDevice(const QImage &) const;
    00259     virtual QRegion mapToDevice(const QRegion &, const QSize &) const;
    00260     virtual QRegion mapFromDevice(const QRegion &, const QSize &) const;
    00261     virtual int transformOrientation() const;
    00262     virtual bool isTransformed() const;
    00263     virtual bool isInterlaced() const;
    00264
    00265     virtual void setDirty(const QRect&);
    00266
    00267     virtual int memoryNeeded(const QString&);
    00268
    00269     virtual void haltUpdates();
    00270     virtual void resumeUpdates();
    00271
    00272     // composition manager methods
    00273     virtual void exposeRegion(QRegion r, int changing);
    00274
    00275     // these work directly on the screen
    00276     virtual void blit(const QImage &img, const QPoint &topLeft, const QRegion &region);
    00277     virtual void solidFill(const QColor &color, const QRegion &region);
    00278     void blit(QWSWindow *bs, const QRegion &clip);
    00279
    00280     virtual QWSWindowSurface* createSurface(QWidget *widget) const;
    00281     virtual QWSWindowSurface* createSurface(const QString &key) const;
    00282
    00283     virtual QList<QScreen*> subScreens() const { return QList<QScreen*>(); }
    00284     virtual QRegion region() const { return QRect(offset(), QSize(w, h)); }
    00285     int subScreenIndexAt(const QPoint &p) const;
    00286
    00287     void setOffset(const QPoint &p);
    00288     QPoint offset() const;
    00289
    00290     int physicalWidth() const { return physWidth; }   // physical display size in mm
    00291     int physicalHeight() const { return physHeight; } // physical display size in mm
    00292
    00293     QPixmapDataFactory* pixmapDataFactory() const; // Deprecated, will be removed in 4.6
    00294     QGraphicsSystem* graphicsSystem() const;
    00295
    00296 #ifdef QT_QWS_CLIENTBLIT
    00297     bool supportsBlitInClients() const;
    00298     void setSupportsBlitInClients(bool);
    00299 #endif
    00300
    00301     ClassId classId() const;
    00302
    00303 protected:
    00304     void setPixelFormat(QImage::Format format);
    00305     void setPixmapDataFactory(QPixmapDataFactory *factory); // Deprecated, will be removed in 4.6
    00306     void setGraphicsSystem(QGraphicsSystem* system);
    00307
    00308     QRgb screenclut[256];
    00309     int screencols;
    00310
    00311     uchar * data;
    00312
    00313     // Table of allocated lumps, kept in sorted highest-to-lowest order
    00314     // The table itself is allocated at the bottom of offscreen memory
    00315     // i.e. it's similar to having a stack (the table) and a heap
    00316     // (the allocated blocks). Freed space is implicitly described
    00317     // by the gaps between the allocated lumps (this saves entries and
    00318     // means we don't need to worry about coalescing freed lumps)
    00319
    00320     QPoolEntry * entries;
    00321     int * entryp;
    00322     unsigned int * lowest;
    00323
    00324     int w;
    00325     int lstep;
    00326     int h;
    00327     int d;
    00328     PixelType pixeltype;
    00329     bool grayscale;
    00330
    00331     int dw;
    00332     int dh;
    00333
    00334     int size;               // Screen size
    00335     int mapsize;       // Total mapped memory
    00336
    00337     int displayId;
    00338
    00339     int physWidth;
    00340     int physHeight;
    00341
    00342     friend class QWSServer;
    00343     friend class QWSServerPrivate;
    00344     static ClearCacheFunc clearCacheFunc;
    00345
    00346 private:
    00347     void compose(int level, const QRegion &exposed, QRegion &blend,
    00348                  QImage **blendbuffer, int changing_level);
    00349     void paintBackground(const QRegion &);
    00350
    00351     friend class QWSOnScreenSurface;
    00352     static bool isWidgetPaintOnScreen(const QWidget *w);
    00353
    00354 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
    00355     void setFrameBufferLittleEndian(bool littleEndian);
    00356     bool frameBufferLittleEndian() const;
    00357     friend class QVNCScreen;
    00358     friend class QLinuxFbScreen;
    00359     friend class QVFbScreen;
    00360     friend class QProxyScreen;
    00361 #endif
    00362     friend void qt_solidFill_setup(QScreen*, const QColor&, const QRegion&);
    00363     friend void qt_blit_setup(QScreen *screen, const QImage &image,
    00364                               const QPoint &topLeft, const QRegion &region);
    00365 #ifdef QT_QWS_DEPTH_GENERIC
    00366     friend void qt_set_generic_blit(QScreen *screen, int bpp,
    00367                                     int len_red, int len_green, int len_blue,
    00368                                     int len_alpha, int off_red, int off_green,
    00369                                     int off_blue, int off_alpha);
    00370 #endif
    00371
    00372     QScreenPrivate *d_ptr;
    00373 };
    00374
    00375 // This lives in loadable modules
    00376
    00377 #ifndef QT_LOADABLE_MODULES
    00378 extern "C" QScreen * qt_get_screen(int display_id, const char* spec);
    00379 #endif
    00380
    00381 // This is in main lib, loads the right module, calls qt_get_screen
    00382 // In non-loadable cases just aliases to qt_get_screen
    00383
    00384 const unsigned char * qt_probe_bus();
    00385
    00386 QT_END_NAMESPACE
    00387
    00388 QT_END_HEADER
    00389
    00390 #endif // QSCREEN_QWS_H