Qt 4.8
|
The QDirectPainter class provides direct access to the underlying hardware in Qt for Embedded Linux. More...
#include <qdirectpainter_qws.h>
Public Types | |
enum | SurfaceFlag { NonReserved = 0, Reserved = 1, ReservedSynchronous = 3 } |
This enum describes the behavior of the region reserved by this QDirectPainter object. More... | |
Public Functions | |
QRegion | allocatedRegion () const |
Returns the currently reserved region. More... | |
void | endPainting () |
Call this function when you are done updating the screen. More... | |
void | endPainting (const QRegion ®ion) |
This function will automatically call flush() to flush the region to the display before notifying the hardware, if necessary, that painting operations have ended. More... | |
void | flush (const QRegion ®ion) |
Flushes the region onto the screen. More... | |
QRect | geometry () const |
Returns the bounding rectangle of the requested region. More... | |
void | lower () |
Lowers the reserved region to the bottom of the widget stack. More... | |
QDirectPainter (QObject *parentObject=0, SurfaceFlag flag=NonReserved) | |
Constructs a QDirectPainter object with the given parent and surface flag. More... | |
void | raise () |
Raises the reserved region to the top of the widget stack. More... | |
virtual void | regionChanged (const QRegion &exposedRegion) |
This function is called when the allocated region changes. More... | |
QRegion | requestedRegion () const |
Returns the region requested by this QDirectPainter. More... | |
void | setGeometry (const QRect &) |
Request to reserve the given rectangle of the framebuffer. More... | |
void | setRegion (const QRegion &) |
Requests to reserve the given region of the framebuffer. More... | |
void | startPainting (bool lockDisplay=true) |
Call this function before you start updating the pixels in the allocated region. More... | |
WId | winId () const |
Returns the window system identifier of the widget. More... | |
~QDirectPainter () | |
Destroys this QDirectPainter object, releasing the reserved region. More... | |
Public Functions inherited from QObject | |
bool | blockSignals (bool b) |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More... | |
const QObjectList & | children () const |
Returns a list of child objects. More... | |
bool | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0) |
bool | disconnect (const QObject *receiver, const char *member=0) |
void | dumpObjectInfo () |
Dumps information about signal connections, etc. More... | |
void | dumpObjectTree () |
Dumps a tree of children to the debug output. More... | |
QList< QByteArray > | dynamicPropertyNames () const |
Returns the names of all properties that were dynamically added to the object using setProperty(). More... | |
virtual bool | event (QEvent *) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. More... | |
virtual bool | eventFilter (QObject *, QEvent *) |
Filters events if this object has been installed as an event filter for the watched object. More... | |
template<typename T > | |
T | findChild (const QString &aName=QString()) const |
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More... | |
template<typename T > | |
QList< T > | findChildren (const QString &aName=QString()) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More... | |
template<typename T > | |
QList< T > | findChildren (const QRegExp &re) const |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More... | |
void | installEventFilter (QObject *) |
Installs an event filter filterObj on this object. More... | |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. More... | |
void | killTimer (int id) |
Kills the timer with timer identifier, id. More... | |
virtual const QMetaObject * | metaObject () const |
Returns a pointer to the meta-object of this object. More... | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. More... | |
QString | objectName () const |
QObject * | parent () const |
Returns a pointer to the parent object. More... | |
QVariant | property (const char *name) const |
Returns the value of the object's name property. More... | |
Q_INVOKABLE | QObject (QObject *parent=0) |
Constructs an object with parent object parent. More... | |
void | removeEventFilter (QObject *) |
Removes an event filter object obj from this object. More... | |
void | setObjectName (const QString &name) |
void | setParent (QObject *) |
Makes the object a child of parent. More... | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. More... | |
void | setUserData (uint id, QObjectUserData *data) |
bool | signalsBlocked () const |
Returns true if signals are blocked; otherwise returns false. More... | |
int | startTimer (int interval) |
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More... | |
QThread * | thread () const |
Returns the thread in which the object lives. More... | |
QObjectUserData * | userData (uint id) const |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. More... | |
Static Public Functions | |
static uchar * | frameBuffer () |
Returns a pointer to the beginning of the display memory. More... | |
static int | linestep () |
Returns the length (in bytes) of each scanline of the framebuffer. More... | |
static void | lock () |
Locks access to the framebuffer. More... | |
static QRegion | region () |
Use QDirectPainter::allocatedRegion() instead. More... | |
static QRegion | reservedRegion () |
Returns the reserved region. More... | |
static QRegion | reserveRegion (const QRegion &) |
Attempts to reserve the region and returns the region that is actually reserved. More... | |
static int | screenDepth () |
Returns the bit depth of the display. More... | |
static int | screenHeight () |
Returns the height of the display in pixels. More... | |
static int | screenWidth () |
Returns the width of the display in pixels. More... | |
static void | unlock () |
Unlocks the lock on the framebuffer (set using the lock() function), allowing other applications to access the screen. More... | |
Static Public Functions inherited from QObject | |
static bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More... | |
static bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
Disconnects signal in object sender from method in object receiver. More... | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static uint | registerUserData () |
static QString | tr (const char *sourceText, const char *comment=0, int n=-1) |
static QString | trUtf8 (const char *sourceText, const char *comment=0, int n=-1) |
Friends | |
void | qt_directpainter_embedevent (QDirectPainter *, const QWSEmbedEvent *) |
void | qt_directpainter_region (QDirectPainter *dp, const QRegion &alloc, int type) |
Additional Inherited Members | |
Public Slots inherited from QObject | |
void | deleteLater () |
Schedules this object for deletion. More... | |
Signals inherited from QObject | |
void | destroyed (QObject *=0) |
This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More... | |
Static Public Variables inherited from QObject | |
static const QMetaObject | staticMetaObject |
This variable stores the meta-object for the class. More... | |
Protected Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *) |
This event handler can be reimplemented in a subclass to receive child events. More... | |
virtual void | connectNotify (const char *signal) |
This virtual function is called when something has been connected to signal in this object. More... | |
virtual void | customEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive custom events. More... | |
virtual void | disconnectNotify (const char *signal) |
This virtual function is called when something has been disconnected from signal in this object. More... | |
QObject (QObjectPrivate &dd, QObject *parent=0) | |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. More... | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More... | |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *) |
This event handler can be reimplemented in a subclass to receive timer events for the object. More... | |
Protected Variables inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Static Protected Variables inherited from QObject | |
static const QMetaObject | staticQtMetaObject |
Related Functions inherited from QObject | |
T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QRegExp ®Exp)() |
T * | qobject_cast (QObject *object) |
QObjectList | |
void * | qt_find_obj_child (QObject *parent, const char *type, const QString &name) |
Returns a pointer to the object named name that inherits type and with a given parent. More... | |
The QDirectPainter class provides direct access to the underlying hardware in Qt for Embedded Linux.
Note that this class is only available in 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.
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.
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() is called.
If 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 QScreen::subScreenIndexAt() and QScreen::subScreens() functions to access the correct subscreen, and the subscreen's QScreen::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() and unlock() functions. Note that calling lock() will prevent all other applications from working until unlock() is called.
In addition, 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() and screenHeight() function return the screen metrics.
Definition at line 58 of file qdirectpainter_qws.h.
This enum describes the behavior of the region reserved by this QDirectPainter object.
Enumerator | |
---|---|
NonReserved | |
Reserved | |
ReservedSynchronous |
Definition at line 63 of file qdirectpainter_qws.h.
|
explicit |
Constructs a QDirectPainter object with the given parent and surface flag.
Definition at line 262 of file qdirectpainter_qws.cpp.
Referenced by reserveRegion().
QDirectPainter::~QDirectPainter | ( | ) |
Destroys this QDirectPainter object, releasing the reserved region.
Definition at line 282 of file qdirectpainter_qws.cpp.
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 for details).
Definition at line 391 of file qdirectpainter_qws.cpp.
Referenced by reservedRegion(), and reserveRegion().
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.
Definition at line 489 of file qdirectpainter_qws.cpp.
Referenced by endPainting().
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.
Definition at line 514 of file qdirectpainter_qws.cpp.
void QDirectPainter::flush | ( | const QRegion & | region | ) |
Flushes the region onto the screen.
Definition at line 528 of file qdirectpainter_qws.cpp.
Referenced by endPainting().
|
static |
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 QScreen::subScreenIndexAt() and QScreen::subScreens() functions to access the correct subscreen, and the subscreen's QScreen::base() function to retrieve a pointer to the framebuffer.
Definition at line 624 of file qdirectpainter_qws.cpp.
QRect QDirectPainter::geometry | ( | ) | const |
Returns the bounding rectangle of the requested region.
Definition at line 320 of file qdirectpainter_qws.cpp.
|
static |
Returns the length (in bytes) of each scanline of the framebuffer.
Definition at line 696 of file qdirectpainter_qws.cpp.
|
static |
Locks access to the framebuffer.
Note that calling this function will prevent all other applications from updating the display until unlock() is called.
Definition at line 713 of file qdirectpainter_qws.cpp.
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.
Definition at line 573 of file qdirectpainter_qws.cpp.
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.
Definition at line 555 of file qdirectpainter_qws.cpp.
|
inlinestatic |
Use QDirectPainter::allocatedRegion() instead.
Definition at line 91 of file qdirectpainter_qws.h.
Referenced by setRegion().
|
virtual |
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.
Definition at line 436 of file qdirectpainter_qws.cpp.
Referenced by qt_directpainter_region().
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 for details).
Definition at line 370 of file qdirectpainter_qws.cpp.
|
static |
Returns the reserved region.
Use allocatedRegion() instead.
Definition at line 646 of file qdirectpainter_qws.cpp.
Attempts to reserve the region and returns the region that is actually reserved.
This function also releases the previously reserved region if any. If not released explicitly, the region will be released on application exit.
Construct a QDirectPainter using QDirectPainter::ReservedSynchronous instead.
Definition at line 598 of file qdirectpainter_qws.cpp.
|
static |
Returns the bit depth of the display.
Definition at line 657 of file qdirectpainter_qws.cpp.
|
static |
Returns the height of the display in pixels.
Definition at line 683 of file qdirectpainter_qws.cpp.
|
static |
Returns the width of the display in pixels.
Definition at line 670 of file qdirectpainter_qws.cpp.
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 object.
Definition at line 305 of file qdirectpainter_qws.cpp.
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 object.
Definition at line 340 of file qdirectpainter_qws.cpp.
Referenced by qt_directpainter_embedevent(), reserveRegion(), and setGeometry().
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() to lock() and 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().
Definition at line 464 of file qdirectpainter_qws.cpp.
|
static |
Unlocks the lock on the framebuffer (set using the lock() function), allowing other applications to access the screen.
Definition at line 723 of file qdirectpainter_qws.cpp.
WId QDirectPainter::winId | ( | ) | const |
Returns the window system identifier of the widget.
Definition at line 411 of file qdirectpainter_qws.cpp.
Referenced by lower(), and raise().
|
friend |
Definition at line 244 of file qdirectpainter_qws.cpp.
|
friend |
Definition at line 223 of file qdirectpainter_qws.cpp.