Diff
Modified: trunk/Source/WebCore/ChangeLog (202251 => 202252)
--- trunk/Source/WebCore/ChangeLog 2016-06-20 23:24:59 UTC (rev 202251)
+++ trunk/Source/WebCore/ChangeLog 2016-06-20 23:26:52 UTC (rev 202252)
@@ -1,3 +1,36 @@
+2016-06-20 Jeremy Jones <jere...@apple.com>
+
+ Adopt commitPriority to get rid of the 2 AVPL solution for PiP
+ https://bugs.webkit.org/show_bug.cgi?id=158949
+ rdar://problem/26867866
+
+ Reviewed by Simon Fraser.
+
+ No new tests because there is no behavior change. This reverts changes from
+ https://bugs.webkit.org/show_bug.cgi?id=158148 and instead uses -[CAContext commitPriority:]
+ to prevent flicker when moving a layer between contexts.
+ commitPriority allows the layer to be added to the destination context before it is
+ removed from the source context.
+
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: remove m_secondaryVideoLayer.
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: ditto
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenGravity): ditto.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::syncTextTrackBounds): ditto.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::destroyVideoLayer): ditto.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::updateVideoLayerGravity): ditto.
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: ditto
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::addDisplayLayer): ditto
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: ditto
+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::createPreviewLayers):ditto
+ * platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h: ditto
+ * platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm: ditto
+ (WebCore::VideoFullscreenLayerManager::setVideoLayer): ditto
+ (WebCore::VideoFullscreenLayerManager::setVideoFullscreenLayer): ditto and adopt commitPriority.
+ (WebCore::VideoFullscreenLayerManager::setVideoFullscreenFrame): ditto
+ (WebCore::VideoFullscreenLayerManager::setVideoLayers): Deleted.
+ (WebCore::VideoFullscreenLayerManager::didDestroyVideoLayer): remove m_secondaryVideoLayer.
+ * platform/spi/cocoa/QuartzCoreSPI.h: Add commitPriority.
+
2016-06-20 Zalan Bujtas <za...@apple.com>
Set the end position on the placeholder BidiRun properly.
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (202251 => 202252)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2016-06-20 23:24:59 UTC (rev 202251)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2016-06-20 23:26:52 UTC (rev 202252)
@@ -340,7 +340,6 @@
RetainPtr<AVPlayer> m_avPlayer;
RetainPtr<AVPlayerItem> m_avPlayerItem;
RetainPtr<AVPlayerLayer> m_videoLayer;
- RetainPtr<AVPlayerLayer> m_secondaryVideoLayer;
#if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
std::unique_ptr<VideoFullscreenLayerManager> m_videoFullscreenLayerManager;
MediaPlayer::VideoGravity m_videoFullscreenGravity;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (202251 => 202252)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2016-06-20 23:24:59 UTC (rev 202251)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2016-06-20 23:26:52 UTC (rev 202252)
@@ -734,25 +734,17 @@
[m_videoLayer setPlayer:m_avPlayer.get()];
[m_videoLayer setBackgroundColor:cachedCGColor(Color::black)];
-#if PLATFORM(MAC)
- m_secondaryVideoLayer = adoptNS([allocAVPlayerLayerInstance() init]);
- [m_secondaryVideoLayer setPlayer:m_avPlayer.get()];
- [m_secondaryVideoLayer setBackgroundColor:cachedCGColor(Color::black)];
-#endif
-
#ifndef NDEBUG
[m_videoLayer setName:@"MediaPlayerPrivate AVPlayerLayer"];
- [m_secondaryVideoLayer setName:@"MediaPlayerPrivate AVPlayerLayer secondary"];
#endif
[m_videoLayer addObserver:m_objcObserver.get() forKeyPath:@"readyForDisplay" options:NSKeyValueObservingOptionNew context:(void *)MediaPlayerAVFoundationObservationContextAVPlayerLayer];
updateVideoLayerGravity();
[m_videoLayer setContentsScale:player()->client().mediaPlayerContentsScale()];
- [m_secondaryVideoLayer setContentsScale:player()->client().mediaPlayerContentsScale()];
IntSize defaultSize = snappedIntRect(player()->client().mediaPlayerContentBoxRect()).size();
LOG(Media, "MediaPlayerPrivateAVFoundationObjC::createVideoLayer(%p) - returning %p", this, m_videoLayer.get());
#if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
- m_videoFullscreenLayerManager->setVideoLayers(m_videoLayer.get(), m_secondaryVideoLayer.get(), defaultSize);
+ m_videoFullscreenLayerManager->setVideoLayer(m_videoLayer.get(), defaultSize);
#if PLATFORM(IOS)
if ([m_videoLayer respondsToSelector:@selector(setPIPModeEnabled:)])
@@ -760,7 +752,6 @@
#endif
#else
[m_videoLayer setFrame:CGRectMake(0, 0, defaultSize.width(), defaultSize.height())];
- [m_secondaryVideoLayer setFrame:CGRectMake(0, 0, defaultSize.width(), defaultSize.height())];
#endif
}
@@ -773,7 +764,6 @@
[m_videoLayer removeObserver:m_objcObserver.get() forKeyPath:@"readyForDisplay"];
[m_videoLayer setPlayer:nil];
- [m_secondaryVideoLayer setPlayer:nil];
#if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
m_videoFullscreenLayerManager->didDestroyVideoLayer();
@@ -780,7 +770,6 @@
#endif
m_videoLayer = nil;
- m_secondaryVideoLayer = nil;
}
MediaTime MediaPlayerPrivateAVFoundationObjC::getStartDate() const
@@ -1231,8 +1220,7 @@
{
m_videoFullscreenGravity = gravity;
- auto activeLayer = m_secondaryVideoLayer.get() ?: m_videoLayer.get();
- if (!activeLayer)
+ if (!m_videoLayer)
return;
NSString *videoGravity = AVLayerVideoGravityResizeAspect;
@@ -1245,10 +1233,10 @@
else
ASSERT_NOT_REACHED();
- if ([activeLayer videoGravity] == videoGravity)
+ if ([m_videoLayer videoGravity] == videoGravity)
return;
- [activeLayer setVideoGravity:videoGravity];
+ [m_videoLayer setVideoGravity:videoGravity];
syncTextTrackBounds();
}
@@ -1901,7 +1889,6 @@
[CATransaction setDisableActions:YES];
NSString* gravity = shouldMaintainAspectRatio() ? AVLayerVideoGravityResizeAspect : AVLayerVideoGravityResize;
[m_videoLayer.get() setVideoGravity:gravity];
- [m_secondaryVideoLayer.get() setVideoGravity:gravity];
[CATransaction commit];
}
@@ -2197,8 +2184,7 @@
return;
FloatRect videoFullscreenFrame = m_videoFullscreenLayerManager->videoFullscreenFrame();
- auto activeLayer = m_secondaryVideoLayer.get() ?: m_videoLayer.get();
- CGRect textFrame = activeLayer ? [activeLayer videoRect] : CGRectMake(0, 0, videoFullscreenFrame.width(), videoFullscreenFrame.height());
+ CGRect textFrame = m_videoLayer ? [m_videoLayer videoRect] : CGRectMake(0, 0, videoFullscreenFrame.width(), videoFullscreenFrame.height());
[m_textTrackRepresentationLayer setFrame:textFrame];
#endif
}
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (202251 => 202252)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2016-06-20 23:24:59 UTC (rev 202251)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2016-06-20 23:26:52 UTC (rev 202252)
@@ -755,7 +755,7 @@
m_player->firstVideoFrameAvailable();
#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
- m_videoFullscreenLayerManager->setVideoLayers(m_sampleBufferDisplayLayer.get(), nil, snappedIntRect(m_player->client().mediaPlayerContentBoxRect()).size());
+ m_videoFullscreenLayerManager->setVideoLayer(m_sampleBufferDisplayLayer.get(), snappedIntRect(m_player->client().mediaPlayerContentBoxRect()).size());
#endif
}
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (202251 => 202252)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm 2016-06-20 23:24:59 UTC (rev 202251)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm 2016-06-20 23:26:52 UTC (rev 202252)
@@ -404,7 +404,7 @@
m_videoBackgroundLayer.get().name = @"MediaPlayerPrivateMediaStreamAVFObjC preview background layer";
#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
- m_videoFullscreenLayerManager->setVideoLayers(m_videoBackgroundLayer.get(), nil, snappedIntRect(m_player->client().mediaPlayerContentBoxRect()).size());
+ m_videoFullscreenLayerManager->setVideoLayer(m_videoBackgroundLayer.get(), snappedIntRect(m_player->client().mediaPlayerContentBoxRect()).size());
#endif
}
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h (202251 => 202252)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h 2016-06-20 23:24:59 UTC (rev 202251)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h 2016-06-20 23:26:52 UTC (rev 202252)
@@ -44,7 +44,7 @@
PlatformLayer *videoInlineLayer() const { return m_videoInlineLayer.get(); }
PlatformLayer *videoFullscreenLayer() const { return m_videoFullscreenLayer.get(); }
FloatRect videoFullscreenFrame() const { return m_videoFullscreenFrame; }
- void setVideoLayers(PlatformLayer *, PlatformLayer *, IntSize contentSize);
+ void setVideoLayer(PlatformLayer *, IntSize contentSize);
void setVideoFullscreenLayer(PlatformLayer *, std::function<void()> completionHandler);
void setVideoFullscreenFrame(FloatRect);
void didDestroyVideoLayer();
@@ -55,7 +55,6 @@
RetainPtr<PlatformLayer> m_videoInlineLayer;
RetainPtr<PlatformLayer> m_videoFullscreenLayer;
RetainPtr<PlatformLayer> m_videoLayer;
- RetainPtr<PlatformLayer> m_secondaryVideoLayer;
FloatRect m_videoFullscreenFrame;
};
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm (202251 => 202252)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm 2016-06-20 23:24:59 UTC (rev 202251)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm 2016-06-20 23:26:52 UTC (rev 202252)
@@ -66,13 +66,11 @@
{
}
-void VideoFullscreenLayerManager::setVideoLayers(PlatformLayer *videoLayer, PlatformLayer *secondaryVideoLayer, IntSize contentSize)
+void VideoFullscreenLayerManager::setVideoLayer(PlatformLayer *videoLayer, IntSize contentSize)
{
m_videoLayer = videoLayer;
- m_secondaryVideoLayer = secondaryVideoLayer;
[m_videoLayer web_disableAllActions];
- [m_secondaryVideoLayer web_disableAllActions];
m_videoInlineLayer = adoptNS([[WebVideoContainerLayer alloc] init]);
#ifndef NDEBUG
[m_videoInlineLayer setName:@"WebVideoContainerLayer"];
@@ -79,14 +77,11 @@
#endif
[m_videoInlineLayer setFrame:CGRectMake(0, 0, contentSize.width(), contentSize.height())];
if (m_videoFullscreenLayer) {
- [m_videoLayer removeFromSuperlayer];
- PlatformLayer *activeLayer = secondaryVideoLayer ? secondaryVideoLayer : videoLayer;
- [activeLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())];
- [m_videoFullscreenLayer insertSublayer:activeLayer atIndex:0];
+ [m_videoLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())];
+ [m_videoFullscreenLayer insertSublayer:m_videoLayer.get() atIndex:0];
} else {
[m_videoInlineLayer insertSublayer:m_videoLayer.get() atIndex:0];
[m_videoLayer setFrame:m_videoInlineLayer.get().bounds];
- [m_secondaryVideoLayer removeFromSuperlayer];
}
}
@@ -102,47 +97,24 @@
[CATransaction begin];
[CATransaction setDisableActions:YES];
- if (m_secondaryVideoLayer && m_videoLayer) {
- if (m_videoFullscreenLayer) {
- [m_videoFullscreenLayer insertSublayer:m_secondaryVideoLayer.get() atIndex:0];
- [m_secondaryVideoLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())];
- } else if (m_videoInlineLayer) {
- [m_videoLayer setFrame:[m_videoInlineLayer bounds]];
- [m_videoInlineLayer insertSublayer:m_videoLayer.get() atIndex:0];
- }
+ if (m_videoLayer) {
+ CAContext *oldContext = [m_videoLayer context];
- RetainPtr<PlatformLayer> fullscreenLayer = m_videoFullscreenLayer;
- RetainPtr<PlatformLayer> videoLayer = m_videoLayer;
- RetainPtr<PlatformLayer> secondaryVideoLayer = m_secondaryVideoLayer;
-
- [CATransaction setCompletionBlock:[completionHandler, fullscreenLayer, videoLayer, secondaryVideoLayer] {
- [CATransaction begin];
- [CATransaction setDisableActions:YES];
-
- if (fullscreenLayer)
- [videoLayer removeFromSuperlayer];
- else
- [secondaryVideoLayer removeFromSuperlayer];
-
- [CATransaction setCompletionBlock:[completionHandler] {
- completionHandler();
- }];
- [CATransaction commit];
- }];
- } else if (m_videoLayer) {
if (m_videoFullscreenLayer) {
[m_videoFullscreenLayer insertSublayer:m_videoLayer.get() atIndex:0];
[m_videoLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())];
} else if (m_videoInlineLayer) {
[m_videoLayer setFrame:[m_videoInlineLayer bounds]];
- [m_videoLayer removeFromSuperlayer];
[m_videoInlineLayer insertSublayer:m_videoLayer.get() atIndex:0];
} else
[m_videoLayer removeFromSuperlayer];
- CAContext *oldContext = [m_videoFullscreenLayer context];
- CAContext *newContext = [m_videoInlineLayer context];
+ CAContext *newContext = [m_videoLayer context];
if (oldContext && newContext && oldContext != newContext) {
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ [oldContext setCommitPriority:0];
+ [newContext setCommitPriority:1];
+#endif
mach_port_t fencePort = [oldContext createFencePort];
[newContext setFencePort:fencePort];
mach_port_deallocate(mach_task_self(), fencePort);
@@ -166,18 +138,15 @@
if (!m_videoFullscreenLayer)
return;
- PlatformLayer *activeLayer = m_secondaryVideoLayer.get() ? m_secondaryVideoLayer.get() : m_videoLayer.get();
- [activeLayer setFrame:CGRectMake(0, 0, videoFullscreenFrame.width(), videoFullscreenFrame.height())];
+ [m_videoLayer setFrame:CGRectMake(0, 0, videoFullscreenFrame.width(), videoFullscreenFrame.height())];
}
void VideoFullscreenLayerManager::didDestroyVideoLayer()
{
[m_videoLayer removeFromSuperlayer];
- [m_secondaryVideoLayer removeFromSuperlayer];
m_videoInlineLayer = nil;
m_videoLayer = nil;
- m_secondaryVideoLayer = nil;
}
}
Modified: trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h (202251 => 202252)
--- trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h 2016-06-20 23:24:59 UTC (rev 202251)
+++ trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h 2016-06-20 23:26:52 UTC (rev 202252)
@@ -59,6 +59,9 @@
- (mach_port_t)createFencePort;
- (void)setFencePort:(mach_port_t)port;
- (void)setFencePort:(mach_port_t)port commitHandler:(void(^)(void))block;
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+@property uint32_t commitPriority;
+#endif
#if PLATFORM(MAC)
@property BOOL colorMatchUntaggedContent;
#endif