Skip to content

Conversation

jepler
Copy link
Contributor

@jepler jepler commented Feb 18, 2025

In Adafruit_dvhstx, the low level driver takes charge of the framebuffer allocations. Consequently, any allocation by the GFXcanvas class would be an unused waste of memory.

Introduce a new constructor parameter bool allocate_buffer=true. The default preserves the old behavior of allocating the buffer in the constructor and freeing it in the destructor, while passing in false skips buffer allocation & freeing.

In this case, the subclass must allocate the buffer before the first drawing operation (such as in its constructor or begin method), and free it in its own destructor or end method.

The subclass can also freely change the buffer pointer at runtime, for instance in a swap method if the underlying framebuffer is double-buffered.

Closes: #464

In Adafruit_dvhstx, the low level driver takes charge of the framebuffer
allocations. Consequently, any allocation by the GFXcanvas class would be
an unused waste of memory.

Introduce a new constructor parameter `bool allocate_buffer=true`. The
default preserves the old behavior of allocating the buffer in the
constructor and freeing it in the destructor, while passing in `false`
skips buffer allocation & freeing.

In this case, the subclass must allocate the buffer before the first
drawing operation (such as in its constructor or begin method), and
free it in its own destructor or end method.

The subclass can also freely change the buffer pointer at runtime, for
instance in a swap method if the underlying framebuffer is double-buffered.
@jepler
Copy link
Contributor Author

jepler commented Feb 18, 2025

I may need some help with this as there are clang-format changes in files I didn't touch and that I don't reproduce locally (with debian stable running Debian clang-format version 14.0.6). I'm not sure what version of clang-format is being used by ci...

This runs version 19.1.7: uvx clang-format -i *.cpp *.h

the changes look similar to what was shown during CI
@jepler jepler requested review from ladyada and a team February 18, 2025 23:37
@jepler
Copy link
Contributor Author

jepler commented Feb 18, 2025

ping @ladyada this PR will be a requirement for the HSTX lib I'm working on

@ladyada ladyada merged commit f80daa5 into master Feb 19, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GFXCanvas: Support double buffering and subclass control of framebuffer allocation
2 participants