Diff
Modified: trunk/Source/WebCore/ChangeLog (257679 => 257680)
--- trunk/Source/WebCore/ChangeLog 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebCore/ChangeLog 2020-02-29 07:21:48 UTC (rev 257680)
@@ -1,3 +1,43 @@
+2020-02-28 Peng Liu <peng.l...@apple.com>
+
+ [Media in GPU process] Implement the video fullscreen and Picture-in-Picture support
+ https://bugs.webkit.org/show_bug.cgi?id=208252
+
+ Reviewed by Simon Fraser.
+
+ Covered by existing tests.
+
+ This patch moves the creation of the CALayer for video fullscreen and picture-in-picture from
+ VideoFullscreenManager to MediaPlayerPrivate classes. With this change, we can support
+ video fullscreen and picture-in-picture no matter the "Media in GPU process"
+ feature is enabled or not. The function createVideoFullscreenLayer() is added to
+ MediaPlayer and MediaPlayerPrivate for that purpose.
+
+ There are duplicated code snippets to create a CALayer in MediaPlayerPrivateAVFoundationObjC,
+ MediaPlayerPrivateMediaSourceAVFObjC, and MediaPlayerPrivateMediaStreamAVFObjC.
+ That will be fixed in a future refactoring (webkit.org/b/208342).
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::createVideoFullscreenLayer):
+ * html/HTMLMediaElement.h:
+ * platform/cocoa/VideoFullscreenModelVideoElement.h:
+ * platform/cocoa/VideoFullscreenModelVideoElement.mm:
+ (WebCore::VideoFullscreenModelVideoElement::createVideoFullscreenLayer):
+ * platform/graphics/MediaPlayer.cpp:
+ (WebCore::MediaPlayer::createVideoFullscreenLayer):
+ * platform/graphics/MediaPlayer.h:
+ * platform/graphics/MediaPlayerPrivate.h:
+ (WebCore::MediaPlayerPrivateInterface::createVideoFullscreenLayer):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoFullscreenLayer):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::createVideoFullscreenLayer):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::createVideoFullscreenLayer):
+
2020-02-28 Wenson Hsieh <wenson_hs...@apple.com>
Add an internal setting to enable or disable canvas rendering in the GPU Process
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (257679 => 257680)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2020-02-29 07:21:48 UTC (rev 257680)
@@ -6261,6 +6261,11 @@
return !m_videoFullscreenLayer;
};
+RetainPtr<PlatformLayer> HTMLMediaElement::createVideoFullscreenLayer()
+{
+ return m_player->createVideoFullscreenLayer();
+}
+
void HTMLMediaElement::setVideoFullscreenLayer(PlatformLayer* platformLayer, WTF::Function<void()>&& completionHandler)
{
INFO_LOG(LOGIDENTIFIER);
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (257679 => 257680)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2020-02-29 07:21:48 UTC (rev 257680)
@@ -179,6 +179,7 @@
void setPreparedToReturnVideoLayerToInline(bool);
void waitForPreparedForInlineThen(WTF::Function<void()>&& completionHandler = [] { });
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
+ RetainPtr<PlatformLayer> createVideoFullscreenLayer();
WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler = [] { });
#ifdef __OBJC__
PlatformLayer* videoFullscreenLayer() const { return m_videoFullscreenLayer.get(); }
Modified: trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h (257679 => 257680)
--- trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h 2020-02-29 07:21:48 UTC (rev 257680)
@@ -55,6 +55,7 @@
WEBCORE_EXPORT virtual ~VideoFullscreenModelVideoElement();
WEBCORE_EXPORT void setVideoElement(HTMLVideoElement*);
HTMLVideoElement* videoElement() const { return m_videoElement.get(); }
+ WEBCORE_EXPORT RetainPtr<PlatformLayer> createVideoFullscreenLayer();
WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler = [] { });
WEBCORE_EXPORT void willExitFullscreen();
WEBCORE_EXPORT void waitForPreparedForInlineThen(WTF::Function<void()>&& completionHandler = [] { });
Modified: trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm (257679 => 257680)
--- trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm 2020-02-29 07:21:48 UTC (rev 257680)
@@ -110,6 +110,11 @@
m_videoElement->willExitFullscreen();
}
+RetainPtr<PlatformLayer> VideoFullscreenModelVideoElement::createVideoFullscreenLayer()
+{
+ return m_videoElement->createVideoFullscreenLayer();
+}
+
void VideoFullscreenModelVideoElement::setVideoFullscreenLayer(PlatformLayer* videoLayer, WTF::Function<void()>&& completionHandler)
{
if (m_videoFullscreenLayer == videoLayer) {
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (257679 => 257680)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2020-02-29 07:21:48 UTC (rev 257680)
@@ -752,6 +752,11 @@
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
+RetainPtr<PlatformLayer> MediaPlayer::createVideoFullscreenLayer()
+{
+ return m_private->createVideoFullscreenLayer();
+}
+
void MediaPlayer::setVideoFullscreenLayer(PlatformLayer* layer, WTF::Function<void()>&& completionHandler)
{
m_private->setVideoFullscreenLayer(layer, WTFMove(completionHandler));
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (257679 => 257680)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2020-02-29 07:21:48 UTC (rev 257680)
@@ -307,6 +307,7 @@
PlatformLayer* platformLayer() const;
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
+ RetainPtr<PlatformLayer> createVideoFullscreenLayer();
void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler = [] { });
void setVideoFullscreenFrame(FloatRect);
void updateVideoFullscreenInlineImage();
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (257679 => 257680)
--- trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h 2020-02-29 07:21:48 UTC (rev 257680)
@@ -62,6 +62,7 @@
virtual PlatformLayer* platformLayer() const { return nullptr; }
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
+ virtual RetainPtr<PlatformLayer> createVideoFullscreenLayer() { return nullptr; }
virtual void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler) { completionHandler(); }
virtual void updateVideoFullscreenInlineImage() { }
virtual void setVideoFullscreenFrame(FloatRect) { }
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (257679 => 257680)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2020-02-29 07:21:48 UTC (rev 257680)
@@ -177,6 +177,7 @@
void paint(GraphicsContext&, const FloatRect&) override;
void paintCurrentFrameInContext(GraphicsContext&, const FloatRect&) override;
PlatformLayer* platformLayer() const override;
+ RetainPtr<PlatformLayer> createVideoFullscreenLayer() override;
void setVideoFullscreenLayer(PlatformLayer*, Function<void()>&& completionHandler) override;
void updateVideoFullscreenInlineImage() final;
void setVideoFullscreenFrame(FloatRect) override;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (257679 => 257680)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2020-02-29 07:21:48 UTC (rev 257680)
@@ -1083,6 +1083,11 @@
m_videoLayerManager->updateVideoFullscreenInlineImage(m_lastImage);
}
+RetainPtr<PlatformLayer> MediaPlayerPrivateAVFoundationObjC::createVideoFullscreenLayer()
+{
+ return adoptNS([[CALayer alloc] init]);
+}
+
void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer(PlatformLayer* videoFullscreenLayer, Function<void()>&& completionHandler)
{
updateLastImage(UpdateType::UpdateSynchronously);
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (257679 => 257680)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2020-02-29 07:21:48 UTC (rev 257680)
@@ -109,6 +109,7 @@
AVSampleBufferDisplayLayer* sampleBufferDisplayLayer() const { return m_sampleBufferDisplayLayer.get(); }
WebCoreDecompressionSession* decompressionSession() const { return m_decompressionSession.get(); }
+ RetainPtr<PlatformLayer> createVideoFullscreenLayer() override;
void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler) override;
void setVideoFullscreenFrame(FloatRect) override;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (257679 => 257680)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2020-02-29 07:21:48 UTC (rev 257680)
@@ -1158,6 +1158,11 @@
m_player->characteristicChanged();
}
+RetainPtr<PlatformLayer> MediaPlayerPrivateMediaSourceAVFObjC::createVideoFullscreenLayer()
+{
+ return adoptNS([[CALayer alloc] init]);
+}
+
void MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer, WTF::Function<void()>&& completionHandler)
{
updateLastImage();
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h (257679 => 257680)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h 2020-02-29 07:21:48 UTC (rev 257680)
@@ -197,6 +197,7 @@
void sampleBufferUpdated(MediaStreamTrackPrivate&, MediaSample&) override;
void readyStateChanged(MediaStreamTrackPrivate&) override;
+ RetainPtr<PlatformLayer> createVideoFullscreenLayer() override;
void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler) override;
void setVideoFullscreenFrame(FloatRect) override;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (257679 => 257680)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm 2020-02-29 07:21:48 UTC (rev 257680)
@@ -773,6 +773,11 @@
return true;
}
+RetainPtr<PlatformLayer> MediaPlayerPrivateMediaStreamAVFObjC::createVideoFullscreenLayer()
+{
+ return adoptNS([[CALayer alloc] init]);
+}
+
void MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenLayer(PlatformLayer* videoFullscreenLayer, WTF::Function<void()>&& completionHandler)
{
updateCurrentFrameImage();
Modified: trunk/Source/WebKit/ChangeLog (257679 => 257680)
--- trunk/Source/WebKit/ChangeLog 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebKit/ChangeLog 2020-02-29 07:21:48 UTC (rev 257680)
@@ -1,3 +1,72 @@
+2020-02-28 Peng Liu <peng.l...@apple.com>
+
+ [Media in GPU process] Implement the video fullscreen and Picture-in-Picture support
+ https://bugs.webkit.org/show_bug.cgi?id=208252
+
+ Reviewed by Simon Fraser.
+
+ The RemoteMediaPlayerProxy in the GPU process creates a LayerHostingContext and
+ share the context ID with the MediaPlayerPrivateRemote in the Web process,
+ which in turn creates a remote layer used by the VideoFullscreenManager.
+
+ Those functions regarding video fullscreen and picture-in-picture have been
+ moved to RemoteMediaPlayerProxy.
+ * GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp:
+ (WebKit::RemoteMediaPlayerManagerProxy::updateVideoFullscreenInlineImage): Deleted.
+ (WebKit::RemoteMediaPlayerManagerProxy::setVideoFullscreenFrame): Deleted.
+ (WebKit::RemoteMediaPlayerManagerProxy::setVideoFullscreenGravity): Deleted.
+ (WebKit::RemoteMediaPlayerManagerProxy::setVideoFullscreenMode): Deleted.
+ (WebKit::RemoteMediaPlayerManagerProxy::setVolume): Deleted.
+ (WebKit::RemoteMediaPlayerManagerProxy::setBufferingPolicy): Deleted.
+ (WebKit::RemoteMediaPlayerManagerProxy::videoFullscreenStandbyChanged): Deleted.
+ * GPUProcess/media/RemoteMediaPlayerManagerProxy.h:
+
+ [GPU process]
+ Add two asynchronous IPC messages (EnterFullscreen and ExitFullscreen) in RemoteMediaPlayerProxy
+ and replace the message SetVideoFullscreenFrame with SetVideoFullscreenFrameFenced.
+ Create the CALayer for the video fullscreen and picture-in-picture features.
+ * GPUProcess/media/RemoteMediaPlayerProxy.cpp:
+ (WebKit::RemoteMediaPlayerProxy::prepareForPlayback): Deleted.
+ (WebKit::RemoteMediaPlayerProxy::setVideoFullscreenFrame): Deleted.
+ (WebKit::RemoteMediaPlayerProxy::mediaPlayerFirstVideoFrameAvailable): Deleted.
+ (WebKit::RemoteMediaPlayerProxy::mediaPlayerRenderingModeChanged): Deleted.
+ * GPUProcess/media/RemoteMediaPlayerProxy.h:
+ * GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
+ * GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm:
+ (WebKit::RemoteMediaPlayerProxy::prepareForPlayback):
+ (WebKit::RemoteMediaPlayerProxy::mediaPlayerFirstVideoFrameAvailable):
+ (WebKit::RemoteMediaPlayerProxy::mediaPlayerRenderingModeChanged):
+ (WebKit::RemoteMediaPlayerProxy::setVideoInlineSizeFenced):
+ (WebKit::RemoteMediaPlayerProxy::enterFullscreen):
+ (WebKit::RemoteMediaPlayerProxy::exitFullscreen):
+ (WebKit::RemoteMediaPlayerProxy::setVideoFullscreenFrameFenced):
+
+ * SourcesCocoa.txt:
+ * WebKit.xcodeproj/project.pbxproj:
+
+ [Web process]
+ Create a hosting layer in the Web process corresponding to the CALayer in the
+ GPU process for video fullscreen and picture-in-picture.
+ Synchronize the properties of the layers cross process boundary with MachSendRight.
+ * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+ (WebKit::MediaPlayerPrivateRemote::prepareForPlayback):
+ (WebKit::MediaPlayerPrivateRemote::acceleratedRenderingStateChanged):
+ (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenLayer):
+ (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenFrameFenced):
+ (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenGravity):
+ (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenFrame): Deleted.
+ * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
+ * WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm: Added.
+ (WebKit::MediaPlayerPrivateRemote::createVideoFullscreenLayer):
+ (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenFrame):
+ * WebProcess/GPU/media/cocoa/VideoLayerRemoteCocoa.mm:
+ (WebKit::createVideoLayerRemote):
+ * WebProcess/cocoa/VideoFullscreenManager.mm:
+ (WebKit::VideoFullscreenManager::enterVideoFullscreenForVideoElement):
+
+ Fix unified build failures.
+ * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+
2020-02-28 Jer Noble <jer.no...@apple.com>
Unreviewed unified build fix; Add include header for IPC::DataReference.
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp (257679 => 257680)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp 2020-02-29 07:21:48 UTC (rev 257680)
@@ -192,48 +192,6 @@
completionHandler(result);
}
-void RemoteMediaPlayerManagerProxy::updateVideoFullscreenInlineImage(MediaPlayerPrivateRemoteIdentifier playerIdentifier)
-{
- if (auto player = m_proxies.get(playerIdentifier))
- player->updateVideoFullscreenInlineImage();
-}
-
-void RemoteMediaPlayerManagerProxy::setVideoFullscreenFrame(MediaPlayerPrivateRemoteIdentifier playerIdentifier, FloatRect frame)
-{
- if (auto player = m_proxies.get(playerIdentifier))
- player->setVideoFullscreenFrame(frame);
-}
-
-void RemoteMediaPlayerManagerProxy::setVideoFullscreenGravity(MediaPlayerPrivateRemoteIdentifier playerIdentifier, MediaPlayer::VideoGravity gravity)
-{
- if (auto player = m_proxies.get(playerIdentifier))
- player->setVideoFullscreenGravity(gravity);
-}
-
-void RemoteMediaPlayerManagerProxy::setVideoFullscreenMode(MediaPlayerPrivateRemoteIdentifier playerIdentifier, MediaPlayer::VideoFullscreenMode mode)
-{
- if (auto player = m_proxies.get(playerIdentifier))
- player->setVideoFullscreenMode(mode);
-}
-
-void RemoteMediaPlayerManagerProxy::setVolume(MediaPlayerPrivateRemoteIdentifier playerIdentifier, double volume)
-{
- if (auto player = m_proxies.get(playerIdentifier))
- player->setVolume(volume);
-}
-
-void RemoteMediaPlayerManagerProxy::setBufferingPolicy(MediaPlayerPrivateRemoteIdentifier playerIdentifier, WebCore::MediaPlayer::BufferingPolicy policy)
-{
- if (auto player = m_proxies.get(playerIdentifier))
- player->setBufferingPolicy(policy);
-}
-
-void RemoteMediaPlayerManagerProxy::videoFullscreenStandbyChanged(MediaPlayerPrivateRemoteIdentifier playerIdentifier)
-{
- if (auto player = m_proxies.get(playerIdentifier))
- player->videoFullscreenStandbyChanged();
-}
-
#if PLATFORM(IOS_FAMILY)
void RemoteMediaPlayerManagerProxy::accessLog(MediaPlayerPrivateRemoteIdentifier playerIdentifier, CompletionHandler<void(String)>&& completionHandler)
{
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.h (257679 => 257680)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.h 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.h 2020-02-29 07:21:48 UTC (rev 257680)
@@ -84,16 +84,6 @@
void clearMediaCacheForOrigins(WebCore::MediaPlayerEnums::MediaEngineIdentifier, const String&&, Vector<WebCore::SecurityOriginData>&&);
void supportsKeySystem(WebCore::MediaPlayerEnums::MediaEngineIdentifier, const String&&, const String&&, CompletionHandler<void(bool)>&&);
- void updateVideoFullscreenInlineImage(MediaPlayerPrivateRemoteIdentifier);
- void setVideoFullscreenFrame(MediaPlayerPrivateRemoteIdentifier, WebCore::FloatRect);
- void setVideoFullscreenGravity(MediaPlayerPrivateRemoteIdentifier, WebCore::MediaPlayer::VideoGravity);
- void setVideoFullscreenMode(MediaPlayerPrivateRemoteIdentifier, WebCore::MediaPlayer::VideoFullscreenMode);
-
- void videoFullscreenStandbyChanged(MediaPlayerPrivateRemoteIdentifier);
-
- void setVolume(MediaPlayerPrivateRemoteIdentifier, double);
- void setBufferingPolicy(MediaPlayerPrivateRemoteIdentifier, WebCore::MediaPlayer::BufferingPolicy);
-
#if PLATFORM(IOS_FAMILY)
void accessLog(MediaPlayerPrivateRemoteIdentifier, CompletionHandler<void(String)>&&);
void errorLog(MediaPlayerPrivateRemoteIdentifier, CompletionHandler<void(String)>&&);
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp (257679 => 257680)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp 2020-02-29 07:21:48 UTC (rev 257680)
@@ -29,7 +29,6 @@
#if ENABLE(GPU_PROCESS)
#include "GPUConnectionToWebProcess.h"
-#include "LayerHostingContext.h"
#include "MediaPlayerPrivateRemoteMessages.h"
#include "RemoteAudioTrackProxy.h"
#include "RemoteMediaPlayerManagerProxy.h"
@@ -107,17 +106,6 @@
completionHandler(WTFMove(configuration));
}
-void RemoteMediaPlayerProxy::prepareForPlayback(bool privateMode, WebCore::MediaPlayerEnums::Preload preload, bool preservesPitch, bool prepareForRendering, float videoContentScale, CompletionHandler<void(Optional<LayerHostingContextID>&& contextId)>&& completionHandler)
-{
- m_player->setPrivateBrowsingMode(privateMode);
- m_player->setPreload(preload);
- m_player->setPreservesPitch(preservesPitch);
- m_player->prepareForRendering();
- m_videoContentScale = videoContentScale;
- m_layerHostingContext = LayerHostingContext::createForExternalHostingProcess();
- completionHandler(m_layerHostingContext->contextID());
-}
-
void RemoteMediaPlayerProxy::cancelLoad()
{
m_updateCachedStateMessageTimer.stop();
@@ -194,11 +182,6 @@
m_player->setShouldMaintainAspectRatio(maintainRatio);
}
-void RemoteMediaPlayerProxy::setVideoFullscreenFrame(WebCore::FloatRect rect)
-{
- m_player->setVideoFullscreenFrame(rect);
-}
-
void RemoteMediaPlayerProxy::setVideoFullscreenGravity(WebCore::MediaPlayerEnums::VideoGravity gravity)
{
m_player->setVideoFullscreenGravity(gravity);
@@ -498,18 +481,6 @@
m_webProcessConnection->send(Messages::MediaPlayerPrivateRemote::EngineUpdated(), m_id);
}
-void RemoteMediaPlayerProxy::mediaPlayerFirstVideoFrameAvailable()
-{
- // Initially the size of the platformLayer will be 0x0 because we do not provide mediaPlayerContentBoxRect() in this class.
- m_layerHostingContext->setRootLayer(m_player->platformLayer());
- m_webProcessConnection->send(Messages::MediaPlayerPrivateRemote::FirstVideoFrameAvailable(), m_id);
-}
-
-void RemoteMediaPlayerProxy::mediaPlayerRenderingModeChanged()
-{
- m_layerHostingContext->setRootLayer(m_player->platformLayer());
-}
-
void RemoteMediaPlayerProxy::mediaPlayerActiveSourceBuffersChanged()
{
m_webProcessConnection->send(Messages::MediaPlayerPrivateRemote::ActiveSourceBuffersChanged(), m_id);
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h (257679 => 257680)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h 2020-02-29 07:21:48 UTC (rev 257680)
@@ -92,7 +92,7 @@
void getConfiguration(RemoteMediaPlayerConfiguration&);
- void prepareForPlayback(bool privateMode, WebCore::MediaPlayerEnums::Preload, bool preservesPitch, bool prepareForRendering, float videoContentScale, CompletionHandler<void(Optional<LayerHostingContextID>&&)>&&);
+ void prepareForPlayback(bool privateMode, WebCore::MediaPlayerEnums::Preload, bool preservesPitch, bool prepareForRendering, float videoContentScale, CompletionHandler<void(Optional<LayerHostingContextID>&& inlineLayerHostingContextId, Optional<LayerHostingContextID>&& fullscreenLayerHostingContextId)>&&);
void prepareForRendering();
void load(URL&&, Optional<SandboxExtension::Handle>&&, const WebCore::ContentType&, const String&, CompletionHandler<void(RemoteMediaPlayerConfiguration&&)>&&);
@@ -115,7 +115,9 @@
void setVisible(bool);
void setShouldMaintainAspectRatio(bool);
- void setVideoFullscreenFrame(WebCore::FloatRect);
+ void enterFullscreen(CompletionHandler<void()>&&);
+ void exitFullscreen(CompletionHandler<void()>&&);
+ void setVideoFullscreenFrameFenced(const WebCore::FloatRect&, const WTF::MachSendRight&);
void setVideoFullscreenGravity(WebCore::MediaPlayerEnums::VideoGravity);
void acceleratedRenderingStateChanged(bool);
void setShouldDisableSleep(bool);
@@ -251,7 +253,8 @@
RefPtr<SandboxExtension> m_sandboxExtension;
Ref<IPC::Connection> m_webProcessConnection;
RefPtr<WebCore::MediaPlayer> m_player;
- std::unique_ptr<LayerHostingContext> m_layerHostingContext;
+ std::unique_ptr<LayerHostingContext> m_inlineLayerHostingContext;
+ std::unique_ptr<LayerHostingContext> m_fullscreenLayerHostingContext;
RemoteMediaPlayerManagerProxy& m_manager;
WebCore::MediaPlayerEnums::MediaEngineIdentifier m_engineIdentifier;
Vector<WebCore::ContentType> m_typesRequiringHardwareSupport;
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in (257679 => 257680)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in 2020-02-29 07:21:48 UTC (rev 257680)
@@ -24,7 +24,7 @@
#if ENABLE(GPU_PROCESS)
messages -> RemoteMediaPlayerProxy NotRefCounted {
- PrepareForPlayback(bool privateMode, enum:uint8_t WebCore::MediaPlayerEnums::Preload preload, bool preservesPitch, bool prepareForRendering, float videoContentScale) -> (Optional<WebKit::LayerHostingContextID> layerHostingContextId) Async
+ PrepareForPlayback(bool privateMode, enum:uint8_t WebCore::MediaPlayerEnums::Preload preload, bool preservesPitch, bool prepareForRendering, float videoContentScale) -> (Optional<WebKit::LayerHostingContextID> inlineLayerHostingContextId, Optional<WebKit::LayerHostingContextID> fullscreenLayerHostingContextId) Async
Load(URL url, Optional<WebKit::SandboxExtension::Handle> sandboxExtension, WebCore::ContentType contentType, String keySystem) -> (struct WebKit::RemoteMediaPlayerConfiguration playerConfiguration) Async
CancelLoad()
@@ -47,7 +47,7 @@
PrepareForRendering()
SetVisible(bool visible)
SetShouldMaintainAspectRatio(bool maintainAspectRatio)
- SetVideoFullscreenFrame(WebCore::FloatRect rect)
+ SetVideoFullscreenFrameFenced(WebCore::FloatRect rect, MachSendRight machSendRight)
SetVideoFullscreenGravity(enum:uint8_t WebCore::MediaPlayerEnums::VideoGravity gravity)
AcceleratedRenderingStateChanged(bool canBeAccelerated)
SetShouldDisableSleep(bool disable)
@@ -67,6 +67,9 @@
SetVideoInlineSizeFenced(WebCore::IntSize size, MachSendRight machSendRight)
#endif
+ EnterFullscreen() -> () Async
+ ExitFullscreen() -> () Async
+
# Paint
# PaintCurrentFrameInContext
Modified: trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm (257679 => 257680)
--- trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm 2020-02-29 07:21:48 UTC (rev 257680)
@@ -29,6 +29,7 @@
#if ENABLE(GPU_PROCESS) && PLATFORM(COCOA)
#import "LayerHostingContext.h"
+#import "MediaPlayerPrivateRemoteMessages.h"
#import <QuartzCore/QuartzCore.h>
#import <WebCore/IntSize.h>
#import <wtf/MachSendRight.h>
@@ -35,16 +36,64 @@
namespace WebKit {
+void RemoteMediaPlayerProxy::prepareForPlayback(bool privateMode, WebCore::MediaPlayerEnums::Preload preload, bool preservesPitch, bool prepareForRendering, float videoContentScale, CompletionHandler<void(Optional<LayerHostingContextID>&& inlineLayerHostingContextId, Optional<LayerHostingContextID>&& fullscreenLayerHostingContextId)>&& completionHandler)
+{
+ m_player->setPrivateBrowsingMode(privateMode);
+ m_player->setPreload(preload);
+ m_player->setPreservesPitch(preservesPitch);
+ m_player->prepareForRendering();
+ m_videoContentScale = videoContentScale;
+ if (!m_inlineLayerHostingContext)
+ m_inlineLayerHostingContext = LayerHostingContext::createForExternalHostingProcess();
+ if (!m_fullscreenLayerHostingContext)
+ m_fullscreenLayerHostingContext = LayerHostingContext::createForExternalHostingProcess();
+ completionHandler(m_inlineLayerHostingContext->contextID(), m_fullscreenLayerHostingContext->contextID());
+}
+
+void RemoteMediaPlayerProxy::mediaPlayerFirstVideoFrameAvailable()
+{
+ // Initially the size of the platformLayer will be 0x0 because we do not provide mediaPlayerContentBoxRect() in this class.
+ m_inlineLayerHostingContext->setRootLayer(m_player->platformLayer());
+ m_webProcessConnection->send(Messages::MediaPlayerPrivateRemote::FirstVideoFrameAvailable(), m_id);
+}
+
+void RemoteMediaPlayerProxy::mediaPlayerRenderingModeChanged()
+{
+ m_inlineLayerHostingContext->setRootLayer(m_player->platformLayer());
+}
+
void RemoteMediaPlayerProxy::setVideoInlineSizeFenced(const WebCore::IntSize& size, const WTF::MachSendRight& machSendRight)
{
- m_layerHostingContext->setFencePort(machSendRight.sendRight());
+ m_inlineLayerHostingContext->setFencePort(machSendRight.sendRight());
// We do not want animations here
[CATransaction begin];
[CATransaction setDisableActions:YES];
- [m_layerHostingContext->rootLayer() setFrame:CGRectMake(0, 0, size.width(), size.height())];
+ [m_inlineLayerHostingContext->rootLayer() setFrame:CGRectMake(0, 0, size.width(), size.height())];
[CATransaction commit];
}
+void RemoteMediaPlayerProxy::enterFullscreen(CompletionHandler<void()>&& completionHandler)
+{
+ auto videoFullscreenLayer = m_player->createVideoFullscreenLayer();
+ [videoFullscreenLayer setName:@"Web Video Fullscreen Layer (remote)"];
+ [videoFullscreenLayer setPosition:CGPointZero];
+ m_fullscreenLayerHostingContext->setRootLayer(videoFullscreenLayer.get());
+
+ m_player->setVideoFullscreenLayer(videoFullscreenLayer.get(), WTFMove(completionHandler));
+}
+
+void RemoteMediaPlayerProxy::exitFullscreen(CompletionHandler<void()>&& completionHandler)
+{
+ m_player->setVideoFullscreenLayer(nullptr, WTFMove(completionHandler));
+ m_fullscreenLayerHostingContext->setRootLayer(nullptr);
+}
+
+void RemoteMediaPlayerProxy::setVideoFullscreenFrameFenced(const WebCore::FloatRect& rect, const WTF::MachSendRight& machSendRight)
+{
+ m_fullscreenLayerHostingContext->setFencePort(machSendRight.sendRight());
+ m_player->setVideoFullscreenFrame(rect);
+}
+
} // namespace WebKit
#endif // ENABLE(GPU_PROCESS) && PLATFORM(COCOA)
Modified: trunk/Source/WebKit/SourcesCocoa.txt (257679 => 257680)
--- trunk/Source/WebKit/SourcesCocoa.txt 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebKit/SourcesCocoa.txt 2020-02-29 07:21:48 UTC (rev 257680)
@@ -558,7 +558,7 @@
WebProcess/EntryPoint/Cocoa/XPCService/WebContentServiceEntryPoint.mm
WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp
-
+WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm
WebProcess/GPU/media/cocoa/VideoLayerRemoteCocoa.mm
WebProcess/InjectedBundle/API/c/WKBundlePageBanner.cpp
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (257679 => 257680)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-02-29 07:21:48 UTC (rev 257680)
@@ -2704,6 +2704,7 @@
1D4D736C23A9DF6000717A25 /* RemoteMediaResourceManagerMessages.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; name = RemoteMediaResourceManagerMessages.h; path = DerivedSources/WebKit2/RemoteMediaResourceManagerMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
1D4D737523A9EB6800717A25 /* RemoteMediaResourceManagerMessagesReplies.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; name = RemoteMediaResourceManagerMessagesReplies.h; path = DerivedSources/WebKit2/RemoteMediaResourceManagerMessagesReplies.h; sourceTree = BUILT_PRODUCTS_DIR; };
1D67B338212E1F6100FAA786 /* ShareSheetCallbackID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShareSheetCallbackID.h; sourceTree = "<group>"; };
+ 1D97EC7D240898D200466FFA /* MediaPlayerPrivateRemoteCocoa.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = MediaPlayerPrivateRemoteCocoa.mm; sourceTree = "<group>"; };
1DA4089423A80A3E0058C950 /* RemoteMediaResourceManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteMediaResourceManager.h; sourceTree = "<group>"; };
1DA4089E23A827780058C950 /* RemoteMediaResourceManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteMediaResourceManager.cpp; sourceTree = "<group>"; };
1DBBB061211CC3CB00502ECC /* WKShareSheet.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKShareSheet.mm; sourceTree = "<group>"; };
@@ -6222,6 +6223,7 @@
1DAF5A4D23EC9F7900B7B518 /* cocoa */ = {
isa = PBXGroup;
children = (
+ 1D97EC7D240898D200466FFA /* MediaPlayerPrivateRemoteCocoa.mm */,
1DFDD0E023F60E1F00E9B490 /* VideoLayerRemoteCocoa.h */,
1DFDD0DF23F60E1E00E9B490 /* VideoLayerRemoteCocoa.mm */,
);
Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp (257679 => 257680)
--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp 2020-02-29 07:21:48 UTC (rev 257680)
@@ -99,14 +99,16 @@
{
auto scale = m_player->playerContentsScale();
- connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::PrepareForPlayback(privateMode, preload, preservesPitch, prepare, scale), [weakThis = makeWeakPtr(*this), this](auto contextId) mutable {
+ connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::PrepareForPlayback(privateMode, preload, preservesPitch, prepare, scale), [weakThis = makeWeakPtr(*this), this](auto inlineLayerHostingContextId, auto fullscreenLayerHostingContextId) mutable {
if (!weakThis)
return;
- if (!contextId)
+ if (!inlineLayerHostingContextId)
return;
- m_videoInlineLayer = createVideoLayerRemote(this, contextId.value());
+ m_videoInlineLayer = createVideoLayerRemote(this, inlineLayerHostingContextId.value());
+
+ m_fullscreenLayerHostingContextId = fullscreenLayerHostingContextId;
}, m_id);
}
@@ -339,6 +341,11 @@
return m_configuration.supportsAcceleratedRendering;
}
+void MediaPlayerPrivateRemote::acceleratedRenderingStateChanged()
+{
+ connection().send(Messages::RemoteMediaPlayerProxy::AcceleratedRenderingStateChanged(m_player->supportsAcceleratedRendering()), m_id);
+}
+
bool MediaPlayerPrivateRemote::canPlayToWirelessPlaybackTarget() const
{
return m_configuration.canPlayToWirelessPlaybackTarget;
@@ -379,21 +386,6 @@
connection().send(Messages::RemoteMediaPlayerProxy::SetShouldMaintainAspectRatio(maintainRatio), m_id);
}
-void MediaPlayerPrivateRemote::setVideoFullscreenFrame(WebCore::FloatRect rect)
-{
- connection().send(Messages::RemoteMediaPlayerProxy::SetVideoFullscreenFrame(rect), m_id);
-}
-
-void MediaPlayerPrivateRemote::setVideoFullscreenGravity(WebCore::MediaPlayerEnums::VideoGravity gravity)
-{
- connection().send(Messages::RemoteMediaPlayerProxy::SetVideoFullscreenGravity(gravity), m_id);
-}
-
-void MediaPlayerPrivateRemote::acceleratedRenderingStateChanged()
-{
- connection().send(Messages::RemoteMediaPlayerProxy::AcceleratedRenderingStateChanged(m_player->supportsAcceleratedRendering()), m_id);
-}
-
void MediaPlayerPrivateRemote::setShouldDisableSleep(bool disable)
{
connection().send(Messages::RemoteMediaPlayerProxy::SetShouldDisableSleep(disable), m_id);
@@ -615,9 +607,16 @@
}
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
-void MediaPlayerPrivateRemote::setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&&)
+
+void MediaPlayerPrivateRemote::setVideoFullscreenLayer(PlatformLayer* videoFullscreenLayer, WTF::Function<void()>&& completionHandler)
{
- notImplemented();
+ if (!videoFullscreenLayer) {
+ connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::ExitFullscreen(), WTFMove(completionHandler), m_id);
+ return;
+ }
+
+ ASSERT(m_videoFullscreenLayer.get() == videoFullscreenLayer);
+ connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::EnterFullscreen(), WTFMove(completionHandler), m_id);
}
void MediaPlayerPrivateRemote::updateVideoFullscreenInlineImage()
@@ -625,6 +624,16 @@
connection().send(Messages::RemoteMediaPlayerProxy::UpdateVideoFullscreenInlineImage(), m_id);
}
+void MediaPlayerPrivateRemote::setVideoFullscreenFrameFenced(const WebCore::FloatRect& rect, const WTF::MachSendRight& sendRight)
+{
+ connection().send(Messages::RemoteMediaPlayerProxy::SetVideoFullscreenFrameFenced(rect, sendRight), m_id);
+}
+
+void MediaPlayerPrivateRemote::setVideoFullscreenGravity(WebCore::MediaPlayerEnums::VideoGravity gravity)
+{
+ connection().send(Messages::RemoteMediaPlayerProxy::SetVideoFullscreenGravity(gravity), m_id);
+}
+
void MediaPlayerPrivateRemote::setVideoFullscreenMode(MediaPlayer::VideoFullscreenMode mode)
{
connection().send(Messages::RemoteMediaPlayerProxy::SetVideoFullscreenMode(mode), m_id);
Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h (257679 => 257680)
--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h 2020-02-29 07:21:48 UTC (rev 257680)
@@ -27,6 +27,7 @@
#if ENABLE(GPU_PROCESS)
+#include "LayerHostingContext.h"
#include "RemoteMediaPlayerConfiguration.h"
#include "RemoteMediaPlayerManager.h"
#include "RemoteMediaPlayerState.h"
@@ -98,6 +99,7 @@
void firstVideoFrameAvailable();
#if PLATFORM(COCOA)
void setVideoInlineSizeFenced(const WebCore::IntSize&, const WTF::MachSendRight&);
+ void setVideoFullscreenFrameFenced(const WebCore::FloatRect&, const WTF::MachSendRight&);
#endif
void addRemoteAudioTrack(TrackPrivateRemoteIdentifier, TrackPrivateRemoteConfiguration&&);
@@ -179,6 +181,7 @@
PlatformLayer* platformLayer() const final;
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
+ RetainPtr<PlatformLayer> createVideoFullscreenLayer() final;
void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler) final;
void updateVideoFullscreenInlineImage() final;
void setVideoFullscreenFrame(WebCore::FloatRect) final;
@@ -357,6 +360,8 @@
WebCore::MediaPlayer* m_player { nullptr };
RefPtr<WebCore::PlatformMediaResourceLoader> m_mediaResourceLoader;
RetainPtr<PlatformLayer> m_videoInlineLayer;
+ RetainPtr<PlatformLayer> m_videoFullscreenLayer;
+ Optional<LayerHostingContextID> m_fullscreenLayerHostingContextId;
RemoteMediaPlayerManager& m_manager;
WebCore::MediaPlayerEnums::MediaEngineIdentifier m_remoteEngineIdentifier;
MediaPlayerPrivateRemoteIdentifier m_id;
Added: trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm (0 => 257680)
--- trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm 2020-02-29 07:21:48 UTC (rev 257680)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MediaPlayerPrivateRemote.h"
+
+#if ENABLE(GPU_PROCESS) && PLATFORM(COCOA)
+
+#import <WebCore/FloatRect.h>
+#import <pal/spi/cocoa/QuartzCoreSPI.h>
+#import <wtf/MachSendRight.h>
+
+namespace WebKit {
+
+#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
+
+RetainPtr<PlatformLayer> MediaPlayerPrivateRemote::createVideoFullscreenLayer()
+{
+ if (!m_fullscreenLayerHostingContextId)
+ return nullptr;
+
+ if (!m_videoFullscreenLayer) {
+ m_videoFullscreenLayer = adoptNS([[CALayer alloc] init]);
+ auto sublayer = LayerHostingContext::createPlatformLayerForHostingContext(m_fullscreenLayerHostingContextId.value());
+ [sublayer setName:@"VideoFullscreenLayerSublayer"];
+ [sublayer setPosition:CGPointMake(0, 0)];
+ [m_videoFullscreenLayer addSublayer:sublayer.get()];
+ }
+
+ return m_videoFullscreenLayer;
+}
+
+void MediaPlayerPrivateRemote::setVideoFullscreenFrame(WebCore::FloatRect rect)
+{
+ auto context = [m_videoFullscreenLayer context];
+ if (!context)
+ return;
+
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+
+ MachSendRight fenceSendRight = MachSendRight::adopt([context createFencePort]);
+ setVideoFullscreenFrameFenced(rect, fenceSendRight);
+
+ [CATransaction commit];
+}
+
+#endif
+
+} // namespace WebKit
+
+#endif // ENABLE(GPU_PROCESS) && PLATFORM(COCOA)
Modified: trunk/Source/WebKit/WebProcess/GPU/media/cocoa/VideoLayerRemoteCocoa.mm (257679 => 257680)
--- trunk/Source/WebKit/WebProcess/GPU/media/cocoa/VideoLayerRemoteCocoa.mm 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebKit/WebProcess/GPU/media/cocoa/VideoLayerRemoteCocoa.mm 2020-02-29 07:21:48 UTC (rev 257680)
@@ -156,15 +156,10 @@
// Initially, all the layers will be empty (both width and height are 0) and invisible.
// The renderer will change the sizes of WKVideoLayerRemote to trigger layout of sublayers and make them visible.
auto videoLayerRemote = adoptNS([[WKVideoLayerRemote alloc] init]);
-#ifndef NDEBUG
[videoLayerRemote setName:@"WKVideoLayerRemote"];
-#endif
-
[videoLayerRemote setMediaPlayerPrivateRemote:mediaPlayerPrivateRemote];
+ [videoLayerRemote addSublayer:LayerHostingContext::createPlatformLayerForHostingContext(contextId).get()];
- auto videoSublayer = LayerHostingContext::createPlatformLayerForHostingContext(contextId);
- [videoLayerRemote addSublayer:videoSublayer.get()];
-
return videoLayerRemote;
}
Modified: trunk/Source/WebKit/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm (257679 => 257680)
--- trunk/Source/WebKit/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebKit/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm 2020-02-29 07:21:48 UTC (rev 257680)
@@ -28,6 +28,7 @@
#if ENABLE(NETSCAPE_PLUGIN_API)
+#import "LayerTreeContext.h"
#import "NetscapeBrowserFuncs.h"
#import "PluginController.h"
#import "WebEvent.h"
Modified: trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm (257679 => 257680)
--- trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm 2020-02-29 07:03:48 UTC (rev 257679)
+++ trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm 2020-02-29 07:21:48 UTC (rev 257680)
@@ -271,10 +271,9 @@
bool allowsPictureInPicture = videoElement.webkitSupportsPresentationMode(HTMLVideoElement::VideoPresentationMode::PictureInPicture);
if (!interface->layerHostingContext()->rootLayer()) {
- PlatformLayer* videoLayer = [CALayer layer];
+ auto videoLayer = model->createVideoFullscreenLayer();
[videoLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];
-
- [videoLayer setName:@"Web video fullscreen manager layer"];
+ [videoLayer setName:@"Web Video Fullscreen Layer"];
[videoLayer setPosition:CGPointMake(0, 0)];
[videoLayer setBackgroundColor:cachedCGColor(WebCore::Color::transparent)];
@@ -283,7 +282,7 @@
float hostingScaleFactor = m_page->deviceScaleFactor();
[videoLayer setTransform:CATransform3DMakeScale(hostingScaleFactor, hostingScaleFactor, 1)];
- interface->layerHostingContext()->setRootLayer(videoLayer);
+ interface->layerHostingContext()->setRootLayer(videoLayer.get());
}
m_page->send(Messages::VideoFullscreenManagerProxy::SetupFullscreenWithID(contextId, interface->layerHostingContext()->contextID(), videoRect, m_page->deviceScaleFactor(), interface->fullscreenMode(), allowsPictureInPicture, standby));