diff options
author | Ihor Dutchak <ihor.youw@gmail.com> | 2020-02-27 02:55:09 +0200 |
---|---|---|
committer | Ihor Dutchak <ihor.youw@gmail.com> | 2020-03-03 13:43:51 +0200 |
commit | b1430b9e60c51b326fd6eaf1b001916b3b8471f5 (patch) | |
tree | a76df4032ca063c7db6b5c35d21a29e5a11e6523 /src/plugins/avfoundation | |
parent | a7f0ba8c2d64dcb942069a6fd5ea17166b3b7a6d (diff) |
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 <valentyn.doroshchuk@qt.io>
Diffstat (limited to 'src/plugins/avfoundation')
-rw-r--r-- | src/plugins/avfoundation/mediaplayer/avfvideowidget.mm | 17 | ||||
-rw-r--r-- | src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.mm | 9 |
2 files changed, 16 insertions, 10 deletions
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 <QtCore/QDebug> -#include <AVFoundation/AVFoundation.h> -#include <QtGui/QResizeEvent> -#include <QtGui/QPaintEvent> -#include <QtGui/QPainter> +#import <AVFoundation/AVFoundation.h> +#import <QuartzCore/CATransaction.h> #if defined(Q_OS_MACOS) #import <AppKit/AppKit.h> @@ -51,6 +48,11 @@ #import <UIKit/UIKit.h> #endif +#include <QtCore/QDebug> +#include <QtGui/QResizeEvent> +#include <QtGui/QPaintEvent> +#include <QtGui/QPainter> + 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 <AVFoundation/AVFoundation.h> +#import <QuartzCore/CATransaction.h> #if QT_HAS_INCLUDE(<AppKit/AppKit.h>) #include <AppKit/AppKit.h> @@ -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]; } } |