-
Fast image drawing
Hi,
I'm wondering what is the fastest way to bring a full screen image, what is in my case an unsigned int image array, 32 bit, ARGB to the screen. As far as I understand QWidget implements a double buffer mechanism and I have to use painter.drawImage to do this.
Copy operations, especially for the whole screen content are slow on the device. With the approach mentioned before I have at least 2 copy operations (back buffer switch + painter.drawImage) and of course I have some application specific operations to fill the image. So we are talking about at least 3 pixel fill operations per frame for the whole screen.
What I'm looking for is something like
1) switching to QWidget single buffer + a fast bitblt/memcpy
2) direct screen buffer access like S60's DSA
Are there any possibilities to do this with Qt?
Best regards,
Henrik
-
Re: Fast image drawing
Hi,
I guess that the QPainter should be the "fast" blitter in QT.
In the QT 4.5 the QPainter should be faster, see this blog entry [url]http://labs.trolltech.com/blogs/2008/10/22/so-long-and-thanks-for-the-blit/[/url] . However I seriously doubt that it will be fast on S60 port :) It would be nice to know, if similar functionality is coming to S60 port too, as they already have in the desktop version.
Update: There seems to be also QDirectPainter in Embedded linux [url]http://doc.trolltech.com/4.5/qdirectpainter.html[/url] The QDirectPainter will give you direct access to the devices framebuffer. This would be ideal for very fast image drawin/blitting ;-)
-summeli
-
Re: Fast image drawing
We found finally a very fast solution by bypassing the Qt rendering pipeline by using DSA. Now we see the achievable performance on S60.
-
Re: Fast image drawing
How did you bypass the QT pipeline? Can you post some source code, please?
-summeli
-
Re: Fast image drawing
Hello,
as mentioned before we used Direct Screen Access with Qt. About DSA itself more informations can be found for example here [url]http://wiki.forum.nokia.com/index.php/Anti-tearing_with_CDirectScreenBitmap[/url] , [url]http://wiki.forum.nokia.com/index.php/How_to_draw_image_to_screen_directly[/url] or [url]http://developer.symbian.com/main/downloads/papers/dsa/direct_screen_access.pdf[/url].
What about using DSA with Qt on s60, we created one single central QWidget for drawing contents:
[CODE]class Window : public QWidget, public CActive, public MDirectScreenAccess
{
Q_OBJECT
//...
// from MDirectScreenAccess class
void Restart(RDirectScreenAccess::TTerminationReasons aReason);
void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
// from CActive
virtual void DoCancel();
virtual void RunL();
CDirectScreenAccess *iDSA;
CDirectScreenBitmap *iDSBitmap;
bool iDraw_dsa;
}[/CODE]
Implementation is very similar to examples that I gave before. Only (but very important) difference is implementation of starting DSA method:
[CODE]void Window::startDSA(){
if(!iDSA){
iDSBitmap = CDirectScreenBitmap::NewL();
iDSA = CDirectScreenAccess::NewL(CEikonEnv::Static()->WsSession(),
*CEikonEnv::Static()->ScreenDevice(),
[B]*winId()->DrawableWindow(),[/B]
*this);
CEikonEnv::Static()->WsSession().Flush();
iDSA->StartL();
CFbsBitGc *gc = iDSA->Gc();
RRegion *region = iDSA->DrawingRegion();
gc->SetClippingRegion(region);
User::LeaveIfError(iDSBitmap->Create(TRect(0, 0, iScreenWidth, iScreenHeight), CDirectScreenBitmap::EDoubleBuffer));
}
} [/CODE]
Solution was tested on device, works pretty good:).
Regards
Pawel
-
Re: Fast image drawing
Hi,
Since i have a wish to improve the refresh rate for some widgets in my Qt application, i am considering to take the approach shown here.
But while experimenting, some questions arise:
1) In the example code ([url]http://wiki.forum.nokia.com/index.php/Anti-tearing_with_CDirectScreenBitmap[/url]) it is mentioned to render the content usint iScreenBuffer. How do i make my QWidget do that? Does it happen automatically?
2) I'm currently doing the rendering in MyWidget:: paintEvent(), do i need to wrap that in calls to BeginDraw() and EndDraw()?
Regards,
Mark.
-
Re: Fast image drawing
The DSA bybasses the Qt stuff, so you can just make your own update() method, and use the DSA from there.