Repository navigation
VideoPlanes
The video related stuff is in the submodule kilipili_video in the Video/ folder.
Everything video related lives in the namespace kilipili::Video.
class VideoPlane is the base class for everything which can be added to the video controller for display. template class FrameBuffer is a subclass of class VideoPlane with it's concrete implementations displaying mostly Pixmap based or CharMap based backing stores.
VideoPlanes & FrameBuffers:
- VideoPlane
- FrameBuffer
- FrameBuffer_SimpleCharMap
- FrameBuffer_CharMap
- HamImageVideoPlane
- UniColorBackdrop
Others:
header file Video/VideoPlane.h
Objects of subclasses of class VideoPlane can be added to the video controller with function void addVideoPlane(VideoPlanePtr, bool wait). Subclasses must provide some specific functions.
The first two functions are the most important. They are more convenient than the function pointer callbacks (see below), but unluckily the c++ compiler always puts some code into the flash and i don't know how to prevent this. So a VideoPlane using virtual function overloads will not be called during flash lockout.
virtual void vblank()
This function is called by the video controller at the start of each frame. It is guaranteed to be called before the first call to renderScanline() is made.
virtual void renderScanline(int row, int width, uint32* buffer)
This function is called for every scanline of the video display for every frame. Depending on screen size you have something around 5 to 20 system clock cycles to calculate and store each pixel. The faster you can do this the more fancy stuff you can display. This function should go into RAM!
Arguments:
row the current row, starting at 0
width number of pixels to draw
buffer destination for the pixel data. The buffer is int32 aligned, but you have to put in pixels of type Color. type Color depends on your hardware settings in the board description file in boards/ and is a 1-byte or 2-byte value, so you have to combine 4 or 2 pixels for one uint32, or you cast to Color\*. Your implementation only needs to accomodate your board's Color size, if this is all you want.
If you want to display your VideoPlane subclass during flash lockout, that is while writing to flash (Preferences or FlashFileSystem) then you must use the function pointers instead of overloading the virtual member functions above. And you have to avoid a lot of other stuff: division, any virtual function, and memcyp() and friends. Be warned that the c++ compiler is very good in figuring out that it could use memcpy() to replace your artfully obfuscated copy loop!
These are the function signatures for the callback functions:
using VblankFu = void(VideoPlane*) noexcept
using RenderFu = void(VideoPlane*, int row, int width, uint32* buffer) noexcept
These are the data members of class VideoPlane which you have to point to your handlers, most likely in the constructor of your subclass:
data member: VblankFu* vblank_fu
data member: RenderFu* render_fu
These function really should go into RAM or there is no point in using the function pointers!
For reference you can look up the default implementations in Video/VideoPlane.cpp or take a look of the implementation in Video/UniColorBackdrop.cpp.
header file Video/FrameBuffer.h
header file Video/FrameBuffer_SimpleCharMap.h
header file Video/FrameBuffer_CharMap.h
header file Video/FrameBuffer_HamImageVideoPlane.h
header file Video/UniColorBackdrop.h
This class provides an opaque backdrop with the given color. Use it if you are not displaying any kind of Pixmap or CharMap based FrameBuffer but only windows, overlays and sprites. Or s.th. like that.
This is the constructor (no surprises here):
UniColorBackdrop(Color)