LCD1bpp
This class contains the various low-level drawing routines for drawing bitmaps, texts and rectangles on 1 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 void | copyAreaFromTFTToClientBuffer(const Rect & region) |
Copies part of the displayed framebuffer to current framebuffer. | |
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 Rect | copyFrameBufferRegionToMemory(const Rect & visRegion, const Rect & absRegion, uint8_t * dst, int16_t dstWidth, int16_t dstHeight) |
Copies part of the framebuffer to memory. | |
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 | enableTextureMapperAll() const |
Enables the texture mappers for all image formats. | |
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. | |
FORCE_INLINE_FUNCTION uint16_t | getFramebufferStride() |
Framebuffer stride in bytes. | |
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) |
Generates a color representation to be used on the LCD, based on 24 bit RGB values. | |
Protected Functions
virtual void | blitCopyRLE(const uint16_t * _sourceData, const Rect & source, const Rect & blitRect, uint8_t alpha) |
Blits a run-length encoded2D source-array to the framebuffer if alpha > zero. | |
void | copyRect(const uint8_t srcAddress, uint16_t srcStride, uint8_t srcPixelOffset, uint8_t RESTRICT dstAddress, uint16_t dstStride, uint8_t dstPixelOffset, uint16_t width, uint16_t height) const |
Copies a rectangular area from the framebuffer til a givene memory address, which is typically in the animation storage or a dynamic bitmap. | |
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 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. | |
void | fillMemory(void *RESTRICT dst, colortype color, uint16_t bytesToFill) |
Fill memory efficiently. | |
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 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. | |
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
copyAreaFromTFTToClientBuffer
virtual void copyAreaFromTFTToClientBuffer | ( | const Rect & | region | ) | |
Copies part of the displayed framebuffer to current framebuffer.
The region given is the absolute region on screen.
region | A rectangle describing what region of the displayed framebuffer is to be copied to the framebuffer. |
Note
The copy is performed only when double buffering is enabled. Otherwise the given region in current framebuffer is left untouched.
Reimplements: touchgfx::LCD::copyAreaFromTFTToClientBuffer
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
copyFrameBufferRegionToMemory
virtual Rect copyFrameBufferRegionToMemory | ( | const Rect & | visRegion , | ||
const Rect & | absRegion , | ||||
uint8_t * | dst , | ||||
int16_t | dstWidth , | ||||
int16_t | dstHeight | ||||
) |
Copies part of the framebuffer to memory.
The memory is assumed to have the same format as the framebuffer. 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. |
dst | Destination memory in same format as the framebuffer. |
dstWidth | Width of the destination. |
dstHeight | Height of the destination. |
The rect that was actually copied to the destination buffer.
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
enableTextureMapperAll
void enableTextureMapperAll | ( | ) | const |
Enables the texture mappers for all image formats.
Currently texture mapping is not supported on 1bpp displays, so this function does not do anything. It is merely included to allow function enableTextureMapperAll() to be called on any subclass of LCD.
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
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.
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 | ||||
) |
Protected Functions Documentation
blitCopyRLE
virtual void blitCopyRLE | ( | const uint16_t * | _sourceData , | ||
const Rect & | source , | ||||
const Rect & | blitRect , | ||||
uint8_t | alpha | ||||
) |
Blits a run-length encoded2D source-array to the framebuffer if alpha > zero.
_sourceData | The source-array pointer (points to the beginning of the data). Data stored in RLE format, where each byte indicates number of pixels with certain color, alternating between black and white. First byte represents black. |
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 (0 = invisible, otherwise solid). |
copyRect
void copyRect | ( | const uint8_t * | srcAddress , | const | |
uint16_t | srcStride , | const | |||
uint8_t | srcPixelOffset , | const | |||
uint8_t *RESTRICT | dstAddress , | const | |||
uint16_t | dstStride , | const | |||
uint8_t | dstPixelOffset , | const | |||
uint16_t | width , | const | |||
uint16_t | height | const | |||
) | const |
Copies a rectangular area from the framebuffer til a givene memory address, which is typically in the animation storage or a dynamic bitmap.
srcAddress | Source address (byte address). |
srcStride | Source stride (number of bytes to advance to next line). |
srcPixelOffset | Source pixel offset (first pixel in first source byte). |
dstAddress | If destination address (byte address). |
dstStride | Destination stride (number of bytes to advance to next line). |
dstPixelOffset | Destination pixel offset (first pixel in destination byte). |
width | The width of area (in pixels). |
height | The height of area (in pixels). |
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
drawTextureMapScanLine
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.
Draw one horizontal line of the texture map on screen. The scan line will be drawn using perspective correct texture mapping. The appearance of the line is determined by the left and right edge and the gradients structure. The edges contain the information about the x,y,z coordinates of the left and right side respectively and also information about the u,v coordinates of the texture map used. The gradients structure contains information about how to interpolate all the values across the scan line. The data drawn should be present in the texture argument.
The scan line will be drawn using the additional arguments. The scan line will be placed and clipped using the absolute and dirty rectangles The alpha will determine how the scan line should be alpha blended. The subDivisionSize will determine the size of the piecewise affine texture mapped lines.
dest | The description of where the texture is drawn - can be used to issue a draw off screen. |
gradients | The gradients using in interpolation across the scan line. |
leftEdge | The left edge of the scan line. |
rightEdge | The right edge of the scan line. |
texture | The texture. |
absoluteRect | The containing rectangle in absolute coordinates. |
dirtyAreaAbsolute | The dirty area in absolute coordinates. |
renderVariant | The render variant - includes the algorithm and the pixel format. |
alpha | The alpha. |
subDivisionSize | The size of the subdivisions of the scan line. A value of 1 will give a completely perspective correct texture mapped scan line. A large value will give an affine texture mapped scan line. |
Reimplements: touchgfx::LCD::drawTextureMapScanLine
fillMemory
static void fillMemory | ( | void *RESTRICT | dst , | ||
colortype | color , | ||||
uint16_t | bytesToFill | ||||
) |
Fill memory efficiently.
Try to get 32bit aligned or 16bit aligned and then copy as quickly as possible.
dst | Pointer to memory to fill. |
color | Color to write to memory, either 0 => 0x00000000 or 1 => 0xFFFFFFFF. |
bytesToFill | Number of bytes to fill. |
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.