Skip to main content

CanvasWidgetRenderer

Class for supporting drawing of figures. This class holds the memory which is used by the underlying algorithms. CanvasWidget will not allocate memory dynamically, but will use memory from the buffer passed to CanvasWidgetRenderer. When using the TouchGFX simulator, it is also possible to get a report on the actual amount of memory used for drawing with CanvasWidgetRenderer to help adjusting the buffer size.

See: Widget, setWriteMemoryUsageReport, getWriteMemoryUsageReport

Public Functions

unsignedgetMissingBufferSize()
Calculate how much memory was required by CanvasWidgets, but was unavailable.
Cell *getOutlineBuffer()
Gets pointer to memory used for Cell objects in Outline.
unsigned intgetOutlineBufferSize()
Gets size of memory area used for Cell objects in Outline.
unsignedgetUsedBufferSize()
Calculate how much memory has been required by CanvasWidgets.
boolgetWriteMemoryUsageReport()
Gets write memory usage report flag.
boolhasBuffer()
Query if CanvasWidgetRenderer has been initialized with a buffer.
voidresetBuffer()
Removes references to a buffer previously setup using setupBuffer().
voidsetupBuffer(uint8_t * buffer, unsigned bufferSize)
Setup the buffers used by CanvasWidget.
voidsetWriteMemoryUsageReport(bool writeUsageReport)
Memory reporting.

Public Functions Documentation

getMissingBufferSize

static unsigned getMissingBufferSize()

Calculate how much memory was required by CanvasWidgets, but was unavailable.

If the value returned is greater than 0 it means the This can be used to fine tune the size of the buffer passed to CanvasWidgetRenderer upon initialization.

Returns:

The number of bytes required.

getOutlineBuffer

static Cell * getOutlineBuffer()

Gets pointer to memory used for Cell objects in Outline.

Returns:

Pointer to memory used internally by Outline.

getOutlineBufferSize

static unsigned int getOutlineBufferSize()

Gets size of memory area used for Cell objects in Outline.

Returns:

Size of memory area used internally by Outline.

getUsedBufferSize

static unsigned getUsedBufferSize()

Calculate how much memory has been required by CanvasWidgets.

This can be used to fine tune the size of the buffer passed to CanvasWidgetRenderer upon initialization.

Returns:

The number of bytes required.

getWriteMemoryUsageReport

Gets write memory usage report flag.

Returns:

true if it CWR writes memory reports, false if not.

hasBuffer

static bool hasBuffer()

Query if CanvasWidgetRenderer has been initialized with a buffer.

Returns:

True if a buffer has been setup.

resetBuffer

static void resetBuffer()

Removes references to a buffer previously setup using setupBuffer().

See also:

setupBuffer

static void setupBuffer(uint8_t *buffer ,
unsignedbufferSize
)

Setup the buffers used by CanvasWidget.

Parameters:
bufferBuffer reserved for CanvasWidget.
bufferSizeThe size of the buffer.

setWriteMemoryUsageReport

static void setWriteMemoryUsageReport(boolwriteUsageReport)

Memory reporting.

Memory reporting can be turned on (and off) using this method. CWR will try to work with the given amount of memory passed when calling setupBuffer(). If the outline of the figure is too complex, this will be reported.

"CWR requires X bytes" means that X bytes is the highest number of bytes required by CWR so far, but since the size of the invalidated area and the shape of things draw can influence this, this may be reported several times with a higher and higher number. Leave your app running for a long time to find out what the memory requirements are.

"CWR requires X bytes (Y bytes missing)" means the same as the report above, but there as was not enough memory to render the entire shape. To get around this, CWR will split the shape into two separate drawings of half size. This means that less memory is required, but drawing will be (somewhat) slower. After you see this message all future draws will be split into smaller chunks, so memory requirements might not get as high. This is followed by:

"CWR will split draw into multiple draws due to limited memory." actually just means that CWR will try to work with a smaller amount of memory.

In general, if there is enough memory available to run the simulation and never see the message "CWR will split draw ...", this is preferred. The size of the buffer required will be the highest number X reported as "CWR requires X bytes". Good numbers can also be around half of X.

Parameters:
writeUsageReporttrue to write report.
See also: