Skip to content

Commit e5f954a

Browse files
committed
Core (LV::Video): Clean up blit_overlay_alphasrc().
1 parent 3096732 commit e5f954a

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

libvisual/libvisual/private/lv_video_blit.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,30 +61,33 @@ namespace LV {
6161
}
6262
}
6363

64-
void VideoBlit::blit_overlay_alphasrc (Video* dest, Video* src)
64+
void VideoBlit::blit_overlay_alphasrc (Video* dst, Video* src)
6565
{
66-
auto destbuf = static_cast<uint8_t*> (dest->get_pixels ());
67-
auto srcbuf = static_cast<uint8_t const*> (src->get_pixels ());
68-
6966
if (visual_cpu_has_mmx ()) {
70-
blit_overlay_alphasrc_mmx (dest, src);
67+
blit_overlay_alphasrc_mmx (dst, src);
7168
return;
7269
}
7370

71+
auto dst_pixel_row_ptr = static_cast<uint8_t*> (dst->get_pixels ());
72+
auto src_pixel_row_ptr = static_cast<uint8_t const*> (src->get_pixels ());
73+
7474
for (int y = 0; y < src->m_impl->height; y++) {
75+
auto dst_pixel = dst_pixel_row_ptr;
76+
auto src_pixel = src_pixel_row_ptr;
77+
7578
for (int x = 0; x < src->m_impl->width; x++) {
76-
uint8_t alpha = srcbuf[3];
79+
uint8_t const src_alpha = src_pixel[3];
7780

78-
destbuf[0] = (alpha * (srcbuf[0] - destbuf[0]) >> 8) + destbuf[0];
79-
destbuf[1] = (alpha * (srcbuf[1] - destbuf[1]) >> 8) + destbuf[1];
80-
destbuf[2] = (alpha * (srcbuf[2] - destbuf[2]) >> 8) + destbuf[2];
81+
dst_pixel[0] = (src_alpha * (src_pixel[0] - dst_pixel[0]) >> 8) + dst_pixel[0];
82+
dst_pixel[1] = (src_alpha * (src_pixel[1] - dst_pixel[1]) >> 8) + dst_pixel[1];
83+
dst_pixel[2] = (src_alpha * (src_pixel[2] - dst_pixel[2]) >> 8) + dst_pixel[2];
8184

82-
destbuf += dest->m_impl->bpp;
83-
srcbuf += src->m_impl->bpp;
85+
src_pixel += 4;
86+
dst_pixel += 4;
8487
}
8588

86-
destbuf += dest->m_impl->pitch - (dest->m_impl->width * dest->m_impl->bpp);
87-
srcbuf += src->m_impl->pitch - (src->m_impl->width * src->m_impl->bpp);
89+
dst_pixel_row_ptr += dst->m_impl->pitch;
90+
src_pixel_row_ptr += src->m_impl->pitch;
8891
}
8992
}
9093

0 commit comments

Comments
 (0)