From b1430b9e60c51b326fd6eaf1b001916b3b8471f5 Mon Sep 17 00:00:00 2001 From: Ihor Dutchak Date: Thu, 27 Feb 2020 02:55:09 +0200 Subject: Fix AVFVideoWindowControl/AVFVideoWidget content flick on resize When AVPlayerLayer as a backend for AVFVideoWindowControl being resized, macOS adds animation that interferes with Qt resize routines. Disabling animation fixes visual flicks. Task-number: QTBUG-82542 Change-Id: I20a5699431369bcc2da8719b8c4a0151273f9973 Reviewed-by: VaL Doroshchuk --- src/plugins/avfoundation/mediaplayer/avfvideowidget.mm | 17 +++++++++++------ .../avfoundation/mediaplayer/avfvideowindowcontrol.mm | 9 +++++---- 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src/plugins/avfoundation') diff --git a/src/plugins/avfoundation/mediaplayer/avfvideowidget.mm b/src/plugins/avfoundation/mediaplayer/avfvideowidget.mm index be349710c..0987342b4 100644 --- a/src/plugins/avfoundation/mediaplayer/avfvideowidget.mm +++ b/src/plugins/avfoundation/mediaplayer/avfvideowidget.mm @@ -38,12 +38,9 @@ ****************************************************************************/ #include "avfvideowidget.h" -#include -#include -#include -#include -#include +#import +#import #if defined(Q_OS_MACOS) #import @@ -51,6 +48,11 @@ #import #endif +#include +#include +#include +#include + QT_USE_NAMESPACE AVFVideoWidget::AVFVideoWidget(QWidget *parent) @@ -178,5 +180,8 @@ void AVFVideoWidget::updateAspectRatio() void AVFVideoWidget::updatePlayerLayerBounds(const QSize &size) { - m_playerLayer.bounds = CGRectMake(0.0f, 0.0f, (float)size.width(), (float)size.height()); + [CATransaction begin]; + [CATransaction setDisableActions: YES]; // disable animation/flicks + m_playerLayer.bounds = QRect(QPoint(0, 0), size).toCGRect(); + [CATransaction commit]; } diff --git a/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.mm b/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.mm index 7fa41fdc2..d61129ec9 100644 --- a/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.mm +++ b/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.mm @@ -40,6 +40,7 @@ #include "avfvideowindowcontrol.h" #include +#import #if QT_HAS_INCLUDE() #include @@ -244,10 +245,10 @@ void AVFVideoWindowControl::updateAspectRatio() void AVFVideoWindowControl::updatePlayerLayerBounds() { if (m_playerLayer) { - CGRect newBounds = CGRectMake(0, 0, - m_displayRect.width(), m_displayRect.height()); - m_playerLayer.bounds = newBounds; - m_playerLayer.position = CGPointMake(m_displayRect.x(), m_displayRect.y()); + [CATransaction begin]; + [CATransaction setDisableActions: YES]; // disable animation/flicks + m_playerLayer.frame = m_displayRect.toCGRect(); + [CATransaction commit]; } } -- cgit v1.2.3