1 /** 2 * @file lv_wayland_smm.h 3 * 4 */ 5 #ifndef LV_WAYLAND_SMM_H 6 #define LV_WAYLAND_SMM_H 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 #ifndef _WIN32 13 14 /********************* 15 * INCLUDES 16 *********************/ 17 18 #include "../../display/lv_display.h" 19 #include LV_STDDEF_INCLUDE 20 #include LV_STDBOOL_INCLUDE 21 22 #if LV_USE_WAYLAND 23 24 /********************* 25 * DEFINES 26 *********************/ 27 28 #define SMM_FD_NAME "lvgl-wayland" 29 #define SMM_POOL_TAGS (1) 30 #define SMM_BUFFER_TAGS (2) 31 #define SMM_GROUP_TAGS (1) 32 33 /********************** 34 * TYPEDEFS 35 **********************/ 36 37 typedef void smm_pool_t; 38 typedef void smm_buffer_t; 39 typedef void smm_group_t; 40 41 /********************** 42 * GLOBAL PROTOTYPES 43 **********************/ 44 45 struct smm_events { 46 void * ctx; 47 bool (*new_pool)(void * ctx, smm_pool_t * pool); 48 void (*expand_pool)(void * ctx, smm_pool_t * pool); 49 void (*free_pool)(void * ctx, smm_pool_t * pool); 50 bool (*new_buffer)(void * ctx, smm_buffer_t * buf); 51 bool (*init_buffer)(void * ctx, smm_buffer_t * buf); 52 void (*free_buffer)(void * ctx, smm_buffer_t * buf); 53 }; 54 55 struct smm_pool_properties { 56 void * tag[SMM_POOL_TAGS]; 57 size_t size; 58 int fd; 59 }; 60 61 struct smm_buffer_properties { 62 void * tag[SMM_BUFFER_TAGS]; 63 smm_group_t * const group; 64 smm_pool_t * const pool; 65 size_t offset; 66 }; 67 68 struct smm_group_properties { 69 void * tag[SMM_GROUP_TAGS]; 70 }; 71 72 void smm_init(struct smm_events * evs); 73 void smm_setctx(void * ctx); 74 void smm_deinit(void); 75 smm_group_t * smm_create(void); 76 void smm_resize(smm_group_t * grp, size_t sz); 77 void smm_destroy(smm_group_t * grp); 78 smm_buffer_t * smm_acquire(smm_group_t * grp); 79 void * smm_map(smm_buffer_t * buf); 80 void smm_release(smm_buffer_t * buf); 81 smm_buffer_t * smm_latest(smm_group_t * grp); 82 smm_buffer_t * smm_next(smm_buffer_t * buf); 83 84 /********************** 85 * MACROS 86 **********************/ 87 88 #define SMM_POOL_PROPERTIES(p) ((const struct smm_pool_properties *)(p)) 89 #define SMM_BUFFER_PROPERTIES(b) ((const struct smm_buffer_properties *)(b)) 90 #define SMM_GROUP_PROPERTIES(g) ((const struct smm_group_properties *)(g)) 91 #define SMM_TAG(o, n, v) \ 92 do { \ 93 void **smm_tag = (void **)((char *)o + (n * sizeof(void *))); \ 94 *smm_tag = (v); \ 95 } while(0) 96 97 98 #endif /* LV_USE_WAYLAND */ 99 #endif /* _WIN32 */ 100 101 #ifdef __cplusplus 102 } /*extern "C"*/ 103 #endif 104 105 #endif /* LV_WAYLAND_SMM_H */ 106