1 #include "lv_draw_dave2d.h"
2 #if LV_USE_DRAW_DAVE2D
3
4 #include "../../../misc/lv_area_private.h"
5
lv_draw_dave2d_line(lv_draw_dave2d_unit_t * u,const lv_draw_line_dsc_t * dsc)6 void lv_draw_dave2d_line(lv_draw_dave2d_unit_t * u, 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
19 clip_line.x1 = LV_MIN(dsc->p1.x, dsc->p2.x) - dsc->width / 2;
20 clip_line.x2 = LV_MAX(dsc->p1.x, dsc->p2.x) + dsc->width / 2;
21 clip_line.y1 = LV_MIN(dsc->p1.y, dsc->p2.y) - dsc->width / 2;
22 clip_line.y2 = LV_MAX(dsc->p1.y, dsc->p2.y) + dsc->width / 2;
23
24 bool is_common;
25 is_common = lv_area_intersect(&clip_line, &clip_line, u->base_unit.clip_area);
26 if(!is_common) return;
27
28 #if LV_USE_OS
29 lv_result_t status;
30 status = lv_mutex_lock(u->pd2Mutex);
31 LV_ASSERT(LV_RESULT_OK == status);
32 #endif
33
34 buffer_area = u->base_unit.target_layer->buf_area;
35 p1_x = dsc->p1.x - buffer_area.x1;
36 p1_y = dsc->p1.y - buffer_area.y1;
37 p2_x = dsc->p2.x - buffer_area.x1;
38 p2_y = dsc->p2.y - buffer_area.y1;
39
40 x = 0 - u->base_unit.target_layer->buf_area.x1;
41 y = 0 - u->base_unit.target_layer->buf_area.y1;
42
43 lv_area_move(&clip_line, x, y);
44 lv_area_move(&buffer_area, x, y);
45
46 bool dashed = dsc->dash_gap && dsc->dash_width;
47
48 if(dashed) {
49 /* TODO */
50 LV_ASSERT(0);
51 }
52
53 #if D2_RENDER_EACH_OPERATION
54 d2_selectrenderbuffer(u->d2_handle, u->renderbuffer);
55 #endif
56 //
57 // Generate render operations
58 //
59 d2_framebuffer_from_layer(u->d2_handle, u->base_unit.target_layer);
60
61 d2_setcolor(u->d2_handle, 0, lv_draw_dave2d_lv_colour_to_d2_colour(dsc->color));
62
63 d2_setalpha(u->d2_handle, dsc->opa);
64
65 d2_cliprect(u->d2_handle, clip_line.x1, clip_line.y1, clip_line.x2, clip_line.y2);
66
67 if((dsc->round_end == 1) || (dsc->round_start == 1)) {
68 mode = d2_lc_round;
69 }
70 else {
71 mode = d2_lc_butt; // lines end directly at endpoints
72 }
73
74 d2_setlinecap(u->d2_handle, mode);
75
76 d2_renderline(u->d2_handle, D2_FIX4(p1_x), D2_FIX4(p1_y), D2_FIX4(p2_x),
77 D2_FIX4(p2_y), D2_FIX4(dsc->width), d2_le_exclude_none);
78
79 //
80 // Execute render operations
81 //
82 #if D2_RENDER_EACH_OPERATION
83 d2_executerenderbuffer(u->d2_handle, u->renderbuffer, 0);
84 d2_flushframe(u->d2_handle);
85 #endif
86
87 #if LV_USE_OS
88 status = lv_mutex_unlock(u->pd2Mutex);
89 LV_ASSERT(LV_RESULT_OK == status);
90 #endif
91 }
92
93 #endif /*LV_USE_DRAW_DAVE2D*/
94