Title: [267725] trunk/Source
Revision
267725
Author
[email protected]
Date
2020-09-28 21:52:54 -0700 (Mon, 28 Sep 2020)

Log Message

[Media in GPU Process] Use VideoLayerManager to manage layers of MediaPlayerPrivateRemote
https://bugs.webkit.org/show_bug.cgi?id=216995

Reviewed by Eric Carlson.

Source/WebCore:

No new tests since no functional changes.

* Headers.cmake:
Export TextTrackRepresentation and VideoLayerManager.

* WebCore.xcodeproj/project.pbxproj:
Add VideoLayerManager.h.
Export TextTrackRepresentation, WebVideoContainerLayer and VideoLayerManager.

* platform/graphics/TextTrackRepresentation.cpp:
* platform/graphics/TextTrackRepresentation.h:
Minor clean-up.

* platform/graphics/VideoLayerManager.h: Added.
Add this interface so that we can use VideoLayerManager in the C++ code.

* platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h:
* platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm:
(WebCore::VideoLayerManagerObjC::videoInlineLayer const):
(WebCore::VideoLayerManagerObjC::videoFullscreenLayer const):
(WebCore::VideoLayerManagerObjC::videoFullscreenFrame const):
(WebCore::VideoLayerManagerObjC::updateVideoFullscreenInlineImage):
Fix the issue when RELEASE_LOG_DISABLED is defined and add WEBCORE_EXPORT
to some functions.

Source/WebKit:

This patch removes the remote hosting layer in the GPU process for video fullscreen and
picture-in-picture. We don't need to keep a layer in the GPU process for video fullscreen
and picture-in-picture because no rendering will be done for that layer. We don't need
EnterFullscreen, ExitFullscreen and SetVideoFullscreenFrameFenced IPC messages after removing
the layer because the RemoteMediaPlayerPrivateRemote in the web process can deal with
the video presentation mode change.

* GPUProcess/media/RemoteMediaPlayerProxy.h:
* GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
* GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm:
(WebKit::RemoteMediaPlayerProxy::prepareForPlayback):
(WebKit::RemoteMediaPlayerProxy::enterFullscreen): Deleted.
(WebKit::RemoteMediaPlayerProxy::exitFullscreen): Deleted.
(WebKit::RemoteMediaPlayerProxy::setVideoFullscreenFrameFenced): Deleted.
Remove unused IPC messages after removing the remote hosting layer for video fullscreen
and picture-in-picture.

* GPUProcess/media/gstreamer/RemoteMediaPlayerProxyGStreamer.cpp:
(WebKit::RemoteMediaPlayerProxy::prepareForPlayback):
(WebKit::RemoteMediaPlayerProxy::enterFullscreen): Deleted.
(WebKit::RemoteMediaPlayerProxy::exitFullscreen): Deleted.
Ditto.

* WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
(WebKit::MediaPlayerPrivateRemote::MediaPlayerPrivateRemote):
(WebKit::MediaPlayerPrivateRemote::~MediaPlayerPrivateRemote):
(WebKit::MediaPlayerPrivateRemote::prepareForPlayback):
Remove the code related to the remote hosting layer for video fullscreen and picture-in-picture.
(WebKit::MediaPlayerPrivateRemote::platformLayer const):
(WebKit::MediaPlayerPrivateRemote::setVideoFullscreenLayer):
Use VideoLayerManager to manage the layer.
(WebKit::MediaPlayerPrivateRemote::setVideoFullscreenFrame): Ditto.
(WebKit::MediaPlayerPrivateRemote::requiresTextTrackRepresentation const): Ditto.
(WebKit::MediaPlayerPrivateRemote::setTextTrackRepresentation): Ditto.
(WebKit::MediaPlayerPrivateRemote::syncTextTrackBounds): Ditto.
(WebKit::MediaPlayerPrivateRemote::setVideoFullscreenFrameFenced): Deleted.
* WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
Need to move the Logger up in the data members so that other members can use it
in the constructor, e.g., VideoLayerManager.

* WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:
(WebKit::MediaPlayerPrivateRemote::MediaPlayerPrivateRemote):
(WebKit::MediaPlayerPrivateRemote::createVideoFullscreenLayer):
(WebKit::MediaPlayerPrivateRemote::setVideoFullscreenFrame): Deleted.
(WebKit::MediaPlayerPrivateRemote::setTextTrackRepresentation): Deleted.
(WebKit::MediaPlayerPrivateRemote::syncTextTrackBounds): Deleted.
Simplify the implementation by managing layers with VideoLayerManager.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (267724 => 267725)


--- trunk/Source/WebCore/ChangeLog	2020-09-29 04:10:11 UTC (rev 267724)
+++ trunk/Source/WebCore/ChangeLog	2020-09-29 04:52:54 UTC (rev 267725)
@@ -1,3 +1,35 @@
+2020-09-28  Peng Liu  <[email protected]>
+
+        [Media in GPU Process] Use VideoLayerManager to manage layers of MediaPlayerPrivateRemote
+        https://bugs.webkit.org/show_bug.cgi?id=216995
+
+        Reviewed by Eric Carlson.
+
+        No new tests since no functional changes.
+
+        * Headers.cmake:
+        Export TextTrackRepresentation and VideoLayerManager.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        Add VideoLayerManager.h.
+        Export TextTrackRepresentation, WebVideoContainerLayer and VideoLayerManager.
+
+        * platform/graphics/TextTrackRepresentation.cpp:
+        * platform/graphics/TextTrackRepresentation.h:
+        Minor clean-up.
+
+        * platform/graphics/VideoLayerManager.h: Added.
+        Add this interface so that we can use VideoLayerManager in the C++ code.
+
+        * platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h:
+        * platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm:
+        (WebCore::VideoLayerManagerObjC::videoInlineLayer const):
+        (WebCore::VideoLayerManagerObjC::videoFullscreenLayer const):
+        (WebCore::VideoLayerManagerObjC::videoFullscreenFrame const):
+        (WebCore::VideoLayerManagerObjC::updateVideoFullscreenInlineImage):
+        Fix the issue when RELEASE_LOG_DISABLED is defined and add WEBCORE_EXPORT
+        to some functions.
+
 2020-09-28  Tetsuharu Ohzeki  <[email protected]>
 
         webkitfullscreenchange does not fire for shadow DOM elements

Modified: trunk/Source/WebCore/Headers.cmake (267724 => 267725)


--- trunk/Source/WebCore/Headers.cmake	2020-09-29 04:10:11 UTC (rev 267724)
+++ trunk/Source/WebCore/Headers.cmake	2020-09-29 04:52:54 UTC (rev 267725)
@@ -1213,9 +1213,11 @@
     platform/graphics/StringTruncator.h
     platform/graphics/TabSize.h
     platform/graphics/TextRun.h
+    platform/graphics/TextTrackRepresentation.h
     platform/graphics/TiledBacking.h
     platform/graphics/TrackPrivateBase.h
     platform/graphics/VelocityData.h
+    platform/graphics/VideoLayerManager.h
     platform/graphics/VideoTrackPrivate.h
     platform/graphics/WidthCache.h
     platform/graphics/WindRule.h

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (267724 => 267725)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-09-29 04:10:11 UTC (rev 267724)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-09-29 04:52:54 UTC (rev 267725)
@@ -630,7 +630,11 @@
 		1D2F8E052344751D00993B68 /* HTMLVideoElementPictureInPicture.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DEF06CC233C3D2000EE228D /* HTMLVideoElementPictureInPicture.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1D2F8E062344752300993B68 /* PictureInPictureWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DEF06CD233C3D2A00EE228D /* PictureInPictureWindow.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1D9F0FC12122029B005D8FD4 /* ShareData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DC55400211BA8C8004B780E /* ShareData.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		1DAB3112251D6BF300FC9485 /* WebVideoContainerLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8B31A12379DC8300883FDE /* WebVideoContainerLayer.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		1DAB3114251D725C00FC9485 /* VideoLayerManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DAB3113251D725C00FC9485 /* VideoLayerManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		1DAB3115251D74DB00FC9485 /* VideoLayerManagerObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = 52D5A18E1C54590300DE34A3 /* VideoLayerManagerObjC.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1DBC1B562347B3D200B901AF /* PictureInPictureObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DBC1B552347B3D200B901AF /* PictureInPictureObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		1DD3B4C6251DA0B80069B24A /* VideoLayerManagerObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52D5A18D1C54590300DE34A3 /* VideoLayerManagerObjC.mm */; };
 		1DF7E81F251A9E0600DB8F61 /* TextTrackRepresentation.h in Headers */ = {isa = PBXBuildFile; fileRef = CDD1E525167BA56400CE820B /* TextTrackRepresentation.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1F36EA9C1E21BA1700621E25 /* WebBackgroundTaskController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F36EA9A1E21BA1700621E25 /* WebBackgroundTaskController.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1F72BF0B187FD45C0009BCB3 /* TileControllerMemoryHandlerIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F72BF09187FD4270009BCB3 /* TileControllerMemoryHandlerIOS.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -1588,7 +1592,6 @@
 		52B0D4BE1C57FD1E0077CE53 /* PlatformView.h in Headers */ = {isa = PBXBuildFile; fileRef = 52B0D4BD1C57FD1E0077CE53 /* PlatformView.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		52B0D4C01C57FD660077CE53 /* VideoFullscreenChangeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 52B0D4BF1C57FD660077CE53 /* VideoFullscreenChangeObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		52B0D4C21C57FF910077CE53 /* VideoFullscreenInterfaceMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 52B0D4C11C57FF910077CE53 /* VideoFullscreenInterfaceMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		52D5A18F1C54592300DE34A3 /* VideoLayerManagerObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52D5A18D1C54590300DE34A3 /* VideoLayerManagerObjC.mm */; };
 		52D5A1A71C57489D00DE34A3 /* VideoFullscreenModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 52D5A1A41C57488900DE34A3 /* VideoFullscreenModel.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		52D5A1A81C5748A300DE34A3 /* VideoFullscreenModelVideoElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 52D5A1A51C57488900DE34A3 /* VideoFullscreenModelVideoElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		52E2CAFC19FF0207001EEB4F /* MediaProducer.h in Headers */ = {isa = PBXBuildFile; fileRef = 52E2CAFB19FF0207001EEB4F /* MediaProducer.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -6727,6 +6730,7 @@
 		1D0026A82374F9D900CA6CDF /* JSEnterPictureInPictureEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEnterPictureInPictureEvent.h; sourceTree = "<group>"; };
 		1D0026A92374F9D900CA6CDF /* JSEnterPictureInPictureEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEnterPictureInPictureEvent.cpp; sourceTree = "<group>"; };
 		1D2C82B6236A3F6A0055D6C5 /* PictureInPictureSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PictureInPictureSupport.h; sourceTree = "<group>"; };
+		1DAB3113251D725C00FC9485 /* VideoLayerManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VideoLayerManager.h; sourceTree = "<group>"; };
 		1DBC1B552347B3D200B901AF /* PictureInPictureObserver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PictureInPictureObserver.h; sourceTree = "<group>"; };
 		1DC553FD211BA12A004B780E /* NavigatorShare.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NavigatorShare.idl; sourceTree = "<group>"; };
 		1DC553FF211BA841004B780E /* ShareData.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ShareData.idl; sourceTree = "<group>"; };
@@ -8719,8 +8723,8 @@
 		52B0D4BF1C57FD660077CE53 /* VideoFullscreenChangeObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoFullscreenChangeObserver.h; sourceTree = "<group>"; };
 		52B0D4C11C57FF910077CE53 /* VideoFullscreenInterfaceMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoFullscreenInterfaceMac.h; sourceTree = "<group>"; };
 		52CB11DB22FDDB2E009F0A64 /* WHLSLDefaultDelete.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLDefaultDelete.h; sourceTree = "<group>"; };
-		52D5A18D1C54590300DE34A3 /* VideoLayerManagerObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoLayerManagerObjC.mm; sourceTree = "<group>"; tabWidth = 8; };
-		52D5A18E1C54590300DE34A3 /* VideoLayerManagerObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoLayerManagerObjC.h; sourceTree = "<group>"; tabWidth = 8; };
+		52D5A18D1C54590300DE34A3 /* VideoLayerManagerObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoLayerManagerObjC.mm; sourceTree = "<group>"; };
+		52D5A18E1C54590300DE34A3 /* VideoLayerManagerObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoLayerManagerObjC.h; sourceTree = "<group>"; };
 		52D5A1A41C57488900DE34A3 /* VideoFullscreenModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoFullscreenModel.h; sourceTree = "<group>"; };
 		52D5A1A51C57488900DE34A3 /* VideoFullscreenModelVideoElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoFullscreenModelVideoElement.h; sourceTree = "<group>"; };
 		52D5A1A61C57488900DE34A3 /* VideoFullscreenModelVideoElement.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoFullscreenModelVideoElement.mm; sourceTree = "<group>"; };
@@ -26196,6 +26200,7 @@
 				E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */,
 				0F5A57CA229B18AE0025EDA9 /* VelocityData.cpp */,
 				0F1A0C36229A481800D37ADB /* VelocityData.h */,
+				1DAB3113251D725C00FC9485 /* VideoLayerManager.h */,
 				BEF29EEA1715DD0900C4B4C9 /* VideoTrackPrivate.h */,
 				CD6FE5BB24BCE7B6009FCDA4 /* VP9Utilities.cpp */,
 				CD6FE5BA24BCE7B6009FCDA4 /* VP9Utilities.h */,
@@ -28495,10 +28500,6 @@
 		E4FB4B1E2395356F003C336A /* integration */ = {
 			isa = PBXGroup;
 			children = (
-				E4A664C72521B779007081DC /* LayoutIntegrationRunIterator.cpp */,
-				E4A664C62521B778007081DC /* LayoutIntegrationRunIterator.h */,
-				E4A664C52521B778007081DC /* LayoutIntegrationRunIteratorLegacyPath.h */,
-				E4A664C42521B777007081DC /* LayoutIntegrationRunIteratorModernPath.h */,
 				E418025623D454B500FFB071 /* LayoutIntegrationBoxTree.cpp */,
 				E418025323D4549A00FFB071 /* LayoutIntegrationBoxTree.h */,
 				E403B79F251B118B0019E800 /* LayoutIntegrationCoverage.cpp */,
@@ -28507,6 +28508,10 @@
 				E4ABABDB236088FD00FA4345 /* LayoutIntegrationLineLayout.h */,
 				E4312AB524B3265600678349 /* LayoutIntegrationPagination.cpp */,
 				E4312AB724B3265600678349 /* LayoutIntegrationPagination.h */,
+				E4A664C72521B779007081DC /* LayoutIntegrationRunIterator.cpp */,
+				E4A664C62521B778007081DC /* LayoutIntegrationRunIterator.h */,
+				E4A664C52521B778007081DC /* LayoutIntegrationRunIteratorLegacyPath.h */,
+				E4A664C42521B777007081DC /* LayoutIntegrationRunIteratorModernPath.h */,
 			);
 			path = integration;
 			sourceTree = "<group>";
@@ -32447,7 +32452,6 @@
 				07969DB017D14151007FF842 /* JSRTCDTMFSender.h in Headers */,
 				07969DB217D14151007FF842 /* JSRTCDTMFToneChangeEvent.h in Headers */,
 				07969DB617D14151007FF842 /* JSRTCIceCandidate.h in Headers */,
-				E4A664CE2521D4C9007081DC /* LayoutIntegrationRunIteratorModernPath.h in Headers */,
 				316DCB4C1E7910A6001B5F87 /* JSRTCIceConnectionState.h in Headers */,
 				316DCB4E1E7910A6001B5F87 /* JSRTCIceGatheringState.h in Headers */,
 				073794EC19EE341E00E5A045 /* JSRTCIceServer.h in Headers */,
@@ -32493,7 +32497,6 @@
 				B59DD6A511902A62007E9684 /* JSSQLStatementCallback.h in Headers */,
 				B59DD6A911902A71007E9684 /* JSSQLStatementErrorCallback.h in Headers */,
 				BC82432A0D0CE8A200460C8F /* JSSQLTransaction.h in Headers */,
-				E4A664CC2521D4AF007081DC /* LayoutIntegrationRunIterator.h in Headers */,
 				B59DD69D11902A42007E9684 /* JSSQLTransactionCallback.h in Headers */,
 				B59DD6A111902A52007E9684 /* JSSQLTransactionErrorCallback.h in Headers */,
 				A86629D309DA2B48009633A7 /* JSStaticRange.h in Headers */,
@@ -32785,6 +32788,9 @@
 				E403B7A2251B11930019E800 /* LayoutIntegrationCoverage.h in Headers */,
 				E4ABABDD236088FE00FA4345 /* LayoutIntegrationLineLayout.h in Headers */,
 				E403B7A3251B11C10019E800 /* LayoutIntegrationPagination.h in Headers */,
+				E4A664CC2521D4AF007081DC /* LayoutIntegrationRunIterator.h in Headers */,
+				E4A664CF2521D4E2007081DC /* LayoutIntegrationRunIteratorLegacyPath.h in Headers */,
+				E4A664CE2521D4C9007081DC /* LayoutIntegrationRunIteratorModernPath.h in Headers */,
 				11310CF420BA4A3D0065A8D0 /* LayoutIterator.h in Headers */,
 				6FFA4C0123F2FED9007E4EBC /* LayoutLineBreakBox.h in Headers */,
 				931D72F615FE695300C4C07E /* LayoutMilestone.h in Headers */,
@@ -32963,7 +32969,6 @@
 				C96F5EC81B5872260091EA9D /* MediaSessionInterruptionProvider.h in Headers */,
 				C96F5EC51B5872260091EA9D /* MediaSessionInterruptionProviderMac.h in Headers */,
 				C90F65561B2253BE002163A1 /* MediaSessionManager.h in Headers */,
-				E4A664CF2521D4E2007081DC /* LayoutIntegrationRunIteratorLegacyPath.h in Headers */,
 				417F7AEF2139BF6F00FBA7EC /* MediaSessionManagerCocoa.h in Headers */,
 				07638A991884487200E15A1B /* MediaSessionManagerIOS.h in Headers */,
 				C9D851F01B39DC780085062E /* MediaSessionMetadata.h in Headers */,
@@ -34381,6 +34386,8 @@
 				52B0D4C21C57FF910077CE53 /* VideoFullscreenInterfaceMac.h in Headers */,
 				52D5A1A71C57489D00DE34A3 /* VideoFullscreenModel.h in Headers */,
 				52D5A1A81C5748A300DE34A3 /* VideoFullscreenModelVideoElement.h in Headers */,
+				1DAB3114251D725C00FC9485 /* VideoLayerManager.h in Headers */,
+				1DAB3115251D74DB00FC9485 /* VideoLayerManagerObjC.h in Headers */,
 				CDE83DB2183C44060031EAA3 /* VideoPlaybackQuality.h in Headers */,
 				0757B13E214AE79900794B0D /* VideoPreset.h in Headers */,
 				CD9D827A1C7B8EE1006FF066 /* VideoTextureCopierCV.h in Headers */,
@@ -34557,6 +34564,7 @@
 				1F8756B21E22C3350042C40D /* WebSQLiteDatabaseTrackerClient.h in Headers */,
 				31DEA4561B39F4D900F77178 /* WebSystemBackdropLayer.h in Headers */,
 				0F580FA31496939100FB5BD8 /* WebTiledBackingLayer.h in Headers */,
+				1DAB3112251D6BF300FC9485 /* WebVideoContainerLayer.h in Headers */,
 				3F42B31D1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h in Headers */,
 				2D7DA0F22435EB1900F048D1 /* WebViewVisualIdentificationOverlay.h in Headers */,
 				F12171F616A8CF0B000053CA /* WebVTTElement.h in Headers */,
@@ -35825,7 +35833,7 @@
 				7CE68344192143A800F4D928 /* UserMessageHandlerDescriptor.cpp in Sources */,
 				7C73FB07191EF417007DE061 /* UserMessageHandlersNamespace.cpp in Sources */,
 				3FBC4AF3189881560046EE38 /* VideoFullscreenInterfaceAVKit.mm in Sources */,
-				52D5A18F1C54592300DE34A3 /* VideoLayerManagerObjC.mm in Sources */,
+				1DD3B4C6251DA0B80069B24A /* VideoLayerManagerObjC.mm in Sources */,
 				CD336F6717FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.cpp in Sources */,
 				CD8B5A42180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.mm in Sources */,
 				26F9A83818A046AC00AEB88A /* ViewportConfiguration.cpp in Sources */,

Modified: trunk/Source/WebCore/platform/graphics/TextTrackRepresentation.cpp (267724 => 267725)


--- trunk/Source/WebCore/platform/graphics/TextTrackRepresentation.cpp	2020-09-29 04:10:11 UTC (rev 267724)
+++ trunk/Source/WebCore/platform/graphics/TextTrackRepresentation.cpp	2020-09-29 04:52:54 UTC (rev 267725)
@@ -24,11 +24,10 @@
  */
 
 #include "config.h"
+#include "TextTrackRepresentation.h"
 
 #if ENABLE(VIDEO)
 
-#include "TextTrackRepresentation.h"
-
 #include "IntRect.h"
 
 namespace WebCore {

Modified: trunk/Source/WebCore/platform/graphics/TextTrackRepresentation.h (267724 => 267725)


--- trunk/Source/WebCore/platform/graphics/TextTrackRepresentation.h	2020-09-29 04:10:11 UTC (rev 267724)
+++ trunk/Source/WebCore/platform/graphics/TextTrackRepresentation.h	2020-09-29 04:52:54 UTC (rev 267725)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TextTrackRepresentation_h
-#define TextTrackRepresentation_h
+#pragma once
 
 #if ENABLE(VIDEO)
 
@@ -61,5 +60,3 @@
 }
 
 #endif
-
-#endif // TextTrackRepresentation_h

Copied: trunk/Source/WebCore/platform/graphics/VideoLayerManager.h (from rev 267724, trunk/Source/WebCore/platform/graphics/TextTrackRepresentation.h) (0 => 267725)


--- trunk/Source/WebCore/platform/graphics/VideoLayerManager.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/VideoLayerManager.h	2020-09-29 04:52:54 UTC (rev 267725)
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include "NativeImage.h"
+#include "PlatformLayer.h"
+#include <wtf/Function.h>
+
+namespace WebCore {
+
+class FloatRect;
+class IntSize;
+
+class VideoLayerManager {
+public:
+    virtual ~VideoLayerManager() = default;
+
+    virtual PlatformLayer* videoInlineLayer() const = 0;
+    virtual void setVideoLayer(PlatformLayer*, IntSize) = 0;
+    virtual void didDestroyVideoLayer() = 0;
+
+#if ENABLE(VIDEO_PRESENTATION_MODE)
+    virtual PlatformLayer* videoFullscreenLayer() const = 0;
+    virtual void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler, NativeImagePtr) = 0;
+    virtual FloatRect videoFullscreenFrame() const = 0;
+    virtual void setVideoFullscreenFrame(FloatRect) = 0;
+    virtual void updateVideoFullscreenInlineImage(NativeImagePtr) = 0;
+#endif
+
+    virtual bool requiresTextTrackRepresentation() const = 0;
+    virtual void setTextTrackRepresentationLayer(PlatformLayer*) = 0;
+    virtual void syncTextTrackBounds() = 0;
+};
+
+}

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h (267724 => 267725)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h	2020-09-29 04:10:11 UTC (rev 267724)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h	2020-09-29 04:52:54 UTC (rev 267725)
@@ -29,6 +29,7 @@
 #include "IntSize.h"
 #include "NativeImage.h"
 #include "PlatformLayer.h"
+#include "VideoLayerManager.h"
 #include "WebVideoContainerLayer.h"
 #include <wtf/Function.h>
 #include <wtf/LoggerHelper.h>
@@ -37,32 +38,44 @@
 
 namespace WebCore {
 
-class TextTrackRepresentation;
-
-class VideoLayerManagerObjC final : public LoggerHelper {
+class VideoLayerManagerObjC final
+    : public VideoLayerManager
+#if !RELEASE_LOG_DISABLED
+    , public LoggerHelper
+#endif
+{
     WTF_MAKE_NONCOPYABLE(VideoLayerManagerObjC);
     WTF_MAKE_FAST_ALLOCATED;
+
 public:
-    VideoLayerManagerObjC(const Logger&, const void*);
+#if !RELEASE_LOG_DISABLED
+    WEBCORE_EXPORT VideoLayerManagerObjC(const Logger&, const void*);
+#else
+    WEBCORE_EXPORT VideoLayerManagerObjC() = default;
+#endif
 
-    PlatformLayer *videoInlineLayer() const { return m_videoInlineLayer.get(); }
+    ~VideoLayerManagerObjC() = default;
 
-    void setVideoLayer(PlatformLayer *, IntSize contentSize);
-    void didDestroyVideoLayer();
+    WEBCORE_EXPORT PlatformLayer* videoInlineLayer() const final;
 
+    WEBCORE_EXPORT void setVideoLayer(PlatformLayer*, IntSize contentSize) final;
+    WEBCORE_EXPORT void didDestroyVideoLayer() final;
+
 #if ENABLE(VIDEO_PRESENTATION_MODE)
-    PlatformLayer *videoFullscreenLayer() const { return m_videoFullscreenLayer.get(); }
-    void setVideoFullscreenLayer(PlatformLayer *, WTF::Function<void()>&& completionHandler, NativeImagePtr);
-    FloatRect videoFullscreenFrame() const { return m_videoFullscreenFrame; }
-    void setVideoFullscreenFrame(FloatRect);
-    void updateVideoFullscreenInlineImage(NativeImagePtr);
+    WEBCORE_EXPORT PlatformLayer* videoFullscreenLayer() const final;
+    WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler, NativeImagePtr) final;
+    WEBCORE_EXPORT FloatRect videoFullscreenFrame() const final;
+    WEBCORE_EXPORT void setVideoFullscreenFrame(FloatRect) final;
+    WEBCORE_EXPORT void updateVideoFullscreenInlineImage(NativeImagePtr) final;
 #endif
 
-    bool requiresTextTrackRepresentation() const;
-    void setTextTrackRepresentationLayer(PlatformLayer*);
-    void syncTextTrackBounds();
+    WEBCORE_EXPORT bool requiresTextTrackRepresentation() const final;
+    WEBCORE_EXPORT void setTextTrackRepresentationLayer(PlatformLayer*) final;
+    WEBCORE_EXPORT void syncTextTrackBounds() final;
 
 private:
+
+#if !RELEASE_LOG_DISABLED
     const Logger& logger() const final { return m_logger.get(); }
     const void* logIdentifier() const final { return m_logIdentifier; }
     const char* logClassName() const final { return "VideoLayerManagerObjC"; }
@@ -70,6 +83,7 @@
 
     Ref<const Logger> m_logger;
     const void* m_logIdentifier;
+#endif
 
     RetainPtr<WebVideoContainerLayer> m_videoInlineLayer;
 #if ENABLE(VIDEO_PRESENTATION_MODE)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm (267724 => 267725)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm	2020-09-29 04:10:11 UTC (rev 267724)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm	2020-09-29 04:52:54 UTC (rev 267725)
@@ -43,12 +43,19 @@
 
 namespace WebCore {
 
+#if !RELEASE_LOG_DISABLED
 VideoLayerManagerObjC::VideoLayerManagerObjC(const Logger& logger, const void* logIdentifier)
     : m_logger(logger)
     , m_logIdentifier(logIdentifier)
 {
 }
+#endif
 
+PlatformLayer* VideoLayerManagerObjC::videoInlineLayer() const
+{
+    return m_videoInlineLayer.get();
+}
+
 void VideoLayerManagerObjC::setVideoLayer(PlatformLayer *videoLayer, IntSize contentSize)
 {
     ALWAYS_LOG(LOGIDENTIFIER, contentSize.width(), ", ", contentSize.height());
@@ -87,10 +94,9 @@
 
 #if ENABLE(VIDEO_PRESENTATION_MODE)
 
-void VideoLayerManagerObjC::updateVideoFullscreenInlineImage(NativeImagePtr image)
+PlatformLayer* VideoLayerManagerObjC::videoFullscreenLayer() const
 {
-    if (m_videoInlineLayer)
-        [m_videoInlineLayer setContents:(__bridge id)image.get()];
+    return m_videoFullscreenLayer.get();
 }
 
 void VideoLayerManagerObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer, WTF::Function<void()>&& completionHandler, NativeImagePtr currentImage)
@@ -140,6 +146,11 @@
     [CATransaction commit];
 }
 
+FloatRect VideoLayerManagerObjC::videoFullscreenFrame() const
+{
+    return m_videoFullscreenFrame;
+}
+
 void VideoLayerManagerObjC::setVideoFullscreenFrame(FloatRect videoFullscreenFrame)
 {
     ALWAYS_LOG(LOGIDENTIFIER, videoFullscreenFrame.x(), ", ", videoFullscreenFrame.y(), ", ", videoFullscreenFrame.width(), ", ", videoFullscreenFrame.height());
@@ -152,6 +163,12 @@
     syncTextTrackBounds();
 }
 
+void VideoLayerManagerObjC::updateVideoFullscreenInlineImage(NativeImagePtr image)
+{
+    if (m_videoInlineLayer)
+        [m_videoInlineLayer setContents:(__bridge id)image.get()];
+}
+
 #endif
 
 bool VideoLayerManagerObjC::requiresTextTrackRepresentation() const

Modified: trunk/Source/WebKit/ChangeLog (267724 => 267725)


--- trunk/Source/WebKit/ChangeLog	2020-09-29 04:10:11 UTC (rev 267724)
+++ trunk/Source/WebKit/ChangeLog	2020-09-29 04:52:54 UTC (rev 267725)
@@ -1,3 +1,58 @@
+2020-09-28  Peng Liu  <[email protected]>
+
+        [Media in GPU Process] Use VideoLayerManager to manage layers of MediaPlayerPrivateRemote
+        https://bugs.webkit.org/show_bug.cgi?id=216995
+
+        Reviewed by Eric Carlson.
+
+        This patch removes the remote hosting layer in the GPU process for video fullscreen and
+        picture-in-picture. We don't need to keep a layer in the GPU process for video fullscreen
+        and picture-in-picture because no rendering will be done for that layer. We don't need
+        EnterFullscreen, ExitFullscreen and SetVideoFullscreenFrameFenced IPC messages after removing
+        the layer because the RemoteMediaPlayerPrivateRemote in the web process can deal with
+        the video presentation mode change.
+
+        * GPUProcess/media/RemoteMediaPlayerProxy.h:
+        * GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
+        * GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm:
+        (WebKit::RemoteMediaPlayerProxy::prepareForPlayback):
+        (WebKit::RemoteMediaPlayerProxy::enterFullscreen): Deleted.
+        (WebKit::RemoteMediaPlayerProxy::exitFullscreen): Deleted.
+        (WebKit::RemoteMediaPlayerProxy::setVideoFullscreenFrameFenced): Deleted.
+        Remove unused IPC messages after removing the remote hosting layer for video fullscreen
+        and picture-in-picture.
+
+        * GPUProcess/media/gstreamer/RemoteMediaPlayerProxyGStreamer.cpp:
+        (WebKit::RemoteMediaPlayerProxy::prepareForPlayback):
+        (WebKit::RemoteMediaPlayerProxy::enterFullscreen): Deleted.
+        (WebKit::RemoteMediaPlayerProxy::exitFullscreen): Deleted.
+        Ditto.
+
+        * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+        (WebKit::MediaPlayerPrivateRemote::MediaPlayerPrivateRemote):
+        (WebKit::MediaPlayerPrivateRemote::~MediaPlayerPrivateRemote):
+        (WebKit::MediaPlayerPrivateRemote::prepareForPlayback):
+        Remove the code related to the remote hosting layer for video fullscreen and picture-in-picture.
+        (WebKit::MediaPlayerPrivateRemote::platformLayer const):
+        (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenLayer):
+        Use VideoLayerManager to manage the layer.
+        (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenFrame): Ditto.
+        (WebKit::MediaPlayerPrivateRemote::requiresTextTrackRepresentation const): Ditto.
+        (WebKit::MediaPlayerPrivateRemote::setTextTrackRepresentation): Ditto.
+        (WebKit::MediaPlayerPrivateRemote::syncTextTrackBounds): Ditto.
+        (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenFrameFenced): Deleted.
+        * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
+        Need to move the Logger up in the data members so that other members can use it
+        in the constructor, e.g., VideoLayerManager.
+
+        * WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:
+        (WebKit::MediaPlayerPrivateRemote::MediaPlayerPrivateRemote):
+        (WebKit::MediaPlayerPrivateRemote::createVideoFullscreenLayer):
+        (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenFrame): Deleted.
+        (WebKit::MediaPlayerPrivateRemote::setTextTrackRepresentation): Deleted.
+        (WebKit::MediaPlayerPrivateRemote::syncTextTrackBounds): Deleted.
+        Simplify the implementation by managing layers with VideoLayerManager.
+
 2020-09-28  Eric Carlson  <[email protected]>
 
         [GPUP] Out-of-band TextTracks

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h (267724 => 267725)


--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h	2020-09-29 04:10:11 UTC (rev 267724)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h	2020-09-29 04:52:54 UTC (rev 267725)
@@ -100,7 +100,7 @@
 
     void getConfiguration(RemoteMediaPlayerConfiguration&);
 
-    void prepareForPlayback(bool privateMode, WebCore::MediaPlayerEnums::Preload, bool preservesPitch, bool prepareForRendering, float videoContentScale, CompletionHandler<void(Optional<LayerHostingContextID>&& inlineLayerHostingContextId, Optional<LayerHostingContextID>&& fullscreenLayerHostingContextId)>&&);
+    void prepareForPlayback(bool privateMode, WebCore::MediaPlayerEnums::Preload, bool preservesPitch, bool prepareForRendering, float videoContentScale, CompletionHandler<void(Optional<LayerHostingContextID>&& inlineLayerHostingContextId)>&&);
     void prepareForRendering();
 
     void load(URL&&, Optional<SandboxExtension::Handle>&&, const WebCore::ContentType&, const String&, CompletionHandler<void(RemoteMediaPlayerConfiguration&&)>&&);
@@ -124,8 +124,6 @@
     void setVisible(bool);
     void setShouldMaintainAspectRatio(bool);
 #if ENABLE(VIDEO_PRESENTATION_MODE)
-    void enterFullscreen(CompletionHandler<void()>&&);
-    void exitFullscreen(CompletionHandler<void()>&&);
     void setVideoFullscreenGravity(WebCore::MediaPlayerEnums::VideoGravity);
 #endif
     void acceleratedRenderingStateChanged(bool);
@@ -138,10 +136,7 @@
 
 #if PLATFORM(COCOA)
     void setVideoInlineSizeFenced(const WebCore::IntSize&, const WTF::MachSendRight&);
-#if ENABLE(VIDEO_PRESENTATION_MODE)
-    void setVideoFullscreenFrameFenced(const WebCore::FloatRect&, const WTF::MachSendRight&);
 #endif
-#endif
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     void setWirelessVideoPlaybackDisabled(bool);

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in (267724 => 267725)


--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in	2020-09-29 04:10:11 UTC (rev 267724)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in	2020-09-29 04:52:54 UTC (rev 267725)
@@ -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> inlineLayerHostingContextId, Optional<WebKit::LayerHostingContextID> fullscreenLayerHostingContextId) Async
+    PrepareForPlayback(bool privateMode, enum:uint8_t WebCore::MediaPlayerEnums::Preload preload, bool preservesPitch, bool prepareForRendering, float videoContentScale) -> (Optional<WebKit::LayerHostingContextID> inlineLayerHostingContextId) Async
 
     Load(URL url, Optional<WebKit::SandboxExtension::Handle> sandboxExtension, WebCore::ContentType contentType, String keySystem) -> (struct WebKit::RemoteMediaPlayerConfiguration playerConfiguration) Async
     CancelLoad()
@@ -68,16 +68,8 @@
 
 #if PLATFORM(COCOA)
     SetVideoInlineSizeFenced(WebCore::IntSize size, MachSendRight machSendRight)
-#if ENABLE(VIDEO_PRESENTATION_MODE)
-    SetVideoFullscreenFrameFenced(WebCore::FloatRect rect, MachSendRight machSendRight)
 #endif
-#endif
 
-#if ENABLE(VIDEO_PRESENTATION_MODE)
-    EnterFullscreen() -> () Async
-    ExitFullscreen() -> () Async
-#endif
-
     # Paint
     # PaintCurrentFrameInContext
 

Modified: trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm (267724 => 267725)


--- trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm	2020-09-29 04:10:11 UTC (rev 267724)
+++ trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm	2020-09-29 04:52:54 UTC (rev 267725)
@@ -36,7 +36,7 @@
 
 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)
+void RemoteMediaPlayerProxy::prepareForPlayback(bool privateMode, WebCore::MediaPlayerEnums::Preload preload, bool preservesPitch, bool prepareForRendering, float videoContentScale, CompletionHandler<void(Optional<LayerHostingContextID>&& inlineLayerHostingContextId)>&& completionHandler)
 {
     m_player->setPrivateBrowsingMode(privateMode);
     m_player->setPreload(preload);
@@ -45,11 +45,7 @@
     m_videoContentScale = videoContentScale;
     if (!m_inlineLayerHostingContext)
         m_inlineLayerHostingContext = LayerHostingContext::createForExternalHostingProcess();
-#if ENABLE(VIDEO_PRESENTATION_MODE)
-    if (!m_fullscreenLayerHostingContext)
-        m_fullscreenLayerHostingContext = LayerHostingContext::createForExternalHostingProcess();
-    completionHandler(m_inlineLayerHostingContext->contextID(), m_fullscreenLayerHostingContext->contextID());
-#endif
+    completionHandler(m_inlineLayerHostingContext->contextID());
 }
 
 void RemoteMediaPlayerProxy::mediaPlayerFirstVideoFrameAvailable()
@@ -74,30 +70,6 @@
     [CATransaction commit];
 }
 
-#if ENABLE(VIDEO_PRESENTATION_MODE)
-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);
-}
-#endif
-
 } // namespace WebKit
 
 #endif // ENABLE(GPU_PROCESS) && PLATFORM(COCOA)

Modified: trunk/Source/WebKit/GPUProcess/media/gstreamer/RemoteMediaPlayerProxyGStreamer.cpp (267724 => 267725)


--- trunk/Source/WebKit/GPUProcess/media/gstreamer/RemoteMediaPlayerProxyGStreamer.cpp	2020-09-29 04:10:11 UTC (rev 267724)
+++ trunk/Source/WebKit/GPUProcess/media/gstreamer/RemoteMediaPlayerProxyGStreamer.cpp	2020-09-29 04:52:54 UTC (rev 267725)
@@ -33,7 +33,7 @@
 
 namespace WebKit {
 
-void RemoteMediaPlayerProxy::prepareForPlayback(bool, WebCore::MediaPlayerEnums::Preload, bool, bool, float videoContentScale, CompletionHandler<void(Optional<LayerHostingContextID>&& inlineLayerHostingContextId, Optional<LayerHostingContextID>&& fullscreenLayerHostingContextId)>&&)
+void RemoteMediaPlayerProxy::prepareForPlayback(bool, WebCore::MediaPlayerEnums::Preload, bool, bool, float videoContentScale, CompletionHandler<void(Optional<LayerHostingContextID>&& inlineLayerHostingContextId)>&&)
 {
     notImplemented();
 }
@@ -48,18 +48,6 @@
     notImplemented();
 }
 
-#if ENABLE(VIDEO_PRESENTATION_MODE)
-void RemoteMediaPlayerProxy::enterFullscreen(CompletionHandler<void()>&& completionHandler)
-{
-    notImplemented();
-}
-
-void RemoteMediaPlayerProxy::exitFullscreen(CompletionHandler<void()>&& completionHandler)
-{
-    notImplemented();
-}
-#endif
-
 } // namespace WebKit
 
 

Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp (267724 => 267725)


--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp	2020-09-29 04:10:11 UTC (rev 267724)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp	2020-09-29 04:52:54 UTC (rev 267725)
@@ -24,11 +24,10 @@
  */
 
 #include "config.h"
+#include "MediaPlayerPrivateRemote.h"
 
 #if ENABLE(GPU_PROCESS)
-#include "MediaPlayerPrivateRemote.h"
 
-#include "AudioTrackPrivateRemote.h"
 #include "Logging.h"
 #include "RemoteLegacyCDM.h"
 #include "RemoteLegacyCDMFactory.h"
@@ -36,9 +35,7 @@
 #include "RemoteMediaPlayerManagerProxyMessages.h"
 #include "RemoteMediaPlayerProxyMessages.h"
 #include "SandboxExtension.h"
-#include "TextTrackPrivateRemote.h"
 #include "VideoLayerRemote.h"
-#include "VideoTrackPrivateRemote.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebProcess.h"
 #include <_javascript_Core/GenericTypedArrayViewInlines.h>
@@ -48,6 +45,8 @@
 #include <WebCore/PlatformLayer.h>
 #include <WebCore/PlatformTimeRanges.h>
 #include <WebCore/ResourceError.h>
+#include <WebCore/TextTrackRepresentation.h>
+#include <WebCore/VideoLayerManager.h>
 #include <wtf/HashMap.h>
 #include <wtf/MachSendRight.h>
 #include <wtf/MainThread.h>
@@ -91,18 +90,29 @@
 } while (0)
 #endif
 
+#if !PLATFORM(COCOA)
 MediaPlayerPrivateRemote::MediaPlayerPrivateRemote(MediaPlayer* player, MediaPlayerEnums::MediaEngineIdentifier engineIdentifier, MediaPlayerPrivateRemoteIdentifier playerIdentifier, RemoteMediaPlayerManager& manager)
-    : m_player(player)
-    , m_mediaResourceLoader(player->createResourceLoader())
+#if !RELEASE_LOG_DISABLED
+    : m_logger(player->mediaPlayerLogger())
+    , m_logIdentifier(player->mediaPlayerLogIdentifier())
+#endif
+    , m_player(player)
+    , m_mediaResourceLoader(*player->createResourceLoader())
     , m_manager(manager)
     , m_remoteEngineIdentifier(engineIdentifier)
     , m_id(playerIdentifier)
-#if !RELEASE_LOG_DISABLED
-    , m_logger(&player->mediaPlayerLogger())
-    , m_logIdentifier(player->mediaPlayerLogIdentifier())
+{
+    INFO_LOG(LOGIDENTIFIER);
+}
 #endif
+
+MediaPlayerPrivateRemote::~MediaPlayerPrivateRemote()
 {
     INFO_LOG(LOGIDENTIFIER);
+#if PLATFORM(COCOA)
+    m_videoLayerManager->didDestroyVideoLayer();
+#endif
+    m_manager.deleteRemoteMediaPlayer(m_id);
 }
 
 void MediaPlayerPrivateRemote::setConfiguration(RemoteMediaPlayerConfiguration&& configuration, WebCore::SecurityOriginData&& documentSecurityOrigin)
@@ -112,17 +122,11 @@
     m_player->mediaEngineUpdated();
 }
 
-MediaPlayerPrivateRemote::~MediaPlayerPrivateRemote()
-{
-    INFO_LOG(LOGIDENTIFIER);
-    m_manager.deleteRemoteMediaPlayer(m_id);
-}
-
 void MediaPlayerPrivateRemote::prepareForPlayback(bool privateMode, MediaPlayer::Preload preload, bool preservesPitch, bool prepare)
 {
     auto scale = m_player->playerContentsScale();
 
-    connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::PrepareForPlayback(privateMode, preload, preservesPitch, prepare, scale), [weakThis = makeWeakPtr(*this), this](auto inlineLayerHostingContextId, auto fullscreenLayerHostingContextId) mutable {
+    connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::PrepareForPlayback(privateMode, preload, preservesPitch, prepare, scale), [weakThis = makeWeakPtr(*this), this](auto inlineLayerHostingContextId) mutable {
         if (!weakThis)
             return;
 
@@ -129,9 +133,9 @@
         if (!inlineLayerHostingContextId)
             return;
 
-        m_videoInlineLayer = createVideoLayerRemote(this, inlineLayerHostingContextId.value());
-#if ENABLE(VIDEO_PRESENTATION_MODE)
-        m_fullscreenLayerHostingContextId = fullscreenLayerHostingContextId;
+        m_videoLayer = createVideoLayerRemote(this, inlineLayerHostingContextId.value());
+#if PLATFORM(COCOA)
+        m_videoLayerManager->setVideoLayer(m_videoLayer.get(), snappedIntRect(m_player->playerContentBoxRect()).size());
 #endif
     }, m_id);
 }
@@ -643,7 +647,11 @@
 
 PlatformLayer* MediaPlayerPrivateRemote::platformLayer() const
 {
-    return m_videoInlineLayer.get();
+#if PLATFORM(COCOA)
+    return m_videoLayerManager->videoInlineLayer();
+#else
+    return nullptr;
+#endif
 }
 
 #if ENABLE(VIDEO_PRESENTATION_MODE)
@@ -650,25 +658,9 @@
 
 void MediaPlayerPrivateRemote::setVideoFullscreenLayer(PlatformLayer* videoFullscreenLayer, WTF::Function<void()>&& completionHandler)
 {
-    if (!videoFullscreenLayer) {
-        connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::ExitFullscreen(), [this, weakThis = makeWeakPtr(*this), completionHandler = WTFMove(completionHandler)]() mutable {
-            if (!weakThis)
-                return;
-
-            m_requiresTextTrackRepresentation = false;
-            completionHandler();
-        }, m_id);
-        return;
-    }
-
-    ASSERT(m_videoFullscreenLayer.get() == videoFullscreenLayer);
-    connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::EnterFullscreen(), [this, weakThis = makeWeakPtr(*this), completionHandler = WTFMove(completionHandler)]() mutable {
-        if (!weakThis)
-            return;
-
-        m_requiresTextTrackRepresentation = true;
-        completionHandler();
-    }, m_id);
+#if PLATFORM(COCOA)
+    m_videoLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), nullptr);
+#endif
 }
 
 void MediaPlayerPrivateRemote::updateVideoFullscreenInlineImage()
@@ -676,9 +668,12 @@
     connection().send(Messages::RemoteMediaPlayerProxy::UpdateVideoFullscreenInlineImage(), m_id);
 }
 
-void MediaPlayerPrivateRemote::setVideoFullscreenFrameFenced(const WebCore::FloatRect& rect, const WTF::MachSendRight& sendRight)
+void MediaPlayerPrivateRemote::setVideoFullscreenFrame(WebCore::FloatRect rect)
 {
-    connection().send(Messages::RemoteMediaPlayerProxy::SetVideoFullscreenFrameFenced(rect, sendRight), m_id);
+#if PLATFORM(COCOA)
+    ALWAYS_LOG(LOGIDENTIFIER, "width = ", rect.size().width(), ", height = ", rect.size().height());
+    m_videoLayerManager->setVideoFullscreenFrame(rect);
+#endif
 }
 
 void MediaPlayerPrivateRemote::setVideoFullscreenGravity(WebCore::MediaPlayerEnums::VideoGravity gravity)
@@ -1021,6 +1016,30 @@
 }
 #endif
 
+bool MediaPlayerPrivateRemote::requiresTextTrackRepresentation() const
+{
+#if PLATFORM(COCOA)
+    return m_videoLayerManager->requiresTextTrackRepresentation();
+#else
+    return false;
+#endif
+}
+
+void MediaPlayerPrivateRemote::setTextTrackRepresentation(WebCore::TextTrackRepresentation* representation)
+{
+#if PLATFORM(COCOA)
+    auto* representationLayer = representation ? representation->platformLayer() : nil;
+    m_videoLayerManager->setTextTrackRepresentationLayer(representationLayer);
+#endif
+}
+
+void MediaPlayerPrivateRemote::syncTextTrackBounds()
+{
+#if PLATFORM(COCOA)
+    m_videoLayerManager->syncTextTrackBounds();
+#endif
+}
+
 void MediaPlayerPrivateRemote::tracksChanged()
 {
     connection().send(Messages::RemoteMediaPlayerProxy::TracksChanged(), m_id);

Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h (267724 => 267725)


--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h	2020-09-29 04:10:11 UTC (rev 267724)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h	2020-09-29 04:52:54 UTC (rev 267725)
@@ -27,6 +27,7 @@
 
 #if ENABLE(GPU_PROCESS)
 
+#include "AudioTrackPrivateRemote.h"
 #include "LayerHostingContext.h"
 #include "RemoteMediaPlayerConfiguration.h"
 #include "RemoteMediaPlayerManager.h"
@@ -33,7 +34,9 @@
 #include "RemoteMediaPlayerState.h"
 #include "RemoteMediaResourceIdentifier.h"
 #include "RemoteMediaResourceProxy.h"
+#include "TextTrackPrivateRemote.h"
 #include "TrackPrivateRemoteIdentifier.h"
+#include "VideoTrackPrivateRemote.h"
 #include <WebCore/MediaPlayerPrivate.h>
 #include <WebCore/SecurityOriginData.h>
 #include <wtf/LoggerHelper.h>
@@ -48,15 +51,12 @@
 struct GenericCueData;
 class ISOWebVTTCue;
 class SerializedPlatformDataCueValue;
-class TextTrackRepresentation;
+class VideoLayerManager;
 }
 
 namespace WebKit {
 
-class AudioTrackPrivateRemote;
-class TextTrackPrivateRemote;
 class UserData;
-class VideoTrackPrivateRemote;
 struct TextTrackPrivateRemoteConfiguration;
 struct TrackPrivateRemoteConfiguration;
 
@@ -101,7 +101,6 @@
     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&&);
@@ -149,14 +148,18 @@
     void currentPlaybackTargetIsWirelessChanged(bool);
 #endif
 
+private:
+
 #if !RELEASE_LOG_DISABLED
-    const Logger& logger() const final { return *m_logger; }
+    const Logger& logger() const final { return m_logger; }
     const char* logClassName() const override { return "MediaPlayerPrivateRemote"; }
     const void* logIdentifier() const final { return reinterpret_cast<const void*>(m_logIdentifier); }
     WTFLogChannel& logChannel() const final;
+
+    Ref<const Logger> m_logger;
+    const void* m_logIdentifier;
 #endif
 
-private:
     void load(const URL&, const WebCore::ContentType&, const String&) final;
     void prepareForPlayback(bool privateMode, WebCore::MediaPlayer::Preload, bool preservesPitch, bool prepare) final;
 
@@ -324,11 +327,10 @@
     void setShouldContinueAfterKeyNeeded(bool) final;
 #endif
 
-    bool requiresTextTrackRepresentation() const final { return m_requiresTextTrackRepresentation; }
-#if PLATFORM(COCOA)
+    bool requiresTextTrackRepresentation() const final;
     void setTextTrackRepresentation(WebCore::TextTrackRepresentation*) final;
     void syncTextTrackBounds() final;
-#endif
+
     void tracksChanged() final;
 
     void beginSimulatedHDCPError() final;
@@ -358,14 +360,12 @@
     bool performTaskAtMediaTime(Function<void()>&&, const MediaTime&) final;
 
     WebCore::MediaPlayer* m_player { nullptr };
-    RefPtr<WebCore::PlatformMediaResourceLoader> m_mediaResourceLoader;
-    bool m_requiresTextTrackRepresentation { false };
-    PlatformLayerContainer m_videoInlineLayer;
-    PlatformLayerContainer m_videoFullscreenLayer;
+    Ref<WebCore::PlatformMediaResourceLoader> m_mediaResourceLoader;
 #if PLATFORM(COCOA)
-    RetainPtr<PlatformLayer> m_textTrackRepresentationLayer;
+    UniqueRef<WebCore::VideoLayerManager> m_videoLayerManager;
 #endif
-    Optional<LayerHostingContextID> m_fullscreenLayerHostingContextId;
+    PlatformLayerContainer m_videoLayer;
+
     RemoteMediaPlayerManager& m_manager;
     WebCore::MediaPlayerEnums::MediaEngineIdentifier m_remoteEngineIdentifier;
     MediaPlayerPrivateRemoteIdentifier m_id;
@@ -388,12 +388,6 @@
     bool m_muted { false };
     bool m_seeking { false };
     bool m_isCurrentPlaybackTargetWireless { false };
-
-#if !RELEASE_LOG_DISABLED
-    RefPtr<const Logger> m_logger;
-    const void* m_logIdentifier;
-#endif
-
     bool m_invalid { false };
 };
 

Modified: trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm (267724 => 267725)


--- trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm	2020-09-29 04:10:11 UTC (rev 267724)
+++ trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm	2020-09-29 04:52:54 UTC (rev 267725)
@@ -28,94 +28,34 @@
 
 #if ENABLE(GPU_PROCESS) && PLATFORM(COCOA)
 
-#import <WebCore/FloatRect.h>
-#import <WebCore/TextTrackRepresentation.h>
+#import <WebCore/VideoLayerManagerObjC.h>
 #import <pal/spi/cocoa/QuartzCoreSPI.h>
-#import <wtf/MachSendRight.h>
 
 namespace WebKit {
+using namespace WebCore;
 
-#if ENABLE(VIDEO_PRESENTATION_MODE)
-
-PlatformLayerContainer MediaPlayerPrivateRemote::createVideoFullscreenLayer()
+MediaPlayerPrivateRemote::MediaPlayerPrivateRemote(MediaPlayer* player, MediaPlayerEnums::MediaEngineIdentifier engineIdentifier, MediaPlayerPrivateRemoteIdentifier playerIdentifier, RemoteMediaPlayerManager& manager)
+#if !RELEASE_LOG_DISABLED
+    : m_logger(player->mediaPlayerLogger())
+    , m_logIdentifier(player->mediaPlayerLogIdentifier())
+#endif
+    , m_player(player)
+    , m_mediaResourceLoader(*player->createResourceLoader())
+    , m_videoLayerManager(makeUniqueRef<VideoLayerManagerObjC>(logger(), logIdentifier()))
+    , m_manager(manager)
+    , m_remoteEngineIdentifier(engineIdentifier)
+    , m_id(playerIdentifier)
 {
-    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;
+    INFO_LOG(LOGIDENTIFIER);
 }
 
-void MediaPlayerPrivateRemote::setVideoFullscreenFrame(WebCore::FloatRect rect)
+#if ENABLE(VIDEO_PRESENTATION_MODE)
+PlatformLayerContainer MediaPlayerPrivateRemote::createVideoFullscreenLayer()
 {
-    auto context = [m_videoFullscreenLayer context];
-    if (!context)
-        return;
-
-    [CATransaction begin];
-    [CATransaction setDisableActions:YES];
-
-    MachSendRight fenceSendRight = MachSendRight::adopt([context createFencePort]);
-    setVideoFullscreenFrameFenced(rect, fenceSendRight);
-
-    [CATransaction commit];
-
-    syncTextTrackBounds();
+    return adoptNS([[CALayer alloc] init]);
 }
-
 #endif
 
-void MediaPlayerPrivateRemote::setTextTrackRepresentation(WebCore::TextTrackRepresentation* representation)
-{
-#if !ENABLE(VIDEO_PRESENTATION_MODE)
-    UNUSED_PARAM(representation);
-#else
-    PlatformLayer* representationLayer = representation ? representation->platformLayer() : nil;
-
-    if (representationLayer == m_textTrackRepresentationLayer) {
-        syncTextTrackBounds();
-        return;
-    }
-
-    [CATransaction begin];
-    [CATransaction setDisableActions:YES];
-
-    if (m_textTrackRepresentationLayer)
-        [m_textTrackRepresentationLayer removeFromSuperlayer];
-
-    m_textTrackRepresentationLayer = representationLayer;
-
-    if (m_videoFullscreenLayer && m_textTrackRepresentationLayer) {
-        syncTextTrackBounds();
-        [m_videoFullscreenLayer addSublayer:m_textTrackRepresentationLayer.get()];
-    }
-
-    [CATransaction commit];
-#endif
-}
-
-void MediaPlayerPrivateRemote::syncTextTrackBounds()
-{
-#if ENABLE(VIDEO_PRESENTATION_MODE)
-    if (!m_videoFullscreenLayer || !m_textTrackRepresentationLayer)
-        return;
-
-    [CATransaction begin];
-    [CATransaction setDisableActions:YES];
-
-    [m_textTrackRepresentationLayer setFrame:m_videoFullscreenLayer.get().bounds];
-
-    [CATransaction commit];
-#endif
-}
-
 } // namespace WebKit
 
 #endif // ENABLE(GPU_PROCESS) && PLATFORM(COCOA)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to