| 1 |
#include "lv_draw_dave2d.h" |
| 2 |
#if LV_USE_DRAW_DAVE2D |
| 3 |
|
| 4 |
#include "../../../misc/lv_area_private.h" |
| 5 |
|
| 6 |
void lv_draw_dave2d_line(lv_draw_task_t * t, const lv_draw_line_dsc_t * dsc) |
| 7 |
{ |
| 8 |
|
| 9 |
lv_area_t clip_line; |
| 10 |
d2_u32 mode; |
| 11 |
lv_area_t buffer_area; |
| 12 |
lv_value_precise_t p1_x; |
| 13 |
lv_value_precise_t p1_y; |
| 14 |
lv_value_precise_t p2_x; |
| 15 |
lv_value_precise_t p2_y; |
| 16 |
int32_t x; |
| 17 |
int32_t y; |
| 18 |
lv_draw_dave2d_unit_t * u = (lv_draw_dave2d_unit_t *)t->draw_unit; |
| 19 |
|
| 20 |
clip_line.x1 = LV_MIN(dsc->p1.x, dsc->p2.x) - dsc->width / 2; |
| 21 |
clip_line.x2 = LV_MAX(dsc->p1.x, dsc->p2.x) + dsc->width / 2; |
| 22 |
clip_line.y1 = LV_MIN(dsc->p1.y, dsc->p2.y) - dsc->width / 2; |
| 23 |
clip_line.y2 = LV_MAX(dsc->p1.y, dsc->p2.y) + dsc->width / 2; |
| 24 |
|
| 25 |
bool is_common; |
| 26 |
is_common = lv_area_intersect(&clip_line, &clip_line, &t->clip_area); |
| 27 |
if(!is_common) return; |
| 28 |
|
| 29 |
#if LV_USE_OS |
| 30 |
lv_result_t status; |
| 31 |
status = lv_mutex_lock(u->pd2Mutex); |
| 32 |
LV_ASSERT(LV_RESULT_OK == status); |
| 33 |
#endif |
| 34 |
|
| 35 |
d2_u8 current_alpha = d2_getalpha(u->d2_handle); |
| 36 |
|
| 37 |
buffer_area = t->target_layer->buf_area; |
| 38 |
p1_x = dsc->p1.x - buffer_area.x1; |
| 39 |
p1_y = dsc->p1.y - buffer_area.y1; |
| 40 |
p2_x = dsc->p2.x - buffer_area.x1; |
| 41 |
p2_y = dsc->p2.y - buffer_area.y1; |
| 42 |
|
| 43 |
x = 0 - t->target_layer->buf_area.x1; |
| 44 |
y = 0 - t->target_layer->buf_area.y1; |
| 45 |
|
| 46 |
lv_area_move(&clip_line, x, y); |
| 47 |
lv_area_move(&buffer_area, x, y); |
| 48 |
|
| 49 |
bool dashed = dsc->dash_gap && dsc->dash_width; |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
d2_framebuffer_from_layer(u->d2_handle, t->target_layer); |
| 55 |
|
| 56 |
d2_setcolor(u->d2_handle, 0, lv_draw_dave2d_lv_colour_to_d2_colour(dsc->color)); |
| 57 |
|
| 58 |
d2_setalpha(u->d2_handle, dsc->opa); |
| 59 |
|
| 60 |
d2_cliprect(u->d2_handle, clip_line.x1, clip_line.y1, clip_line.x2, clip_line.y2); |
| 61 |
|
| 62 |
if((dsc->round_end == 1) || (dsc->round_start == 1)) { |
| 63 |
mode = d2_lc_round; |
| 64 |
} |
| 65 |
else { |
| 66 |
mode = d2_lc_butt; |
| 67 |
} |
| 68 |
|
| 69 |
d2_setlinecap(u->d2_handle, mode); |
| 70 |
|
| 71 |
d2_renderline(u->d2_handle, D2_FIX4(p1_x), D2_FIX4(p1_y), D2_FIX4(p2_x), |
| 72 |
D2_FIX4(p2_y), D2_FIX4(dsc->width), d2_le_exclude_none); |
| 73 |
|
| 74 |
d2_setalpha(u->d2_handle, current_alpha); |
| 75 |
#if LV_USE_OS |
| 76 |
status = lv_mutex_unlock(u->pd2Mutex); |
| 77 |
LV_ASSERT(LV_RESULT_OK == status); |
| 78 |
#endif |
| 79 |
} |
| 80 |
|
| 81 |
#endif |