| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include "../../../misc/lv_area_private.h" |
| 10 |
#include "lv_draw_sw_blend_private.h" |
| 11 |
#include "../../lv_draw_private.h" |
| 12 |
#include "../lv_draw_sw.h" |
| 13 |
#if LV_DRAW_SW_SUPPORT_A8 |
| 14 |
#include "lv_draw_sw_blend_to_a8.h" |
| 15 |
#endif |
| 16 |
#if LV_DRAW_SW_SUPPORT_L8 |
| 17 |
#include "lv_draw_sw_blend_to_l8.h" |
| 18 |
#endif |
| 19 |
#if LV_DRAW_SW_SUPPORT_AL88 |
| 20 |
#include "lv_draw_sw_blend_to_al88.h" |
| 21 |
#endif |
| 22 |
#if LV_DRAW_SW_SUPPORT_RGB565 |
| 23 |
#include "lv_draw_sw_blend_to_rgb565.h" |
| 24 |
#endif |
| 25 |
#if LV_DRAW_SW_SUPPORT_RGB565_SWAPPED |
| 26 |
#include "lv_draw_sw_blend_to_rgb565_swapped.h" |
| 27 |
#endif |
| 28 |
#if LV_DRAW_SW_SUPPORT_ARGB8888 |
| 29 |
#include "lv_draw_sw_blend_to_argb8888.h" |
| 30 |
#endif |
| 31 |
#if LV_DRAW_SW_SUPPORT_ARGB8888_PREMULTIPLIED |
| 32 |
#include "lv_draw_sw_blend_to_argb8888_premultiplied.h" |
| 33 |
#endif |
| 34 |
#if LV_DRAW_SW_SUPPORT_RGB888 || LV_DRAW_SW_SUPPORT_XRGB8888 |
| 35 |
#include "lv_draw_sw_blend_to_rgb888.h" |
| 36 |
#endif |
| 37 |
#if LV_DRAW_SW_SUPPORT_I1 |
| 38 |
#include "lv_draw_sw_blend_to_i1.h" |
| 39 |
#endif |
| 40 |
#if LV_USE_DRAW_SW |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
static inline void lv_draw_sw_blend_color(lv_color_format_t layer_cf, |
| 55 |
lv_draw_sw_blend_fill_dsc_t * fill_dsc); |
| 56 |
|
| 57 |
static inline void lv_draw_sw_blend_image(lv_color_format_t layer_cf, |
| 58 |
lv_draw_sw_blend_image_dsc_t * image_dsc); |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
void lv_draw_sw_blend(lv_draw_task_t * t, const lv_draw_sw_blend_dsc_t * blend_dsc) |
| 74 |
{ |
| 75 |
|
| 76 |
if(blend_dsc->opa <= LV_OPA_MIN) return; |
| 77 |
if(blend_dsc->mask_buf && blend_dsc->mask_res == LV_DRAW_SW_MASK_RES_TRANSP) return; |
| 78 |
|
| 79 |
lv_area_t blend_area; |
| 80 |
if(!lv_area_intersect(&blend_area, blend_dsc->blend_area, &t->clip_area)) return; |
| 81 |
|
| 82 |
LV_PROFILER_DRAW_BEGIN; |
| 83 |
lv_layer_t * layer = t->target_layer; |
| 84 |
uint32_t layer_stride_byte = layer->draw_buf->header.stride; |
| 85 |
|
| 86 |
lv_draw_sw_blend_handler_t handler = lv_draw_sw_get_blend_handler(layer->color_format); |
| 87 |
if(handler) { |
| 88 |
handler(t, blend_dsc); |
| 89 |
LV_PROFILER_DRAW_END; |
| 90 |
return; |
| 91 |
} |
| 92 |
|
| 93 |
if(blend_dsc->src_buf == NULL) { |
| 94 |
lv_draw_sw_blend_fill_dsc_t fill_dsc; |
| 95 |
fill_dsc.dest_w = lv_area_get_width(&blend_area); |
| 96 |
fill_dsc.dest_h = lv_area_get_height(&blend_area); |
| 97 |
fill_dsc.dest_stride = layer_stride_byte; |
| 98 |
fill_dsc.opa = blend_dsc->opa; |
| 99 |
fill_dsc.color = blend_dsc->color; |
| 100 |
fill_dsc.mask_stride = 0; |
| 101 |
|
| 102 |
if(blend_dsc->mask_buf == NULL) fill_dsc.mask_buf = NULL; |
| 103 |
else if(blend_dsc->mask_res == LV_DRAW_SW_MASK_RES_FULL_COVER) fill_dsc.mask_buf = NULL; |
| 104 |
else fill_dsc.mask_buf = blend_dsc->mask_buf; |
| 105 |
|
| 106 |
|
| 107 |
fill_dsc.relative_area = blend_area; |
| 108 |
lv_area_move(&fill_dsc.relative_area, -layer->buf_area.x1, -layer->buf_area.y1); |
| 109 |
fill_dsc.dest_buf = lv_draw_layer_go_to_xy(layer, blend_area.x1 - layer->buf_area.x1, |
| 110 |
blend_area.y1 - layer->buf_area.y1); |
| 111 |
if(fill_dsc.mask_buf) { |
| 112 |
fill_dsc.mask_stride = blend_dsc->mask_stride == 0 ? lv_area_get_width(blend_dsc->mask_area) : blend_dsc->mask_stride; |
| 113 |
fill_dsc.mask_buf += fill_dsc.mask_stride * (blend_area.y1 - blend_dsc->mask_area->y1) + |
| 114 |
(blend_area.x1 - blend_dsc->mask_area->x1); |
| 115 |
} |
| 116 |
|
| 117 |
lv_draw_sw_blend_color(layer->color_format, &fill_dsc); |
| 118 |
} |
| 119 |
else { |
| 120 |
if(!lv_area_intersect(&blend_area, &blend_area, blend_dsc->src_area)) { |
| 121 |
LV_PROFILER_DRAW_END; |
| 122 |
return; |
| 123 |
} |
| 124 |
|
| 125 |
if(blend_dsc->mask_area && !lv_area_intersect(&blend_area, &blend_area, blend_dsc->mask_area)) { |
| 126 |
LV_PROFILER_DRAW_END; |
| 127 |
return; |
| 128 |
} |
| 129 |
|
| 130 |
lv_draw_sw_blend_image_dsc_t image_dsc; |
| 131 |
image_dsc.dest_w = lv_area_get_width(&blend_area); |
| 132 |
image_dsc.dest_h = lv_area_get_height(&blend_area); |
| 133 |
image_dsc.dest_stride = layer_stride_byte; |
| 134 |
|
| 135 |
image_dsc.opa = blend_dsc->opa; |
| 136 |
image_dsc.blend_mode = blend_dsc->blend_mode; |
| 137 |
image_dsc.src_stride = blend_dsc->src_stride; |
| 138 |
image_dsc.src_color_format = blend_dsc->src_color_format; |
| 139 |
|
| 140 |
const uint8_t * src_buf = blend_dsc->src_buf; |
| 141 |
uint32_t src_px_size = lv_color_format_get_bpp(blend_dsc->src_color_format); |
| 142 |
src_buf += image_dsc.src_stride * (blend_area.y1 - blend_dsc->src_area->y1); |
| 143 |
src_buf += ((blend_area.x1 - blend_dsc->src_area->x1) * src_px_size) >> 3; |
| 144 |
image_dsc.src_buf = src_buf; |
| 145 |
image_dsc.mask_stride = 0; |
| 146 |
|
| 147 |
if(blend_dsc->mask_buf == NULL) image_dsc.mask_buf = NULL; |
| 148 |
else if(blend_dsc->mask_res == LV_DRAW_SW_MASK_RES_FULL_COVER) image_dsc.mask_buf = NULL; |
| 149 |
else image_dsc.mask_buf = blend_dsc->mask_buf; |
| 150 |
|
| 151 |
if(image_dsc.mask_buf) { |
| 152 |
LV_ASSERT_NULL(blend_dsc->mask_area); |
| 153 |
image_dsc.mask_buf = blend_dsc->mask_buf; |
| 154 |
image_dsc.mask_stride = blend_dsc->mask_stride ? blend_dsc->mask_stride : lv_area_get_width(blend_dsc->mask_area); |
| 155 |
image_dsc.mask_buf += image_dsc.mask_stride * (blend_area.y1 - blend_dsc->mask_area->y1) + |
| 156 |
(blend_area.x1 - blend_dsc->mask_area->x1); |
| 157 |
} |
| 158 |
|
| 159 |
image_dsc.relative_area = blend_area; |
| 160 |
lv_area_move(&image_dsc.relative_area, -layer->buf_area.x1, -layer->buf_area.y1); |
| 161 |
|
| 162 |
image_dsc.src_area = *blend_dsc->src_area; |
| 163 |
lv_area_move(&image_dsc.src_area, -layer->buf_area.x1, -layer->buf_area.y1); |
| 164 |
|
| 165 |
image_dsc.dest_buf = lv_draw_layer_go_to_xy(layer, blend_area.x1 - layer->buf_area.x1, |
| 166 |
blend_area.y1 - layer->buf_area.y1); |
| 167 |
|
| 168 |
lv_draw_sw_blend_image(layer->color_format, &image_dsc); |
| 169 |
} |
| 170 |
LV_PROFILER_DRAW_END; |
| 171 |
} |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
static inline void LV_ATTRIBUTE_FAST_MEM lv_draw_sw_blend_color(lv_color_format_t layer_cf, |
| 178 |
lv_draw_sw_blend_fill_dsc_t * fill_dsc) |
| 179 |
{ |
| 180 |
switch(layer_cf) { |
| 181 |
#if LV_DRAW_SW_SUPPORT_RGB565 |
| 182 |
case LV_COLOR_FORMAT_RGB565: |
| 183 |
lv_draw_sw_blend_color_to_rgb565(fill_dsc); |
| 184 |
break; |
| 185 |
#endif |
| 186 |
#if LV_DRAW_SW_SUPPORT_RGB565_SWAPPED |
| 187 |
case LV_COLOR_FORMAT_RGB565_SWAPPED: |
| 188 |
lv_draw_sw_blend_color_to_rgb565_swapped(fill_dsc); |
| 189 |
break; |
| 190 |
#endif |
| 191 |
#if LV_DRAW_SW_SUPPORT_ARGB8888 |
| 192 |
case LV_COLOR_FORMAT_ARGB8888: |
| 193 |
lv_draw_sw_blend_color_to_argb8888(fill_dsc); |
| 194 |
break; |
| 195 |
#endif |
| 196 |
#if LV_DRAW_SW_SUPPORT_RGB888 |
| 197 |
case LV_COLOR_FORMAT_RGB888: |
| 198 |
lv_draw_sw_blend_color_to_rgb888(fill_dsc, 3); |
| 199 |
break; |
| 200 |
#endif |
| 201 |
#if LV_DRAW_SW_SUPPORT_XRGB8888 |
| 202 |
case LV_COLOR_FORMAT_XRGB8888: |
| 203 |
lv_draw_sw_blend_color_to_rgb888(fill_dsc, 4); |
| 204 |
break; |
| 205 |
#endif |
| 206 |
#if LV_DRAW_SW_SUPPORT_ARGB8888_PREMULTIPLIED |
| 207 |
case LV_COLOR_FORMAT_ARGB8888_PREMULTIPLIED: |
| 208 |
lv_draw_sw_blend_color_to_argb8888_premultiplied(fill_dsc); |
| 209 |
break; |
| 210 |
#endif |
| 211 |
#if LV_DRAW_SW_SUPPORT_A8 |
| 212 |
case LV_COLOR_FORMAT_A8: |
| 213 |
lv_draw_sw_blend_color_to_a8(fill_dsc); |
| 214 |
break; |
| 215 |
#endif |
| 216 |
#if LV_DRAW_SW_SUPPORT_L8 |
| 217 |
case LV_COLOR_FORMAT_L8: |
| 218 |
lv_draw_sw_blend_color_to_l8(fill_dsc); |
| 219 |
break; |
| 220 |
#endif |
| 221 |
#if LV_DRAW_SW_SUPPORT_AL88 |
| 222 |
case LV_COLOR_FORMAT_AL88: |
| 223 |
lv_draw_sw_blend_color_to_al88(fill_dsc); |
| 224 |
break; |
| 225 |
#endif |
| 226 |
#if LV_DRAW_SW_SUPPORT_I1 |
| 227 |
case LV_COLOR_FORMAT_I1: |
| 228 |
lv_draw_sw_blend_color_to_i1(fill_dsc); |
| 229 |
break; |
| 230 |
#endif |
| 231 |
default: |
| 232 |
break; |
| 233 |
} |
| 234 |
} |
| 235 |
|
| 236 |
static inline void LV_ATTRIBUTE_FAST_MEM lv_draw_sw_blend_image(lv_color_format_t layer_cf, |
| 237 |
lv_draw_sw_blend_image_dsc_t * image_dsc) |
| 238 |
{ |
| 239 |
switch(layer_cf) { |
| 240 |
#if LV_DRAW_SW_SUPPORT_RGB565 |
| 241 |
case LV_COLOR_FORMAT_RGB565: |
| 242 |
case LV_COLOR_FORMAT_RGB565A8: |
| 243 |
lv_draw_sw_blend_image_to_rgb565(image_dsc); |
| 244 |
break; |
| 245 |
#endif |
| 246 |
#if LV_DRAW_SW_SUPPORT_RGB565_SWAPPED |
| 247 |
case LV_COLOR_FORMAT_RGB565_SWAPPED: |
| 248 |
lv_draw_sw_blend_image_to_rgb565_swapped(image_dsc); |
| 249 |
break; |
| 250 |
#endif |
| 251 |
#if LV_DRAW_SW_SUPPORT_ARGB8888 |
| 252 |
case LV_COLOR_FORMAT_ARGB8888: |
| 253 |
lv_draw_sw_blend_image_to_argb8888(image_dsc); |
| 254 |
break; |
| 255 |
#endif |
| 256 |
#if LV_DRAW_SW_SUPPORT_RGB888 |
| 257 |
case LV_COLOR_FORMAT_RGB888: |
| 258 |
lv_draw_sw_blend_image_to_rgb888(image_dsc, 3); |
| 259 |
break; |
| 260 |
#endif |
| 261 |
#if LV_DRAW_SW_SUPPORT_XRGB8888 |
| 262 |
case LV_COLOR_FORMAT_XRGB8888: |
| 263 |
lv_draw_sw_blend_image_to_rgb888(image_dsc, 4); |
| 264 |
break; |
| 265 |
#endif |
| 266 |
#if LV_DRAW_SW_SUPPORT_ARGB8888_PREMULTIPLIED |
| 267 |
case LV_COLOR_FORMAT_ARGB8888_PREMULTIPLIED: |
| 268 |
lv_draw_sw_blend_image_to_argb8888_premultiplied(image_dsc); |
| 269 |
break; |
| 270 |
#endif |
| 271 |
#if LV_DRAW_SW_SUPPORT_A8 |
| 272 |
case LV_COLOR_FORMAT_A8: |
| 273 |
lv_draw_sw_blend_image_to_a8(image_dsc); |
| 274 |
break; |
| 275 |
#endif |
| 276 |
#if LV_DRAW_SW_SUPPORT_L8 |
| 277 |
case LV_COLOR_FORMAT_L8: |
| 278 |
lv_draw_sw_blend_image_to_l8(image_dsc); |
| 279 |
break; |
| 280 |
#endif |
| 281 |
#if LV_DRAW_SW_SUPPORT_AL88 |
| 282 |
case LV_COLOR_FORMAT_AL88: |
| 283 |
lv_draw_sw_blend_image_to_al88(image_dsc); |
| 284 |
break; |
| 285 |
#endif |
| 286 |
#if LV_DRAW_SW_SUPPORT_I1 |
| 287 |
case LV_COLOR_FORMAT_I1: |
| 288 |
lv_draw_sw_blend_image_to_i1(image_dsc); |
| 289 |
break; |
| 290 |
#endif |
| 291 |
default: |
| 292 |
break; |
| 293 |
} |
| 294 |
} |
| 295 |
|
| 296 |
#endif |