Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PicoVector Enhancements & PicoGraphics Layers #1019

Open
wants to merge 58 commits into
base: main
Choose a base branch
from

Conversation

Gadgetoid
Copy link
Member

@Gadgetoid Gadgetoid commented Oct 25, 2024

Merges and replaces #853 and #1011, since these features both relate to drawing and we usually need both of them in experimental builds.

⚠️ This is built against our experimental/psram branch of MicroPython which we ideally don't want in production. If/when we merge these features, this CI change should not be included!

PicoVector

Incorporates the updated Pretty Poly library, which required a near complete rewrite of Pico Vector and will probably inform a redesign of the Python API.

There's now a proper C++ PicoVector library which will underpin the MicroPython bindings.

Alright Fonts are in an absolute state of turmoil, pending us figuring out how they might work. As the very least, the "af" format might change and break compatibility with the initial PicoVector release.

This is all a bit of a pain, but it will hopefully be worth it.

Hub75 / Interstate75

Dropped RGB565 mode altogether, it should never be necessary since the displays are very low resolution anyway. Currently the largest supported display needs 64kb. If/when we add other modes, we should support them all and caveat that they will be much, much slower to flip.

Increased performance of RGB88 mode flip from 13.8ms down to about 2.87ms. This should make it much more feasible to hit 60FPS since user code costs additional time over these baseline numbers.

Layers

Add preliminary support for multiple layered drawing surfaces.

Allows, for example, static content to be loaded into one layer and remain unmodified while the above layer contains animations.

Particularly useful for drawing PNG or JPEG UI elements which are then overdrawn with text or animated elements, without paying the cost of loading/decoding every frame.

Support for two layers is currently hard-coded for RGB332 and RGB565 pen types. There is no alpha blending, a pixel from the top layer is shown if it is not black (0) otherwise the underlying layer is displayed.

Since RAM usage is a multiple of layers, RGB332 will take 320240num_layers and RGB565 would be 3202402*num_layers, this is very much better suited for Pico 2 albeit RGB332 works well on a Pico.

Layer support is provided by the frame_convert function, as such it must always be called, even if the display native type matches the graphics buffer. EG: ST7735 and ST7789 displays supporting RGB565 now must call frame_convert even if your display buffer is RGB565. This could be improved by checking the number of layers and skipping the call if it's 1.

TODO

  1. Add support to all pen types
  2. Add fast-path to skip layer support when layers == 1 and buffer pen type == display pen type
  3. Explore basic blending options, these will slow things down but could be cool
  4. Decide if we want to support only two layers, in which case layers= should be layered=
  5. Benchmark, since we're now calculating an additional offset for every pixel drawn (could cache this when set_layer) is called?

@Gadgetoid Gadgetoid added the !! DO NOT MERGE !! Do not merge! label Oct 25, 2024
@Gadgetoid Gadgetoid force-pushed the feature/picovector2-and-layers branch 2 times, most recently from 7053bfa to 5d92aeb Compare October 25, 2024 14:57
@Gadgetoid Gadgetoid force-pushed the feature/picovector2-and-layers branch 2 times, most recently from 5b2e806 to f2d84fa Compare October 31, 2024 11:59
@Gadgetoid Gadgetoid removed the !! DO NOT MERGE !! Do not merge! label Oct 31, 2024
@Gadgetoid Gadgetoid force-pushed the feature/picovector2-and-layers branch from e6d4182 to 96beb08 Compare October 31, 2024 13:59
@Gadgetoid Gadgetoid force-pushed the feature/picovector2-and-layers branch 5 times, most recently from 633d387 to f4409d8 Compare December 2, 2024 12:15
@Gadgetoid Gadgetoid mentioned this pull request Dec 3, 2024
@Gadgetoid Gadgetoid force-pushed the feature/picovector2-and-layers branch from f4409d8 to 01d8aa7 Compare December 3, 2024 12:56
Gadgetoid and others added 14 commits December 4, 2024 16:56
Add preliminary support for multiple layered drawing surfaces.

Allows, for example, static content to be loaded into one layer and
remain unmodified while the above layer contains animations.

Particularly useful for drawing PNG or JPEG UI elements which are
then overdrawn with text or animated elements, without paying the
cost of loading/decoding every frame.
Ignore sign compare and narrowing conversion errors in pretty-poly.h.
Pointers were being incremented as if they were bytes, rather than larger
containers.
pretty-poly.h is not giving us fully clipped rectangles, so revert to the
slower bounds checked pixel for now.
@Gadgetoid Gadgetoid force-pushed the feature/picovector2-and-layers branch from 01d8aa7 to 762c5cb Compare December 4, 2024 16:57
Fix spurious point in top-left corner causing a broken triangular
rectangle when any permutation of corners other than the bottom-left
is rounded.
For some reason this was unset causing drawing to fail.

Reset it to a known good state in the constructor.
@berlincount
Copy link

What's the status of this PR? I guess I'd want the Vector changes so I can play with the Tufty 2040 more, and I'd also love to try layers there - or maybe at least some kind of Double Buffering for moving text on top of a a PNG ...

@Gadgetoid
Copy link
Member Author

You can grab one of the test builds from here: https://github.com/pimoroni/pimoroni-pico/actions/runs/12372911360?pr=1019

There's also something resembling documentation here: https://github.com/pimoroni/presto/blob/main/docs/picovector.md

@berlincount
Copy link

You can grab one of the test builds from here: https://github.com/pimoroni/pimoroni-pico/actions/runs/12372911360?pr=1019

There's also something resembling documentation here: https://github.com/pimoroni/presto/blob/main/docs/picovector.md

ooooh there goes my sleep tonight 😆 thanks!

@Gadgetoid
Copy link
Member Author

ooooh there goes my sleep tonight 😆 thanks!

Can relate!

PicoVector is still getting the rough edges bashed off, but it's close to release. Or, at least, I haven't run into a serious bug for a while. Any feedback would be welcome!

@berlincount
Copy link

heh, let's see. probably something for 38c3 next week ... what I'd actually want is an SVG loader (for something minimal, though) - I actually need tufty as a badge, and want it to
be a bit fancy ...

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.

4 participants