LCD8bpp_RGBA2222
This class contains the various low-level drawing routines for drawing bitmaps, texts and rectangles on 16 bits per pixel displays.
See: LCD
Note: All coordinates are expected to be in absolute coordinates!
Inherits from: LCD
Public Functions
virtual uint8_t | bitDepth() const |
Number of bits per pixel used by the display. | |
virtual void | blitCopy(const uint16_t * sourceData, const Rect & source, const Rect & blitRect, uint8_t alpha, bool hasTransparentPixels) |
Blits (directly copies) a block of data to the framebuffer, performing alpha blending (and tranparency keying) as specified. | |
virtual void | blitCopy(const uint8_t * sourceData, Bitmap::BitmapFormat sourceFormat, const Rect & source, const Rect & blitRect, uint8_t alpha, bool hasTransparentPixels) |
Blits (directly copies) a block of data to the framebuffer, performing alpha blending (and tranparency keying) as specified. | |
virtual uint16_t * | copyFrameBufferRegionToMemory(const Rect & visRegion, const Rect & absRegion, const BitmapId bitmapId) |
Copies part of the framebuffer to the data section of a bitmap. | |
virtual void | drawPartialBitmap(const Bitmap & bitmap, int16_t x, int16_t y, const Rect & rect, uint8_t alpha =255, bool useOptimized =true) |
Draws all (or a part) of a bitmap. | |
void | enableTextureMapperA4() |
Enables the texture mappers for A4 image format. | |
void | enableTextureMapperA4_BilinearInterpolation() |
Enables the texture mappers for A4 image format. | |
void | enableTextureMapperA4_NearestNeighbor() |
Enables the texture mappers for A4 image format. | |
void | enableTextureMapperAll() |
Enables the texture mappers for all image formats. | |
void | enableTextureMapperARGB8888() |
Enables the texture mappers for ARGB8888 image format. | |
void | enableTextureMapperARGB8888_BilinearInterpolation() |
Enables the texture mappers for ARGB8888 image format. | |
void | enableTextureMapperARGB8888_NearestNeighbor() |
Enables the texture mappers for ARGB8888 image format. | |
void | enableTextureMapperRGBA2222() |
Enables the texture mappers for RGBA2222 image format. | |
void | enableTextureMapperRGBA2222_BilinearInterpolation() |
Enables the texture mappers for RGBA2222 image format. | |
void | enableTextureMapperRGBA2222_NearestNeighbor() |
Enables the texture mappers for RGBA2222 image format. | |
virtual void | fillBuffer(uint8_t *const destination, uint16_t pixelStride, const Rect & rect, const colortype color, const uint8_t alpha) |
Draws a filled rectangle in destination memory using the specified color and opacity. | |
virtual void | fillRect(const Rect & rect, colortype color, uint8_t alpha =255) |
Draws a filled rectangle in the framebuffer in the specified color and opacity. | |
virtual Bitmap::BitmapFormat | framebufferFormat() const |
Framebuffer format used by the display. | |
virtual uint16_t | framebufferStride() const |
Framebuffer stride in bytes. | |
LCD8bpp_RGBA2222() | |
FORCE_INLINE_FUNCTION uint8_t | getAlphaFromNativeColor(uint8_t color) |
Gets alpha from color. | |
FORCE_INLINE_FUNCTION uint8_t | getBlueFromNativeColor(uint8_t color) |
Gets blue from color. | |
FORCE_INLINE_FUNCTION uint16_t | getFramebufferStride() |
Framebuffer stride in bytes. | |
FORCE_INLINE_FUNCTION uint8_t | getGreenFromNativeColor(uint8_t color) |
Gets green from color. | |
FORCE_INLINE_FUNCTION uint8_t | getNativeColor(colortype color) |
Generates a color representation to be used on the LCD, based on 24 bit RGB values. | |
FORCE_INLINE_FUNCTION uint8_t | getNativeColorFromRGB(uint8_t red, uint8_t green, uint8_t blue) |
Gets color from RGB. | |
FORCE_INLINE_FUNCTION uint8_t | getRedFromNativeColor(uint8_t color) |
Gets red from color. | |
Protected Functions
virtual void | drawGlyph(uint16_t wbuf16, Rect widgetArea, int16_t x, int16_t y, uint16_t offsetX, uint16_t offsetY, const Rect & invalidatedArea, const GlyphNode glyph, const uint8_t * glyphData, uint8_t byteAlignRow, colortype color, uint8_t bitsPerPixel, uint8_t alpha, TextRotation rotation) |
Private version of draw-glyph with explicit destination buffer pointer argument. | |
virtual DrawTextureMapScanLineBase * | getTextureMapperDrawScanLine(const TextureSurface & texture, RenderingVariant renderVariant, uint8_t alpha) |
Gets pointer to object that can draw a scan line which allows for highly specialized and optimized implementation. | |
void | blitCopyAlphaPerPixel(const uint16_t * sourceData16, const Rect & source, const Rect & blitRect, uint8_t alpha) |
Blit a 2D source-array to the framebuffer performing alpha-blending per pixel as specified Performs always a software blend. | |
void | blitCopyARGB8888(const uint32_t * sourceData, const Rect & source, const Rect & blitRect, uint8_t alpha) |
Blit a 2D source-array to the framebuffer performing alpha-blending per pixel as specified if ARGB8888 is not supported by the DMA a software blend is performed. | |
int | nextLine(bool rotatedDisplay, TextRotation textRotation) |
Find out how much to advance in the display buffer to get to the next line. | |
int | nextPixel(bool rotatedDisplay, TextRotation textRotation) |
Find out how much to advance in the display buffer to get to the next pixel. | |
Additional inherited members
Public Classes inherited from LCD
struct | StringVisuals |
The visual elements when writing a string. | |
Protected Classes inherited from LCD
class | DrawTextureMapScanLineBase |
Base class for drawing scanline by the texture mapper. | |
Public Functions inherited from LCD
void | drawString(Rect widgetArea, const Rect & invalidatedArea, const StringVisuals & stringVisuals, const Unicode::UnicodeChar * format, ... ) |
Draws the specified Unicode string. | |
virtual void | drawTextureMapQuad(const DrawingSurface & dest, const Point3D * vertices, const TextureSurface & texture, const Rect & absoluteRect, const Rect & dirtyAreaAbsolute, RenderingVariant renderVariant, uint8_t alpha =255, uint16_t subDivisionSize =12) |
Texture map quad. | |
virtual void | drawTextureMapTriangle(const DrawingSurface & dest, const Point3D * vertices, const TextureSurface & texture, const Rect & absoluteRect, const Rect & dirtyAreaAbsolute, RenderingVariant renderVariant, uint8_t alpha =255, uint16_t subDivisionSize =12) |
Texture map triangle. | |
colortype | getDefaultColor() const |
Gets default color previously set using setDefaultColor. | |
LCD() | |
Initializes a new instance of the LCD class. | |
virtual void | setDefaultColor(colortype color) |
Sets default color as used by alpha level only bitmap formats, e.g. | |
virtual bool | supportDynamicBitmapDrawing(const Bitmap::BitmapFormat format) |
Check if LCD support dynamic bitmap drawing. | |
virtual | ~LCD() |
Finalizes an instance of the LCD class. | |
FORCE_INLINE_FUNCTION uint8_t | div255(uint16_t num) |
Approximates an integer division of a 16bit value by 255. | |
FORCE_INLINE_FUNCTION uint32_t | div255g(uint32_t pixelxAlpha) |
Divides the green component of pixelxAlpha by 255. | |
FORCE_INLINE_FUNCTION uint32_t | div255rb(uint32_t pixelxAlpha) |
Divides the red and blue components of pixelxAlpha by 255. | |
Protected Functions inherited from LCD
void | drawStringLTR(const Rect & widgetArea, const Rect & invalidatedArea, const StringVisuals & visuals, const Unicode::UnicodeChar * format, va_list pArg) |
Draws the specified Unicode string. | |
void | drawStringRTL(const Rect & widgetArea, const Rect & invalidatedArea, const StringVisuals & visuals, const Unicode::UnicodeChar * format, va_list pArg) |
Draws the specified Unicode string. | |
virtual void | drawTextureMapScanLine(const DrawingSurface & dest, const Gradients & gradients, const Edge leftEdge, const Edge rightEdge, const TextureSurface & texture, const Rect & absoluteRect, const Rect & dirtyAreaAbsolute, RenderingVariant renderVariant, uint8_t alpha, uint16_t subDivisionSize) |
Draw scan line. | |
FORCE_INLINE_FUNCTION uint8_t | getAlphaFromA4(const uint16_t * data, uint32_t offset) |
Gets alpha from A4 image at given offset. | |
uint16_t | getNumLines(TextProvider & textProvider, WideTextAction wideTextAction, TextDirection textDirection, const Font * font, int16_t width) |
Gets number of lines for a given text taking word wrap into consideration. | |
int | realX(const Rect & widgetArea, int16_t x, int16_t y, TextRotation rotation) |
Find the real, absolute x coordinate of a point inside a widget with regards to rotation. | |
int | realY(const Rect & widgetArea, int16_t x, int16_t y, TextRotation rotation) |
Find the real, absolute y coordinate of a point inside a widget with regards to rotation. | |
void | rotateRect(Rect & rect, const Rect & canvas, const TextRotation rotation) |
Rotate a rectangle inside another rectangle. | |
uint16_t | stringWidth(TextProvider & textProvider, const Font & font, const int numChars, TextDirection textDirection) |
Find string width of the given number of ligatures read from the given TextProvider. | |
Protected Attributes inherited from LCD
colortype | defaultColor |
Default Color to use when displaying transparency-only elements, e.g. A4 bitmaps. | |
const uint16_t | newLine |
NewLine value. | |
Public Functions Documentation
bitDepth
virtual uint8_t bitDepth | ( | ) | const |
Number of bits per pixel used by the display.
The number of bits per pixel.
Reimplements: touchgfx::LCD::bitDepth
blitCopy
virtual void blitCopy | ( | const uint16_t * | sourceData , | ||
const Rect & | source , | ||||
const Rect & | blitRect , | ||||
uint8_t | alpha , | ||||
bool | hasTransparentPixels | ||||
) |
Blits (directly copies) a block of data to the framebuffer, performing alpha blending (and tranparency keying) as specified.
Performs a software blend if HAL does not support BLIT_COPY_WITH_ALPHA and alpha != 255 (solid).
sourceData | The source array pointer (points to the beginning of the data). The sourceData must be stored in a format suitable for the selected display. |
source | The position and dimensions of the source. The x and y of this rect should both be 0. |
blitRect | A rectangle describing what region of the sourceData is to be copied to the framebuffer. |
alpha | The alpha value to use for blending ranging from 0=invisible to 255=solid=no blending. |
hasTransparentPixels | If true, this data copy contains transparent pixels and require hardware support for that to be enabled. |
Reimplements: touchgfx::LCD::blitCopy
blitCopy
virtual void blitCopy | ( | const uint8_t * | sourceData , | ||
Bitmap::BitmapFormat | sourceFormat , | ||||
const Rect & | source , | ||||
const Rect & | blitRect , | ||||
uint8_t | alpha , | ||||
bool | hasTransparentPixels | ||||
) |
Blits (directly copies) a block of data to the framebuffer, performing alpha blending (and tranparency keying) as specified.
Performs a software blend if HAL does not support BLIT_COPY_WITH_ALPHA and alpha < 255 (solid).
If the display does not support the specified sourceFormat, an assert will be raised.
sourceData | The source array pointer (points to the beginning of the data). The sourceData must be stored in a format suitable for the selected display. |
sourceFormat | The bitmap format used in the source data. |
source | The position and dimensions of the source. The x and y of this rect should both be 0. |
blitRect | A rectangle describing what region of the sourceData is to be copied to the framebuffer. |
alpha | The alpha value to use for blending ranging from 0=invisible to 255=solid=no blending. |
hasTransparentPixels | If true, this data copy contains transparent pixels and require hardware support for that to be enabled. |
Reimplements: touchgfx::LCD::blitCopy
copyFrameBufferRegionToMemory
virtual uint16_t * copyFrameBufferRegionToMemory | ( | const Rect & | visRegion , | ||
const Rect & | absRegion , | ||||
const BitmapId | bitmapId | ||||
) |
Copies part of the framebuffer to the data section of a bitmap.
The bitmap must be a dynamic bitmap or animation storage (BITMAP_ANIMATION_STORAGE). The two regions given are the visible region and the absolute region on screen. This is used to copy only a part of the framebuffer. This might be the case if a SnapshotWidget is placed inside a Container where parts of the SnapshowWidget is outside the area defined by the Container. The visible region must be completely inside the absolute region.
visRegion | The visible region. |
absRegion | The absolute region. |
bitmapId | Identifier for the bitmap. |
Null if it fails, else a pointer to the data in the given bitmap.
Note
There is only one instance of animation storage. The content of the bitmap data /animation storage outside the given region is left untouched.
Reimplements: touchgfx::LCD::copyFrameBufferRegionToMemory
drawPartialBitmap
virtual void drawPartialBitmap | ( | const Bitmap & | bitmap , | ||
int16_t | x , | ||||
int16_t | y , | ||||
const Rect & | rect , | ||||
uint8_t | alpha =255, | ||||
bool | useOptimized =true | ||||
) |
Draws all (or a part) of a bitmap.
The coordinates of the corner of the bitmap is given in (x, y) and rect describes which part of the bitmap should be drawn. The bitmap can be drawn as it is or more or less transparent depending on the value of alpha. The value of alpha is independent of the transparency of the individual pixels of the given bitmap.
bitmap | The bitmap to draw. |
x | The absolute x coordinate to place (0, 0) of the bitmap on the screen. |
y | The absolute y coordinate to place (0, 0) of the bitmap on the screen. |
rect | A rectangle describing what region of the bitmap is to be drawn. |
alpha | (Optional) Optional alpha value ranging from 0=invisible to 255=solid. Default is 255 (solid). |
useOptimized | (Optional) if false, do not attempt to substitute (parts of) this bitmap with faster fillrects. |
Reimplements: touchgfx::LCD::drawPartialBitmap
enableTextureMapperA4
void enableTextureMapperA4 | ( | ) |
Enables the texture mappers for A4 image format.
This allows drawing A4 images using Bilinear Interpolation and Nearest Neighbor algorithms.
enableTextureMapperA4_BilinearInterpolation
Enables the texture mappers for A4 image format.
This allows drawing A4 images using Bilinear Interpolation algorithm.
enableTextureMapperA4_NearestNeighbor
Enables the texture mappers for A4 image format.
This allows drawing A4 images using Nearest Neighbor algorithm.
enableTextureMapperAll
void enableTextureMapperAll | ( | ) |
Enables the texture mappers for all image formats.
This allows drawing any image using Bilinear Interpolation and Nearest Neighbor algorithms, but might use a lot of memory for the drawing algorithms.
enableTextureMapperARGB8888
void enableTextureMapperARGB8888 | ( | ) |
Enables the texture mappers for ARGB8888 image format.
This allows drawing ARGB8888 images using Bilinear Interpolation and Nearest Neighbor algorithms.
enableTextureMapperARGB8888_BilinearInterpolation
Enables the texture mappers for ARGB8888 image format.
This allows drawing ARGB8888 images using Bilinear Interpolation algorithm.
enableTextureMapperARGB8888_NearestNeighbor
Enables the texture mappers for ARGB8888 image format.
This allows drawing ARGB8888 images using Nearest Neighbor algorithm.
enableTextureMapperRGBA2222
void enableTextureMapperRGBA2222 | ( | ) |
Enables the texture mappers for RGBA2222 image format.
This allows drawing RGBA2222 images using Bilinear Interpolation and Nearest Neighbor algorithms.
enableTextureMapperRGBA2222_BilinearInterpolation
Enables the texture mappers for RGBA2222 image format.
This allows drawing RGBA2222 images using Bilinear Interpolation algorithm.
enableTextureMapperRGBA2222_NearestNeighbor
Enables the texture mappers for RGBA2222 image format.
This allows drawing RGBA2222 images using Nearest Neighbor algorithm.
fillBuffer
virtual void fillBuffer | ( | uint8_t *const | destination , | ||
uint16_t | pixelStride , | ||||
const Rect & | rect , | ||||
const colortype | color , | ||||
const uint8_t | alpha | ||||
) |
Draws a filled rectangle in destination memory using the specified color and opacity.
The destination memory must have the same format as the display framebuffer. By default the rectangle will be drawn as a solid box. The rectangle can be drawn with transparency by specifying alpha from 0=invisible to 255=solid.
destination | The start of the memory area to fill. |
pixelStride | The pixel stride, i.e. number of pixels in a row. |
rect | The rectangle to fill absolute coordinates. |
color | The rectangle color. |
alpha | The rectangle opacity, from 0=invisible to 255=solid. |
Note
The pixelStride is rounded up to nearest whole bytes for displays with more than one pixel per byte (LCD1bpp, LCD2bpp and LCD4bpp)
Reimplements: touchgfx::LCD::fillBuffer
fillRect
Draws a filled rectangle in the framebuffer in the specified color and opacity.
By default the rectangle will be drawn as a solid box. The rectangle can be drawn with transparency by specifying alpha from 0=invisible to 255=solid.
rect | The rectangle to draw in absolute display coordinates. |
color | The rectangle color. |
alpha | (Optional) The rectangle opacity, from 0=invisible to 255=solid. |
Reimplements: touchgfx::LCD::fillRect
framebufferFormat
virtual Bitmap::BitmapFormat framebufferFormat | ( | ) | const |
framebufferStride
virtual uint16_t framebufferStride | ( | ) | const |
Framebuffer stride in bytes.
The distance (in bytes) from the start of one framebuffer row, to the next.
The number of bytes in one framebuffer row.
Reimplements: touchgfx::LCD::framebufferStride
LCD8bpp_RGBA2222
getAlphaFromNativeColor
static FORCE_INLINE_FUNCTION uint8_t getAlphaFromNativeColor | ( | uint8_t | color | ) | |
Gets alpha from color.
color | The color. |
The alpha from color.
getBlueFromNativeColor
static FORCE_INLINE_FUNCTION uint8_t getBlueFromNativeColor | ( | uint8_t | color | ) | |
Gets blue from color.
color | The color. |
The blue from color.
getFramebufferStride
static FORCE_INLINE_FUNCTION uint16_t getFramebufferStride | ( | ) |
Framebuffer stride in bytes.
The distance (in bytes) from the start of one framebuffer row, to the next.
The number of bytes in one framebuffer row.
getGreenFromNativeColor
static FORCE_INLINE_FUNCTION uint8_t getGreenFromNativeColor | ( | uint8_t | color | ) | |
Gets green from color.
color | The color. |
The green from color.
getNativeColor
static FORCE_INLINE_FUNCTION uint8_t getNativeColor | ( | colortype | color | ) | |
getNativeColorFromRGB
static FORCE_INLINE_FUNCTION uint8_t getNativeColorFromRGB | ( | uint8_t | red , | ||
uint8_t | green , | ||||
uint8_t | blue | ||||
) |
Gets color from RGB.
red | The red. |
green | The green. |
blue | The blue. |
The color from RGB.
getRedFromNativeColor
static FORCE_INLINE_FUNCTION uint8_t getRedFromNativeColor | ( | uint8_t | color | ) | |
Gets red from color.
color | The color. |
The red from color.
Protected Functions Documentation
drawGlyph
virtual void drawGlyph | ( | uint16_t * | wbuf16 , | ||
Rect | widgetArea , | ||||
int16_t | x , | ||||
int16_t | y , | ||||
uint16_t | offsetX , | ||||
uint16_t | offsetY , | ||||
const Rect & | invalidatedArea , | ||||
const GlyphNode * | glyph , | ||||
const uint8_t * | glyphData , | ||||
uint8_t | byteAlignRow , | ||||
colortype | color , | ||||
uint8_t | bitsPerPixel , | ||||
uint8_t | alpha , | ||||
TextRotation | rotation | ||||
) |
Private version of draw-glyph with explicit destination buffer pointer argument.
For all parameters (except the buffer pointer) see the public function drawString().
wbuf16 | The destination (frame) buffer to draw to. |
widgetArea | The canvas to draw the glyph inside. |
x | Horizontal offset to start drawing the glyph. |
y | Vertical offset to start drawing the glyph. |
offsetX | Horizontal offset in the glyph to start drawing from. |
offsetY | Vertical offset in the glyph to start drawing from. |
invalidatedArea | The area to draw inside. |
glyph | Specifications of the glyph to draw. |
glyphData | Data containing the actual glyph (dense format) |
byteAlignRow | Each row of glyph data starts in a new byte. |
color | The color of the glyph. |
bitsPerPixel | Bit depth of the glyph. |
alpha | The transparency of the glyph. |
rotation | Rotation to do before drawing the glyph. |
Reimplements: touchgfx::LCD::drawGlyph
getTextureMapperDrawScanLine
virtual DrawTextureMapScanLineBase * getTextureMapperDrawScanLine | ( | const TextureSurface & | texture , | ||
RenderingVariant | renderVariant , | ||||
uint8_t | alpha | ||||
) |
Gets pointer to object that can draw a scan line which allows for highly specialized and optimized implementation.
texture | The texture Surface. |
renderVariant | The render variant. |
alpha | The global alpha. |
Null if it fails, else the pointer to the texture mapper draw scan line object.
Reimplements: touchgfx::LCD::getTextureMapperDrawScanLine
blitCopyAlphaPerPixel
static void blitCopyAlphaPerPixel | ( | const uint16_t * | sourceData16 , | ||
const Rect & | source , | ||||
const Rect & | blitRect , | ||||
uint8_t | alpha | ||||
) |
Blit a 2D source-array to the framebuffer performing alpha-blending per pixel as specified Performs always a software blend.
sourceData16 | The source-array pointer (points to the beginning of the data). The sourceData must be stored as 8-bit RGBA2222 values. |
source | The location and dimensions of the source. |
blitRect | A rectangle describing what region is to be drawn. |
alpha | The alpha value to use for blending applied to the whole image (255 = solid, no blending) |
blitCopyARGB8888
static void blitCopyARGB8888 | ( | const uint32_t * | sourceData , | ||
const Rect & | source , | ||||
const Rect & | blitRect , | ||||
uint8_t | alpha | ||||
) |
Blit a 2D source-array to the framebuffer performing alpha-blending per pixel as specified if ARGB8888 is not supported by the DMA a software blend is performed.
sourceData | The source-array pointer (points to the beginning of the data). The sourceData must be stored as 32- bits ARGB8888 values. |
source | The location and dimensions of the source. |
blitRect | A rectangle describing what region is to be drawn. |
alpha | The alpha value to use for blending applied to the whole image (255 = solid, no blending) |
nextLine
static int nextLine | ( | bool | rotatedDisplay , | ||
TextRotation | textRotation | ||||
) |
Find out how much to advance in the display buffer to get to the next line.
rotatedDisplay | Is the display running in portrait mode? |
textRotation | Rotation to perform. |
How much to advance to get to the next line.
nextPixel
static int nextPixel | ( | bool | rotatedDisplay , | ||
TextRotation | textRotation | ||||
) |
Find out how much to advance in the display buffer to get to the next pixel.
rotatedDisplay | Is the display running in portrait mode? |
textRotation | Rotation to perform. |
How much to advance to get to the next pixel.