-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
feat(sdl_render): support all draw task types #6437
Conversation
@W-Mai will you have time to take a look at it in the near future? |
After testing, it was found that the system freezes and images do not rotate. I have attempted to fix these two issues, please test again From 876d0c6397e80ad1c3c38af33e9bc1db770ca91a Mon Sep 17 00:00:00 2001
From: lhdjply <lhdjply@126.com>
Date: Mon, 15 Jul 2024 16:24:08 +0800
Subject: [PATCH] fix freezing issues and add image rotation functionality.
Signed-off-by: lhdjply <lhdjply@126.com>
---
demos/widgets/lv_demo_widgets.c | 4 ++--
src/draw/sdl/lv_draw_sdl.c | 10 ++++------
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/demos/widgets/lv_demo_widgets.c b/demos/widgets/lv_demo_widgets.c
index eb0e880d6..be4ebf75f 100644
--- a/demos/widgets/lv_demo_widgets.c
+++ b/demos/widgets/lv_demo_widgets.c
@@ -252,8 +252,8 @@ static void profile_create(lv_obj_t * parent)
LV_IMAGE_DECLARE(img_demo_widgets_avatar);
lv_obj_t * avatar = lv_image_create(panel1);
- // lv_image_set_src(avatar, &img_demo_widgets_avatar);
- lv_image_set_src(avatar, "A:lvgl/demos/widgets/assets/avatar.png");
+ lv_image_set_src(avatar, &img_demo_widgets_avatar);
+ // lv_image_set_src(avatar, "A:lvgl/demos/widgets/assets/avatar.png")
lv_obj_t * name = lv_label_create(panel1);
lv_label_set_text(name, "Elena Smith");
diff --git a/src/draw/sdl/lv_draw_sdl.c b/src/draw/sdl/lv_draw_sdl.c
index 511dd064c..d685ff31f 100644
--- a/src/draw/sdl/lv_draw_sdl.c
+++ b/src/draw/sdl/lv_draw_sdl.c
@@ -345,8 +345,8 @@ static bool draw_to_texture(lv_draw_sdl_unit_t * u, cache_data_t * cache_data)
cache_data->draw_dsc = lv_malloc(base_dsc->dsc_size);
lv_memcpy((void *)cache_data->draw_dsc, base_dsc, base_dsc->dsc_size);
- cache_data->w = texture_w;
- cache_data->h = texture_h;
+ cache_data->w = lv_area_get_width(&task->area);
+ cache_data->h = lv_area_get_height(&task->area);
cache_data->texture = texture;
if(obj) {
@@ -441,7 +441,8 @@ static void draw_from_cached_texture(lv_draw_sdl_unit_t * u)
rect.h = lv_area_get_height(&image_area);
SDL_RenderSetClipRect(renderer, &clip_rect);
- SDL_RenderCopy(renderer, texture, NULL, &rect);
+ SDL_Point center = {draw_dsc->pivot.x, draw_dsc->pivot.y};
+ SDL_RenderCopyEx(renderer, texture, NULL, &rect, draw_dsc->rotation / 10, ¢er, SDL_FLIP_NONE);
}
else {
rect.x = t->_real_area.x1 - dest_layer->buf_area.x1;
@@ -460,12 +461,9 @@ static void draw_from_cached_texture(lv_draw_sdl_unit_t * u)
lv_draw_label_dsc_t * label_dsc = t->draw_dsc;
if(label_dsc->text_local) {
// lv_cache_entry_set_invalid(entry_cached, true);
- printf("a\n");
}
}
- printf("b\n");
lv_cache_release(u->texture_cache, entry_cached, u);
- printf("c\n");
}
static void execute_drawing(lv_draw_sdl_unit_t * u)
--
2.43.0
|
src/draw/sdl/lv_draw_sdl.c
Outdated
if(t->type == LV_DRAW_TASK_TYPE_LABEL) { | ||
lv_draw_label_dsc_t * label_dsc = t->draw_dsc; | ||
if(label_dsc->text_local) { | ||
// lv_cache_entry_set_invalid(entry_cached, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this API is private, don't use
I resolved the caching issue by using I've also added support for image rotation. It's done by LVGL not SDL to make sure that all SW render features are supported. |
Nice! Currently, two issues have been identified:
|
Thanks, I've fixed both. |
Test passed. Please rebase onto the master branch to resolve conflicts. |
hello,
|
I'll test the performance issue tomorrow. |
25811db
to
f16fa63
Compare
I've significantly improved the perfornace. opa_layered still could be faster, but I think it's okay for the first round. |
@@ -9,13 +9,13 @@ | |||
#include "../lv_draw_private.h" | |||
#if LV_USE_DRAW_SDL | |||
#include LV_SDL_INCLUDE_PATH | |||
#include <SDL2/SDL_image.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please confirm it's remove as intended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed. It was one of the goals to get rid of SDL_image
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed. It was one of the goals to get rid of
SDL_image
.
Can it be removed from lv_dsl_window.c
, tests/CMakeLists.txt
, and scripts/install-prerequisites.sh
too?
@@ -998,11 +997,11 @@ void shop_create(lv_obj_t * parent) | |||
lv_obj_add_style(title, &style_title, 0); | |||
|
|||
LV_IMAGE_DECLARE(img_clothes); | |||
create_shop_item(list, &img_clothes, "Blue jeans", "Clothes", "$722"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert unnecessary changes.
|
||
// lv_obj_t * img2 = lv_image_create(lv_screen_active()); | ||
// lv_image_set_src(img2, LV_SYMBOL_OK "Accept"); | ||
// lv_obj_align_to(img2, img1, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's cleanup a bit.
src/draw/sdl/lv_draw_sdl.c
Outdated
{ | ||
static int32_t x = 0; | ||
printf("%d\n", x++); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
src/draw/sdl/lv_draw_sdl.c
Outdated
break; | ||
} | ||
default: | ||
return false; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
Updated, please review again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the Kconfig.
@@ -9,13 +9,13 @@ | |||
#include "../lv_draw_private.h" | |||
#if LV_USE_DRAW_SDL | |||
#include LV_SDL_INCLUDE_PATH | |||
#include <SDL2/SDL_image.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed. It was one of the goals to get rid of
SDL_image
.
Can it be removed from lv_dsl_window.c
, tests/CMakeLists.txt
, and scripts/install-prerequisites.sh
too?
Thank you Liam, all fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, just this leftover now: https://github.com/kisvegabor/lvgl_upstream/blob/850272c7ed430be07bc45b9d3c05461297aa0cbf/tests/CMakeLists.txt#L463
Fixed |
Force merging now for v9.2. There shouldn't be major issues. |
I noticed heavy performance degradation in basic screens from 9.1 to 9.2. Let me know if you need more details but i wanted to put it here just in case is related. |
Wow, that's not ideal for sure. Can you run Could you try |
Fixes #6410,
Description of the feature or fix
I'm working on adding support to all draw task types, but I'm facing a cache related issue. The current code crashes in
lv_example_buttonmatrix_1()
if this line is enabled:I'd like to immediately drop the cache in some case. In this case with
text_local = 1
thelabel_draw_dsc->text
will be freed later, so we cannot keep a reference to it in thedraw_dsc
saved in the cache..Other thing: In
sdl_texture_cache_compare_cb
I'd like to compare text of the label draw dsc-s withstrcmp
and not by pointer value. Can I simply returnreturn strcmp_res > 0 ? 1 : -1;
?cc @W-Mai
Notes
lv_conf_template.h
run lv_conf_internal_gen.py and update Kconfig.scripts/code-format.py
(astyle version v3.4.12 needs to be installed) and follow the Code Conventions.