| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 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 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 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 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 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 |
|
| 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 |
| 94 |
#endif |