Changeset 201514 in webkit
- Timestamp:
- May 31, 2016, 8:58:14 AM (9 years ago)
- Location:
- branches/safari-602.1.32-branch/Source
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-602.1.32-branch/Source/WebCore/ChangeLog
r201321 r201514 1 2016-05-31 Babak Shafiei <bshafiei@apple.com> 2 3 Merge r201474. rdar://problem/24476949 4 5 2016-05-27 Jeremy Jones <jeremyj@apple.com> 6 7 Decrease flicker when changing video presentation mode. 8 https://bugs.webkit.org/show_bug.cgi?id=158148 9 rdar://problem/24476949 10 11 Reviewed by Jer Noble. 12 13 No new tests because there is no behavior change. This change is about the timing of 14 moving AVPlayerLayers between layers to prevent flicker. 15 16 1) Moving an AVPlayerLayer between CAContexts can flicker. So always keep two 17 AVPlayerLayers around and add and remove them from the inline and fullscreen contexts. 18 2) Wait to show the inline placeholder until the fullscreen video layer has been installed. 19 3) Wait to remove the fullscreen video layer until the placeholder has been removed. 20 21 * Modules/mediacontrols/MediaControlsHost.cpp: 22 (WebCore::MediaControlsHost::isVideoLayerInline): Expose isVideoLayerInline to the shadow DOM. 23 (WebCore::MediaControlsHost::setPreparedForInline): Expose setPreparedForInline to the shadow DOM. 24 * Modules/mediacontrols/MediaControlsHost.h: Add setPreparedForInline and isVideoLayerInline 25 * Modules/mediacontrols/MediaControlsHost.idl: Add setPreparedForInline and isVideoLayerInline 26 * Modules/mediacontrols/mediaControlsApple.js: 27 (Controller.prototype.showInlinePlaybackPlaceholderWhenSafe): Wait to show placeholder when entering fullscreen. 28 (Controller.prototype.handlePresentationModeChange): Wait to show placeholder, and notify when placeholder is removed. 29 * html/HTMLMediaElement.cpp: 30 (WebCore::HTMLMediaElement::setPreparedForInline): 31 (WebCore::HTMLMediaElement::waitForPreparedForInlineThen): Used to delay fullscreen cleanup until placeholder is removed. 32 (WebCore::HTMLMediaElement::setVideoFullscreenLayer): Add a callback so we can wait until this completes before continuing. 33 * html/HTMLMediaElement.h: 34 (WebCore::HTMLMediaElement::isVideoLayerInline): 35 (WebCore::HTMLMediaElement::waitForPreparedForInlineThen): 36 (WebCore::HTMLMediaElement::setVideoFullscreenLayer): Add completionHandler. 37 * platform/cocoa/WebVideoFullscreenModelVideoElement.h: 38 (WebCore::WebVideoFullscreenModelVideoElement::setVideoFullscreenLayer): Add completionHandler. 39 (WebCore::WebVideoFullscreenModelVideoElement::waitForPreparedForInlineThen): Added. 40 * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: 41 (WebVideoFullscreenModelVideoElement::setVideoFullscreenLayer): Add completionHandler. 42 (WebVideoFullscreenModelVideoElement::waitForPreparedForInlineThen): 43 * platform/graphics/MediaPlayer.cpp: 44 (WebCore::MediaPlayer::setVideoFullscreenLayer): Add completionHandler. 45 * platform/graphics/MediaPlayer.h: 46 (WebCore::MediaPlayer::setVideoFullscreenLayer): Add completionHandler. 47 * platform/graphics/MediaPlayerPrivate.h: 48 (WebCore::MediaPlayerPrivateInterface::setVideoFullscreenLayer): Add completionHandler. 49 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: 50 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 51 (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer): Create two video layers. 52 (WebCore::MediaPlayerPrivateAVFoundationObjC::destroyVideoLayer): Allow two video layers. 53 (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer): Add completionHandler. 54 (WebCore::MediaPlayerPrivateAVFoundationObjC::updateVideoLayerGravity): Allow two video layers. 55 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h: 56 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: 57 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::addDisplayLayer): Allow two video layers. 58 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenLayer): Add completionHandler. 59 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: 60 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: 61 (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::createPreviewLayers): Allow two video layers. 62 (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenLayer): Add completionHandler. 63 * platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h: 64 * platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm: 65 (WebCore::VideoFullscreenLayerManager::setVideoLayers): Allow two video layers. 66 (WebCore::VideoFullscreenLayerManager::setVideoFullscreenLayer): Add completionHandler. 67 (WebCore::VideoFullscreenLayerManager::setVideoFullscreenFrame): Allow two video layers. 68 (WebCore::VideoFullscreenLayerManager::didDestroyVideoLayer): Allow two video layers. 69 (WebCore::VideoFullscreenLayerManager::setVideoLayer): Deleted. 70 * platform/ios/WebVideoFullscreenControllerAVKit.mm: 71 (WebVideoFullscreenControllerContext::didSetupFullscreen): Use completionHandler. 72 (WebVideoFullscreenControllerContext::didExitFullscreen): Use completionHandler. 73 1 74 2016-05-23 Babak Shafiei <bshafiei@apple.com> 2 75 -
branches/safari-602.1.32-branch/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp
r200361 r201514 211 211 } 212 212 213 bool MediaControlsHost::isVideoLayerInline() 214 { 215 return m_mediaElement->isVideoLayerInline(); 216 } 217 218 void MediaControlsHost::setPreparedForInline(bool value) 219 { 220 m_mediaElement->setPreparedForInline(value); 221 } 222 213 223 bool MediaControlsHost::userGestureRequired() const 214 224 { -
branches/safari-602.1.32-branch/Source/WebCore/Modules/mediacontrols/MediaControlsHost.h
r200361 r201514 65 65 bool allowsInlineMediaPlayback() const; 66 66 bool supportsFullscreen(); 67 bool isVideoLayerInline(); 67 68 bool userGestureRequired() const; 69 void setPreparedForInline(bool); 68 70 69 71 void updateCaptionDisplaySizes(); -
branches/safari-602.1.32-branch/Source/WebCore/Modules/mediacontrols/MediaControlsHost.idl
r199963 r201514 43 43 readonly attribute DOMString captionDisplayMode; 44 44 void setSelectedTextTrack(TextTrack? track); 45 void setPreparedForInline(boolean prepared); 45 46 readonly attribute HTMLElement textTrackContainer; 46 47 readonly attribute boolean allowsInlineMediaPlayback; 47 48 readonly attribute boolean supportsFullscreen; 49 readonly attribute boolean isVideoLayerInline; 48 50 readonly attribute boolean userGestureRequired; 49 51 -
branches/safari-602.1.32-branch/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js
r201034 r201514 83 83 webkitendfullscreen: 'handleFullscreenChange', 84 84 }, 85 PlaceholderPollingDelay: 33, 85 86 HideControlsDelay: 4 * 1000, 86 87 RewindAmount: 30, … … 835 836 }, 836 837 838 showInlinePlaybackPlaceholderWhenSafe: function() { 839 if (this.presentationMode() != 'picture-in-picture') 840 return; 841 842 if (!this.host.isVideoLayerInline) 843 this.controls.inlinePlaybackPlaceholder.classList.remove(this.ClassNames.hidden); 844 else 845 setTimeout(this.showInlinePlaybackPlaceholderWhenSafe.bind(this), this.PlaceholderPollingDelay); 846 }, 847 837 848 handlePresentationModeChange: function(event) 838 849 { … … 852 863 this.controls.panel.classList.add(this.ClassNames.pictureInPicture); 853 864 this.controls.inlinePlaybackPlaceholder.classList.add(this.ClassNames.pictureInPicture); 854 this. controls.inlinePlaybackPlaceholder.classList.remove(this.ClassNames.hidden);865 this.showInlinePlaybackPlaceholderWhenSafe(); 855 866 856 867 this.controls.inlinePlaybackPlaceholderTextTop.innerText = this.UIString('This video is playing in Picture in Picture'); … … 876 887 if (presentationMode != 'fullscreen' && this.video.paused && this.controlsAreHidden()) 877 888 this.showControls(); 889 this.host.setPreparedForInline(presentationMode === 'inline') 878 890 }, 879 891 -
branches/safari-602.1.32-branch/Source/WebCore/html/HTMLMediaElement.cpp
r201321 r201514 5403 5403 } 5404 5404 5405 void HTMLMediaElement::setPreparedForInline(bool value) 5406 { 5407 m_preparedForInline = value; 5408 if (m_preparedForInline && m_preparedForInlineCompletionHandler) { 5409 m_preparedForInlineCompletionHandler(); 5410 m_preparedForInlineCompletionHandler = nullptr; 5411 } 5412 } 5413 5414 void HTMLMediaElement::waitForPreparedForInlineThen(std::function<void()> completionHandler) 5415 { 5416 ASSERT(!m_preparedForInlineCompletionHandler); 5417 if (m_preparedForInline) { 5418 completionHandler(); 5419 return; 5420 } 5421 5422 m_preparedForInlineCompletionHandler = completionHandler; 5423 } 5424 5405 5425 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)) 5406 5426 5407 void HTMLMediaElement::setVideoFullscreenLayer(PlatformLayer* platformLayer) 5427 bool HTMLMediaElement::isVideoLayerInline() 5428 { 5429 return !m_videoFullscreenLayer; 5430 }; 5431 5432 void HTMLMediaElement::setVideoFullscreenLayer(PlatformLayer* platformLayer, std::function<void()> completionHandler) 5408 5433 { 5409 5434 m_videoFullscreenLayer = platformLayer; 5410 if (!m_player) 5411 return; 5435 if (!m_player) { 5436 completionHandler(); 5437 return; 5438 } 5412 5439 5413 m_player->setVideoFullscreenLayer(platformLayer );5440 m_player->setVideoFullscreenLayer(platformLayer, completionHandler); 5414 5441 setNeedsStyleRecalc(SyntheticStyleChange); 5415 5442 #if ENABLE(VIDEO_TRACK) … … 5431 5458 m_player->setVideoFullscreenGravity(gravity); 5432 5459 } 5460 5461 #else 5462 5463 bool HTMLMediaElement::isVideoLayerInline() 5464 { 5465 return true; 5466 }; 5433 5467 5434 5468 #endif -
branches/safari-602.1.32-branch/Source/WebCore/html/HTMLMediaElement.h
r200520 r201514 132 132 WEBCORE_EXPORT PlatformMedia platformMedia() const; 133 133 PlatformLayer* platformLayer() const; 134 bool isVideoLayerInline(); 135 void setPreparedForInline(bool); 136 void waitForPreparedForInlineThen(std::function<void()> completionHandler = [] { }); 134 137 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)) 135 void setVideoFullscreenLayer(PlatformLayer* );138 void setVideoFullscreenLayer(PlatformLayer*, std::function<void()> completionHandler = [] { }); 136 139 PlatformLayer* videoFullscreenLayer() const { return m_videoFullscreenLayer.get(); } 137 140 void setVideoFullscreenFrame(FloatRect); … … 832 835 833 836 VideoFullscreenMode m_videoFullscreenMode; 837 bool m_preparedForInline; 838 std::function<void()> m_preparedForInlineCompletionHandler; 834 839 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)) 835 840 RetainPtr<PlatformLayer> m_videoFullscreenLayer; -
branches/safari-602.1.32-branch/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.h
r201153 r201514 35 35 #include "PlatformLayer.h" 36 36 #include "WebVideoFullscreenModel.h" 37 #include <functional> 37 38 #include <wtf/RefPtr.h> 38 39 #include <wtf/RetainPtr.h> … … 56 57 WEBCORE_EXPORT void setVideoElement(HTMLVideoElement*); 57 58 WEBCORE_EXPORT HTMLVideoElement* videoElement() const { return m_videoElement.get(); } 58 WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*); 59 WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*, std::function<void()> completionHandler = [] { }); 60 WEBCORE_EXPORT void waitForPreparedForInlineThen(std::function<void()> completionHandler = [] { }); 59 61 WebPlaybackSessionModelMediaElement& playbackSessionModel() { return m_playbackSessionModel; } 60 62 -
branches/safari-602.1.32-branch/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm
r201153 r201514 121 121 } 122 122 123 void WebVideoFullscreenModelVideoElement::setVideoFullscreenLayer(PlatformLayer* videoLayer) 124 { 125 if (m_videoFullscreenLayer == videoLayer) 126 return; 123 void WebVideoFullscreenModelVideoElement::setVideoFullscreenLayer(PlatformLayer* videoLayer, std::function<void()> completionHandler) 124 { 125 if (m_videoFullscreenLayer == videoLayer) { 126 completionHandler(); 127 return; 128 } 127 129 128 130 m_videoFullscreenLayer = videoLayer; … … 134 136 [m_videoFullscreenLayer setBounds:m_videoFrame]; 135 137 136 if (m_videoElement) 137 m_videoElement->setVideoFullscreenLayer(m_videoFullscreenLayer.get()); 138 if (!m_videoElement) { 139 completionHandler(); 140 return; 141 } 142 143 m_videoElement->setVideoFullscreenLayer(m_videoFullscreenLayer.get(), completionHandler); 144 } 145 146 void WebVideoFullscreenModelVideoElement::waitForPreparedForInlineThen(std::function<void()> completionHandler) 147 { 148 if (!m_videoElement) { 149 completionHandler(); 150 return; 151 } 152 153 m_videoElement->waitForPreparedForInlineThen(completionHandler); 138 154 } 139 155 -
branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/MediaPlayer.cpp
r199326 r201514 661 661 662 662 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)) 663 void MediaPlayer::setVideoFullscreenLayer(PlatformLayer* layer )664 { 665 m_private->setVideoFullscreenLayer(layer );663 void MediaPlayer::setVideoFullscreenLayer(PlatformLayer* layer, std::function<void()> completionHandler) 664 { 665 m_private->setVideoFullscreenLayer(layer, completionHandler); 666 666 } 667 667 -
branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/MediaPlayer.h
r199326 r201514 309 309 310 310 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)) 311 void setVideoFullscreenLayer(PlatformLayer* );311 void setVideoFullscreenLayer(PlatformLayer*, std::function<void()> completionHandler = [] { }); 312 312 void setVideoFullscreenFrame(FloatRect); 313 313 using MediaPlayerEnums::VideoGravity; -
branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/MediaPlayerPrivate.h
r199326 r201514 60 60 61 61 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)) 62 virtual void setVideoFullscreenLayer(PlatformLayer* ) {}62 virtual void setVideoFullscreenLayer(PlatformLayer*, std::function<void()> completionHandler) { completionHandler(); } 63 63 virtual void setVideoFullscreenFrame(FloatRect) { } 64 64 virtual void setVideoFullscreenGravity(MediaPlayer::VideoGravity) { } -
branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
r199672 r201514 173 173 PlatformLayer* platformLayer() const override; 174 174 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)) 175 void setVideoFullscreenLayer(PlatformLayer* ) override;175 void setVideoFullscreenLayer(PlatformLayer*, std::function<void()> completionHandler) override; 176 176 void setVideoFullscreenFrame(FloatRect) override; 177 177 void setVideoFullscreenGravity(MediaPlayer::VideoGravity) override; … … 330 330 RetainPtr<AVPlayerItem> m_avPlayerItem; 331 331 RetainPtr<AVPlayerLayer> m_videoLayer; 332 RetainPtr<AVPlayerLayer> m_secondaryVideoLayer; 332 333 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)) 333 334 std::unique_ptr<VideoFullscreenLayerManager> m_videoFullscreenLayerManager; -
branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r200354 r201514 731 731 [m_videoLayer setPlayer:m_avPlayer.get()]; 732 732 [m_videoLayer setBackgroundColor:cachedCGColor(Color::black)]; 733 734 m_secondaryVideoLayer = adoptNS([allocAVPlayerLayerInstance() init]); 735 [m_secondaryVideoLayer setPlayer:m_avPlayer.get()]; 736 [m_secondaryVideoLayer setBackgroundColor:cachedCGColor(Color::black)]; 737 733 738 #ifndef NDEBUG 734 739 [m_videoLayer setName:@"MediaPlayerPrivate AVPlayerLayer"]; 740 [m_secondaryVideoLayer setName:@"MediaPlayerPrivate AVPlayerLayer secondary"]; 735 741 #endif 736 742 [m_videoLayer addObserver:m_objcObserver.get() forKeyPath:@"readyForDisplay" options:NSKeyValueObservingOptionNew context:(void *)MediaPlayerAVFoundationObservationContextAVPlayerLayer]; 737 743 updateVideoLayerGravity(); 738 744 [m_videoLayer setContentsScale:player()->client().mediaPlayerContentsScale()]; 745 [m_secondaryVideoLayer setContentsScale:player()->client().mediaPlayerContentsScale()]; 739 746 IntSize defaultSize = snappedIntRect(player()->client().mediaPlayerContentBoxRect()).size(); 740 747 LOG(Media, "MediaPlayerPrivateAVFoundationObjC::createVideoLayer(%p) - returning %p", this, m_videoLayer.get()); 741 748 742 749 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)) 743 m_videoFullscreenLayerManager->setVideoLayer (m_videoLayer.get(), defaultSize);750 m_videoFullscreenLayerManager->setVideoLayers(m_videoLayer.get(), m_secondaryVideoLayer.get(), defaultSize); 744 751 745 752 #if PLATFORM(IOS) … … 749 756 #else 750 757 [m_videoLayer setFrame:CGRectMake(0, 0, defaultSize.width(), defaultSize.height())]; 758 [m_secondaryVideoLayer setFrame:CGRectMake(0, 0, defaultSize.width(), defaultSize.height())]; 751 759 #endif 752 760 } … … 759 767 LOG(Media, "MediaPlayerPrivateAVFoundationObjC::destroyVideoLayer(%p) - destroying %p", this, m_videoLayer.get()); 760 768 761 [m_videoLayer.get() removeObserver:m_objcObserver.get() forKeyPath:@"readyForDisplay"]; 762 [m_videoLayer.get() setPlayer:nil]; 769 [m_videoLayer removeObserver:m_objcObserver.get() forKeyPath:@"readyForDisplay"]; 770 [m_videoLayer setPlayer:nil]; 771 [m_secondaryVideoLayer setPlayer:nil]; 763 772 764 773 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)) … … 767 776 768 777 m_videoLayer = nil; 778 m_secondaryVideoLayer = nil; 769 779 } 770 780 … … 1184 1194 1185 1195 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)) 1186 void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer(PlatformLayer* videoFullscreenLayer) 1187 { 1188 if (m_videoFullscreenLayerManager->videoFullscreenLayer() == videoFullscreenLayer) 1189 return; 1190 1191 m_videoFullscreenLayerManager->setVideoFullscreenLayer(videoFullscreenLayer); 1196 void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer(PlatformLayer* videoFullscreenLayer, std::function<void()> completionHandler) 1197 { 1198 if (m_videoFullscreenLayerManager->videoFullscreenLayer() == videoFullscreenLayer) { 1199 completionHandler(); 1200 return; 1201 } 1202 1203 m_videoFullscreenLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, completionHandler); 1192 1204 1193 1205 if (m_videoFullscreenLayerManager->videoFullscreenLayer() && m_textTrackRepresentationLayer) { … … 1873 1885 NSString* gravity = shouldMaintainAspectRatio() ? AVLayerVideoGravityResizeAspect : AVLayerVideoGravityResize; 1874 1886 [m_videoLayer.get() setVideoGravity:gravity]; 1887 [m_secondaryVideoLayer.get() setVideoGravity:gravity]; 1875 1888 [CATransaction commit]; 1876 1889 } -
branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
r197563 r201514 88 88 89 89 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE) 90 void setVideoFullscreenLayer(PlatformLayer* ) override;90 void setVideoFullscreenLayer(PlatformLayer*, std::function<void()> completionHandler) override; 91 91 void setVideoFullscreenFrame(FloatRect) override; 92 92 #endif -
branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
r200315 r201514 771 771 772 772 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE) 773 m_videoFullscreenLayerManager->setVideoLayer (m_sampleBufferDisplayLayer.get(), snappedIntRect(m_player->client().mediaPlayerContentBoxRect()).size());773 m_videoFullscreenLayerManager->setVideoLayers(m_sampleBufferDisplayLayer.get(), nil, snappedIntRect(m_player->client().mediaPlayerContentBoxRect()).size()); 774 774 #endif 775 775 } … … 829 829 830 830 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE) 831 void MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer )832 { 833 m_videoFullscreenLayerManager->setVideoFullscreenLayer(videoFullscreenLayer );831 void MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer, std::function<void()> completionHandler) 832 { 833 m_videoFullscreenLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, completionHandler); 834 834 } 835 835 -
branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h
r197807 r201514 161 161 162 162 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE) 163 void setVideoFullscreenLayer(PlatformLayer* ) override;163 void setVideoFullscreenLayer(PlatformLayer*, std::function<void()> completionHandler) override; 164 164 void setVideoFullscreenFrame(FloatRect) override; 165 165 #endif -
branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm
r197807 r201514 405 405 406 406 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE) 407 m_videoFullscreenLayerManager->setVideoLayer (m_videoBackgroundLayer.get(), snappedIntRect(m_player->client().mediaPlayerContentBoxRect()).size());407 m_videoFullscreenLayerManager->setVideoLayers(m_videoBackgroundLayer.get(), nil, snappedIntRect(m_player->client().mediaPlayerContentBoxRect()).size()); 408 408 #endif 409 409 } … … 475 475 476 476 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE) 477 void MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer )478 { 479 m_videoFullscreenLayerManager->setVideoFullscreenLayer(videoFullscreenLayer );477 void MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer, std::function<void()> completionHandler) 478 { 479 m_videoFullscreenLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, completionHandler); 480 480 } 481 481 -
branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h
r195595 r201514 32 32 #include "IntSize.h" 33 33 #include "PlatformLayer.h" 34 #include <functional> 34 35 #include <wtf/RetainPtr.h> 35 36 … … 44 45 PlatformLayer *videoFullscreenLayer() const { return m_videoFullscreenLayer.get(); } 45 46 FloatRect videoFullscreenFrame() const { return m_videoFullscreenFrame; } 46 void setVideoLayer (PlatformLayer *, IntSize contentSize);47 void setVideoFullscreenLayer(PlatformLayer * );47 void setVideoLayers(PlatformLayer *, PlatformLayer *, IntSize contentSize); 48 void setVideoFullscreenLayer(PlatformLayer *, std::function<void()> completionHandler); 48 49 void setVideoFullscreenFrame(FloatRect); 49 50 void didDestroyVideoLayer(); … … 55 56 RetainPtr<PlatformLayer> m_videoFullscreenLayer; 56 57 RetainPtr<PlatformLayer> m_videoLayer; 58 RetainPtr<PlatformLayer> m_secondaryVideoLayer; 57 59 FloatRect m_videoFullscreenFrame; 58 60 }; -
branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm
r195595 r201514 67 67 } 68 68 69 void VideoFullscreenLayerManager::setVideoLayer (PlatformLayer *videoLayer, IntSize contentSize)69 void VideoFullscreenLayerManager::setVideoLayers(PlatformLayer *videoLayer, PlatformLayer *secondaryVideoLayer, IntSize contentSize) 70 70 { 71 71 m_videoLayer = videoLayer; 72 m_secondaryVideoLayer = secondaryVideoLayer; 72 73 73 74 [m_videoLayer web_disableAllActions]; 75 [m_secondaryVideoLayer web_disableAllActions]; 74 76 m_videoInlineLayer = adoptNS([[WebVideoContainerLayer alloc] init]); 75 77 #ifndef NDEBUG … … 78 80 [m_videoInlineLayer setFrame:CGRectMake(0, 0, contentSize.width(), contentSize.height())]; 79 81 if (m_videoFullscreenLayer) { 80 [m_videoLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())]; 81 [m_videoFullscreenLayer insertSublayer:m_videoLayer.get() atIndex:0]; 82 [m_videoLayer removeFromSuperlayer]; 83 PlatformLayer *activeLayer = secondaryVideoLayer ? secondaryVideoLayer : videoLayer; 84 [activeLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())]; 85 [m_videoFullscreenLayer insertSublayer:activeLayer atIndex:0]; 82 86 } else { 83 87 [m_videoInlineLayer insertSublayer:m_videoLayer.get() atIndex:0]; 84 88 [m_videoLayer setFrame:m_videoInlineLayer.get().bounds]; 89 [m_secondaryVideoLayer removeFromSuperlayer]; 85 90 } 86 91 } 87 92 88 void VideoFullscreenLayerManager::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer )93 void VideoFullscreenLayerManager::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer, std::function<void()> completionHandler) 89 94 { 90 if (m_videoFullscreenLayer == videoFullscreenLayer) 95 if (m_videoFullscreenLayer == videoFullscreenLayer) { 96 completionHandler(); 91 97 return; 98 } 92 99 93 100 m_videoFullscreenLayer = videoFullscreenLayer; … … 96 103 [CATransaction setDisableActions:YES]; 97 104 98 CAContext *oldContext = [m_videoLayer context]; 99 CAContext *newContext = nil; 105 if (m_secondaryVideoLayer && m_videoLayer) { 106 if (m_videoFullscreenLayer) { 107 [m_videoFullscreenLayer insertSublayer:m_secondaryVideoLayer.get() atIndex:0]; 108 [m_secondaryVideoLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())]; 109 } else if (m_videoInlineLayer) { 110 [m_videoLayer setFrame:[m_videoInlineLayer bounds]]; 111 [m_videoInlineLayer insertSublayer:m_videoLayer.get() atIndex:0]; 112 } 100 113 101 if (m_videoFullscreenLayer && m_videoLayer) { 102 [m_videoFullscreenLayer insertSublayer:m_videoLayer.get() atIndex:0]; 103 [m_videoLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())]; 104 newContext = [m_videoFullscreenLayer context]; 105 } else if (m_videoInlineLayer && m_videoLayer) { 106 [m_videoLayer setFrame:[m_videoInlineLayer bounds]]; 107 [m_videoLayer removeFromSuperlayer]; 108 [m_videoInlineLayer insertSublayer:m_videoLayer.get() atIndex:0]; 109 newContext = [m_videoInlineLayer context]; 110 } else if (m_videoLayer) 111 [m_videoLayer removeFromSuperlayer]; 114 RetainPtr<PlatformLayer> fullscreenLayer = m_videoFullscreenLayer; 115 RetainPtr<PlatformLayer> videoLayer = m_videoLayer; 116 RetainPtr<PlatformLayer> secondaryVideoLayer = m_secondaryVideoLayer; 112 117 113 if (oldContext && newContext && oldContext != newContext) { 114 mach_port_t fencePort = [oldContext createFencePort]; 115 [newContext setFencePort:fencePort]; 116 mach_port_deallocate(mach_task_self(), fencePort); 118 [CATransaction setCompletionBlock:[completionHandler, fullscreenLayer, videoLayer, secondaryVideoLayer] { 119 [CATransaction begin]; 120 [CATransaction setDisableActions:YES]; 121 122 if (fullscreenLayer) 123 [videoLayer removeFromSuperlayer]; 124 else 125 [secondaryVideoLayer removeFromSuperlayer]; 126 127 [CATransaction setCompletionBlock:[completionHandler] { 128 completionHandler(); 129 }]; 130 [CATransaction commit]; 131 }]; 132 } else if (m_videoLayer) { 133 if (m_videoFullscreenLayer) { 134 [m_videoFullscreenLayer insertSublayer:m_videoLayer.get() atIndex:0]; 135 [m_videoLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())]; 136 } else if (m_videoInlineLayer) { 137 [m_videoLayer setFrame:[m_videoInlineLayer bounds]]; 138 [m_videoLayer removeFromSuperlayer]; 139 [m_videoInlineLayer insertSublayer:m_videoLayer.get() atIndex:0]; 140 } else 141 [m_videoLayer removeFromSuperlayer]; 142 143 CAContext *oldContext = [m_videoFullscreenLayer context]; 144 CAContext *newContext = [m_videoInlineLayer context]; 145 if (oldContext && newContext && oldContext != newContext) { 146 mach_port_t fencePort = [oldContext createFencePort]; 147 [newContext setFencePort:fencePort]; 148 mach_port_deallocate(mach_task_self(), fencePort); 149 } 150 151 [CATransaction setCompletionBlock:[completionHandler] { 152 completionHandler(); 153 }]; 154 } else { 155 [CATransaction setCompletionBlock:[completionHandler] { 156 completionHandler(); 157 }]; 117 158 } 159 118 160 [CATransaction commit]; 119 161 } … … 125 167 return; 126 168 127 if (m_videoLayer)128 [m_videoLayer setFrame:CGRectMake(0, 0, videoFullscreenFrame.width(), videoFullscreenFrame.height())];169 PlatformLayer *activeLayer = m_secondaryVideoLayer.get() ? m_secondaryVideoLayer.get() : m_videoLayer.get(); 170 [activeLayer setFrame:CGRectMake(0, 0, videoFullscreenFrame.width(), videoFullscreenFrame.height())]; 129 171 } 130 172 131 173 void VideoFullscreenLayerManager::didDestroyVideoLayer() 132 174 { 133 if (m_videoFullscreenLayer)134 [m_videoLayer removeFromSuperlayer];175 [m_videoLayer removeFromSuperlayer]; 176 [m_secondaryVideoLayer removeFromSuperlayer]; 135 177 136 178 m_videoInlineLayer = nil; 137 179 m_videoLayer = nil; 180 m_secondaryVideoLayer = nil; 138 181 } 139 182 -
branches/safari-602.1.32-branch/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm
r201153 r201514 248 248 WebThreadRun([strongThis, this, videoFullscreenLayer] { 249 249 [videoFullscreenLayer setBackgroundColor:cachedCGColor(WebCore::Color::transparent)]; 250 m_model->setVideoFullscreenLayer(videoFullscreenLayer.get()); 251 dispatch_async(dispatch_get_main_queue(), [strongThis, this] { 252 m_interface->enterFullscreen(); 250 m_model->setVideoFullscreenLayer(videoFullscreenLayer.get(), [strongThis, this] { 251 dispatch_async(dispatch_get_main_queue(), [strongThis, this] { 252 m_interface->enterFullscreen(); 253 }); 253 254 }); 254 255 }); … … 260 261 RefPtr<WebVideoFullscreenControllerContext> strongThis(this); 261 262 WebThreadRun([strongThis, this] { 262 m_model->setVideoFullscreenLayer(nil); 263 dispatch_async(dispatch_get_main_queue(), [strongThis, this] { 264 m_interface->cleanupFullscreen(); 263 m_model->setVideoFullscreenLayer(nil, [strongThis, this] { 264 dispatch_async(dispatch_get_main_queue(), [strongThis, this] { 265 m_interface->cleanupFullscreen(); 266 }); 265 267 }); 266 268 }); -
branches/safari-602.1.32-branch/Source/WebKit2/ChangeLog
r201252 r201514 1 2016-05-31 Babak Shafiei <bshafiei@apple.com> 2 3 Merge r201474. rdar://problem/24476949 4 5 2016-05-27 Jeremy Jones <jeremyj@apple.com> 6 7 Decrease flicker when changing video presentation mode. 8 https://bugs.webkit.org/show_bug.cgi?id=158148 9 rdar://problem/24476949 10 11 Reviewed by Tim Horton. 12 13 Prevent flicker by using setVideoFullscreenLayer with a completion handler to delay 14 enter fullscreen and cleanup fullscreen until the video layer has completely been 15 installed or removed. 16 17 * WebProcess/cocoa/WebVideoFullscreenManager.mm: 18 (WebKit::WebVideoFullscreenManager::didSetupFullscreen): 19 (WebKit::WebVideoFullscreenManager::didExitFullscreen): 20 1 21 2016-05-22 Babak Shafiei <bshafiei@apple.com> 2 22 -
branches/safari-602.1.32-branch/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm
r200157 r201514 370 370 371 371 interface->layerHostingContext()->setRootLayer(videoLayer); 372 model->setVideoFullscreenLayer(videoLayer); 373 372 373 RefPtr<WebVideoFullscreenManager> strongThis(this); 374 375 model->setVideoFullscreenLayer(videoLayer, [strongThis, this, contextId] { 376 dispatch_async(dispatch_get_main_queue(), [strongThis, this, contextId] { 377 m_page->send(Messages::WebVideoFullscreenManagerProxy::EnterFullscreen(contextId), m_page->pageID()); 378 }); 379 }); 380 374 381 [CATransaction commit]; 375 376 RefPtr<WebVideoFullscreenManager> strongThis(this);377 dispatch_async(dispatch_get_main_queue(), [strongThis, this, contextId] {378 m_page->send(Messages::WebVideoFullscreenManagerProxy::EnterFullscreen(contextId), m_page->pageID());379 });380 382 } 381 383 … … 408 410 RefPtr<WebVideoFullscreenInterfaceContext> interface; 409 411 std::tie(model, interface) = ensureModelAndInterface(contextId); 410 411 model->setVideoFullscreenLayer(nil);412 413 412 RefPtr<WebVideoFullscreenManager> strongThis(this); 414 dispatch_async(dispatch_get_main_queue(), [strongThis, contextId, interface] { 415 if (interface->layerHostingContext()) { 416 interface->layerHostingContext()->setRootLayer(nullptr); 417 interface->setLayerHostingContext(nullptr); 418 } 419 if (strongThis->m_page) 420 strongThis->m_page->send(Messages::WebVideoFullscreenManagerProxy::CleanupFullscreen(contextId), strongThis->m_page->pageID()); 413 414 model->waitForPreparedForInlineThen([strongThis, this, contextId, interface, model] { 415 dispatch_async(dispatch_get_main_queue(), [strongThis, this, contextId, interface, model] { 416 model->setVideoFullscreenLayer(nil, [strongThis, this, contextId, interface] { 417 dispatch_async(dispatch_get_main_queue(), [strongThis, this, contextId, interface] { 418 if (interface->layerHostingContext()) { 419 interface->layerHostingContext()->setRootLayer(nullptr); 420 interface->setLayerHostingContext(nullptr); 421 } 422 if (strongThis->m_page) 423 strongThis->m_page->send(Messages::WebVideoFullscreenManagerProxy::CleanupFullscreen(contextId), strongThis->m_page->pageID()); 424 }); 425 }); 426 }); 421 427 }); 422 428 }
Note:
See TracChangeset
for help on using the changeset viewer.