From 03b04a45b97ce2cb18dca57bb394b0eafbc22973 Mon Sep 17 00:00:00 2001 From: Mariotaku Date: Tue, 26 Jul 2022 04:00:48 +0900 Subject: [PATCH] fix(SDL): fix typos and other minor issues (#3517) * fix(sdl): wrong coords for transformed backgrounds * fix(sdl): fixed typo * fix(sdl): fixed typo --- env_support/cmsis-pack/lv_conf_cmsis.h | 6 +++--- lv_conf_template.h | 6 +++--- src/draw/sdl/lv_draw_sdl.h | 2 +- src/draw/sdl/lv_draw_sdl_composite.c | 8 ++++---- src/draw/sdl/lv_draw_sdl_composite.h | 2 +- src/draw/sdl/lv_draw_sdl_img.c | 2 +- src/draw/sdl/lv_draw_sdl_img.h | 2 +- src/draw/sdl/lv_draw_sdl_label.c | 2 +- src/draw/sdl/lv_draw_sdl_mask.h | 2 +- src/draw/sdl/lv_draw_sdl_priv.h | 2 +- src/draw/sdl/lv_draw_sdl_rect.c | 22 ++++++++++++++++++++-- src/draw/sdl/lv_draw_sdl_rect.h | 2 +- src/draw/sdl/lv_draw_sdl_texture_cache.c | 2 +- src/draw/sdl/lv_draw_sdl_texture_cache.h | 2 +- src/draw/sdl/lv_draw_sdl_utils.h | 2 +- src/lv_conf_internal.h | 24 ++++++++++++------------ 16 files changed, 53 insertions(+), 35 deletions(-) diff --git a/env_support/cmsis-pack/lv_conf_cmsis.h b/env_support/cmsis-pack/lv_conf_cmsis.h index 616ee9bb5..559ca900b 100644 --- a/env_support/cmsis-pack/lv_conf_cmsis.h +++ b/env_support/cmsis-pack/lv_conf_cmsis.h @@ -191,11 +191,11 @@ /*Use SDL renderer API*/ #define LV_USE_DRAW_SDL 0 #if LV_USE_DRAW_SDL - #define LV_DARW_SDL_INCLUDE_PATH + #define LV_DRAW_SDL_INCLUDE_PATH /*Texture cache size, 8MB by default*/ - #define LV_DARW_SDL_LRU_SIZE (1024 * 1024 * 8) + #define LV_DRAW_SDL_LRU_SIZE (1024 * 1024 * 8) /*Custom blend mode for mask drawing, disable if you need to link with older SDL2 lib*/ - #define LV_DARW_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6)) + #define LV_DRAW_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6)) #endif /*------------- diff --git a/lv_conf_template.h b/lv_conf_template.h index 48e109556..3ebf1d466 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -149,11 +149,11 @@ /*Use SDL renderer API*/ #define LV_USE_DRAW_SDL 0 #if LV_USE_DRAW_SDL - #define LV_DARW_SDL_INCLUDE_PATH + #define LV_DRAW_SDL_INCLUDE_PATH /*Texture cache size, 8MB by default*/ - #define LV_DARW_SDL_LRU_SIZE (1024 * 1024 * 8) + #define LV_DRAW_SDL_LRU_SIZE (1024 * 1024 * 8) /*Custom blend mode for mask drawing, disable if you need to link with older SDL2 lib*/ - #define LV_DARW_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6)) + #define LV_DRAW_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6)) #endif /*===================== diff --git a/src/draw/sdl/lv_draw_sdl.h b/src/draw/sdl/lv_draw_sdl.h index 0fe0e9356..d6abd3f59 100644 --- a/src/draw/sdl/lv_draw_sdl.h +++ b/src/draw/sdl/lv_draw_sdl.h @@ -18,7 +18,7 @@ extern "C" { #if LV_USE_DRAW_SDL -#include LV_DARW_SDL_INCLUDE_PATH +#include LV_DRAW_SDL_INCLUDE_PATH #include "../lv_draw.h" #include "../../core/lv_disp.h" diff --git a/src/draw/sdl/lv_draw_sdl_composite.c b/src/draw/sdl/lv_draw_sdl_composite.c index 57e0956c4..e5e65f4bc 100644 --- a/src/draw/sdl/lv_draw_sdl_composite.c +++ b/src/draw/sdl/lv_draw_sdl_composite.c @@ -79,7 +79,7 @@ bool lv_draw_sdl_composite_begin(lv_draw_sdl_ctx_t * ctx, const lv_area_t * coor if(!_lv_area_intersect(apply_area, &full_coords, clip_in)) return false; bool has_mask = lv_draw_mask_is_any(apply_area); - const bool draw_mask = has_mask && LV_DARW_SDL_CUSTOM_BLEND_MODE; + const bool draw_mask = has_mask && LV_DRAW_SDL_CUSTOM_BLEND_MODE; const bool draw_blend = blend_mode != LV_BLEND_MODE_NORMAL; if(draw_mask || draw_blend) { lv_draw_sdl_context_internals_t * internals = ctx->internals; @@ -96,7 +96,7 @@ bool lv_draw_sdl_composite_begin(lv_draw_sdl_ctx_t * ctx, const lv_area_t * coor SDL_SetRenderTarget(ctx->renderer, internals->composition); SDL_SetRenderDrawColor(ctx->renderer, 255, 255, 255, 0); SDL_RenderClear(ctx->renderer); -#if LV_DARW_SDL_CUSTOM_BLEND_MODE +#if LV_DRAW_SDL_CUSTOM_BLEND_MODE internals->mask = lv_draw_sdl_composite_texture_obtain(ctx, LV_DRAW_SDL_COMPOSITE_TEXTURE_ID_STREAM0, w, h); dump_masks(internals->mask, apply_area); #endif @@ -125,7 +125,7 @@ void lv_draw_sdl_composite_end(lv_draw_sdl_ctx_t * ctx, const lv_area_t * apply_ { lv_draw_sdl_context_internals_t * internals = ctx->internals; SDL_Rect src_rect = {0, 0, lv_area_get_width(apply_area), lv_area_get_height(apply_area)}; -#if LV_DARW_SDL_CUSTOM_BLEND_MODE +#if LV_DRAW_SDL_CUSTOM_BLEND_MODE if(internals->mask) { SDL_BlendMode mode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD, SDL_BLENDFACTOR_ZERO, @@ -148,7 +148,7 @@ void lv_draw_sdl_composite_end(lv_draw_sdl_ctx_t * ctx, const lv_area_t * apply_ case LV_BLEND_MODE_ADDITIVE: SDL_SetTextureBlendMode(internals->composition, SDL_BLENDMODE_ADD); break; -#if LV_DARW_SDL_CUSTOM_BLEND_MODE +#if LV_DRAW_SDL_CUSTOM_BLEND_MODE case LV_BLEND_MODE_SUBTRACTIVE: { SDL_BlendMode mode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT, SDL_BLENDFACTOR_ONE, diff --git a/src/draw/sdl/lv_draw_sdl_composite.h b/src/draw/sdl/lv_draw_sdl_composite.h index f91c92e3b..fda61a7b1 100644 --- a/src/draw/sdl/lv_draw_sdl_composite.h +++ b/src/draw/sdl/lv_draw_sdl_composite.h @@ -16,7 +16,7 @@ extern "C" { #include "../../lv_conf_internal.h" -#include LV_DARW_SDL_INCLUDE_PATH +#include LV_DRAW_SDL_INCLUDE_PATH #include "lv_draw_sdl.h" #include "../../misc/lv_area.h" diff --git a/src/draw/sdl/lv_draw_sdl_img.c b/src/draw/sdl/lv_draw_sdl_img.c index a98acaefb..829a46da4 100644 --- a/src/draw/sdl/lv_draw_sdl_img.c +++ b/src/draw/sdl/lv_draw_sdl_img.c @@ -398,7 +398,7 @@ static SDL_Texture * img_rounded_frag_obtain(lv_draw_sdl_ctx_t * ctx, SDL_Textur SDL_SetTextureAlphaMod(texture, 0xFF); SDL_SetTextureColorMod(texture, 0xFF, 0xFF, 0xFF); -#if LV_DARW_SDL_CUSTOM_BLEND_MODE +#if LV_DRAW_SDL_CUSTOM_BLEND_MODE SDL_BlendMode blend_mode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ZERO, SDL_BLENDOPERATION_ADD, SDL_BLENDFACTOR_DST_ALPHA, SDL_BLENDFACTOR_ZERO, SDL_BLENDOPERATION_ADD); diff --git a/src/draw/sdl/lv_draw_sdl_img.h b/src/draw/sdl/lv_draw_sdl_img.h index ea169d010..753a6aa37 100644 --- a/src/draw/sdl/lv_draw_sdl_img.h +++ b/src/draw/sdl/lv_draw_sdl_img.h @@ -18,7 +18,7 @@ extern "C" { #if LV_USE_DRAW_SDL -#include LV_DARW_SDL_INCLUDE_PATH +#include LV_DRAW_SDL_INCLUDE_PATH #include "../lv_draw.h" diff --git a/src/draw/sdl/lv_draw_sdl_label.c b/src/draw/sdl/lv_draw_sdl_label.c index 3b450d7e7..bab712033 100644 --- a/src/draw/sdl/lv_draw_sdl_label.c +++ b/src/draw/sdl/lv_draw_sdl_label.c @@ -11,7 +11,7 @@ #if LV_USE_DRAW_SDL -#include LV_DARW_SDL_INCLUDE_PATH +#include LV_DRAW_SDL_INCLUDE_PATH #include "../lv_draw_label.h" #include "../../misc/lv_utils.h" diff --git a/src/draw/sdl/lv_draw_sdl_mask.h b/src/draw/sdl/lv_draw_sdl_mask.h index 0980c9a77..e7b68b24c 100644 --- a/src/draw/sdl/lv_draw_sdl_mask.h +++ b/src/draw/sdl/lv_draw_sdl_mask.h @@ -16,7 +16,7 @@ extern "C" { #include "../../lv_conf_internal.h" -#include LV_DARW_SDL_INCLUDE_PATH +#include LV_DRAW_SDL_INCLUDE_PATH #include "lv_draw_sdl.h" #include "../../misc/lv_area.h" diff --git a/src/draw/sdl/lv_draw_sdl_priv.h b/src/draw/sdl/lv_draw_sdl_priv.h index a249e8d05..0211d1e23 100644 --- a/src/draw/sdl/lv_draw_sdl_priv.h +++ b/src/draw/sdl/lv_draw_sdl_priv.h @@ -18,7 +18,7 @@ extern "C" { #if LV_USE_DRAW_SDL -#include LV_DARW_SDL_INCLUDE_PATH +#include LV_DRAW_SDL_INCLUDE_PATH #include "../lv_draw.h" #include "../../misc/lv_lru.h" diff --git a/src/draw/sdl/lv_draw_sdl_rect.c b/src/draw/sdl/lv_draw_sdl_rect.c index 129e28afe..71385d9f8 100644 --- a/src/draw/sdl/lv_draw_sdl_rect.c +++ b/src/draw/sdl/lv_draw_sdl_rect.c @@ -297,7 +297,12 @@ static void draw_bg_img(lv_draw_sdl_ctx_t * ctx, const lv_area_t * coords, const label_draw_dsc.font = dsc->bg_img_symbol_font; label_draw_dsc.color = dsc->bg_img_recolor; label_draw_dsc.opa = dsc->bg_img_opa; + + /* Reset transform state temporarilly, so the label will be drawn in desinated position */ + uint8_t transform_count = ctx->internals->transform_count; + ctx->internals->transform_count = 0; lv_draw_label((lv_draw_ctx_t *) ctx, &label_draw_dsc, &a, dsc->bg_img_src, NULL); + ctx->internals->transform_count = transform_count; } else { lv_img_header_t header; @@ -340,7 +345,12 @@ static void draw_bg_img(lv_draw_sdl_ctx_t * ctx, const lv_area_t * coords, const area.x2 = area.x1 + header.w - 1; area.y2 = area.y1 + header.h - 1; + + /* Reset transform state temporarilly, so the image will be drawn in desinated position */ + uint8_t transform_count = ctx->internals->transform_count; + ctx->internals->transform_count = 0; lv_draw_img((lv_draw_ctx_t *) ctx, &img_dsc, &area, dsc->bg_img_src); + ctx->internals->transform_count = transform_count; } else { lv_area_t area; @@ -351,9 +361,14 @@ static void draw_bg_img(lv_draw_sdl_ctx_t * ctx, const lv_area_t * coords, const area.x1 = coords->x1; area.x2 = area.x1 + header.w - 1; + + /* Reset transform state temporarilly, so the image will be drawn in desinated position */ + uint8_t transform_count = ctx->internals->transform_count; + ctx->internals->transform_count = 0; for(; area.x1 <= coords->x2; area.x1 += header.w, area.x2 += header.w) { lv_draw_img((lv_draw_ctx_t *) ctx, &img_dsc, &area, dsc->bg_img_src); } + ctx->internals->transform_count = transform_count; } } @@ -452,9 +467,12 @@ static void draw_border(lv_draw_sdl_ctx_t * ctx, const lv_area_t * coords, const lv_coord_t coords_w = lv_area_get_width(coords), coords_h = lv_area_get_height(coords); lv_coord_t short_side = LV_MIN(coords_w, coords_h); - lv_coord_t rout = LV_MIN(dsc->radius, short_side / 2);/*Get the inner area*/ + lv_coord_t rout = LV_MIN(dsc->radius, short_side / 2); + + /*Get the inner area*/ lv_area_t area_inner; - lv_area_copy(&area_inner, coords);// lv_area_increase(&area_inner, 1, 1); + lv_area_copy(&area_inner, coords); + area_inner.x1 += ((dsc->border_side & LV_BORDER_SIDE_LEFT) ? dsc->border_width : -(dsc->border_width + rout)); area_inner.x2 -= ((dsc->border_side & LV_BORDER_SIDE_RIGHT) ? dsc->border_width : -(dsc->border_width + rout)); area_inner.y1 += ((dsc->border_side & LV_BORDER_SIDE_TOP) ? dsc->border_width : -(dsc->border_width + rout)); diff --git a/src/draw/sdl/lv_draw_sdl_rect.h b/src/draw/sdl/lv_draw_sdl_rect.h index fec658127..ad76f7900 100644 --- a/src/draw/sdl/lv_draw_sdl_rect.h +++ b/src/draw/sdl/lv_draw_sdl_rect.h @@ -18,7 +18,7 @@ extern "C" { #if LV_USE_DRAW_SDL -#include LV_DARW_SDL_INCLUDE_PATH +#include LV_DRAW_SDL_INCLUDE_PATH #include "../lv_draw.h" diff --git a/src/draw/sdl/lv_draw_sdl_texture_cache.c b/src/draw/sdl/lv_draw_sdl_texture_cache.c index 1375f18e0..4d84457a7 100644 --- a/src/draw/sdl/lv_draw_sdl_texture_cache.c +++ b/src/draw/sdl/lv_draw_sdl_texture_cache.c @@ -56,7 +56,7 @@ static draw_cache_value_t * draw_cache_get_entry(lv_draw_sdl_ctx_t * ctx, const void lv_draw_sdl_texture_cache_init(lv_draw_sdl_ctx_t * ctx) { - ctx->internals->texture_cache = lv_lru_create(LV_DARW_SDL_LRU_SIZE, 65536, + ctx->internals->texture_cache = lv_lru_create(LV_DRAW_SDL_LRU_SIZE, 65536, (lv_lru_free_t *) draw_cache_free_value, NULL); } diff --git a/src/draw/sdl/lv_draw_sdl_texture_cache.h b/src/draw/sdl/lv_draw_sdl_texture_cache.h index 4335a6a07..75c4f67d3 100644 --- a/src/draw/sdl/lv_draw_sdl_texture_cache.h +++ b/src/draw/sdl/lv_draw_sdl_texture_cache.h @@ -18,7 +18,7 @@ extern "C" { #if LV_USE_DRAW_SDL -#include LV_DARW_SDL_INCLUDE_PATH +#include LV_DRAW_SDL_INCLUDE_PATH #include "lv_draw_sdl.h" #include "lv_draw_sdl_priv.h" #include "../../draw/lv_img_decoder.h" diff --git a/src/draw/sdl/lv_draw_sdl_utils.h b/src/draw/sdl/lv_draw_sdl_utils.h index 530a461a0..e7668b393 100644 --- a/src/draw/sdl/lv_draw_sdl_utils.h +++ b/src/draw/sdl/lv_draw_sdl_utils.h @@ -20,7 +20,7 @@ extern "C" { #include "../../misc/lv_color.h" #include "../../misc/lv_area.h" -#include LV_DARW_SDL_INCLUDE_PATH +#include LV_DRAW_SDL_INCLUDE_PATH /********************* * DEFINES diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index c774ef7b3..f992a4eb8 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -433,27 +433,27 @@ #endif #endif #if LV_USE_DRAW_SDL - #ifndef LV_DARW_SDL_INCLUDE_PATH - #ifdef CONFIG_LV_DARW_SDL_INCLUDE_PATH - #define LV_DARW_SDL_INCLUDE_PATH CONFIG_LV_DARW_SDL_INCLUDE_PATH + #ifndef LV_DRAW_SDL_INCLUDE_PATH + #ifdef CONFIG_LV_DRAW_SDL_INCLUDE_PATH + #define LV_DRAW_SDL_INCLUDE_PATH CONFIG_LV_DRAW_SDL_INCLUDE_PATH #else - #define LV_DARW_SDL_INCLUDE_PATH + #define LV_DRAW_SDL_INCLUDE_PATH #endif #endif /*Texture cache size, 8MB by default*/ - #ifndef LV_DARW_SDL_LRU_SIZE - #ifdef CONFIG_LV_DARW_SDL_LRU_SIZE - #define LV_DARW_SDL_LRU_SIZE CONFIG_LV_DARW_SDL_LRU_SIZE + #ifndef LV_DRAW_SDL_LRU_SIZE + #ifdef CONFIG_LV_DRAW_SDL_LRU_SIZE + #define LV_DRAW_SDL_LRU_SIZE CONFIG_LV_DRAW_SDL_LRU_SIZE #else - #define LV_DARW_SDL_LRU_SIZE (1024 * 1024 * 8) + #define LV_DRAW_SDL_LRU_SIZE (1024 * 1024 * 8) #endif #endif /*Custom blend mode for mask drawing, disable if you need to link with older SDL2 lib*/ - #ifndef LV_DARW_SDL_CUSTOM_BLEND_MODE - #ifdef CONFIG_LV_DARW_SDL_CUSTOM_BLEND_MODE - #define LV_DARW_SDL_CUSTOM_BLEND_MODE CONFIG_LV_DARW_SDL_CUSTOM_BLEND_MODE + #ifndef LV_DRAW_SDL_CUSTOM_BLEND_MODE + #ifdef CONFIG_LV_DRAW_SDL_CUSTOM_BLEND_MODE + #define LV_DRAW_SDL_CUSTOM_BLEND_MODE CONFIG_LV_DRAW_SDL_CUSTOM_BLEND_MODE #else - #define LV_DARW_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6)) + #define LV_DRAW_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6)) #endif #endif #endif