kopia lustrzana https://github.com/pimoroni/pimoroni-pico
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
rodzic
8f87e1c75f
commit
8b32174fc9
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Ładowanie…
Reference in New Issue