1 /**
2  * @file lv_draw_vg_lite_layer.c
3  *
4  */
5 
6 /*********************
7  *      INCLUDES
8  *********************/
9 
10 #include "lv_draw_vg_lite.h"
11 
12 #if LV_USE_DRAW_VG_LITE
13 
14 #include "lv_vg_lite_utils.h"
15 #include "lv_draw_vg_lite_type.h"
16 
17 /*********************
18  *      DEFINES
19  *********************/
20 
21 /**********************
22  *      TYPEDEFS
23  **********************/
24 
25 /**********************
26  *  STATIC PROTOTYPES
27  **********************/
28 
29 /**********************
30  *  STATIC VARIABLES
31  **********************/
32 
33 /**********************
34  *      MACROS
35  **********************/
36 
37 /**********************
38  *   GLOBAL FUNCTIONS
39  **********************/
40 
lv_draw_vg_lite_layer(lv_draw_unit_t * draw_unit,const lv_draw_image_dsc_t * draw_dsc,const lv_area_t * coords)41 void lv_draw_vg_lite_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
42                            const lv_area_t * coords)
43 {
44     lv_layer_t * layer = (lv_layer_t *)draw_dsc->src;
45     struct _lv_draw_vg_lite_unit_t * u = (struct _lv_draw_vg_lite_unit_t *)draw_unit;
46 
47     /*It can happen that nothing was draw on a layer and therefore its buffer is not allocated.
48      *In this case just return. */
49     if(layer->draw_buf == NULL)
50         return;
51 
52     LV_PROFILER_DRAW_BEGIN;
53 
54     /* The GPU output should already be premultiplied RGB */
55     if(!lv_draw_buf_has_flag(layer->draw_buf, LV_IMAGE_FLAGS_PREMULTIPLIED)) {
56         LV_LOG_WARN("Non-premultiplied layer buffer for GPU to draw.");
57     }
58 
59     lv_draw_image_dsc_t new_draw_dsc = *draw_dsc;
60     new_draw_dsc.src = layer->draw_buf;
61     lv_draw_vg_lite_img(draw_unit, &new_draw_dsc, coords, true);
62 
63     /* Wait for the GPU drawing to complete here,
64      * otherwise it may cause the drawing to fail. */
65     lv_vg_lite_finish(u);
66 
67     LV_PROFILER_DRAW_END;
68 }
69 
70 /**********************
71  *   STATIC FUNCTIONS
72  **********************/
73 
74 #endif /*LV_USE_DRAW_VG_LITE*/
75