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_bg.c (2998B)
1 /** 2 * @file lv_draw_sdl_bg.c 3 * 4 */ 5 6 /********************* 7 * INCLUDES 8 *********************/ 9 10 #include "../../lv_conf_internal.h" 11 12 #if LV_USE_GPU_SDL 13 14 #include "../lv_draw_rect.h" 15 #include "../lv_draw_img.h" 16 #include "../lv_draw_label.h" 17 #include "../lv_draw_mask.h" 18 #include "../../core/lv_refr.h" 19 #include "lv_draw_sdl_utils.h" 20 #include "lv_draw_sdl_texture_cache.h" 21 #include "lv_draw_sdl_composite.h" 22 23 /********************* 24 * DEFINES 25 *********************/ 26 27 /********************** 28 * TYPEDEFS 29 **********************/ 30 31 /********************** 32 * STATIC PROTOTYPES 33 **********************/ 34 35 static void draw_bg_color(lv_draw_sdl_ctx_t * ctx, const lv_area_t * coords, const lv_area_t * draw_area, 36 const lv_draw_rect_dsc_t * dsc); 37 38 static void draw_bg_img(lv_draw_sdl_ctx_t * ctx, const lv_area_t * coords, const lv_area_t * draw_area, 39 const lv_draw_rect_dsc_t * dsc); 40 41 /********************** 42 * STATIC VARIABLES 43 **********************/ 44 45 /********************** 46 * MACROS 47 **********************/ 48 49 /********************** 50 * GLOBAL FUNCTIONS 51 **********************/ 52 53 void lv_draw_sdl_draw_bg(lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords) 54 { 55 const lv_area_t * clip = draw_ctx->clip_area; 56 lv_draw_sdl_ctx_t * ctx = (lv_draw_sdl_ctx_t *) draw_ctx; 57 /* Coords will be translated so coords will start at (0,0) */ 58 lv_area_t t_area; 59 bool has_content = _lv_area_intersect(&t_area, coords, clip); 60 61 /* Shadows and outlines will also draw in extended area */ 62 if(has_content) { 63 if(dsc->bg_img_src) { 64 draw_bg_img(ctx, coords, &t_area, dsc); 65 } 66 else { 67 draw_bg_color(ctx, coords, &t_area, dsc); 68 } 69 } 70 71 } 72 73 /********************** 74 * STATIC FUNCTIONS 75 **********************/ 76 77 static void draw_bg_color(lv_draw_sdl_ctx_t * ctx, const lv_area_t * coords, const lv_area_t * draw_area, 78 const lv_draw_rect_dsc_t * dsc) 79 { 80 SDL_Color bg_color; 81 lv_color_to_sdl_color(&dsc->bg_color, &bg_color); 82 SDL_SetRenderDrawBlendMode(ctx->renderer, SDL_BLENDMODE_NONE); 83 SDL_SetRenderDrawColor(ctx->renderer, bg_color.r, bg_color.g, bg_color.b, dsc->bg_opa); 84 85 SDL_Rect rect; 86 lv_area_to_sdl_rect(draw_area, &rect); 87 SDL_RenderFillRect(ctx->renderer, &rect); 88 89 SDL_SetRenderDrawBlendMode(ctx->renderer, SDL_BLENDMODE_BLEND); 90 } 91 92 static void draw_bg_img(lv_draw_sdl_ctx_t * ctx, const lv_area_t * coords, const lv_area_t * draw_area, 93 const lv_draw_rect_dsc_t * dsc) 94 { 95 SDL_SetRenderDrawBlendMode(ctx->renderer, SDL_BLENDMODE_NONE); 96 SDL_SetRenderDrawColor(ctx->renderer, 0, 0, 0, 0); 97 98 SDL_Rect rect; 99 lv_area_to_sdl_rect(draw_area, &rect); 100 SDL_RenderFillRect(ctx->renderer, &rect); 101 102 SDL_SetRenderDrawBlendMode(ctx->renderer, SDL_BLENDMODE_BLEND); 103 lv_draw_rect((lv_draw_ctx_t *) ctx, dsc, coords); 104 } 105 106 #endif /*LV_USE_GPU_SDL*/