Sophie

Sophie

distrib > Mandriva > current > i586 > media > main-updates > by-pkgid > 8e6051afcdb111a0317a58fb64c2abf5 > files > 5087

qt4-doc-4.6.3-0.2mdv2010.2.i586.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- emb-accel.qdoc -->
<head>
  <title>Qt 4.6: Adding an Accelerated Graphics Driver to Qt for Embedded Linux</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">Adding an Accelerated Graphics Driver to Qt for Embedded Linux<br /><span class="subtitle"></span>
</h1>
<a name="add-your-graphics-driver-to-qt-for-embedded-linux"></a><p>In <a href="qt-embedded-linux.html">Qt for Embedded Linux</a>, painting is a pure software implementation normally performed in two steps. First, each window is rendered onto a QWSWindowSurface using <a href="qpaintengine.html">QPaintEngine</a>. Second, the server composes the surface images and copies the composition to the screen (see <a href="qt-embedded-architecture.html">Qt for Embedded Linux Architecture</a> for details). <a href="qt-embedded-linux.html">Qt for Embedded Linux</a> uses <a href="qrasterpaintengine.html">QRasterPaintEngine</a> (a raster-based implementation of <a href="qpaintengine.html">QPaintEngine</a>) to implement painting operations, and uses <a href="qscreen.html">QScreen</a> to implement window composition.</p>
<p>It is possible to add an accelerated graphics driver to take advantage of available hardware resources. This is described in detail in the <a href="qws-svgalib.html">Accelerated Graphics Driver Example</a> which uses the following approach:</p>
<ul><li><a href="#step-1-create-a-custom-screen">Step 1: Create a Custom Screen</a></li>
<li><a href="#step-2-implement-a-custom-raster-paint-engine">Step 2: Implement a Custom Raster Paint Engine</a></li>
<li><a href="#step-3-make-the-paint-device-aware-of-your-paint-engine">Step 3: Make the Paint Device Aware of Your Paint Engine</a></li>
<li><a href="#step-4-make-the-window-surface-aware-of-your-paint-device">Step 4: Make the Window Surface Aware of Your Paint Device</a></li>
<li><a href="#step-5-enable-creation-of-an-instance-of-your-window-surface">Step 5: Enable Creation of an Instance of Your Window Surface</a></li>
</ul>
<p><b>Warning:</b> This feature is under development and is subject to change.</p>
<a name="step-1-create-a-custom-screen"></a>
<h2>Step 1: Create a Custom Screen</h2>
<p>Create a custom screen by deriving from the <a href="qscreen.html">QScreen</a> class.</p>
<p>The <a href="qscreen.html#connect">connect()</a>, <a href="qscreen.html#disconnect">disconnect()</a>, <a href="qscreen.html#initDevice">initDevice()</a> and <a href="qscreen.html#shutdownDevice">shutdownDevice()</a> functions are declared as pure virtual functions in <a href="qscreen.html">QScreen</a> and must be implemented. These functions are used to configure the hardware, or query its configuration. The <a href="qscreen.html#connect">connect()</a> and <a href="qscreen.html#disconnect">disconnect()</a> are called by both the server and client processes, while the <a href="qscreen.html#initDevice">initDevice()</a> and <a href="qscreen.html#shutdownDevice">shutdownDevice()</a> functions are only called by the server process.</p>
<p>You might want to accelerate the final copying to the screen by reimplementing the <a href="qscreen.html#blit">blit()</a> and <a href="qscreen.html#solidFill">solidFill()</a> functions.</p>
<a name="step-2-implement-a-custom-raster-paint-engine"></a>
<h2>Step 2: Implement a Custom Raster Paint Engine</h2>
<p>Implement the painting operations by subclassing the <a href="qrasterpaintengine.html">QRasterPaintEngine</a> class.</p>
<p>To accelerate a graphics primitive, simply reimplement the corresponding function in your custom paint engine. If there is functionality you do not want to reimplement (such as certain pens, brushes, modes, etc.), you can just call the corresponding base class implementation.</p>
<a name="step-3-make-the-paint-device-aware-of-your-paint-engine"></a>
<h2>Step 3: Make the Paint Device Aware of Your Paint Engine</h2>
<p>To activate your paint engine you must create a subclass of the <a href="qcustomrasterpaintdevice.html">QCustomRasterPaintDevice</a> class and reimplement its <a href="qpaintdevice.html#paintEngine">paintEngine()</a> function. Let this function return a pointer to your paint engine. In addition, the <a href="qcustomrasterpaintdevice.html#memory">QCustomRasterPaintDevice::memory</a>() function must be reimplemented to return a pointer to the buffer where the painting should be done.</p>
<p><table class="generic" align="center" cellpadding="2" cellspacing="1" border="0">
<thead><tr valign="top" class="qt-style"><th>Acceleration Without a Memory Buffer</th></tr></thead>
<tr valign="top" class="odd"><td>By default the <a href="qrasterpaintengine.html">QRasterPaintEngine</a> draws into a memory buffer (this can be local memory, shared memory or graphics memory mapped into application memory). In some cases you might want to avoid using a memory buffer directly, e.g if you want to use an accelerated graphic controller to handle all the buffer manipulation. This can be implemented by reimplementing the <a href="qcustomrasterpaintdevice.html#memory">QCustomRasterPaintDevice::memory</a>() function to return 0 (meaning no buffer available). Then, whenever a color or image buffer normally would be written into paint engine buffer, the paint engine will call the <a href="qrasterpaintengine.html#drawColorSpans">QRasterPaintEngine::drawColorSpans</a>() and <a href="qrasterpaintengine.html#drawBufferSpan">QRasterPaintEngine::drawBufferSpan</a>() functions instead.<p>Note that the default implementations of these functions only calls <a href="qtglobal.html#qFatal">qFatal</a>() with an error message; reimplement the functions and let them do the appropriate communication with the accelerated graphics controller.</p>
</td></tr>
</table></p>
<a name="step-4-make-the-window-surface-aware-of-your-paint-device"></a>
<h2>Step 4: Make the Window Surface Aware of Your Paint Device</h2>
<p>Derive from the QWSWindowSurface class and reimplement its <a href="qwswindowsurface.html#paintDevice">paintDevice()</a> function. Make this function return a pointer to your custom raster paint device.</p>
<a name="step-5-enable-creation-of-an-instance-of-your-window-surface"></a>
<h2>Step 5: Enable Creation of an Instance of Your Window Surface</h2>
<p>Finally, reimplement <a href="qscreen.html">QScreen</a>'s <a href="qscreen.html#createSurface">createSurface()</a> function and make this function able to create an instance of your QWSWindowSurface subclass.</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="40%" align="left">Copyright &copy; 2010 Nokia Corporation and/or its subsidiary(-ies)</td>
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="40%" align="right"><div align="right">Qt 4.6.3</div></td>
</tr></table></div></address></body>
</html>