Debian Codegraph @

lvgl/src/draw/nxp/g2d/lv_draw_buf_g2d.c

raw symbols SCIP
1 /**
2 * @file lv_draw_buf_g2d.c
3 *
4 */
5
6 /**
7 * Copyright 2024 NXP
8 *
9 * SPDX-License-Identifier: MIT
10 */
11
12 /*********************
13 * INCLUDES
14 *********************/
15
16 #include "lv_draw_g2d.h"
17
18 #if LV_USE_G2D
19 #if LV_USE_DRAW_G2D || LV_USE_ROTATE_G2D
20 #include "../../lv_draw_buf_private.h"
21 #include "g2d.h"
22 #include "lv_g2d_buf_map.h"
23 #include "lv_g2d_utils.h"
24
25
26 /*********************
27 * DEFINES
28 *********************/
29
30 /**********************
31 * TYPEDEFS
32 **********************/
33
34 /**********************
35 * STATIC PROTOTYPES
36 **********************/
37
38 static void * _buf_malloc(size_t size_bytes, lv_color_format_t color_format);
39
40 static void _buf_free(void * buf);
41
42 static void _invalidate_cache(const lv_draw_buf_t * draw_buf, const lv_area_t * area);
43
44 /**********************
45 * STATIC VARIABLES
46 **********************/
47
48 /**********************
49 * MACROS
50 **********************/
51
52 /**********************
53 * GLOBAL FUNCTIONS
54 **********************/
55
56 void lv_draw_buf_g2d_init_handlers(void)
57 {
58 lv_draw_buf_handlers_t * handlers = lv_draw_buf_get_handlers();
59
60 handlers->buf_malloc_cb = _buf_malloc;
61 handlers->buf_free_cb = _buf_free;
62 handlers->invalidate_cache_cb = _invalidate_cache;
63 }
64
65 /**********************
66 * STATIC FUNCTIONS
67 **********************/
68
69 static void * _buf_malloc(size_t size_bytes, lv_color_format_t color_format)
70 {
71 LV_UNUSED(color_format);
72
73 size_bytes += LV_DRAW_BUF_ALIGN - 1;
74 struct g2d_buf * buf = g2d_alloc(size_bytes, 1);
75 G2D_ASSERT_MSG(buf, "Failed to alloc buffer.");
76 g2d_insert_buf_map(buf->buf_vaddr, buf);
77 return buf->buf_vaddr;
78 }
79
80 static void _buf_free(void * buf)
81 {
82 g2d_free_item(buf);
83 }
84
85 static void _invalidate_cache(const lv_draw_buf_t * draw_buf, const lv_area_t * area)
86 {
87 LV_UNUSED(area);
88 struct g2d_buf * buf = g2d_search_buf_map(draw_buf->data);
89 G2D_ASSERT_MSG(buf, "Failed to find buffer in map.");
90 g2d_cache_op(buf, G2D_CACHE_FLUSH);
91 }
92
93 #endif /*LV_USE_DRAW_G2D || LV_USE_ROTATE_G2D*/
94 #endif /*LV_USE_G2D*/