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. | |
virtual void | render(uint8_t ptr, int x, int xAdjust, int y, unsigned count, const uint8_t covers) =0 |
Paint a designated part of the RenderingBuffer with respect to the amount of coverage of each pixel given by the parameter covers. | |
virtual | ~AbstractPainter() |
Finalizes an instance of the AbstractPainter class. | |
Protected Functions
void | setAreaOffset(uint16_t offsetX, uint16_t offsetY) |
Sets the offset of the area being drawn. | |
void | setWidgetAlpha(const uint8_t alpha) |
Sets the widget alpha to allow an entire canvas widget to easily be faded without changing the painter of the widget. | |
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 | areaOffsetX |
The offset x coordinate of the area being drawn. | |
int16_t | areaOffsetY |
The offset y coordinate of the area being drawn. | |
uint8_t | widgetAlpha |
The alpha of the widget using the painter. | |
Public Functions Documentation
AbstractPainter
Initializes a new instance of the AbstractPainter class.
render
virtual void render | ( | uint8_t * | ptr , | =0 | |
int | x , | =0 | |||
int | xAdjust , | =0 | |||
int | y , | =0 | |||
unsigned | count , | =0 | |||
const uint8_t * | covers | =0 | |||
) | =0 |
Paint a designated part of the RenderingBuffer with respect to the amount of coverage of each pixel given by the parameter covers.
The cover is the alpha for each pixel, which is what makes it possible to have smooth anti-aliased edges on the shapes drawn with CanvasWidgetRenderer.
ptr | Pointer to the row in the RenderingBuffer. |
x | The x coordinate. |
xAdjust | The minor adjustment of x (used when a pixel is smaller than a byte to specify that the ptr should have been advanced "xAdjust" pixels futher into the byte). |
y | The y coordinate. |
count | Number of pixels to fill. |
covers | The coverage in of each pixel. |
Note
The implementation of render() in the AbstractPainter classes is a generic (i.e. slow) implementation that should be completely implemented in subclasses of AbstractPainter for better performance.
Reimplemented by: touchgfx::AbstractPainterABGR2222::render, touchgfx::AbstractPainterARGB2222::render, touchgfx::AbstractPainterARGB8888::render, touchgfx::AbstractPainterBGRA2222::render, touchgfx::AbstractPainterBW::render, touchgfx::AbstractPainterGRAY2::render, touchgfx::AbstractPainterGRAY4::render, touchgfx::AbstractPainterRGB565::render, touchgfx::AbstractPainterRGB888::render, touchgfx::AbstractPainterRGBA2222::render, touchgfx::PainterABGR2222::render, touchgfx::PainterABGR2222Bitmap::render, touchgfx::PainterARGB2222::render, touchgfx::PainterARGB2222Bitmap::render, touchgfx::PainterARGB8888::render, touchgfx::PainterARGB8888Bitmap::render, touchgfx::PainterARGB8888L8Bitmap::render, touchgfx::PainterBGRA2222::render, touchgfx::PainterBGRA2222Bitmap::render, touchgfx::PainterBW::render, touchgfx::PainterBWBitmap::render, touchgfx::PainterGRAY2::render, touchgfx::PainterGRAY2Bitmap::render, touchgfx::PainterGRAY4::render, touchgfx::PainterGRAY4Bitmap::render, touchgfx::PainterRGB565::render, touchgfx::PainterRGB565Bitmap::render, touchgfx::PainterRGB565L8Bitmap::render, touchgfx::PainterRGB888::render, touchgfx::PainterRGB888Bitmap::render, touchgfx::PainterRGB888L8Bitmap::render, touchgfx::PainterRGBA2222::render, touchgfx::PainterRGBA2222Bitmap::render, touchgfx::PainterXRGB8888::render, touchgfx::PainterXRGB8888Bitmap::render, touchgfx::PainterXRGB8888L8Bitmap::render
~AbstractPainter
virtual ~AbstractPainter | ( | ) |
Finalizes an instance of the AbstractPainter class.
Protected Functions Documentation
setAreaOffset
void setAreaOffset | ( | uint16_t | offsetX , | ||
uint16_t | offsetY | ||||
) |
Sets the offset of the area being drawn.
This allows render() to calculate the x, y relative to the widget, and not just relative to the invalidated area.
offsetX | The offset x coordinate of the invalidated area relative to the widget. |
offsetY | The offset y coordinate of the invalidated area relative to the widget. |
Note
Used by CanvasWidgetRenderer - should not be overwritten.
setWidgetAlpha
void setWidgetAlpha | ( | const uint8_t | alpha | ) | |
Sets the widget alpha to allow an entire canvas widget to easily be faded without changing the painter of the widget.
alpha | The alpha. |
Note
Used internally by CanvasWidgetRenderer.
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
areaOffsetX
int16_t areaOffsetX
The offset x coordinate of the area being drawn.
areaOffsetY
int16_t areaOffsetY
The offset y coordinate of the area being drawn.
widgetAlpha
uint8_t widgetAlpha
The alpha of the widget using the painter.