8000 extmod/modframebuf Enable blit between different formats. by peterhinch · Pull Request #7666 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

extmod/modframebuf Enable blit between different formats. #7666

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

Closed
wants to merge 1 commit into from

Conversation

peterhinch
Copy link
Contributor

This achieves a substantial performance improvement when rendering glyphs to color displays, the benefit increasing proportional to the number of pixels in the glyph. Its inclusion would enable me to improve the performance of most of my GUI repos. Please see framebuf.rst for details.

@jimmo This has a similar aim to the dynamic C module you wrote, but is more general, faster and portable (I never managed to successfully build your module for anything other than STM).

My GitFu has failed me here and I seem to have a lot of cruft included with this PR. Any guidance as to how to fix this would be much appreciated.

Copy link
Member
@jimmo jimmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @peterhinch, this is a really good enhancement, and only +40 bytes on PYBV11.

(I've replied to #7665 regarding your question about fixing the PR diffs)

mp_obj_framebuf_t *palette = MP_OBJ_NULL;
if (n_args > 5 && args[5] != mp_const_none) {
mp_obj_t palette_in = mp_obj_cast_to_native_base(args[5], MP_OBJ_FROM_PTR(&mp_type_framebuf));
palette = MP_OBJ_TO_PTR(palette_in);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mp_obj_cast_to_native_base can return mp_const_none, but that's not the same as MP_OBJ_NULL.

So needs to be

if (palette_in != mp_const_none) {
  palette = MP_OBJ_TO_PTR(palette_in);
}

in order to make the code below work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I'm being dumb here but I'm afraid I don't understand this.

This check worked if I didn't pass palette or I explicitly passed a palette value None:

if (n_args > 5 && args[5] != mp_const_none)

Are you saying that I need an additional check after the above, or that the above check should only be on n_args and be followed by this subsequent check? I'm not clear about the circumstances in which palette_in is mp_const_none.

if (palette_in != mp_const_none) {
  palette = MP_OBJ_TO_PTR(palette_in);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The case that this matters for is if palette is non-None but isn't derived from FrameBuffer.

But I said completely the wrong thing -- mp_obj_cast_to_native_base does actually return MP_OBJ_NULL in this case. Which means the code as you have it is exactly correct. Sorry!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! That's fortuitous as I hadn't considered that case :)

@peterhinch
Copy link
Contributor Author

This is superseded by #7682 which I believe now contains only the correct files.

@dpgeorge dpgeorge closed this Aug 19, 2021
@peterhinch peterhinch deleted the framebuf-palette branch August 20, 2021 08:05
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Mar 13, 2023
…n-main

Translations update from Hosted Weblate
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.

3 participants
0