fix(color): drawFilledCircle EM crash when using LibGUI widget (#4959)
This commit is contained in:
+51
-12
@@ -485,7 +485,35 @@ void BitmapBuffer::drawFilledTriangle(coord_t x0, coord_t y0, coord_t x1,
|
|||||||
void BitmapBuffer::drawFilledCircle(coord_t x, coord_t y, coord_t radius,
|
void BitmapBuffer::drawFilledCircle(coord_t x, coord_t y, coord_t radius,
|
||||||
LcdFlags flags)
|
LcdFlags flags)
|
||||||
{
|
{
|
||||||
drawCircle(x, y, radius, flags, radius);
|
APPLY_OFFSET();
|
||||||
|
|
||||||
|
lv_draw_rect_dsc_t rect_dsc;
|
||||||
|
lv_draw_rect_dsc_init(&rect_dsc);
|
||||||
|
rect_dsc.bg_opa = LV_OPA_COVER;
|
||||||
|
rect_dsc.bg_color = makeLvColor(flags);
|
||||||
|
rect_dsc.radius = LV_RADIUS_CIRCLE;
|
||||||
|
|
||||||
|
if (draw_ctx) {
|
||||||
|
x += draw_ctx->buf_area->x1;
|
||||||
|
y += draw_ctx->buf_area->y1;
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_area_t coords = {
|
||||||
|
(lv_coord_t)(x - radius),
|
||||||
|
(lv_coord_t)(y - radius),
|
||||||
|
(lv_coord_t)(x + radius),
|
||||||
|
(lv_coord_t)(y + radius),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (draw_ctx) {
|
||||||
|
lv_draw_rect(draw_ctx, &rect_dsc, &coords);
|
||||||
|
}
|
||||||
|
#if !defined(BOOT)
|
||||||
|
else if (canvas) {
|
||||||
|
lv_canvas_draw_rect(canvas, coords.x1, coords.y1, coords.x2 - coords.x1 + 1,
|
||||||
|
coords.y2 - coords.y1 + 1, &rect_dsc);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapBuffer::drawCircle(coord_t x, coord_t y, coord_t radius,
|
void BitmapBuffer::drawCircle(coord_t x, coord_t y, coord_t radius,
|
||||||
@@ -493,22 +521,33 @@ void BitmapBuffer::drawCircle(coord_t x, coord_t y, coord_t radius,
|
|||||||
{
|
{
|
||||||
APPLY_OFFSET();
|
APPLY_OFFSET();
|
||||||
|
|
||||||
lv_draw_arc_dsc_t arc_dsc;
|
lv_draw_rect_dsc_t rect_dsc;
|
||||||
lv_draw_arc_dsc_init(&arc_dsc);
|
lv_draw_rect_dsc_init(&rect_dsc);
|
||||||
|
rect_dsc.bg_opa = LV_OPA_TRANSP;
|
||||||
arc_dsc.width = thickness;
|
rect_dsc.border_opa = LV_OPA_COVER;
|
||||||
arc_dsc.opa = LV_OPA_COVER;
|
rect_dsc.border_color = makeLvColor(flags);
|
||||||
arc_dsc.color = makeLvColor(flags);
|
rect_dsc.border_width = thickness;
|
||||||
|
rect_dsc.radius = LV_RADIUS_CIRCLE;
|
||||||
|
|
||||||
if (draw_ctx) {
|
if (draw_ctx) {
|
||||||
lv_point_t p;
|
x += draw_ctx->buf_area->x1;
|
||||||
p.x = x + draw_ctx->buf_area->x1;
|
y += draw_ctx->buf_area->y1;
|
||||||
p.y = y + draw_ctx->buf_area->y1;
|
}
|
||||||
lv_draw_arc(draw_ctx, &arc_dsc, &p, radius, 0, 360);
|
|
||||||
|
lv_area_t coords = {
|
||||||
|
(lv_coord_t)(x - radius),
|
||||||
|
(lv_coord_t)(y - radius),
|
||||||
|
(lv_coord_t)(x + radius),
|
||||||
|
(lv_coord_t)(y + radius),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (draw_ctx) {
|
||||||
|
lv_draw_rect(draw_ctx, &rect_dsc, &coords);
|
||||||
}
|
}
|
||||||
#if !defined(BOOT)
|
#if !defined(BOOT)
|
||||||
else if (canvas) {
|
else if (canvas) {
|
||||||
lv_canvas_draw_arc(canvas, x, y, radius, 0, 360, &arc_dsc);
|
lv_canvas_draw_rect(canvas, coords.x1, coords.y1, coords.x2 - coords.x1 + 1,
|
||||||
|
coords.y2 - coords.y1 + 1, &rect_dsc);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user