From 18ee5e57fdfd126bb39091fb054d9747bc208f06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 7 Jan 2020 20:01:14 +0200 Subject: [PATCH] compositor: Alpha inputs with the SOURCE operator can be considered opaque We don't have to look at each pixel's alpha component because we will directly write it over the background. --- gst/compositor/compositor.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gst/compositor/compositor.c b/gst/compositor/compositor.c index 206855853a..44be5dd710 100644 --- a/gst/compositor/compositor.c +++ b/gst/compositor/compositor.c @@ -324,11 +324,12 @@ _pad_obscures_rectangle (GstVideoAggregator * vagg, GstVideoAggregatorPad * pad, if (!gst_video_aggregator_pad_has_current_buffer (pad)) return FALSE; - /* Can't obscure if it's transparent and if the format has an alpha component - * we'd have to inspect every pixel to know if the frame is opaque, so assume - * it doesn't obscure. As a bonus, if the rectangle is fully transparent, we - * can also obscure it if we have alpha components on the pad */ - if (!rect_transparent && + /* Can't obscure if it's transparent and if the format has an alpha + * component we'd have to inspect every pixel to know if the frame is + * opaque, so assume it doesn't obscure unless it uses the SOURCE operator. + * As a bonus, if the rectangle is fully transparent, we can also obscure it + * if we have alpha components on the pad */ + if (cpad->op != COMPOSITOR_OPERATOR_SOURCE && !rect_transparent && (cpad->alpha != 1.0 || GST_VIDEO_INFO_HAS_ALPHA (&pad->info))) return FALSE;