1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

fix(dave2d): fix various smaller issues (#5043)

Co-authored-by: Jeremy Baker <jeremy.baker@renesas.com>

See https://github.com/lvgl/lv_renesas/issues/3
This commit is contained in:
Gabor Kiss-Vamosi 2023-12-18 21:15:15 +01:00 committed by GitHub
parent 1f86e1ed80
commit 9b67c5ba67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 285 additions and 141 deletions

View File

@ -267,15 +267,15 @@ static int32_t _dave2d_evaluate(lv_draw_unit_t * u, lv_draw_task_t * t)
case LV_DRAW_TASK_TYPE_IMAGE: {
#if USE_D2
lv_draw_image_dsc_t * draw_dsc = t->draw_dsc;
if(draw_dsc->header.cf != LV_COLOR_FORMAT_RGB565A8) {
t->preferred_draw_unit_id = DRAW_UNIT_ID_DAVE2D;
t->preference_score = 0;
}
lv_draw_image_dsc_t * draw_dsc = t->draw_dsc;
if(draw_dsc->header.cf != LV_COLOR_FORMAT_RGB565A8) {
t->preferred_draw_unit_id = DRAW_UNIT_ID_DAVE2D;
t->preference_score = 0;
}
#endif
ret = 0;
break;
}
ret = 0;
break;
}
case LV_DRAW_TASK_TYPE_BORDER: {
#if USE_D2

View File

@ -95,41 +95,87 @@ void lv_draw_dave2d_arc(lv_draw_dave2d_unit_t * u, const lv_draw_arc_dsc_t * dsc
sin_end = lv_trigo_sin((int16_t)dsc->end_angle);
cos_end = lv_trigo_cos((int16_t)dsc->end_angle);
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(arc_centre.x),
(d2_point) D2_FIX4(arc_centre.y),
(d2_width) D2_FIX4(dsc->radius - dsc->width / 2),
(d2_width) D2_FIX4(dsc->width),
-(d2_s32)(sin_start << 1),
(d2_s32)(cos_start << 1),
(d2_s32)(sin_end << 1),
-(d2_s32)(cos_end << 1),
flags);
if(D2_OK != result) {
__BKPT(0);
bool draw_arc;
lv_area_t arc_area;
lv_area_t clip_arc;
lv_point_t start_point;
lv_point_t end_point;
start_point.x = arc_centre.x + (int16_t)(((dsc->radius) * cos_start) >> LV_TRIGO_SHIFT);
start_point.y = arc_centre.y + (int16_t)(((dsc->radius) * sin_start) >> LV_TRIGO_SHIFT);
end_point.x = arc_centre.x + (int16_t)(((dsc->radius) * cos_end) >> LV_TRIGO_SHIFT);
end_point.y = arc_centre.y + (int16_t)(((dsc->radius) * sin_end) >> LV_TRIGO_SHIFT);
arc_area.x1 = LV_MIN3(start_point.x, end_point.x, arc_centre.x);
arc_area.y1 = LV_MIN3(start_point.y, end_point.y, arc_centre.y);
arc_area.x2 = LV_MAX3(start_point.x, end_point.x, arc_centre.x);
arc_area.y2 = LV_MAX3(start_point.y, end_point.y, arc_centre.y);
/* 0 degrees */
if((dsc->end_angle < dsc->start_angle) || ((dsc->start_angle < 360) && (dsc->end_angle > 360))) {
arc_area.x2 = arc_centre.x + dsc->radius;
}
if(dsc->rounded) {
lv_point_t start_coord;
lv_point_t end_coord;
/* 90 degrees */
if(((dsc->end_angle > 90) && (dsc->start_angle < 90)) || ((dsc->start_angle < 90) &&
(dsc->end_angle < dsc->start_angle))) {
arc_area.y2 = arc_centre.y + dsc->radius;
}
start_coord.x = arc_centre.x + (int16_t)(((dsc->radius - dsc->width / 2) * cos_start) >> LV_TRIGO_SHIFT);
start_coord.y = arc_centre.y + (int16_t)(((dsc->radius - dsc->width / 2) * sin_start) >> LV_TRIGO_SHIFT);
/* 180 degrees */
if(((dsc->end_angle > 180) && (dsc->start_angle < 180)) || ((dsc->start_angle < 180) &&
(dsc->end_angle < dsc->start_angle))) {
arc_area.x1 = arc_centre.x - dsc->radius;
}
/** Render a circle. */
d2_rendercircle(u->d2_handle,
(d2_point) D2_FIX4((uint16_t)(start_coord.x)),
(d2_point) D2_FIX4((uint16_t)(start_coord.y)),
(d2_width) D2_FIX4(dsc->width / 2), 0);
/* 270 degrees */
if(((dsc->end_angle > 270) && (dsc->start_angle < 270)) || ((dsc->start_angle < 270) &&
(dsc->end_angle < dsc->start_angle))) {
arc_area.y1 = arc_centre.y - dsc->radius;
}
end_coord.x = arc_centre.x + (int16_t)(((dsc->radius - dsc->width / 2) * cos_end) >> LV_TRIGO_SHIFT);
end_coord.y = arc_centre.y + (int16_t)(((dsc->radius - dsc->width / 2) * sin_end) >> LV_TRIGO_SHIFT);
draw_arc = _lv_area_intersect(&clip_arc, &arc_area, &clipped_area);
/** Render a circle. */
d2_rendercircle(u->d2_handle,
(d2_point) D2_FIX4((uint16_t)(end_coord.x)),
(d2_point) D2_FIX4((uint16_t)(end_coord.y)),
(d2_width) D2_FIX4(dsc->width / 2), 0);
if(draw_arc) {
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(arc_centre.x),
(d2_point) D2_FIX4(arc_centre.y),
(d2_width) D2_FIX4(dsc->radius - dsc->width / 2),
(d2_width) D2_FIX4(dsc->width),
-(d2_s32)(sin_start << 1),
(d2_s32)(cos_start << 1),
(d2_s32)(sin_end << 1),
-(d2_s32)(cos_end << 1),
flags);
if(D2_OK != result) {
__BKPT(0);
}
if(dsc->rounded) {
lv_point_t start_coord;
lv_point_t end_coord;
start_coord.x = arc_centre.x + (int16_t)(((dsc->radius - dsc->width / 2) * cos_start) >> LV_TRIGO_SHIFT);
start_coord.y = arc_centre.y + (int16_t)(((dsc->radius - dsc->width / 2) * sin_start) >> LV_TRIGO_SHIFT);
/** Render a circle. */
d2_rendercircle(u->d2_handle,
(d2_point) D2_FIX4((uint16_t)(start_coord.x)),
(d2_point) D2_FIX4((uint16_t)(start_coord.y)),
(d2_width) D2_FIX4(dsc->width / 2), 0);
end_coord.x = arc_centre.x + (int16_t)(((dsc->radius - dsc->width / 2) * cos_end) >> LV_TRIGO_SHIFT);
end_coord.y = arc_centre.y + (int16_t)(((dsc->radius - dsc->width / 2) * sin_end) >> LV_TRIGO_SHIFT);
/** Render a circle. */
d2_rendercircle(u->d2_handle,
(d2_point) D2_FIX4((uint16_t)(end_coord.x)),
(d2_point) D2_FIX4((uint16_t)(end_coord.y)),
(d2_width) D2_FIX4(dsc->width / 2), 0);
}
}
}

View File

@ -184,7 +184,6 @@ static void dave2d_draw_border_complex(lv_draw_dave2d_unit_t * u, const lv_area_
inner_area = *orig_inner_area;
if(!_lv_area_intersect(&draw_area, &outer_area, u->base_unit.clip_area)) return;
int32_t draw_area_w = lv_area_get_width(&draw_area);
#if LV_USE_OS
lv_result_t status;
@ -296,35 +295,60 @@ static void dave2d_draw_border_complex(lv_draw_dave2d_unit_t * u, const lv_area_
if(blend_w > 0) {
if(left_side || top_side) {
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(core_area.x1),
(d2_point) D2_FIX4(core_area.y1),
(d2_width) D2_FIX4(rout),
(d2_width) D2_FIX4((rout - rin)),
(d2_s32) D2_FIX16(0), // 180 Degrees
(d2_s32) D2_FIX16((int16_t) -1),
(d2_s32) D2_FIX16((int16_t) -1),//( 270 Degrees
(d2_s32) D2_FIX16(0),
flags);
if(D2_OK != result) {
__BKPT(0);
lv_area_t arc_area;
lv_area_t clip_arc;
arc_area.x1 = core_area.x1 - rout;
arc_area.y1 = core_area.y1 - rout;
arc_area.x2 = core_area.x1;
arc_area.y2 = core_area.y1;
if(_lv_area_intersect(&clip_arc, &arc_area, &draw_area)) {
d2_cliprect(u->d2_handle, (d2_border)clip_arc.x1, (d2_border)clip_arc.y1, (d2_border)clip_arc.x2,
(d2_border)clip_arc.y2);
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(core_area.x1),
(d2_point) D2_FIX4(core_area.y1),
(d2_width) D2_FIX4(rout),
(d2_width) D2_FIX4((rout - rin)),
(d2_s32) D2_FIX16(0), // 180 Degrees
(d2_s32) D2_FIX16((int16_t) -1),
(d2_s32) D2_FIX16((int16_t) -1),//( 270 Degrees
(d2_s32) D2_FIX16(0),
flags);
if(D2_OK != result) {
__BKPT(0);
}
}
}
if(left_side || bottom_side) {
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(core_area.x1),
(d2_point) D2_FIX4(core_area.y2),
(d2_width) D2_FIX4(rout),
(d2_width) D2_FIX4((rout - rin)),
(d2_s32) D2_FIX16((int16_t) -1), //90 degrees
(d2_s32) D2_FIX16(0),
(d2_s32) D2_FIX16(0), //180 degrees
(d2_s32) D2_FIX16(1),
flags);
if(D2_OK != result) {
__BKPT(0);
lv_area_t arc_area;
lv_area_t clip_arc;
arc_area.x1 = core_area.x1 - rout;
arc_area.y1 = core_area.y2;
arc_area.x2 = core_area.x1;
arc_area.y2 = core_area.y2 + rout;
if(_lv_area_intersect(&clip_arc, &arc_area, &draw_area)) {
d2_cliprect(u->d2_handle, (d2_border)clip_arc.x1, (d2_border)clip_arc.y1, (d2_border)clip_arc.x2,
(d2_border)clip_arc.y2);
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(core_area.x1),
(d2_point) D2_FIX4(core_area.y2),
(d2_width) D2_FIX4(rout),
(d2_width) D2_FIX4((rout - rin)),
(d2_s32) D2_FIX16((int16_t) -1), //90 degrees
(d2_s32) D2_FIX16(0),
(d2_s32) D2_FIX16(0), //180 degrees
(d2_s32) D2_FIX16(1),
flags);
if(D2_OK != result) {
__BKPT(0);
}
}
}
@ -337,35 +361,62 @@ static void dave2d_draw_border_complex(lv_draw_dave2d_unit_t * u, const lv_area_
if(blend_w > 0) {
if(right_side || top_side) {
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(core_area.x2),
(d2_point) D2_FIX4(core_area.y1),
(d2_width) D2_FIX4(rout),
(d2_width) D2_FIX4((rout - rin)),
(d2_s32) D2_FIX16((int16_t)1), // 270 Degrees
(d2_s32) D2_FIX16(0),
(d2_s32) D2_FIX16(0),// 0 degrees
(d2_s32) D2_FIX16(-1),
flags);
if(D2_OK != result) {
__BKPT(0);
lv_area_t arc_area;
lv_area_t clip_arc;
arc_area.x1 = core_area.x2;
arc_area.y1 = core_area.y1 - rout;
arc_area.x2 = core_area.x2 + rout;
arc_area.y2 = core_area.y1;
if(_lv_area_intersect(&clip_arc, &arc_area, &draw_area)) {
d2_cliprect(u->d2_handle, (d2_border)clip_arc.x1, (d2_border)clip_arc.y1, (d2_border)clip_arc.x2,
(d2_border)clip_arc.y2);
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(core_area.x2),
(d2_point) D2_FIX4(core_area.y1),
(d2_width) D2_FIX4(rout),
(d2_width) D2_FIX4((rout - rin)),
(d2_s32) D2_FIX16((int16_t)1), // 270 Degrees
(d2_s32) D2_FIX16(0),
(d2_s32) D2_FIX16(0),// 0 degrees
(d2_s32) D2_FIX16(-1),
flags);
if(D2_OK != result) {
__BKPT(0);
}
}
}
if(right_side || bottom_side) {
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(core_area.x2),
(d2_point) D2_FIX4(core_area.y2),
(d2_width) D2_FIX4(rout),
(d2_width) D2_FIX4((rout - rin)),
(d2_s32) D2_FIX16(0),// 0 degrees
(d2_s32) D2_FIX16(1),
(d2_s32) D2_FIX16(1),// 90 degrees
(d2_s32) D2_FIX16(0),
flags);
if(D2_OK != result) {
__BKPT(0);
lv_area_t arc_area;
lv_area_t clip_arc;
arc_area.x1 = core_area.x2;
arc_area.y1 = core_area.y2;
arc_area.x2 = core_area.x2 + rout;
arc_area.y2 = core_area.y2 + rout;
if(_lv_area_intersect(&clip_arc, &arc_area, &draw_area)) {
d2_cliprect(u->d2_handle, (d2_border)clip_arc.x1, (d2_border)clip_arc.y1, (d2_border)clip_arc.x2,
(d2_border)clip_arc.y2);
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(core_area.x2),
(d2_point) D2_FIX4(core_area.y2),
(d2_width) D2_FIX4(rout),
(d2_width) D2_FIX4((rout - rin)),
(d2_s32) D2_FIX16(0),// 0 degrees
(d2_s32) D2_FIX16(1),
(d2_s32) D2_FIX16(1),// 90 degrees
(d2_s32) D2_FIX16(0),
flags);
if(D2_OK != result) {
__BKPT(0);
}
}
}
}

View File

@ -27,7 +27,7 @@ void lv_draw_dave2d_fill(lv_draw_dave2d_unit_t * u, const lv_draw_fill_dsc_t * d
#endif
buffer_area = u->base_unit.target_layer->buf_area;
coordinates = *coords;
lv_area_copy(&coordinates, coords);
x = 0 - u->base_unit.target_layer->buf_area.x1;
y = 0 - u->base_unit.target_layer->buf_area.y1;
@ -166,74 +166,123 @@ void lv_draw_dave2d_fill(lv_draw_dave2d_unit_t * u, const lv_draw_fill_dsc_t * d
}
}
else {
lv_area_t arc_area;
lv_area_t clip_arc;
arc_centre.x = coordinates.x1 + radius;
arc_centre.y = coordinates.y1 + radius;
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(arc_centre.x),
(d2_point) D2_FIX4(arc_centre.y),
(d2_width) D2_FIX4(radius),
(d2_width) D2_FIX4(0),
(d2_s32) D2_FIX16(0), // 180 Degrees
(d2_s32) D2_FIX16((int16_t) -1),
(d2_s32) D2_FIX16((int16_t) -1),//( 270 Degrees
(d2_s32) D2_FIX16(0),
flags);
if(D2_OK != result) {
__BKPT(0);
arc_area.x1 = coordinates.x1;
arc_area.y1 = coordinates.y1;
arc_area.x2 = coordinates.x1 + radius;
arc_area.y2 = coordinates.y1 + radius;
if(_lv_area_intersect(&clip_arc, &arc_area, &draw_area)) {
d2_cliprect(u->d2_handle, (d2_border)clip_arc.x1, (d2_border)clip_arc.y1, (d2_border)clip_arc.x2,
(d2_border)clip_arc.y2);
// d2_renderwedge internally changes the clip rectangle, only draw it if it is in side the current clip rectangle
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(arc_centre.x),
(d2_point) D2_FIX4(arc_centre.y),
(d2_width) D2_FIX4(radius),
(d2_width) D2_FIX4(0),
(d2_s32) D2_FIX16(0), // 180 Degrees
(d2_s32) D2_FIX16((int16_t) -1),
(d2_s32) D2_FIX16((int16_t) -1),//( 270 Degrees
(d2_s32) D2_FIX16(0),
flags);
if(D2_OK != result) {
__BKPT(0);
}
}
arc_centre.x = coordinates.x2 - radius;
arc_centre.y = coordinates.y1 + radius;
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(arc_centre.x),
(d2_point) D2_FIX4(arc_centre.y),
(d2_width) D2_FIX4(radius),
(d2_width) D2_FIX4(0),
(d2_s32) D2_FIX16((int16_t)1), // 270 Degrees
(d2_s32) D2_FIX16(0),
(d2_s32) D2_FIX16(0),// 0 degrees
(d2_s32) D2_FIX16(-1),
flags);
if(D2_OK != result) {
__BKPT(0);
arc_area.x1 = coordinates.x2 - radius;
arc_area.y1 = coordinates.y1;
arc_area.x2 = coordinates.x2;
arc_area.y2 = coordinates.y1 + radius;
if(_lv_area_intersect(&clip_arc, &arc_area, &draw_area)) {
d2_cliprect(u->d2_handle, (d2_border)clip_arc.x1, (d2_border)clip_arc.y1, (d2_border)clip_arc.x2,
(d2_border)clip_arc.y2);
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(arc_centre.x),
(d2_point) D2_FIX4(arc_centre.y),
(d2_width) D2_FIX4(radius),
(d2_width) D2_FIX4(0),
(d2_s32) D2_FIX16((int16_t)1), // 270 Degrees
(d2_s32) D2_FIX16(0),
(d2_s32) D2_FIX16(0),// 0 degrees
(d2_s32) D2_FIX16(-1),
flags);
if(D2_OK != result) {
__BKPT(0);
}
}
arc_centre.x = coordinates.x2 - radius;
arc_centre.y = coordinates.y2 - radius;
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(arc_centre.x),
(d2_point) D2_FIX4(arc_centre.y),
(d2_width) D2_FIX4(radius),
(d2_width) D2_FIX4(0),
(d2_s32) D2_FIX16(0),// 0 degrees
(d2_s32) D2_FIX16(1),
(d2_s32) D2_FIX16(1),// 90 degrees
(d2_s32) D2_FIX16(0),
flags);
if(D2_OK != result) {
__BKPT(0);
arc_area.x1 = coordinates.x2 - radius;
arc_area.y1 = coordinates.y2 - radius;
arc_area.x2 = coordinates.x2;
arc_area.y2 = coordinates.y2;
if(_lv_area_intersect(&clip_arc, &arc_area, &draw_area)) {
d2_cliprect(u->d2_handle, (d2_border)clip_arc.x1, (d2_border)clip_arc.y1, (d2_border)clip_arc.x2,
(d2_border)clip_arc.y2);
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(arc_centre.x),
(d2_point) D2_FIX4(arc_centre.y),
(d2_width) D2_FIX4(radius),
(d2_width) D2_FIX4(0),
(d2_s32) D2_FIX16(0),// 0 degrees
(d2_s32) D2_FIX16(1),
(d2_s32) D2_FIX16(1),// 90 degrees
(d2_s32) D2_FIX16(0),
flags);
if(D2_OK != result) {
__BKPT(0);
}
}
arc_centre.x = coordinates.x1 + radius;
arc_centre.y = coordinates.y2 - radius;
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(arc_centre.x),
(d2_point) D2_FIX4(arc_centre.y),
(d2_width) D2_FIX4(radius),
(d2_width) D2_FIX4(0),
(d2_s32) D2_FIX16((int16_t) -1), //90 degrees
(d2_s32) D2_FIX16(0),
(d2_s32) D2_FIX16(0), //180 degrees
(d2_s32) D2_FIX16(1),
flags);
if(D2_OK != result) {
__BKPT(0);
arc_area.x1 = coordinates.x1;
arc_area.y1 = coordinates.y2 - radius;
arc_area.x2 = coordinates.x1 + radius;
arc_area.y2 = coordinates.y2;
if(_lv_area_intersect(&clip_arc, &arc_area, &draw_area)) {
d2_cliprect(u->d2_handle, (d2_border)clip_arc.x1, (d2_border)clip_arc.y1, (d2_border)clip_arc.x2,
(d2_border)clip_arc.y2);
result = d2_renderwedge(u->d2_handle,
(d2_point)D2_FIX4(arc_centre.x),
(d2_point) D2_FIX4(arc_centre.y),
(d2_width) D2_FIX4(radius),
(d2_width) D2_FIX4(0),
(d2_s32) D2_FIX16((int16_t) -1), //90 degrees
(d2_s32) D2_FIX16(0),
(d2_s32) D2_FIX16(0), //180 degrees
(d2_s32) D2_FIX16(1),
flags);
if(D2_OK != result) {
__BKPT(0);
}
}
/* reset the clip rectangle */
d2_cliprect(u->d2_handle, (d2_border)draw_area.x1, (d2_border)draw_area.y1, (d2_border)draw_area.x2,
(d2_border)draw_area.y2);
result = d2_renderbox(u->d2_handle,
(d2_width)D2_FIX4(coordinates.x1 + radius),
(d2_width)D2_FIX4(coordinates.y1),

View File

@ -3,7 +3,6 @@
*
*/
/*********************
* INCLUDES
*********************/
@ -106,7 +105,6 @@ static void img_draw_core(lv_draw_unit_t * u_base, const lv_draw_image_dsc_t * d
lv_area_move(&buffer_area, x, y);
lv_area_move(&clipped_area, x, y);
/* Generate render operations*/
#if D2_RENDER_EACH_OPERATION
d2_selectrenderbuffer(u->d2_handle, u->renderbuffer);
@ -133,7 +131,7 @@ static void img_draw_core(lv_draw_unit_t * u_base, const lv_draw_image_dsc_t * d
#if defined(RENESAS_CORTEX_M85)
#if (BSP_CFG_DCACHE_ENABLED)
d1_cacheblockflush(u->d2_handle, 0, src_buf,
img_stride * decoder_dsc->header.h); //Stride is in bytes, not pixels/texels
img_stride * decoder_dsc->header.h); //Stride is in bytes, not pixels/texels
#endif
#endif
@ -256,7 +254,4 @@ static void img_draw_core(lv_draw_unit_t * u_base, const lv_draw_image_dsc_t * d
}
#endif //LV_USE_DRAW_DAVE2D

View File

@ -90,6 +90,9 @@ void lv_draw_dave2d_triangle(lv_draw_dave2d_unit_t * u, const lv_draw_triangle_d
p[1].y -= u->base_unit.target_layer->buf_area.y1;
p[2].y -= u->base_unit.target_layer->buf_area.y1;
p[1].y -= 1;
p[2].y -= 1;
current_alpha_mode = d2_getalphamode(u->d2_handle);
if(LV_GRAD_DIR_NONE != dsc->bg_grad.dir) {