feat(mipi_dsi): round to boundary when draw pixel

pull/13879/head
morris 2024-04-30 18:52:25 +08:00
rodzic c706096f45
commit b9f15ba3ab
6 zmienionych plików z 16 dodań i 9 usunięć

Wyświetl plik

@ -3,6 +3,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <sys/param.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
@ -417,6 +418,14 @@ static esp_err_t dpi_panel_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int
size_t frame_buffer_size = dpi_panel->frame_buffer_size;
size_t bytes_per_pixel = dpi_panel->bytes_per_pixel;
// clip to boundaries
int h_res = dpi_panel->h_pixels;
int v_res = dpi_panel->v_pixels;
x_start = MAX(x_start, 0);
x_end = MIN(x_end, h_res);
y_start = MAX(y_start, 0);
y_end = MIN(y_end, v_res);
bool do_copy = false;
uint8_t draw_buf_fb_index = 0;
// check if the user draw buffer resides in any frame buffer's memory range

Wyświetl plik

@ -706,7 +706,6 @@ static esp_err_t rgb_panel_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int
{
esp_rgb_panel_t *rgb_panel = __containerof(panel, esp_rgb_panel_t, base);
ESP_RETURN_ON_FALSE(rgb_panel->num_fbs > 0, ESP_ERR_NOT_SUPPORTED, TAG, "no frame buffer installed");
assert((x_start < x_end) && (y_start < y_end) && "start position must be smaller than end position");
// check if we need to copy the draw buffer (pointed by the color_data) to the driver's frame buffer
bool do_copy = false;
@ -726,18 +725,19 @@ static esp_err_t rgb_panel_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int
y_start += rgb_panel->y_gap;
x_end += rgb_panel->x_gap;
y_end += rgb_panel->y_gap;
// round the boundary
// clip to boundaries
int h_res = rgb_panel->timings.h_res;
int v_res = rgb_panel->timings.v_res;
if (rgb_panel->rotate_mask & ROTATE_MASK_SWAP_XY) {
x_start = MIN(x_start, v_res);
x_start = MAX(x_start, 0);
x_end = MIN(x_end, v_res);
y_start = MIN(y_start, h_res);
y_start = MAX(y_start, 0);
y_end = MIN(y_end, h_res);
} else {
x_start = MIN(x_start, h_res);
x_start = MAX(x_start, 0);
x_end = MIN(x_end, h_res);
y_start = MIN(y_start, v_res);
y_start = MAX(y_start, 0);
y_end = MIN(y_end, v_res);
}

Wyświetl plik

@ -188,7 +188,6 @@ static esp_err_t panel_nt35510_draw_bitmap(esp_lcd_panel_t *panel, int x_start,
const void *color_data)
{
nt35510_panel_t *nt35510 = __containerof(panel, nt35510_panel_t, base);
assert((x_start < x_end) && (y_start < y_end) && "start position must be smaller than end position");
esp_lcd_panel_io_handle_t io = nt35510->io;
x_start += nt35510->x_gap;

Wyświetl plik

@ -32,6 +32,7 @@ esp_err_t esp_lcd_panel_del(esp_lcd_panel_handle_t panel)
esp_err_t esp_lcd_panel_draw_bitmap(esp_lcd_panel_handle_t panel, int x_start, int y_start, int x_end, int y_end, const void *color_data)
{
ESP_RETURN_ON_FALSE(panel, ESP_ERR_INVALID_ARG, TAG, "invalid panel handle");
ESP_RETURN_ON_FALSE((x_start < x_end) && (y_start < y_end), ESP_ERR_INVALID_ARG, TAG, "start position must be smaller than end position");
ESP_RETURN_ON_FALSE(panel->draw_bitmap, ESP_ERR_NOT_SUPPORTED, TAG, "draw_bitmap is not supported by this panel");
return panel->draw_bitmap(panel, x_start, y_start, x_end, y_end, color_data);
}

Wyświetl plik

@ -168,7 +168,6 @@ static esp_err_t panel_ssd1306_init(esp_lcd_panel_t *panel)
static esp_err_t panel_ssd1306_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data)
{
ssd1306_panel_t *ssd1306 = __containerof(panel, ssd1306_panel_t, base);
assert((x_start < x_end) && (y_start < y_end) && "start position must be smaller than end position");
esp_lcd_panel_io_handle_t io = ssd1306->io;
// adding extra gap

Wyświetl plik

@ -198,7 +198,6 @@ static esp_err_t panel_st7789_draw_bitmap(esp_lcd_panel_t *panel, int x_start, i
const void *color_data)
{
st7789_panel_t *st7789 = __containerof(panel, st7789_panel_t, base);
assert((x_start < x_end) && (y_start < y_end) && "start position must be smaller than end position");
esp_lcd_panel_io_handle_t io = st7789->io;
x_start += st7789->x_gap;