QDirectPainter Class

The QDirectPainter class provides direct access to the underlying hardware in Qt for Embedded Linux. 更多...

头: #include <QDirectPainter>
继承: QObject

公共类型

enum SurfaceFlag { NonReserved, Reserved, ReservedSynchronous }

公共函数

QDirectPainter (QObject * parent = 0, SurfaceFlag flag = NonReserved)
~QDirectPainter ()
QRegion allocatedRegion () const
void endPainting ()
void endPainting (const QRegion & region )
void flush (const QRegion & region )
QRect geometry () const
void lower ()
void raise ()
virtual void regionChanged (const QRegion & newRegion )
QRegion requestedRegion () const
void setGeometry (const QRect & rectangle )
void setRegion (const QRegion & region )
void startPainting (bool lockDisplay = true)
WId winId () const

静态公共成员

uchar * frameBuffer ()
int linestep ()
void lock ()
int screenDepth ()
int screenHeight ()
int screenWidth ()
void unlock ()

额外继承成员

详细描述

The QDirectPainter class provides direct access to the underlying hardware in Qt for Embedded Linux.

注意,此类只可用于 Qt for Embedded Linux .

QDirectPainter allows a client application to reserve a region of the framebuffer and render directly onto the screen. There are two ways of using the QDirectPainter class: You can either reserve a region using the provided static functions, or you can instantiate an object and make use of its more dynamic API.

Dynamic Allocation

By instantiating a QDirectPainter object using the default QDirectPainter::NonReserved surface flag, the client application only gets some control over the reserved region, i.e., it can still render directly onto the screen but the allocated region may change (for example, if a window with a higher focus requests parts of the same region). The currently allocated region can be retrieved using the allocatedRegion () function, while the requestedRegion () function returns the originally reserved region.

Static Allocation

Using the static approach, the client application gets complete control over the reserved region, i.e., the affected region will never be modified by the screen driver.

To create a static region, pass the QDirectPainter::Reserved surface flag to the constructor. After the reserved region is reported through regionChanged (), the allocated region will not change, unless setRegion () 被调用。

QDirectPainter::ReservedSynchronous is passed to the constructor, calls to setRegion () will block until the region is reserved, meaning that allocatedRegion () will be available immediately. Note that in the current version setRegion () will cause the application event loop to be entered, potentially causing reentrancy issues.

渲染

To draw on a given region, the application must first get hold of a pointer to the framebuffer. In most cases, this pointer can be retrieved using the QDirectPainter::frameBuffer () function. But note that if the current screen has subscreens, you must query the screen driver instead to identify the correct subscreen. A pointer to the current screen driver can always be retrieved using the static QScreen::instance () function. Then use QScreen 's subScreenIndexAt() and subScreens() functions to access the correct subscreen, and the subscreen's base() function to retrieve a pointer to the framebuffer.

Depending on the hardware, it might be necessary to lock the framebuffer for exclusive use while writing to it. This is possible using the lock () 和 unlock () functions. Note that calling lock () will prevent all other applications from working until unlock () 被调用。

此外, QDirectPainter provides several functions returning information about the framebuffer: the linestep () function returns the length (in bytes) of each scanline of the framebuffer while the screenDepth (), screenWidth () 和 screenHeight () function return the screen metrics.

另请参阅 QScreen , QWSEmbedWidget ,和 Qt for Embedded Linux 体系结构 .

成员类型文档编制

enum QDirectPainter:: SurfaceFlag

This enum describes the behavior of the region reserved by this QDirectPainter 对象。

常量 描述
QDirectPainter::NonReserved 0 The allocated region may change, e.g., if a window with a higher focus requests parts of the same region. See also Dynamic Allocation .
QDirectPainter::Reserved 1 The allocated region will never change. See also Static Allocation .
QDirectPainter::ReservedSynchronous 3 The allocated region will never change and each function that changes the allocated region will be blocking.

另请参阅 allocatedRegion ().

成员函数文档编制

QDirectPainter:: QDirectPainter ( QObject * parent = 0, SurfaceFlag flag = NonReserved)

构造 QDirectPainter 对象采用给定 parent and surface flag .

QDirectPainter:: ~QDirectPainter ()

销毁此 QDirectPainter object, releasing the reserved region.

另请参阅 allocatedRegion ().

QRegion QDirectPainter:: allocatedRegion () const

Returns the currently reserved region.

Note that if the QDirectPainter::Reserved flag is set, the region returned by this function will always be equivalent to the region returned by the requestedRegion () function. Otherwise they might differ (see Dynamic Allocation 了解细节)。

该函数在 Qt 4.2 引入。

另请参阅 requestedRegion () 和 geometry ().

void QDirectPainter:: endPainting ()

Call this function when you are done updating the screen. It will notify the hardware, if necessary, that your painting operations have ended.

该函数在 Qt 4.2 引入。

void QDirectPainter:: endPainting (const QRegion & region )

这是重载函数。

This function will automatically call flush () to flush the region to the display before notifying the hardware, if necessary, that painting operations have ended.

该函数在 Qt 4.3 引入。

void QDirectPainter:: flush (const QRegion & region )

Flushes the region 到屏幕。

该函数在 Qt 4.3 引入。

[static] uchar * QDirectPainter:: frameBuffer ()

Returns a pointer to the beginning of the display memory.

Note that it is the application's responsibility to limit itself to modifying only the reserved region.

Do not use this pointer if the current screen has subscreens, query the screen driver instead: A pointer to the current screen driver can always be retrieved using the static QScreen::instance () function. Then use QScreen 's subScreenIndexAt() and subScreens() functions to access the correct subscreen, and the subscreen's base() function to retrieve a pointer to the framebuffer.

另请参阅 requestedRegion (), allocatedRegion (),和 linestep ().

QRect QDirectPainter:: geometry () const

Returns the bounding rectangle of the requested region.

该函数在 Qt 4.2 引入。

另请参阅 setGeometry () 和 requestedRegion ().

[static] int QDirectPainter:: linestep ()

Returns the length (in bytes) of each scanline of the framebuffer.

另请参阅 frameBuffer ().

[static] void QDirectPainter:: lock ()

Locks access to the framebuffer.

Note that calling this function will prevent all other applications from updating the display until unlock () 被调用。

另请参阅 unlock ().

void QDirectPainter:: lower ()

Lowers the reserved region to the bottom of the widget stack.

After this call the reserved region will be visually behind (and therefore obscured by) any overlapping widgets.

该函数在 Qt 4.2 引入。

另请参阅 raise () 和 requestedRegion ().

void QDirectPainter:: raise ()

Raises the reserved region to the top of the widget stack.

After this call the reserved region will be visually in front of any overlapping widgets.

该函数在 Qt 4.2 引入。

另请参阅 lower () 和 requestedRegion ().

[虚拟] void QDirectPainter:: regionChanged (const QRegion & newRegion )

This function is called when the allocated region changes.

This function is not called for region changes that happen while the startPainting () function is executing.

Note that the given region, newRegion , is not guaranteed to be correct at the time you access the display. To prevent reentrancy problems you should always call startPainting () before updating the display and then use allocatedRegion () to retrieve the correct region.

该函数在 Qt 4.2 引入。

另请参阅 allocatedRegion (), startPainting (),和 Dynamic Allocation .

QRegion QDirectPainter:: requestedRegion () const

Returns the region requested by this QDirectPainter .

Note that if the QDirectPainter::Reserved flag is set, the region returned by this function will always be equivalent to the region returned by the allocatedRegion () function. Otherwise they might differ (see Dynamic Allocation 了解细节)。

该函数在 Qt 4.2 引入。

另请参阅 geometry (), setRegion (),和 allocatedRegion ().

[static] int QDirectPainter:: screenDepth ()

Returns the bit depth of the display.

另请参阅 screenHeight () 和 screenWidth ().

[static] int QDirectPainter:: screenHeight ()

Returns the height of the display in pixels.

另请参阅 screenWidth () 和 screenDepth ().

[static] int QDirectPainter:: screenWidth ()

Returns the width of the display in pixels.

另请参阅 screenHeight () 和 screenDepth ().

void QDirectPainter:: setGeometry (const QRect & rectangle )

Request to reserve the given rectangle of the framebuffer.

Note that the actually allocated region might differ from the requested one, e.g., if the given region overlaps with the region of another QDirectPainter 对象。

该函数在 Qt 4.2 引入。

另请参阅 geometry (), allocatedRegion (),和 setRegion ().

void QDirectPainter:: setRegion (const QRegion & region )

Requests to reserve the given region of the framebuffer.

Note that the actually allocated region might differ from the requested one, e.g., if the given region overlaps with the region of another QDirectPainter 对象。

该函数在 Qt 4.2 引入。

另请参阅 region (), requestedRegion (), allocatedRegion (),和 Dynamic Allocation .

void QDirectPainter:: startPainting ( bool lockDisplay = true)

Call this function before you start updating the pixels in the allocated region. The hardware will be notified, if necessary, that you are about to start painting operations.

Set lockDisplay if you want startPainting() and endPainting () 到 lock () 和 unlock () the display automatically.

Note that for a NonReserved direct painter, you must call allocatedRegion () after calling this function, since the allocated region is only guaranteed to be correct after this function has returned.

The regionChanged () function will not be called between startPainting() and endPainting ().

该函数在 Qt 4.2 引入。

另请参阅 endPainting () 和 flush ().

[static] void QDirectPainter:: unlock ()

Unlocks the lock on the framebuffer (set using the lock () function), allowing other applications to access the screen.

另请参阅 lock ().

WId QDirectPainter:: winId () const

返回 Widget 的窗口系统标识符。

该函数在 Qt 4.2 引入。