-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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(draw): add basic vector APIs #4528
Conversation
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.
Looks good in general! Just a few comments.
Hey, Thank you! Have you already tried it out with ThorVG or VG-Lite (or other GPU)? |
As these files uses |
Not yet, this is only the task distribution part and no task handler has been implemented so far. |
ec1f081
to
68a8279
Compare
Updated:
|
src/draw/lv_draw_vector.h
Outdated
void lv_vpath_set_order(lv_vpath_dsc_t * dsc, bool stroke_first); | ||
|
||
/*Draw path commands*/ | ||
lv_vpath_task_t * lv_vpath_task_create(void); |
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.
lv_vpath_task_t needs to be an private data and should not be created and maintained by the API caller
src/draw/lv_draw_vector.h
Outdated
void lv_vpath_draw(struct _lv_layer_t * layer, lv_vpath_task_t * task, lv_vpath_t * path, lv_vpath_dsc_t * dsc); | ||
void lv_vpath_clear(struct _lv_layer_t * layer, lv_vpath_task_t * task, lv_area_t * rect, lv_color_t color); | ||
void lv_vpath_submit(struct _lv_layer_t * layer, lv_vpath_task_t * task); | ||
void lv_vpath_draw_oneshot(struct _lv_layer_t * layer, lv_vpath_t * path, lv_vpath_dsc_t * dsc); |
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.
“void lv_vpath_draw_oneshot(struct _lv_layer_t * layer, lv_vpath_t * path, lv_vpath_dsc_t * dsc);”
why need this?
void lv_matrix_scale(lv_matrix_t * matrix, float scale_x, float scale_y); | ||
void lv_matrix_rotate(lv_matrix_t * matrix, float angle); | ||
/*Pseudo 3D rotation (using affine transformations to simulate 3d rotations cast to xy plane)*/ | ||
void lv_matrix_rotate_p3d(lv_matrix_t * matrix, float rx, float ry, float rz); |
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.
“
void lv_matrix_rotate_p3d(lv_matrix_t * matrix, float rx, float ry, float rz);
void lv_matrix_rotate_quaternion(lv_matrix_t * matrix, float q0, float q1, float q2, float q3);
”
If you want to implement 3D transformation, you need matrix[4][4], not matrix[3][3]
src/draw/lv_draw_vector.h
Outdated
/*Helper functions*/ | ||
void lv_matrix_translate(lv_matrix_t * matrix, float dx, float dy); | ||
void lv_matrix_scale(lv_matrix_t * matrix, float scale_x, float scale_y); | ||
void lv_matrix_rotate(lv_matrix_t * matrix, float angle); |
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.
Missing matrix skew method
src/draw/lv_draw_vector.h
Outdated
void lv_vpath_append_path(lv_vpath_t * path, lv_vpath_t * subpath); | ||
|
||
/*Param operations*/ | ||
void lv_vpath_dsc_init(lv_vpath_dsc_t * dsc); |
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.
void lv_vpath_dsc_init(lv_vpath_dsc_t * dsc); | |
lv_vpath_draw_context_t* lv_vpath_draw_context_create(struct _lv_layer_t * layer); |
In order to save the lv_vpath_task_t we can change lv_vpath_dsc_t to lv_vpath_draw_context_t
That we can create and maintain it using methods like:
lv_vpath_draw_context_t* lv_vpath_draw_context_create(struct _lv_layer_t * layer);
lv_vpath_draw_context_destroy(lv_vpath_draw_context_t* ctx)
The drawing function can be:
void lv_vpath_draw( lv_vpath_draw_context_t * ctx, lv_vpath_t * path);
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.
@PeterBee97 Do you think this is better?
src/draw/lv_draw_vector.h
Outdated
lv_vpath_blend_t blend; | ||
lv_area_t scissor_area; | ||
bool stroke_first; | ||
} lv_vpath_dsc_t; |
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.
} lv_vpath_dsc_t; | |
} lv_vpath_dsc_t; | |
typedef struct { | |
lv_vpath_dsc_t draw_dsc; | |
lv_vpath_task_t * task; | |
lv_vpath_task_t * current_task; | |
} lv_vpath_draw_context_t; |
Please use |
I think "lv_vector_path_" is too long as a prefix, how about “lvg_" ? @kisvegabor |
I looked into the API again I'm a little bit puzzled by
have the same prefix as What about something like this: /*Same as `lv_vpath_t`
*"vector_path" is not prefix but the whole name here*/
lv_vector_path_t * lv_vector_path_create(void);
void lv_vector_path_quad_to(lv_vector_path_t * path, lv_fpoint_t p1, lv_fpoint_t p2);
/*Same as `lv_vpath_dsc_t`
*lv_vector_draw_dsc_t ) has `lv_vector_path_t * path` and `lv_vector_draw_dsc_t * next` fields*/
void lv_vector_draw_dsc_init(lv_vector_draw_dsc_t * dsc);
dsc.path = some_path;
dsc.fill_dsc.color = lv_color_hex(0xffaa00);
dsc.next = &another_dsc;
/*Start drawing*/
void lv_vector_draw(struct _lv_layer_t * layer, lv_vector_draw_dsc_t * dsc); |
I think this way is not easy to use. The draw_dsc list should be implements under a contxt and should not be maintained by the caller, which is easy cause to errors.
In this way, the caller of the API does not need to worry about drawing the list and can focus on the drawing logic. |
What is the content of So For the sake of consistency with other draw tasks, it'd be great if |
|
Basic draw task distribution via lv_draw_vector() Providing swift helper functions for matrix calculation Change-Id: I29e5a3fd8b8010ae172bd9ead053c44eaa4d4188 Signed-off-by: Peter Bee <[email protected]>
Refined API naming and added skew functions. There is one more thing from our internal discussion: |
You mean |
We need some feedback on this pull request. Now we mark this as "stale" because there was no activity here for 14 days. Remove the "stale" label or comment else this will be closed in 7 days. |
Not stale |
Signed-off-by: zhangjipeng <[email protected]>
Signed-off-by: zhangjipeng <[email protected]>
Signed-off-by: zhangjipeng <[email protected]>
Signed-off-by: zhangjipeng <[email protected]>
Signed-off-by: zhangjipeng <[email protected]>
Signed-off-by: zhangjipeng <[email protected]>
Signed-off-by: zhangjipeng <[email protected]>
) Signed-off-by: zhangjipeng <[email protected]>
) Signed-off-by: zhangjipeng <[email protected]>
) Signed-off-by: zhangjipeng <[email protected]>
…lvgl#4528) Signed-off-by: zhangjipeng <[email protected]>
lvgl#4528) Signed-off-by: zhangjipeng <[email protected]>
Signed-off-by: zhangjipeng <[email protected]>
We need some feedback on this pull request. Now we mark this as "stale" because there was no activity here for 14 days. Remove the "stale" label or comment else this will be closed in 7 days. |
…PIs (lvgl#4528) Signed-off-by: zhangjipeng <[email protected]>
Closing in favor of #4691. |
Signed-off-by: zhangjipeng <[email protected]>
Signed-off-by: zhangjipeng <[email protected]>
Signed-off-by: zhangjipeng <[email protected]>
Signed-off-by: zhangjipeng <[email protected]> Co-authored-by: zhangjipeng <[email protected]> Co-authored-by: Gabor Kiss-Vamosi <[email protected]>
VELAPLATFO-18794 Change-Id: Ibef19691436ac0c03afc6cfe19dc2e6b19423489 Signed-off-by: zhangjipeng <[email protected]> (cherry picked from commit 4806589a6133a93313c1e19e4bc1824d552eec42)
VELAPLATFO-18794 Change-Id: I8fc1ea228f045804edfa187aca4754f25fb96693 Signed-off-by: zhangjipeng <[email protected]>
Description of the feature or fix
Vector APIs and basic draw task distribution following #4388 . Some matrix helper functions are provided.
Checkpoints
code-format.py
from the scripts folder. astyle needs to be installed.lv_conf_template.h
run lv_conf_internal_gen.py and update Kconfig.Be sure the following conventions are followed:
enum
s instead of macros. If inevitable to usedefine
s export them withLV_EXPORT_CONST_INT(defined_value)
right after thedefine
.type name[]
declaration for array parameters instead oftype * name
void *
pointersmalloc
into a static or global variables. Instead declare the variable inlv_global_t
structure inlv_global.h
and mark the variable with(LV_GLOBAL_DEFAULT()->variable)
when it's used. See a detailed description here.lv_<widget_name>_create(lv_obj_t * parent)
pattern.lv_<modul_name>
and should receivelv_obj_t *
as first argument which is a pointer to widget object itself.struct
s should be used via an API and not modified directly via their elements.struct
APIs should follow the widgets' conventions. That is to receive a pointer to thestruct
as the first argument, and the prefix of thestruct
name should be used as the prefix of the function name too (e.g.lv_disp_set_default(lv_disp_t * disp)
)struct
s which are not part of the public API must begin with underscore in order to mark them as "private".struct
as the first argument. Thestruct
must containvoid * user_data
field.void * user_data
and the sameuser_data
needs to be passed as the last argument of the callback.xcb_t
.