Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Integrate TilePaletteMapper and TileGrid further #10318

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

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

Conversation

FoamyGuy
Copy link
Collaborator

@FoamyGuy FoamyGuy commented May 7, 2025

This makes the following functional changes:

  • TilePaletteMapper now has tilegrid as an argument instead of width, and height
  • TileGrid now allows pixel_shader argument to be None or omitted. But _add_layer() now validates that it it isn't None before it can be added to a Group to be shown on the display.
  • TileGrid is refactored to have a displayio_tilegrid_mark_tile_dirty() function that gets called by set_tile
  • TilePaletteMapper makes use of the new displayio_tilegrid_mark_tile_dirty() to mark individual tiles as dirty when the mapping for that tile is updated, rather than causing the whole TileGrid to be refreshed
  • TilePaletteMapper no longer has needs_refresh or finish_refresh concepts

I have tested the updated TPM functionality with the Matrix CircuitPython code (updated to use the new API), and with the text editor that I am working on for Fruit Jam OS, it uses TPM to highlight the bottom bar with hotkeys in it. All functionality appears to work as expected.

I have not specifically tested / validated the smaller dirty area refresh by ensuring that it speeds up refresh rate when single mappings are updated. That will confirm that it isn't updating the full TileGrid any longer, I will do that once I get the cursor changed to use TPM in the text editor.

I noticed that this change is showing some edits to the .pot file that I did not knowingly make. I ran pre-commit locally and it seems to have made some of those changes even though they appear unrelated to TileGrid or TilePaletteMapper. I'm not sure if that is a git or update / merge issue or something else. Let me know if I need to do anything further in that file though.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

I understand there is a circularity to this that needs to be broken. I'd do it the other way so TG always has a pixel_shader. Allow TPM to be constructed without allocating the mapping memory and "bind" the two when the TG is created. This can also check that multiple TG aren't given the TPM. (Or it could track multiple TG to mark dirty.)

@tannewt
Copy link
Member

tannewt commented May 8, 2025

I noticed that this change is showing some edits to the .pot file that I did not knowingly make. I ran pre-commit locally and it seems to have made some of those changes even though they appear unrelated to TileGrid or TilePaletteMapper. I'm not sure if that is a git or update / merge issue or something else. Let me know if I need to do anything further in that file though.

It looks fine to me. I'm not sure why Weblate didn't do it but it seems to be active. Updating these here is fine.

…or width/height, internal bind function is used to bind a TileGrid to a TilePaletteMapper when the TileGrid is init with or has pixel_shader set to a TPM
@FoamyGuy
Copy link
Collaborator Author

FoamyGuy commented May 8, 2025

The latest commit swaps this over to how you describe. pixel_shader is required for TileGrid as it was originally. TPM no longer accepts width, height, or tilegrid. The new internal bind function links a TPM to a TileGrid and is called when the TileGrid is created with a TPM pixel_shader, or has its pixel_shader set to a TPM.

Tested successfully on fruitjam with the circuitpython matrix code, and the latest version of text editor updated to use the new API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants