I'm working on a graphical application, made for console mode, and facing some performance issues when working with large resolution (1920px wide here).
One part of the display, a video background, is generated and displayed via pygame (SDL 1.2 python bindings).
The other part of the display, the UI, is also generated with pygame, but is displayed as a GPU overlay (based on the dispmanx API : https://github.com/AndrewFromMelbourne/raspidmx), via a fork of pngview, launched as a subprocess.
Here is the detailled steps and timings :
- UI image is generated on a pygame Surface. (take 0.03s)
- Pygame surface is converted to a (x,y,4) int8 array, representing the RGBA array. (also take 0.03s)
layerRGBA = np.fromstring(layerUI.get_buffer().raw,np.uint8).reshape(resX,resY, 4)
- The pixel array is then written to a memory mapped file (take 0.03s too)
fp = np.memmap("/tmp/layerRGBA.raw",dtype='int8', mode='w+', shape=(resX,resY,4))
fp[:] = res
- Then the subprocess is told to refresh the UI via a stdin message. (take 0.00s)
Can I expect to achieve better performance on the conversion or mmap part ? Or is there a faster way to communicate this RGBA layer from my main python app to my dispmanx C program than mmap?
Thank you for your suggestions !