Speed up QPainter.drawPixmap in pc emulators
-
I've been porting AppleWin to Linux and I chose Qt as gui framework.
Everything works, but it uses a lot of CPU 20% (vs the Windows version of < 5%). And there is more I need to squeeze in in the future.
The bootle-neck with my implementation is drawing the screen.What I do is I first draw to an offscreen QPixmap and then paint the pixmap to the widget with rescaling.
The issue is with the first part.
The way it works is that for every block I copy from precreated pixmaps with calls likepainter.drawPixmap(xpixel, ypixel, text80Col, sx, sy, 7, 16);
where the blocks can be 7x16, 14x16, 14x2 or 7x2.
Total size is 560x384In the end I just copy many blocks of memory from the templates to the actual QPixmap.
Copying it to the widget is very quick.Tried to use QPixmap and QImage but did not see a difference.
What is the best strategy of copying many small blocks like this?
Would I have more luck with memcpy? Not sure how to do it though.
OpenGL? could it be of any use? -
Hi,
What is contained in these small blocks ?
OpenGL is likely something you should consider in any case.
-
I have pre drawn all possible blocks in some offline QPixmaps, so at runtime I do a lookup.
E.g.: if memory video address = 0x4b, then read block 14x16 from x and y from the offline templates and copy them to the current video buffer.
The templates contain text bitmaps and all possible color blocks for graphics.
E.g.: 0x4b could mean in graphics "blue black yellow black black". I've got them all ready and I just copy them over.If I use OpenGL. what do I draw? single pixels?
-
The OpenGL Cube example shows the technique to map a PNG containing all the cube faces on a 3D cube.