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.c (3326B)

      1 /**
      2  * @file lv_draw_sdl.c
      3  *
      4  */
      5 
      6 /*********************
      7  *      INCLUDES
      8  *********************/
      9 
     10 
     11 #include "../../lv_conf_internal.h"
     12 
     13 #if LV_USE_GPU_SDL
     14 
     15 #include "lv_draw_sdl.h"
     16 #include "lv_draw_sdl_utils.h"
     17 #include "lv_draw_sdl_texture_cache.h"
     18 
     19 /*********************
     20  *      DEFINES
     21  *********************/
     22 void lv_draw_sdl_draw_rect(lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords);
     23 
     24 lv_res_t lv_draw_sdl_img_core(lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * draw_dsc,
     25                               const lv_area_t * coords, const void * src);
     26 
     27 void lv_draw_sdl_draw_letter(lv_draw_ctx_t * draw_ctx, const lv_draw_label_dsc_t * dsc,  const lv_point_t * pos_p,
     28                              uint32_t letter);
     29 
     30 void lv_draw_sdl_draw_line(lv_draw_ctx_t * draw_ctx, const lv_draw_line_dsc_t * dsc, const lv_point_t * point1,
     31                            const lv_point_t * point2);
     32 
     33 void lv_draw_sdl_draw_arc(lv_draw_ctx_t * draw_ctx, const lv_draw_arc_dsc_t * dsc, const lv_point_t * center,
     34                           uint16_t radius, uint16_t start_angle, uint16_t end_angle);
     35 
     36 void lv_draw_sdl_polygon(lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * draw_dsc, const lv_point_t * points,
     37                          uint16_t point_cnt);
     38 
     39 void lv_draw_sdl_draw_bg(lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords);
     40 
     41 /**********************
     42  *      TYPEDEFS
     43  **********************/
     44 
     45 /**********************
     46  *  STATIC PROTOTYPES
     47  **********************/
     48 
     49 /**********************
     50  *  STATIC VARIABLES
     51  **********************/
     52 
     53 /**********************
     54  *      MACROS
     55  **********************/
     56 
     57 /**********************
     58  *   GLOBAL FUNCTIONS
     59  **********************/
     60 
     61 void lv_draw_sdl_init_ctx(lv_disp_drv_t * disp_drv, lv_draw_ctx_t * draw_ctx)
     62 {
     63     _lv_draw_sdl_utils_init();
     64     lv_memset_00(draw_ctx, sizeof(lv_draw_sdl_ctx_t));
     65     draw_ctx->draw_rect = lv_draw_sdl_draw_rect;
     66     draw_ctx->draw_img = lv_draw_sdl_img_core;
     67     draw_ctx->draw_letter = lv_draw_sdl_draw_letter;
     68     draw_ctx->draw_line = lv_draw_sdl_draw_line;
     69     draw_ctx->draw_arc = lv_draw_sdl_draw_arc;
     70     draw_ctx->draw_polygon = lv_draw_sdl_polygon;
     71     draw_ctx->draw_bg = lv_draw_sdl_draw_bg;
     72     lv_draw_sdl_ctx_t * draw_ctx_sdl = (lv_draw_sdl_ctx_t *) draw_ctx;
     73     draw_ctx_sdl->renderer = ((lv_draw_sdl_drv_param_t *) disp_drv->user_data)->renderer;
     74     draw_ctx_sdl->internals = lv_mem_alloc(sizeof(lv_draw_sdl_context_internals_t));
     75     lv_memset_00(draw_ctx_sdl->internals, sizeof(lv_draw_sdl_context_internals_t));
     76     lv_draw_sdl_texture_cache_init(draw_ctx_sdl);
     77 }
     78 
     79 void lv_draw_sdl_deinit_ctx(lv_disp_drv_t * disp_drv, lv_draw_ctx_t * draw_ctx)
     80 {
     81     lv_draw_sdl_ctx_t * draw_ctx_sdl = (lv_draw_sdl_ctx_t *) draw_ctx;
     82     lv_draw_sdl_texture_cache_deinit(draw_ctx_sdl);
     83     lv_mem_free(draw_ctx_sdl->internals);
     84     _lv_draw_sdl_utils_deinit();
     85 }
     86 
     87 SDL_Texture * lv_draw_sdl_create_screen_texture(SDL_Renderer * renderer, lv_coord_t hor, lv_coord_t ver)
     88 {
     89     SDL_Texture * texture = SDL_CreateTexture(renderer, LV_DRAW_SDL_TEXTURE_FORMAT, SDL_TEXTUREACCESS_TARGET, hor, ver);
     90     SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
     91     return texture;
     92 }
     93 
     94 /**********************
     95  *   STATIC FUNCTIONS
     96  **********************/
     97 
     98 #endif /*LV_USE_GPU_SDL*/