PicoVector: Avoid MicroPython GC.

Since we're not using tracked allocation, any memory we don't explicitly
hold a reference to will be assumed unused by MicroPython's GC.

Pass up the pp_nodes and pp_node_counts points (hackily) to fix this.
pull/1064/head
Phil Howard 2024-11-21 12:08:46 +00:00
rodzic 8f87e1c75f
commit 8b32174fc9
2 zmienionych plików z 11 dodań i 0 usunięć

Wyświetl plik

@ -31,6 +31,10 @@ namespace pimoroni {
class PicoVector {
private:
af_text_metrics_t text_metrics;
// Hold copies of pretty-poly's pointers
// so MicroPython does not garbage collect them!
void *_pp_nodes;
void *_pp_node_counts;
public:
static PicoGraphics *graphics;
@ -40,6 +44,8 @@ namespace pimoroni {
// TODO: Make these configurable?
// Tile buffer size, Max nodes per scanline
pp_init(16);
_pp_nodes = pp_nodes;
_pp_node_counts = pp_node_counts;
pp_tile_callback(PicoVector::tile_callback);

Wyświetl plik

@ -127,6 +127,11 @@ extern pp_tile_callback_t _pp_tile_callback;
extern pp_antialias_t _pp_antialias;
extern pp_mat3_t *_pp_transform;
// Our parent scope might want to hold a pointer to these
// ie: MicroPython to avoid garbage collection
extern int32_t *pp_nodes;
extern uint32_t *pp_node_counts;
void pp_clip(int32_t x, int32_t y, int32_t w, int32_t h);
void pp_tile_callback(pp_tile_callback_t callback);
void pp_antialias(pp_antialias_t antialias);