📄 qscreen_qws.cpp
字号:
qrgb::len_green = len_green; qrgb::len_blue = len_blue; qrgb::len_alpha = len_alpha; qrgb::off_red = off_red; qrgb::off_green = off_green; qrgb::off_blue = off_blue; qrgb::off_alpha = off_alpha; screen->d_ptr->blit = blit_rgb; if (bpp == 16) screen->d_ptr->solidFill = solidFill_rgb_16bpp; else if (bpp == 32) screen->d_ptr->solidFill = solidFill_rgb_32bpp;}#endif // QT_QWS_DEPTH_GENERICvoid qt_blit_setup(QScreen *screen, const QImage &image, const QPoint &topLeft, const QRegion ®ion){ switch (screen->depth()) {#ifdef QT_QWS_DEPTH_32 case 32: screen->d_ptr->blit = blit_32; break;#endif#ifdef QT_QWS_DEPTH_24 case 24: screen->d_ptr->blit = blit_template<quint24, quint32>; break;#endif#ifdef QT_QWS_DEPTH_18 case 18: screen->d_ptr->blit = blit_template<quint18, quint32>; break;#endif#ifdef QT_QWS_DEPTH_16 case 16:#if Q_BYTE_ORDER == Q_BIG_ENDIAN if (screen->d_ptr->fb_is_littleEndian) screen->d_ptr->blit = blit_16_bigToLittleEndian; else#endif screen->d_ptr->blit = blit_16; break;#endif#ifdef QT_QWS_DEPTH_8 case 8: screen->d_ptr->blit = blit_8; break;#endif#ifdef QT_QWS_DEPTH_4 case 4: screen->d_ptr->blit = blit_4; break;#endif#ifdef QT_QWS_DEPTH_1 case 1: screen->d_ptr->blit = blit_1; break;#endif default: qFatal("blit_setup(): Screen depth %d not supported!", screen->depth()); screen->d_ptr->blit = 0; break; } screen->d_ptr->blit(screen, image, topLeft, region);}QScreenPrivate::QScreenPrivate(QScreen *parent) : pixelFormat(QImage::Format_Invalid), q_ptr(parent){ solidFill = qt_solidFill_setup; blit = qt_blit_setup;#if Q_BYTE_ORDER == Q_BIG_ENDIAN fb_is_littleEndian = false;#endif}QImage::Format QScreenPrivate::preferredImageFormat() const{ if (q_ptr->depth() <= 16) return QImage::Format_RGB16; else return pixelFormat;}/*! \class QScreen \ingroup qws \brief The QScreen class is a base class for screen drivers in Qtopia Core. Note that this class is only available in \l {Qtopia Core}. \l {Qtopia Core} provides ready-made drivers for several screen protocols, see the \l {Qtopia Core Display Management}{display management} documentation for details. Custom screen drivers can be implemented by subclassing the QScreen class and creating a screen driver plugin (derived from QScreenDriverPlugin). \l {Qtopia Core}'s implementation of the QScreenDriverFactory class will automatically detect the plugin, and load the driver into the server application at runtime using Qt's \l {How to Create Qt Plugins}{plugin system}. When rendering, \l {Qtopia Core}'s default behavior is for each client to render its widgets as well as its decorations into memory, while the server copies the memory content to the device's framebuffer using the screen driver. See the \l {Qtopia Core Architecture} overview for details (note that it is possible for the clients to manipulate and control the underlying hardware directly as well). Starting with \l {Qtopia Core} 4.2, it is also possible to add an accelerated graphics driver to take advantage of available hardware resources. See the \l {Adding an Accelerated Graphics Driver in Qtopia Core} documentation for details. \tableofcontents \section1 Framebuffer Management When a \l {Qtopia Core} application starts running, it calls the screen driver's connect() function to map into the framebuffer and the accelerated drivers that the graphics card control registers. Note that if the application acts as the server, the application will call the initDevice() function prior to the connect() function, to initialize the framebuffer. The initDevice() function can be reimplemented to set up the graphics card. Likewise, just before a \l {Qtopia Core} application exits, it calls the screen driver's disconnect() function. The server application will in addition call the shutdownDevice() function before it calls disconnect(). Note that the default implementation of the shutdownDevice() function only hides the mouse cursor. QScreen also provides the save() and restore() functions, making it possible to save and restore the state of the graphics card. Note that the default implementations do nothing. Hardware screen drivers should reimplement these functions to save (and restore) its registers, enabling switching between virtual consoles. In addition, you can use the base() function to retrieve a pointer to the beginning of the framebuffer, and the region() function to retrieve the framebuffer's region. Use the onCard() function to determine whether the framebuffer is within the graphics card's memory, and the totalSize() function to determine the size of the available graphics card memory (including the screen). Finally, you can use the offset() function to retrieve the offset between the framebuffer's coordinates and the application's coordinate system. \section1 Palette Management QScreen provides several functions to retrieve information about the color palette: The clut() function returns a pointer to the color lookup table (i.e. its color palette). Use the numCols() function to determine the number of entries in this table, and the alloc() function to retrieve the palette index of the color that is the closest match to a given RGB value. To determine if the screen driver supports a given color depth, use the supportsDepth() function that returns true of the specified depth is supported. \section1 Drawing on Screen When a screen update is required, the \l {Qtopia Core} server runs through all the top-level windows that intersect with the region that is about to be updated, and ensures that the associated clients have updated their memory buffer. Then the server calls the exposeRegion() function that composes the window surfaces and copies the content of memory to screen by calling the blit() and solidFill() functions. The blit() function copies a given region in a given image to a specified point using device coordinates, while the solidFill() function fills the given region of the screen with the specified color. Note that normally there is no need to call either of these functions explicitly. In addition, QScreen provides the blank() function that can be reimplemented to prevent any contents from being displayed on the screen, and the setDirty() function that can be reimplemented to indicate that a given rectangle of the screen has been altered. Note that the default implementations of these functions do nothing. Reimplement the the mapFromDevice() and mapToDevice() functions to map objects from the framebuffer coordinate system to the coordinate space used by the application, and vice versa. Be aware that the default implementations simply return the given objects as they are. \section1 Properties \table \header \o Property \o Functions \row \o Size \o The size of the screen can be retrieved using the screenSize() function. The size is returned in bytes. The framebuffer's logical width and height can be retrieved using width() and height(), respectively. These functions return values are given in pixels. Alternatively, the physicalWidth() and physicalHeight() function returns the same metrics in millimeters. QScreen also provides the deviceWidth() and deviceHeight() functions returning the physical width and height of the device in pixels. Note that the latter metrics can differ from the ones used if the display is centered within the framebuffer. \row \o Resolution \o Reimplement the setMode() function to be able to set the framebuffer to a new resolution (width and height) and bit depth. The current depth of the framebuffer can be always be retrieved using the depth() function. Use the pixmapDepth() function to obtain the preferred depth for pixmaps. \row \o Pixmap Alignment \o Use the pixmapOffsetAlignment() function to retrieve the value to which the start address of pixmaps held in the graphics card's memory, should be aligned. Use the pixmapLinestepAlignment() to retrieve the value to which the \e {individual scanlines} of pixmaps should be aligned. \row \o Image Display \o The isInterlaced() function tells whether the screen is displaying images progressively, and the isTransformed() function whether it is rotated. The transformOrientation() function can be reimplemented to return the current rotation. \row \o Scanlines \o Use the linestep() function to retrieve the length of each scanline of the framebuffer. \row \o Pixel Type \o The pixelType() function returns the screen's pixel storage format as described by the PixelType enum. \endtable \sa QScreenDriverPlugin, QScreenDriverFactory, {Qtopia Core Display Management}*//*! \enum QScreen::PixelType This enum describes the pixel storage format of the screen, i.e. the order of the red (R), green (G) and blue (B) components of a pixel. \value NormalPixel Red-green-blue (RGB) \value BGRPixel Blue-green-red (BGR) \sa pixelType()*//*! \fn static QScreen* QScreen::instance() Returns a pointer to the application's QScreen instance. If this screen consists of several subscreens, operations to the returned instance will affect all its subscreens. Use the subscreens() function to retrieve access to a particular subscreen. \sa subScreens(), subScreenIndexAt()*//*! \fn QList<QScreen*> QScreen::subScreens() const \since 4.2 Returns a list of this screen's subscreens. Use the subScreenIndexAt() function to retrieve the index of a screen at a given position. Note that if \e this screen consists of several subscreens, operations to \e this instance will affect all subscreens by default. \sa instance(), subScreenIndexAt()*//*! \fn int QScreen::physicalWidth() const \since 4.2 Returns the physical width of the screen in millimeters. \sa width(), deviceWidth(), physicalHeight()*//*! \fn int QScreen::physicalHeight() const \since 4.2 Returns the physical height of the screen in millimeters. \sa height(), deviceHeight(), physicalWidth()*//*! \fn virtual bool QScreen::initDevice() = 0 This function is called by the \l {Qtopia Core} server to initialize the framebuffer. Note that a server application will call the connect() function prior to this function. Implement this function to make accelerated drivers set up the graphics card. Return true to indicate success and false to indicate failure. \sa shutdownDevice(), connect()*//*! \fn virtual bool QScreen::connect(const QString &displaySpec) = 0 This function is called by every \l {Qtopia Core} application on startup, and must be implemented to map in the framebuffer and the accelerated drivers that the graphics card control registers. Note that it is called \e before the initDevice() function. Ensure that the function returns true if a connection to the screen device can be made; otherwise return false. The \a displaySpec argument is passed by the QWS_DISPLAY environment variable or the -display command line parameter, and has the following syntax: \code [screen driver][:driver specific options][:display number] \endcode For example, to use the mach64 driver on fb1 as display 2: \code Mach64:/dev/fb1:2 \endcode See \l {Qtopia Core Display Management} for more details. \sa disconnect(), initDevice(), {Running Qtopia Core Applications}*//*! \fn QScreen::disconnect() This function is called by every \l {Qtopia Core} application before exiting, and must be implemented to unmap the framebuffer. Note that a server application will call the shutdownDevice() function prior to this function. \sa connect(), shutdownDevice(), {Running Qtopia Core Applications}*//*! \fn QScreen::setMode(int width, int height, int depth) Implement this function to reset the framebuffer's resolution (\a width and \a height) and bit \a depth. After the resolution has been set, existing paint engines will be invalid and the framebuffer should be completely redrawn. In a multiple-process situation, all other applications must be notified to reset their mode and update themselves accordingly.*//*! \fn QScreen::blank(bool on) Prevents the screen driver form displaying any content on the screen. Note that the default implementation does nothing. Reimplement this function to prevent the screen driver from displaying any contents on the screen if \a on is true; otherwise the contents is expected to be shown. \sa blit()*//*! \fn int QScreen::pixmapOffsetAlignment() Returns the value (in bits) to which the start address of pixmaps held in the graphics card's memory, should be aligned. Note that the default implementation returns 64; reimplement this function to override the return value, e.g., when implementing an accelerated driver (see the \l {Adding an Accelerated Graphics Driver in Qtopia Core}{Adding an Accelerated Graphics Driver} documentation for details). \sa pixmapLinestepAlignment()*//*! \fn int QScreen::pixmapLinestepAlignment() Returns the value (in bits) to which individual scanlines of pixmaps held in the graphics card's memory, should be aligned. Note that the default implementation returns 64; reimplement this function to override the return value, e.g., when implementing an accelerated driver (see the \l {Adding an Accelerated Graphics Driver in Qtopia Core}{Adding an Accelerated Graphics Driver} documentation for details). \sa pixmapOffsetAlignment()*//*! \fn QScreen::width() const
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -