주요 내용으로 건너뛰기

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 voidrender(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.
voidsetOffset(uint16_t offsetX, uint16_t offsetY)
Sets the offset of the area being drawn.
virtual ~AbstractPainter()
Finalizes an instance of the AbstractPainter class.

Protected Functions

voidsetWidgetAlpha(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 boolcompatibleFramebuffer(Bitmap::BitmapFormat format)
Helper function to check if the provided bitmap format matches the current framebuffer format.

Protected Attributes

int16_tareaOffsetX
The offset x coordinate of the area being drawn.
int16_tareaOffsetY
The offset y coordinate of the area being drawn.
uint8_twidgetAlpha
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
intx ,=0
intxAdjust ,=0
inty ,=0
unsignedcount ,=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.

Parameters:
ptrPointer to the row in the RenderingBuffer.
xThe x coordinate.
xAdjustThe 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).
yThe y coordinate.
countNumber of pixels to fill.
coversThe 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

setOffset

void setOffset(uint16_toffsetX ,
uint16_toffsetY
)

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.

Parameters:
offsetXThe offset x coordinate of the invalidated area relative to the widget.
offsetYThe offset y coordinate of the invalidated area relative to the widget.
Note

Used by CanvasWidgetRenderer - should not be overwritten.

~AbstractPainter

virtual ~AbstractPainter()

Finalizes an instance of the AbstractPainter class.

Protected Functions Documentation

setWidgetAlpha

void setWidgetAlpha(const uint8_talpha)

Sets the widget alpha to allow an entire canvas widget to easily be faded without changing the painter of the widget.

Parameters:
alphaThe alpha.
Note

Used internally by CanvasWidgetRenderer.

compatibleFramebuffer

static FORCE_INLINE_FUNCTION bool compatibleFramebuffer(Bitmap::BitmapFormatformat)

Helper function to check if the provided bitmap format matches the current framebuffer format.

Parameters:
formatA bitmap format.
Returns:

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.