Skip to content

CTX Rendering

rahix requested to merge rahix/ctx into master

So, I decided to push the current state of my ctx integration work here to have a place to track the progress where other's can also provide feedback instead of just me hacking away on my own.

I tried to keep the changeset as clean as possible so it should be easy to follow along by looking at the individual commits.

Once again, huge thanks to pippin for the ctx library!

Current Status

Right now, basic integration on Epicardium side is done. This means that all rendering in Epicardium is now done via ctx, with one notable exception being the epic_disp_blit() function (this is now resolved!).

So far, no Epicardium API for ctx exists yet, instead all the existing drawing API calls were updated to use ctx under the hood. This provides nice insight into where visual regressions are happening - Mostly it is looking pretty good already, though :) Here's a few pictures (left is ctx but I hope that's obvious):

Click to expand comparison pictures

splash menu text mm1 mm2

The next step will be to refactor the epic_disp_blit() function so it does not depend on gfx anymore and once that's done, I'll start working on the Pycardium side and Epicardium API for ctx.

Known Bugs/Regressions

Here is a list of visual artifacts I came across so far. This is mostly for reference - we should evaluate whether it is worth fixing them or whether we accept that some legacy code will look slightly off.

  • I am unsure what exactly is going on but it seems that pixels set by ctx_set_pixel_u8() are slightly less bright than e.g. those from a rectangle. For example, notice the few manually written pixels on the end of each 7-segment segment:

    Click to show example picture


  • Some simple_menu based apps with custom row rendering code will look wrong (background color does not strech to the right screen border). I fixed this for the personal_state app, but I am not sure whether there is a viable solution for everything else...

  • epic_disp_print() and epic_disp_print_adv() no longer wrap text at the screen border.

  • This circle appears cut off:

    d.clear().circ(80, 40, 30, col=color.CAMPGREEN).update()
    Click to show example picture


  • A pattern of rectangles which "touch" but don't overlap leaves stripes between them:

      for i in range(40):
          d.rect(10, i * 2, 150, i * 2 + 1, col=color.WHITE)
    Click to show example picture


  • xeyes needs to visit a doctor ASAP! I believe this comes from xeyes overdrawing the previous pupil in white before redrawing the new one.

    Click to show example picture


  • For everything else which I found so far, I already added workarounds ;)

Cc: @schneider
Cc: @pippin

Edited by rahix

Merge request reports