AbstractPainter
An abstract class for creating painter classes for drawing canvas widgets. All canvas widgets need a painter to fill the shape drawn with a CanvasWidgetRenderer. The painter must provide the color of a pixel on a given coordinate, which will the be blended into the framebuffer depending on the position of the canvas widget and the transparency of the given pixel.
The AbstractPainter also implements a function which will blend each pixel in a scanline snippet into the framebuffer, but for better performance, the function should be reimplemented in each painter.
Inherited by: AbstractPainterABGR2222, AbstractPainterARGB2222, AbstractPainterARGB8888, AbstractPainterBGRA2222, AbstractPainterBW, AbstractPainterGRAY2, AbstractPainterGRAY4, AbstractPainterRGB565, AbstractPainterRGB888, AbstractPainterRGBA2222
Public Functions
AbstractPainter() | |
Initializes a new instance of the AbstractPainter class. | |
void | framebufferToDisplay(int16_t & widgetX, int16_t & widgetY) const |
Convert Framebuffer widget coordinates to display widget coordinates. | |
virtual HAL::RenderingMethod | getRenderingMethod() const |
Return the applicable rendering method of the painter. | |
virtual void | paint(uint8_t * destination, int16_t offset, int16_t widgetX, int16_t widgetY, int16_t count, uint8_t alpha) const =0 |
Paints a streak of pixels (all with the same alpha) in the framebuffer. | |
virtual bool | setup(const Rect & widgetRect) const |
This function is called before any actual paint operation is started. | |
virtual void | tearDown() const |
This function is called after all paint operation have finished. | |
virtual | ~AbstractPainter() |
Finalizes an instance of the AbstractPainter class. | |
Protected Functions
FORCE_INLINE_FUNCTION bool | compatibleFramebuffer(Bitmap::BitmapFormat format) |
Helper function to check if the provided bitmap format matches the current framebuffer format. | |
Protected Attributes
int16_t | widgetWidth |
The width of the widget on screen, used by framebufferToDisplay() | |
Public Functions Documentation
AbstractPainter
Initializes a new instance of the AbstractPainter class.
framebufferToDisplay
void framebufferToDisplay | ( | int16_t & | widgetX , | const | |
int16_t & | widgetY | const | |||
) | const |
Convert Framebuffer widget coordinates to display widget coordinates.
This is handy when creating a custom painter and the X,Y is needed in the same coordinate system as the widget on the display.
widgetX | The widget x coordinate. |
widgetY | The widget y coordinate. |
getRenderingMethod
virtual HAL::RenderingMethod getRenderingMethod | ( | ) | const |
Return the applicable rendering method of the painter.
HARDWARE if the painter uses hardware based drawing, SOFTWARE otherwise. Relevant on platforms using DCACHE.
HARDWARE if painter uses hardware based drawing, SOFTWARE otherwise.
Reimplemented by: touchgfx::PainterRGB565::getRenderingMethod, touchgfx::PainterRGB565Bitmap::getRenderingMethod, touchgfx::PainterRGB565L8Bitmap::getRenderingMethod, touchgfx::PainterRGB888::getRenderingMethod, touchgfx::PainterRGB888Bitmap::getRenderingMethod, touchgfx::PainterRGB888L8Bitmap::getRenderingMethod
paint
virtual void paint | ( | uint8_t * | destination , | const =0 | |
int16_t | offset , | const =0 | |||
int16_t | widgetX , | const =0 | |||
int16_t | widgetY , | const =0 | |||
int16_t | count , | const =0 | |||
uint8_t | alpha | const =0 | |||
) | const =0 |
Paints a streak of pixels (all with the same alpha) in the framebuffer.
The first pixel to paint is at 'offset' relative to 'destination' (to be able to support 1bpp, 2bpp and 4bpp). The first pixel to paint is at the given 'widgetX', 'widgetY' coordinate. The number of pixels to paint is 'count' and the alpha to apply is 'alpha'.
Note that the widgetX, widgetY is relative to the widget in the framebuffer, not the display. To convert the coordinate to display widget coordinates, use framebufferToDisplay().
destination | If non-null, the pointer. |
offset | The offset to add to the destination. |
widgetX | The widget x coordinate. |
widgetY | The widget y coordinate. |
count | Number of pixels. |
alpha | The alpha of the pixels. |
Reimplemented by: touchgfx::PainterABGR2222::paint, touchgfx::PainterABGR2222Bitmap::paint, touchgfx::PainterARGB2222::paint, touchgfx::PainterARGB2222Bitmap::paint, touchgfx::PainterARGB8888::paint, touchgfx::PainterARGB8888Bitmap::paint, touchgfx::PainterARGB8888L8Bitmap::paint, touchgfx::PainterBGRA2222::paint, touchgfx::PainterBGRA2222Bitmap::paint, touchgfx::PainterBW::paint, touchgfx::PainterBWBitmap::paint, touchgfx::PainterGRAY2::paint, touchgfx::PainterGRAY2Bitmap::paint, touchgfx::PainterGRAY4::paint, touchgfx::PainterGRAY4Bitmap::paint, touchgfx::PainterRGB565::paint, touchgfx::PainterRGB565Bitmap::paint, touchgfx::PainterRGB565L8Bitmap::paint, touchgfx::PainterRGB888::paint, touchgfx::PainterRGB888Bitmap::paint, touchgfx::PainterRGB888L8Bitmap::paint, touchgfx::PainterRGBA2222::paint, touchgfx::PainterRGBA2222Bitmap::paint, touchgfx::PainterXRGB8888::paint, touchgfx::PainterXRGB8888Bitmap::paint, touchgfx::PainterXRGB8888L8Bitmap::paint
setup
This function is called before any actual paint operation is started.
This allows the painter to initialize variables and optional dma queues. This happens before the first scan line segment is being drawn. If the painter is unable to draw, e.g. no bitmap assigned to a bitmap painter, 'false' should be returned.
widgetRect | The widget rectangle. |
True if the painter is ready to paint, false otherwise.
Reimplemented by: touchgfx::PainterABGR2222Bitmap::setup, touchgfx::PainterARGB2222Bitmap::setup, touchgfx::PainterARGB8888Bitmap::setup, touchgfx::PainterARGB8888L8Bitmap::setup, touchgfx::PainterBGRA2222Bitmap::setup, touchgfx::PainterBWBitmap::setup, touchgfx::PainterGRAY2Bitmap::setup, touchgfx::PainterGRAY4Bitmap::setup, touchgfx::PainterRGB565Bitmap::setup, touchgfx::PainterRGB565L8Bitmap::setup, touchgfx::PainterRGB888Bitmap::setup, touchgfx::PainterRGB888L8Bitmap::setup, touchgfx::PainterRGBA2222Bitmap::setup, touchgfx::PainterXRGB8888Bitmap::setup, touchgfx::PainterXRGB8888L8Bitmap::setup
tearDown
virtual void tearDown | ( | ) | const |
This function is called after all paint operation have finished.
This allows the painter to close down dma queues etc. This happens after the last scan line segment has been drawn.
Reimplemented by: touchgfx::PainterRGB565::tearDown, touchgfx::PainterRGB565Bitmap::tearDown, touchgfx::PainterRGB565L8Bitmap::tearDown, touchgfx::PainterRGB888::tearDown, touchgfx::PainterRGB888Bitmap::tearDown, touchgfx::PainterRGB888L8Bitmap::tearDown
~AbstractPainter
virtual ~AbstractPainter | ( | ) |
Finalizes an instance of the AbstractPainter class.
Protected Functions Documentation
compatibleFramebuffer
static FORCE_INLINE_FUNCTION bool compatibleFramebuffer | ( | Bitmap::BitmapFormat | format | ) | |
Helper function to check if the provided bitmap format matches the current framebuffer format.
format | A bitmap format. |
True if the format matches the framebuffer format, false otherwise.
Protected Attributes Documentation
widgetWidth
int16_t widgetWidth
The width of the widget on screen, used by framebufferToDisplay()