Skip to content

Commit 0e95069

Browse files
committed
Core (LV::Video): Add explanatory note on calculation in blit_overlay_alphasrc() per Sebastian (hartwork)'s suggestion.
1 parent 8cbfb5c commit 0e95069

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

libvisual/libvisual/private/lv_video_blit.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ namespace LV {
7878
for (int x = 0; x < src->m_impl->width; x++) {
7979
uint8_t const src_alpha = src_pixel[3];
8080

81+
// NOTE: This is effectively
82+
// "(src_alpha / 255) * src_pixel[i] + (1 - src_alpha / 255) * dst_pixel[i]"
83+
// but with only a single multiplication, a single division by 256 rather than 255, for speed.
8184
dst_pixel[0] = (src_alpha * (src_pixel[0] - dst_pixel[0]) >> 8) + dst_pixel[0];
8285
dst_pixel[1] = (src_alpha * (src_pixel[1] - dst_pixel[1]) >> 8) + dst_pixel[1];
8386
dst_pixel[2] = (src_alpha * (src_pixel[2] - dst_pixel[2]) >> 8) + dst_pixel[2];

0 commit comments

Comments
 (0)