Debian Codegraph @

lvgl/src/draw/nxp/pxp/lv_draw_pxp_layer.c

raw symbols SCIP
1 /**
2 * @file lv_draw_pxp_layer.c
3 *
4 */
5
6 /**
7 * Copyright 2023-2024 NXP
8 *
9 * SPDX-License-Identifier: MIT
10 */
11
12 /*********************
13 * INCLUDES
14 *********************/
15
16 #include "lv_draw_pxp.h"
17
18 #if LV_USE_PXP
19 #if LV_USE_DRAW_PXP
20
21 #include "../../../stdlib/lv_string.h"
22 #if LV_USE_PARALLEL_DRAW_DEBUG
23 #include "../../../core/lv_global.h"
24 #endif
25
26 /*********************
27 * DEFINES
28 *********************/
29
30 /**********************
31 * TYPEDEFS
32 **********************/
33
34 /**********************
35 * STATIC PROTOTYPES
36 **********************/
37
38 /**********************
39 * STATIC VARIABLES
40 **********************/
41
42 #if LV_USE_PARALLEL_DRAW_DEBUG
43 #define _draw_info LV_GLOBAL_DEFAULT()->draw_info
44 #endif
45
46 /**********************
47 * MACROS
48 **********************/
49
50 /**********************
51 * GLOBAL FUNCTIONS
52 **********************/
53
54 void lv_draw_pxp_layer(lv_draw_task_t * t)
55 {
56 lv_draw_image_dsc_t * draw_dsc = t->draw_dsc;
57
58 lv_layer_t * layer_to_draw = (lv_layer_t *)draw_dsc->src;
59 const lv_draw_buf_t * draw_buf = layer_to_draw->draw_buf;
60
61 /* It can happen that nothing was draw on a layer and therefore its buffer is not allocated.
62 * In this case just return.
63 */
64 if(draw_buf == NULL)
65 return;
66
67 const lv_area_t area_to_draw = {
68 .x1 = 0,
69 .y1 = 0,
70 .x2 = draw_buf->header.w - 1,
71 .y2 = draw_buf->header.h - 1
72 };
73 lv_draw_buf_invalidate_cache(draw_buf, &area_to_draw);
74
75 lv_draw_image_dsc_t new_draw_dsc = *draw_dsc;
76 new_draw_dsc.src = draw_buf;
77 t->draw_dsc = &new_draw_dsc;
78 lv_draw_pxp_img(t);
79 t->draw_dsc = draw_dsc;
80
81 #if LV_USE_LAYER_DEBUG || LV_USE_PARALLEL_DRAW_DEBUG
82 const lv_area_t * coords = &t->area;
83 lv_area_t area_rot;
84 lv_area_copy(&area_rot, coords);
85 if(draw_dsc->rotation || draw_dsc->scale_x != LV_SCALE_NONE || draw_dsc->scale_y != LV_SCALE_NONE) {
86 int32_t w = lv_area_get_width(coords);
87 int32_t h = lv_area_get_height(coords);
88
89 lv_image_buf_get_transformed_area(&area_rot, w, h, draw_dsc->rotation, draw_dsc->scale_x, draw_dsc->scale_y,
90 &draw_dsc->pivot);
91
92 area_rot.x1 += coords->x1;
93 area_rot.y1 += coords->y1;
94 area_rot.x2 += coords->x1;
95 area_rot.y2 += coords->y1;
96 }
97 lv_area_t draw_area;
98 if(!lv_area_intersect(&draw_area, &area_rot, &t->clip_area)) return;
99 #endif
100
101 #if LV_USE_LAYER_DEBUG
102 lv_draw_fill_dsc_t fill_dsc;
103 lv_draw_fill_dsc_init(&fill_dsc);
104 fill_dsc.color = lv_color_hex(layer_to_draw->color_format == LV_COLOR_FORMAT_ARGB8888 ? 0xff0000 : 0x00ff00);
105 fill_dsc.opa = LV_OPA_20;
106 lv_draw_sw_fill(t, &fill_dsc, &area_rot);
107
108 lv_draw_border_dsc_t border_dsc;
109 lv_draw_border_dsc_init(&border_dsc);
110 border_dsc.color = fill_dsc.color;
111 border_dsc.opa = LV_OPA_60;
112 border_dsc.width = 2;
113 lv_draw_sw_border(t, &border_dsc, &area_rot);
114
115 #endif
116
117 #if LV_USE_PARALLEL_DRAW_DEBUG
118 int32_t idx = t->draw_unit->idx;
119
120 lv_draw_fill_dsc_t fill_dsc;
121 lv_draw_rect_dsc_init(&fill_dsc);
122 fill_dsc.color = lv_palette_main(idx % LV_PALETTE_LAST);
123 fill_dsc.opa = LV_OPA_10;
124 lv_draw_sw_fill(t, &fill_dsc, &area_rot);
125
126 lv_draw_border_dsc_t border_dsc;
127 lv_draw_border_dsc_init(&border_dsc);
128 border_dsc.color = lv_palette_main(idx % LV_PALETTE_LAST);
129 border_dsc.opa = LV_OPA_100;
130 border_dsc.width = 2;
131 lv_draw_sw_border(t, &border_dsc, &area_rot);
132
133 lv_point_t txt_size;
134 lv_text_get_size_attributes(&txt_size, "W", LV_FONT_DEFAULT, 0, 0, 100, LV_TEXT_FLAG_NONE);
135
136 lv_area_t txt_area;
137 txt_area.x1 = draw_area.x1;
138 txt_area.x2 = draw_area.x1 + txt_size.x - 1;
139 txt_area.y2 = draw_area.y2;
140 txt_area.y1 = draw_area.y2 - txt_size.y + 1;
141
142 lv_draw_fill_dsc_init(&fill_dsc);
143 fill_dsc.color = lv_color_black();
144 lv_draw_sw_fill(t, &fill_dsc, &txt_area);
145
146 char buf[8];
147 lv_snprintf(buf, sizeof(buf), "%d", idx);
148 lv_draw_label_dsc_t label_dsc;
149 lv_draw_label_dsc_init(&label_dsc);
150 label_dsc.color = lv_color_white();
151 label_dsc.text = buf;
152 lv_draw_sw_label(t, &label_dsc, &txt_area);
153 #endif
154 }
155
156 #endif /*LV_USE_DRAW_PXP*/
157 #endif /*LV_USE_PXP*/