1 /**
2  * @file lv_draw_sw.c
3  *
4  */
5 
6 /*********************
7  *      INCLUDES
8  *********************/
9 #include "../lv_draw.h"
10 #include "lv_draw_sw.h"
11 
12 /*********************
13  *      DEFINES
14  *********************/
15 
16 /**********************
17  *      TYPEDEFS
18  **********************/
19 
20 /**********************
21  *  STATIC PROTOTYPES
22  **********************/
23 
24 /**********************
25  *  GLOBAL PROTOTYPES
26  **********************/
27 
28 /**********************
29  *  STATIC VARIABLES
30  **********************/
31 
32 /**********************
33  *      MACROS
34  **********************/
35 
36 /**********************
37  *   GLOBAL FUNCTIONS
38  **********************/
39 
lv_draw_sw_init_ctx(lv_disp_drv_t * drv,lv_draw_ctx_t * draw_ctx)40 void lv_draw_sw_init_ctx(lv_disp_drv_t * drv, lv_draw_ctx_t * draw_ctx)
41 {
42     LV_UNUSED(drv);
43 
44     lv_draw_sw_ctx_t * draw_sw_ctx = (lv_draw_sw_ctx_t *) draw_ctx;
45     lv_memset_00(draw_sw_ctx, sizeof(lv_draw_sw_ctx_t));
46 
47     draw_sw_ctx->base_draw.draw_arc = lv_draw_sw_arc;
48     draw_sw_ctx->base_draw.draw_rect = lv_draw_sw_rect;
49     draw_sw_ctx->base_draw.draw_bg = lv_draw_sw_bg;
50     draw_sw_ctx->base_draw.draw_letter = lv_draw_sw_letter;
51     draw_sw_ctx->base_draw.draw_img_decoded = lv_draw_sw_img_decoded;
52     draw_sw_ctx->base_draw.draw_line = lv_draw_sw_line;
53     draw_sw_ctx->base_draw.draw_polygon = lv_draw_sw_polygon;
54 #if LV_DRAW_COMPLEX
55     draw_sw_ctx->base_draw.draw_transform = lv_draw_sw_transform;
56 #endif
57     draw_sw_ctx->base_draw.wait_for_finish = lv_draw_sw_wait_for_finish;
58     draw_sw_ctx->base_draw.buffer_copy = lv_draw_sw_buffer_copy;
59     draw_sw_ctx->base_draw.layer_init = lv_draw_sw_layer_create;
60     draw_sw_ctx->base_draw.layer_adjust = lv_draw_sw_layer_adjust;
61     draw_sw_ctx->base_draw.layer_blend = lv_draw_sw_layer_blend;
62     draw_sw_ctx->base_draw.layer_destroy = lv_draw_sw_layer_destroy;
63     draw_sw_ctx->blend = lv_draw_sw_blend_basic;
64     draw_ctx->layer_instance_size = sizeof(lv_draw_sw_layer_ctx_t);
65 }
66 
lv_draw_sw_deinit_ctx(lv_disp_drv_t * drv,lv_draw_ctx_t * draw_ctx)67 void lv_draw_sw_deinit_ctx(lv_disp_drv_t * drv, lv_draw_ctx_t * draw_ctx)
68 {
69     LV_UNUSED(drv);
70 
71     lv_draw_sw_ctx_t * draw_sw_ctx = (lv_draw_sw_ctx_t *) draw_ctx;
72     lv_memset_00(draw_sw_ctx, sizeof(lv_draw_sw_ctx_t));
73 }
74 
lv_draw_sw_wait_for_finish(lv_draw_ctx_t * draw_ctx)75 void lv_draw_sw_wait_for_finish(lv_draw_ctx_t * draw_ctx)
76 {
77     LV_UNUSED(draw_ctx);
78     /*Nothing to wait for*/
79 }
80 
lv_draw_sw_buffer_copy(lv_draw_ctx_t * draw_ctx,void * dest_buf,lv_coord_t dest_stride,const lv_area_t * dest_area,void * src_buf,lv_coord_t src_stride,const lv_area_t * src_area)81 void lv_draw_sw_buffer_copy(lv_draw_ctx_t * draw_ctx,
82                             void * dest_buf, lv_coord_t dest_stride, const lv_area_t * dest_area,
83                             void * src_buf, lv_coord_t src_stride, const lv_area_t * src_area)
84 {
85     LV_UNUSED(draw_ctx);
86 
87     lv_color_t * dest_bufc =  dest_buf;
88     lv_color_t * src_bufc =  src_buf;
89 
90     /*Got the first pixel of each buffer*/
91     dest_bufc += dest_stride * dest_area->y1;
92     dest_bufc += dest_area->x1;
93 
94     src_bufc += src_stride * src_area->y1;
95     src_bufc += src_area->x1;
96 
97     uint32_t line_length = lv_area_get_width(dest_area) * sizeof(lv_color_t);
98     lv_coord_t y;
99     for(y = dest_area->y1; y <= dest_area->y2; y++) {
100         lv_memcpy(dest_bufc, src_bufc, line_length);
101         dest_bufc += dest_stride;
102         src_bufc += src_stride;
103     }
104 }
105 
106 /**********************
107  *   STATIC FUNCTIONS
108  **********************/
109