1 /**
2  * @file lv_draw_vglite_blend.h
3  *
4  */
5 
6 /**
7  * MIT License
8  *
9  * Copyright 2020-2023 NXP
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a copy
12  * of this software and associated documentation files (the "Software"), to deal
13  * in the Software without restriction, including without limitation the rights to
14  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
15  * the Software, and to permit persons to whom the Software is furnished to do so,
16  * subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice (including the next paragraph)
19  * shall be included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
22  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23  * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
25  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
26  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27  *
28  */
29 
30 #ifndef LV_DRAW_VGLITE_BLEND_H
31 #define LV_DRAW_VGLITE_BLEND_H
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /*********************
38  *      INCLUDES
39  *********************/
40 
41 #include "../../../lv_conf_internal.h"
42 
43 #if LV_USE_GPU_NXP_VG_LITE
44 #include "lv_vglite_utils.h"
45 
46 /*********************
47  *      DEFINES
48  *********************/
49 
50 /**
51  * Enable BLIT quality degradation workaround for RT595,
52  * recommended for screen's dimension > 352 pixels.
53  */
54 #define RT595_BLIT_WRKRND_ENABLED 1
55 
56 /* Internal compound symbol */
57 #if (defined(CPU_MIMXRT595SFFOB) || defined(CPU_MIMXRT595SFFOB_cm33) || \
58     defined(CPU_MIMXRT595SFFOC) || defined(CPU_MIMXRT595SFFOC_cm33)) && \
59     RT595_BLIT_WRKRND_ENABLED
60 #define VG_LITE_BLIT_SPLIT_ENABLED 1
61 #else
62 #define VG_LITE_BLIT_SPLIT_ENABLED 0
63 #endif
64 
65 /**********************
66  *      TYPEDEFS
67  **********************/
68 
69 /**********************
70  * GLOBAL PROTOTYPES
71  **********************/
72 
73 /**
74  * Fill area, with optional opacity.
75  *
76  * @param[in] dest_area Area with relative coordinates of destination buffer
77  * @param[in] color Color
78  * @param[in] opa Opacity (255 = full, 128 = 50% background/50% color, 0 = no fill)
79  *
80  * @retval LV_RES_OK Fill completed
81  * @retval LV_RES_INV Error occurred (\see LV_GPU_NXP_VG_LITE_LOG_ERRORS)
82  */
83 lv_res_t lv_gpu_nxp_vglite_fill(const lv_area_t * dest_area, lv_color_t color, lv_opa_t opa);
84 
85 #if VG_LITE_BLIT_SPLIT_ENABLED
86 /**
87  * BLock Image Transfer - copy rectangular image from src_buf to dst_buf with effects.
88  * By default, image is copied directly, with optional opacity.
89  *
90  * @param[in/out] dest_buf Destination buffer
91  * @param[in] dest_area Area with relative coordinates of destination buffer
92  * @param[in] dest_stride Stride of destination buffer in pixels
93  * @param[in] src_buf Source buffer
94  * @param[in] src_area Source area with relative coordinates of source buffer
95  * @param[in] src_stride Stride of source buffer in pixels
96  * @param[in] opa Opacity
97  *
98  * @retval LV_RES_OK Transfer complete
99  * @retval LV_RES_INV Error occurred (\see LV_GPU_NXP_VG_LITE_LOG_ERRORS)
100  */
101 lv_res_t lv_gpu_nxp_vglite_blit_split(lv_color_t * dest_buf, lv_area_t * dest_area, lv_coord_t dest_stride,
102                                       const lv_color_t * src_buf, lv_area_t * src_area, lv_coord_t src_stride,
103                                       lv_opa_t opa);
104 #else
105 /**
106  * BLock Image Transfer - copy rectangular image from src_buf to dst_buf with effects.
107  * By default, image is copied directly, with optional opacity.
108  *
109  * @param[in] dest_stride Stride of destination buffer in pixels
110  * @param[in] src_buf Source buffer
111  * @param[in] src_area Source area with relative coordinates of source buffer
112  * @param[in] src_stride Stride of source buffer in pixels
113  * @param[in] opa Opacity
114  *
115  * @retval LV_RES_OK Transfer complete
116  * @retval LV_RES_INV Error occurred (\see LV_GPU_NXP_VG_LITE_LOG_ERRORS)
117  */
118 lv_res_t lv_gpu_nxp_vglite_blit(const lv_area_t * dest_area,
119                                 const lv_color_t * src_buf, const lv_area_t * src_area, lv_coord_t src_stride,
120                                 lv_opa_t opa);
121 
122 /**
123  * BLock Image Transfer - copy rectangular image from src_buf to dst_buf with transformation.
124  * By default, image is copied directly, with optional opacity.
125  *
126  * @param[in] dest_area Area with relative coordinates of destination buffer
127  * @param[in] clip_area Clip area with relative coordinates of destination buffer
128  * @param[in] src_buf Source buffer
129  * @param[in] src_area Source area with relative coordinates of source buffer
130  * @param[in] src_stride Stride of source buffer in pixels
131  * @param[in] dsc Image descriptor
132  *
133  * @retval LV_RES_OK Transfer complete
134  * @retval LV_RES_INV Error occurred (\see LV_GPU_NXP_VG_LITE_LOG_ERRORS)
135  */
136 lv_res_t lv_gpu_nxp_vglite_blit_transform(const lv_area_t * dest_area, const lv_area_t * clip_area,
137                                           const lv_color_t * src_buf, const lv_area_t * src_area, lv_coord_t src_stride,
138                                           const lv_draw_img_dsc_t * dsc);
139 
140 #endif /*VG_LITE_BLIT_SPLIT_ENABLED*/
141 
142 /**
143  * BLock Image Transfer - simple copy of rectangular image from source to destination.
144  *
145  * @param[in] dest_buf Destination buffer
146  * @param[in] dest_area Area with relative coordinates of destination buffer
147  * @param[in] dest_stride Stride of destination buffer in pixels
148  * @param[in] src_buf Source buffer
149  * @param[in] src_area Source area with relative coordinates of source buffer
150  * @param[in] src_stride Stride of source buffer in pixels
151  *
152  * @retval LV_RES_OK Transfer complete
153  * @retval LV_RES_INV Error occurred (\see LV_GPU_NXP_VG_LITE_LOG_ERRORS)
154  */
155 lv_res_t lv_gpu_nxp_vglite_buffer_copy(lv_color_t * dest_buf, const lv_area_t * dest_area, lv_coord_t dest_stride,
156                                        const lv_color_t * src_buf, const lv_area_t * src_area, lv_coord_t src_stride);
157 
158 /**********************
159  *      MACROS
160  **********************/
161 
162 #endif /*LV_USE_GPU_NXP_VG_LITE*/
163 
164 #ifdef __cplusplus
165 } /*extern "C"*/
166 #endif
167 
168 #endif /*LV_DRAW_VGLITE_BLEND_H*/
169