[sdl][mipi_spi] Respect clipping when drawing (#9722)

Co-authored-by: clydebarrow <2366188+clydebarrow@users.noreply.github.com>
This commit is contained in:
JonasB2497 2025-07-20 00:29:02 +02:00 committed by GitHub
parent 5ed77c10ae
commit 727e8ca376
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View File

@ -534,6 +534,8 @@ class MipiSpiBuffer : public MipiSpi<BUFFERTYPE, BUFFERPIXEL, IS_BIG_ENDIAN, DIS
// Draw a pixel at the given coordinates. // Draw a pixel at the given coordinates.
void draw_pixel_at(int x, int y, Color color) override { void draw_pixel_at(int x, int y, Color color) override {
if (!this->get_clipping().inside(x, y))
return;
rotate_coordinates_(x, y); rotate_coordinates_(x, y);
if (x < 0 || x >= WIDTH || y < this->start_line_ || y >= this->end_line_) if (x < 0 || x >= WIDTH || y < this->start_line_ || y >= this->end_line_)
return; return;

View File

@ -48,6 +48,9 @@ void Sdl::draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *
} }
void Sdl::draw_pixel_at(int x, int y, Color color) { void Sdl::draw_pixel_at(int x, int y, Color color) {
if (!this->get_clipping().inside(x, y))
return;
SDL_Rect rect{x, y, 1, 1}; SDL_Rect rect{x, y, 1, 1};
auto data = (display::ColorUtil::color_to_565(color, display::COLOR_ORDER_RGB)); auto data = (display::ColorUtil::color_to_565(color, display::COLOR_ORDER_RGB));
SDL_UpdateTexture(this->texture_, &rect, &data, 2); SDL_UpdateTexture(this->texture_, &rect, &data, 2);