acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
lv_draw_sdl_mask.c (2362B)
1 /** 2 * @file lv_draw_sdl_mask.c 3 * 4 */ 5 6 /********************* 7 * INCLUDES 8 *********************/ 9 #include "../../lv_conf_internal.h" 10 11 #if LV_USE_GPU_SDL 12 13 #include "../../misc/lv_gc.h" 14 #include "lv_draw_sdl_mask.h" 15 #include "lv_draw_sdl_utils.h" 16 17 /********************* 18 * DEFINES 19 *********************/ 20 #ifndef HAVE_SDL_CUSTOM_BLEND_MODE 21 #define HAVE_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6)) 22 #endif 23 24 /********************** 25 * TYPEDEFS 26 **********************/ 27 28 /********************** 29 * STATIC PROTOTYPES 30 **********************/ 31 32 /********************** 33 * STATIC VARIABLES 34 **********************/ 35 36 /********************** 37 * MACROS 38 **********************/ 39 40 /********************** 41 * GLOBAL FUNCTIONS 42 **********************/ 43 44 lv_opa_t * lv_draw_sdl_mask_dump_opa(const lv_area_t * coords, const int16_t * ids, int16_t ids_count) 45 { 46 SDL_assert(coords->x2 >= coords->x1); 47 SDL_assert(coords->y2 >= coords->y1); 48 lv_coord_t w = lv_area_get_width(coords), h = lv_area_get_height(coords); 49 lv_opa_t * mask_buf = lv_mem_buf_get(w * h); 50 for(lv_coord_t y = 0; y < h; y++) { 51 lv_opa_t * line_buf = &mask_buf[y * w]; 52 lv_memset_ff(line_buf, w); 53 lv_coord_t abs_x = (lv_coord_t) coords->x1, abs_y = (lv_coord_t)(y + coords->y1), len = (lv_coord_t) w; 54 lv_draw_mask_res_t res; 55 if(ids) { 56 res = lv_draw_mask_apply_ids(line_buf, abs_x, abs_y, len, ids, ids_count); 57 } 58 else { 59 res = lv_draw_mask_apply(line_buf, abs_x, abs_y, len); 60 } 61 if(res == LV_DRAW_MASK_RES_TRANSP) { 62 lv_memset_00(line_buf, w); 63 } 64 } 65 return mask_buf; 66 } 67 68 SDL_Texture * lv_draw_sdl_mask_dump_texture(SDL_Renderer * renderer, const lv_area_t * coords, const int16_t * ids, 69 int16_t ids_count) 70 { 71 lv_coord_t w = lv_area_get_width(coords), h = lv_area_get_height(coords); 72 lv_opa_t * mask_buf = lv_draw_sdl_mask_dump_opa(coords, ids, ids_count); 73 SDL_Surface * surface = lv_sdl_create_opa_surface(mask_buf, w, h, w); 74 lv_mem_buf_release(mask_buf); 75 SDL_Texture * texture = SDL_CreateTextureFromSurface(renderer, surface); 76 SDL_FreeSurface(surface); 77 return texture; 78 } 79 80 /********************** 81 * STATIC FUNCTIONS 82 **********************/ 83 84 #endif /*LV_USE_GPU_SDL*/