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

Add support for graphics clipping #770

Closed

Conversation

ImpulseAdventure
Copy link
Contributor

Drawing inside clipping regions

This enhancement adds setClipRect() which defines the clipping region used for the drawing primitives that follow (per #769 ).

  • setClipRect(int32_t x, int32_t y, int32_t w, int32_t h)
  • This can be useful when only a portion of an image needs to be updated; speeding up the redraw in the process

Supported functions

I tried to update all of the APIs that previously performed screen region clipping to support the custom clipping region. This means that the following APIs now support the clipping region:

  • pushImage(): all variants
  • drawChar(): the default function
  • drawPixel()
  • drawFastVLine()
  • drawFastHLine()
  • fillRect()

Functions not updated

  • Sprite operations were not touched
  • DMA operations were not touched
  • I have not touched the drawChar() UNICODE variant

Notes

  • The clipping region works with dynamic setRotation(), and is reset accordingly
  • I would expect this enhancement to have no negative performance impact (it should only improve performance)
  • If a user has set a custom clipping region, it can be reset to the default by assigning the entire display: tft.setClipRect(0,0,tft.width(),tft.height());

Testing

  • Testing of this revision on a number of example sketches so far appears to show it to be working.
  • Attached is a modified version of TFT_graphicstest_one_lib that demonstrates the result of a custom clipping region. You can un/comment the TEST_CLIP macro to observe the changes.
  • TFT_graphicstest_one_lib-clip2.zip

Thanks for your time

- Includes drawChar, drawPixel, fillRect, drawFastHLine, drawFastVLine
@Bodmer
Copy link
Owner

Bodmer commented Oct 5, 2020

See "viewport" branch of TFT_eSPI.

@Bodmer Bodmer closed this Oct 5, 2020
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.

2 participants