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:
parent
1f86e1ed80
commit
9b67c5ba67
@ -95,6 +95,51 @@ 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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
draw_arc = _lv_area_intersect(&clip_arc, &arc_area, &clipped_area);
|
||||
|
||||
if(draw_arc) {
|
||||
|
||||
result = d2_renderwedge(u->d2_handle,
|
||||
(d2_point)D2_FIX4(arc_centre.x),
|
||||
(d2_point) D2_FIX4(arc_centre.y),
|
||||
@ -132,6 +177,7 @@ void lv_draw_dave2d_arc(lv_draw_dave2d_unit_t * u, const lv_draw_arc_dsc_t * dsc
|
||||
(d2_width) D2_FIX4(dsc->width / 2), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Execute render operations
|
||||
|
@ -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,6 +295,17 @@ static void dave2d_draw_border_complex(lv_draw_dave2d_unit_t * u, const lv_area_
|
||||
|
||||
if(blend_w > 0) {
|
||||
if(left_side || top_side) {
|
||||
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),
|
||||
@ -309,10 +319,23 @@ static void dave2d_draw_border_complex(lv_draw_dave2d_unit_t * u, const lv_area_
|
||||
if(D2_OK != result) {
|
||||
__BKPT(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(left_side || bottom_side) {
|
||||
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),
|
||||
@ -327,6 +350,7 @@ static void dave2d_draw_border_complex(lv_draw_dave2d_unit_t * u, const lv_area_
|
||||
__BKPT(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Right corners*/
|
||||
blend_area.x1 = LV_MAX(draw_area.x1, blend_area.x2 + 1); /*To not overlap with the left side*/
|
||||
@ -337,6 +361,19 @@ static void dave2d_draw_border_complex(lv_draw_dave2d_unit_t * u, const lv_area_
|
||||
|
||||
if(blend_w > 0) {
|
||||
if(right_side || top_side) {
|
||||
|
||||
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),
|
||||
@ -350,10 +387,23 @@ static void dave2d_draw_border_complex(lv_draw_dave2d_unit_t * u, const lv_area_
|
||||
if(D2_OK != result) {
|
||||
__BKPT(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(right_side || bottom_side) {
|
||||
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),
|
||||
@ -370,6 +420,7 @@ static void dave2d_draw_border_complex(lv_draw_dave2d_unit_t * u, const lv_area_
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Execute render operations
|
||||
|
@ -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,9 +166,23 @@ 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;
|
||||
|
||||
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),
|
||||
@ -182,10 +196,20 @@ void lv_draw_dave2d_fill(lv_draw_dave2d_unit_t * u, const lv_draw_fill_dsc_t * d
|
||||
if(D2_OK != result) {
|
||||
__BKPT(0);
|
||||
}
|
||||
}
|
||||
|
||||
arc_centre.x = coordinates.x2 - radius;
|
||||
arc_centre.y = coordinates.y1 + radius;
|
||||
|
||||
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),
|
||||
@ -199,10 +223,20 @@ void lv_draw_dave2d_fill(lv_draw_dave2d_unit_t * u, const lv_draw_fill_dsc_t * d
|
||||
if(D2_OK != result) {
|
||||
__BKPT(0);
|
||||
}
|
||||
}
|
||||
|
||||
arc_centre.x = coordinates.x2 - radius;
|
||||
arc_centre.y = coordinates.y2 - radius;
|
||||
|
||||
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),
|
||||
@ -216,10 +250,20 @@ void lv_draw_dave2d_fill(lv_draw_dave2d_unit_t * u, const lv_draw_fill_dsc_t * d
|
||||
if(D2_OK != result) {
|
||||
__BKPT(0);
|
||||
}
|
||||
}
|
||||
|
||||
arc_centre.x = coordinates.x1 + radius;
|
||||
arc_centre.y = coordinates.y2 - radius;
|
||||
|
||||
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),
|
||||
@ -233,6 +277,11 @@ void lv_draw_dave2d_fill(lv_draw_dave2d_unit_t * u, const lv_draw_fill_dsc_t * d
|
||||
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),
|
||||
|
@ -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);
|
||||
@ -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
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user