[Qt-embedded-interest] Custom Graphics Driver Without mmap()
Bryce Salmi
Bryce.Salmi at zoran.com
Tue Jul 7 22:19:45 CEST 2009
Qt-embedded-interest,
I decided to create a new thread as opposed to keeping my previous double buffer thread alive since I am no longer using the double buffer driver. I have tried to implement Tom Cooksey's suggestions to create a custom driver and one of my main obstacles is that my board (ARM) does not support mmap so I must work around that:
"I don't know to any simple examples you could use. I think actually
you just need to create a new driver which inherits QScreen. As you
can't get a pointer to your graphics memory, the driver will need a
"shadow" buffer instead (So it can read data for blend operations).
You can create a QImage for that in initDevice, and set the screen's
addr pointer to the image's bits(). Then you just need to re-implement
blit() to copy the blended data to your real framebuffer using an
ioctl or whatever.
Hope that helps?
Cheers,
Tom"
I have implemented what I could and created a space in memory for the buffer with QImage and I believe set the screens address pointer (QImage::data) to it. The following code is my implementation .cpp sourcefile named vopuScreenDriver.cpp
*****
// vopuScreenDriver.cpp
bool vopuScreenDriver::connect(const QString &displaySpec)
{
// Screen info
QScreen::lstep = 480;
QScreen::dw = QScreen::w = 480;
QScreen::dh = QScreen::h = 240;
QScreen::d = 24;
QScreen::size = QScreen::lstep * dh;
QScreen::data = 0;
setPixelFormat(QImage::Format_RGB888);
//dpi set to internet standard of 72 dpi
const int dpi = 72;
QScreen::physWidth = qRound(QScreen::dw * 25.4 / dpi);
QScreen::physHeight = qRound(QScreen::dh * 25.4 / dpi);
}
bool vopuScreenDriver::initDevice()
{
//should more be placed here? seems like
//svgalib specific stuff is used here
//for debugging related info
initColorMap();
// create address to QImage memory
int vopuBuffer = QImage::QImage(int 480, int 240, Format Format_RGB888);
QScreen::data = vopuBuffer;
QScreenCursor::initSoftwareCursor();
return true;
}
void vopuScreenDriver::shutdownDevice();
{
gl_freecontext(content);
//vga_setmode(TEXT);
}
void vopuScreenDriver::disconnect()
{
}
void SvgalibScreen::blit(const QImage &img, const QPoint &topLeft, const QRegion ®)
{
if (img.format() != pixelFormat()) {
if (base())
QScreen::blit(img, topLeft, reg);
return;
}
const QVector<QRect> rects = (reg & region()).rects();
for (int i = 0; i < rects.size(); ++i) {
const QRect r = rects.at(i);
gl_putboxpart(r.x(), r.y(), r.width(), r.height(),
img.width(), img.height(),
static_cast<void*>(const_cast<uchar*>(img.bits())),
r.x() - topLeft.x(), r.y() - topLeft.y());
}
}
*****
The stars (*****) indicate the start and finish of the code, it made more sense on the web based email I am using when I implemented them to separate the code from text. I would really appreciate any information on fixing up this code and also how to use this driver (compile,etc) when I get it completed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-embedded-interest/attachments/20090707/2e3e60da/attachment.html
More information about the Qt-embedded-interest
mailing list