Title: [267491] trunk/Source
Revision
267491
Author
[email protected]
Date
2020-09-23 11:45:11 -0700 (Wed, 23 Sep 2020)

Log Message

[Media in GPU Process] Implement caption support in video fullscreen and PiP
https://bugs.webkit.org/show_bug.cgi?id=208752

Reviewed by Eric Carlson.

Source/WebCore:

Export TextTrackRepresentation so that WebKit can use it. Also, update the
interface of VideoLayerManagerObjC related to text track representation to
use PlatformLayer* instead of TextTrackRepresentation*.

Manually tested.

* WebCore.xcodeproj/project.pbxproj:
Change target membership of TextTrackRepresentation.h.

* platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h:
* platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm:
(WebCore::VideoLayerManagerObjC::setTextTrackRepresentationLayer):
(WebCore::VideoLayerManagerObjC::setTextTrackRepresentation): Deleted.
Replace setTextTrackRepresentation() with setTextTrackRepresentationLayer().

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::setTextTrackRepresentation):
Use VideoLayerManagerObjC::setTextTrackRepresentationLayer() instead of
VideoLayerManagerObjC::setTextTrackRepresentation().

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setTextTrackRepresentation): Ditto.

Source/WebKit:

* GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::RemoteMediaPlayerProxy::syncTextTrackBounds): Deleted.
* GPUProcess/media/RemoteMediaPlayerProxy.h:
* GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
Remove syncTextTrackBounds() because the GPU process does not need to deal with
the text track bounds.

* WebProcess/GPU/GPUProcessConnection.cpp:
(WebKit::GPUProcessConnection::dispatchMessage):
Add a missing IPC message receiver.

* WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
(WebKit::MediaPlayerPrivateRemote::setVideoFullscreenLayer): Set the flag
m_requiresTextTrackRepresentation when changing video presentation mode.
(WebKit::MediaPlayerPrivateRemote::requiresTextTrackRepresentation const): Deleted.
(WebKit::MediaPlayerPrivateRemote::setTextTrackRepresentation): Deleted.
(WebKit::MediaPlayerPrivateRemote::syncTextTrackBounds): Deleted.
Move the implementation of those functions to MediaPlayerPrivateRemoteCocoa.

* WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
Add the flag m_requiresTextTrackRepresentation and add a reference
to the layer used to render text track (in fullscreen or picture-in-picture).

* WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:
(WebKit::MediaPlayerPrivateRemote::setVideoFullscreenFrame):
(WebKit::MediaPlayerPrivateRemote::setTextTrackRepresentation):
(WebKit::MediaPlayerPrivateRemote::syncTextTrackBounds):
Those functions share a similar implementation as VideoLayerManagerObjC.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (267490 => 267491)


--- trunk/Source/WebCore/ChangeLog	2020-09-23 17:55:35 UTC (rev 267490)
+++ trunk/Source/WebCore/ChangeLog	2020-09-23 18:45:11 UTC (rev 267491)
@@ -1,3 +1,33 @@
+2020-09-23  Peng Liu  <[email protected]>
+
+        [Media in GPU Process] Implement caption support in video fullscreen and PiP
+        https://bugs.webkit.org/show_bug.cgi?id=208752
+
+        Reviewed by Eric Carlson.
+
+        Export TextTrackRepresentation so that WebKit can use it. Also, update the
+        interface of VideoLayerManagerObjC related to text track representation to
+        use PlatformLayer* instead of TextTrackRepresentation*.
+
+        Manually tested.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        Change target membership of TextTrackRepresentation.h.
+
+        * platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h:
+        * platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm:
+        (WebCore::VideoLayerManagerObjC::setTextTrackRepresentationLayer):
+        (WebCore::VideoLayerManagerObjC::setTextTrackRepresentation): Deleted.
+        Replace setTextTrackRepresentation() with setTextTrackRepresentationLayer().
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setTextTrackRepresentation):
+        Use VideoLayerManagerObjC::setTextTrackRepresentationLayer() instead of
+        VideoLayerManagerObjC::setTextTrackRepresentation().
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setTextTrackRepresentation): Ditto.
+
 2020-09-23  Chris Dumez  <[email protected]>
 
         webaudio/AudioBufferSource/audiobuffersource-playbackrate.html is crashing

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (267490 => 267491)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-09-23 17:55:35 UTC (rev 267490)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-09-23 18:45:11 UTC (rev 267491)
@@ -634,6 +634,7 @@
 		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, ); }; };
 		1DBC1B562347B3D200B901AF /* PictureInPictureObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DBC1B552347B3D200B901AF /* PictureInPictureObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		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, ); }; };
 		1F8756B21E22C3350042C40D /* WebSQLiteDatabaseTrackerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F8756B11E22BEEF0042C40D /* WebSQLiteDatabaseTrackerClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -34228,6 +34229,7 @@
 				076970871463AD8700F502CF /* TextTrackList.h in Headers */,
 				B1AD4E7413A12A4600846B27 /* TextTrackLoader.h in Headers */,
 				CD8B5A49180E138B008B8E65 /* TextTrackMediaSource.h in Headers */,
+				1DF7E81F251A9E0600DB8F61 /* TextTrackRepresentation.h in Headers */,
 				1C73A7132185757E004CCEA5 /* TextUnderlineOffset.h in Headers */,
 				29FAF4B6195AB08900A522DC /* TextUndoInsertionMarkupMac.h in Headers */,
 				498770F11242C535002226BA /* Texture.h in Headers */,

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (267490 => 267491)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2020-09-23 17:55:35 UTC (rev 267490)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2020-09-23 18:45:11 UTC (rev 267491)
@@ -2112,7 +2112,8 @@
 
 void MediaPlayerPrivateAVFoundationObjC::setTextTrackRepresentation(TextTrackRepresentation* representation)
 {
-    m_videoLayerManager->setTextTrackRepresentation(representation);
+    auto* representationLayer = representation ? representation->platformLayer() : nil;
+    m_videoLayerManager->setTextTrackRepresentationLayer(representationLayer);
 }
 
 #if ENABLE(WEB_AUDIO) && USE(MEDIATOOLBOX)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (267490 => 267491)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2020-09-23 17:55:35 UTC (rev 267490)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2020-09-23 18:45:11 UTC (rev 267491)
@@ -1240,7 +1240,8 @@
     
 void MediaPlayerPrivateMediaSourceAVFObjC::setTextTrackRepresentation(TextTrackRepresentation* representation)
 {
-    m_videoLayerManager->setTextTrackRepresentation(representation);
+    auto* representationLayer = representation ? representation->platformLayer() : nil;
+    m_videoLayerManager->setTextTrackRepresentationLayer(representationLayer);
 }
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)

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


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h	2020-09-23 17:55:35 UTC (rev 267490)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h	2020-09-23 18:45:11 UTC (rev 267491)
@@ -47,6 +47,7 @@
 
     PlatformLayer *videoInlineLayer() const { return m_videoInlineLayer.get(); }
     void setVideoLayer(PlatformLayer *, IntSize contentSize);
+    void didDestroyVideoLayer();
 
 #if ENABLE(VIDEO_PRESENTATION_MODE)
     PlatformLayer *videoFullscreenLayer() const { return m_videoFullscreenLayer.get(); }
@@ -56,10 +57,8 @@
     void setVideoFullscreenFrame(FloatRect);
 #endif
 
-    void didDestroyVideoLayer();
-
     bool requiresTextTrackRepresentation() const;
-    void setTextTrackRepresentation(TextTrackRepresentation*);
+    void setTextTrackRepresentationLayer(PlatformLayer*);
     void syncTextTrackBounds();
 
 private:

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


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm	2020-09-23 17:55:35 UTC (rev 267490)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm	2020-09-23 18:45:11 UTC (rev 267491)
@@ -182,14 +182,13 @@
 #endif
 }
 
-void VideoLayerManagerObjC::setTextTrackRepresentation(TextTrackRepresentation* representation)
+void VideoLayerManagerObjC::setTextTrackRepresentationLayer(PlatformLayer* representationLayer)
 {
 #if !ENABLE(VIDEO_PRESENTATION_MODE)
-    UNUSED_PARAM(representation);
+    UNUSED_PARAM(representationLayer);
 #else
     ALWAYS_LOG(LOGIDENTIFIER);
 
-    PlatformLayer* representationLayer = representation ? representation->platformLayer() : nil;
     if (representationLayer == m_textTrackRepresentationLayer) {
         syncTextTrackBounds();
         return;

Modified: trunk/Source/WebKit/ChangeLog (267490 => 267491)


--- trunk/Source/WebKit/ChangeLog	2020-09-23 17:55:35 UTC (rev 267490)
+++ trunk/Source/WebKit/ChangeLog	2020-09-23 18:45:11 UTC (rev 267491)
@@ -1,3 +1,39 @@
+2020-09-23  Peng Liu  <[email protected]>
+
+        [Media in GPU Process] Implement caption support in video fullscreen and PiP
+        https://bugs.webkit.org/show_bug.cgi?id=208752
+
+        Reviewed by Eric Carlson.
+
+        * GPUProcess/media/RemoteMediaPlayerProxy.cpp:
+        (WebKit::RemoteMediaPlayerProxy::syncTextTrackBounds): Deleted.
+        * GPUProcess/media/RemoteMediaPlayerProxy.h:
+        * GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
+        Remove syncTextTrackBounds() because the GPU process does not need to deal with
+        the text track bounds.
+
+        * WebProcess/GPU/GPUProcessConnection.cpp:
+        (WebKit::GPUProcessConnection::dispatchMessage):
+        Add a missing IPC message receiver.
+
+        * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+        (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenLayer): Set the flag
+        m_requiresTextTrackRepresentation when changing video presentation mode.
+        (WebKit::MediaPlayerPrivateRemote::requiresTextTrackRepresentation const): Deleted.
+        (WebKit::MediaPlayerPrivateRemote::setTextTrackRepresentation): Deleted.
+        (WebKit::MediaPlayerPrivateRemote::syncTextTrackBounds): Deleted.
+        Move the implementation of those functions to MediaPlayerPrivateRemoteCocoa.
+
+        * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
+        Add the flag m_requiresTextTrackRepresentation and add a reference
+        to the layer used to render text track (in fullscreen or picture-in-picture).
+
+        * WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:
+        (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenFrame):
+        (WebKit::MediaPlayerPrivateRemote::setTextTrackRepresentation):
+        (WebKit::MediaPlayerPrivateRemote::syncTextTrackBounds):
+        Those functions share a similar implementation as VideoLayerManagerObjC.
+
 2020-09-23  Per Arne Vollan  <[email protected]>
 
         [macOS] Start collecting telemetry from a set of XPC services

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp (267490 => 267491)


--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp	2020-09-23 17:55:35 UTC (rev 267490)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp	2020-09-23 18:45:11 UTC (rev 267491)
@@ -836,11 +836,6 @@
     m_player->tracksChanged();
 }
 
-void RemoteMediaPlayerProxy::syncTextTrackBounds()
-{
-    m_player->syncTextTrackBounds();
-}
-
 void RemoteMediaPlayerProxy::performTaskAtMediaTime(const MediaTime& taskTime, WallTime messageTime, CompletionHandler<void(Optional<MediaTime>)>&& completionHandler)
 {
     if (m_performTaskAtMediaTimeCompletionHandler) {

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h (267490 => 267491)


--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h	2020-09-23 17:55:35 UTC (rev 267490)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h	2020-09-23 18:45:11 UTC (rev 267491)
@@ -175,7 +175,6 @@
 
     void notifyTrackModeChanged();
     void tracksChanged();
-    void syncTextTrackBounds();
 
     void performTaskAtMediaTime(const MediaTime&, WallTime, CompletionHandler<void(Optional<MediaTime>)>&&);
     void wouldTaintOrigin(struct WebCore::SecurityOriginData, CompletionHandler<void(Optional<bool>)>&&);

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


--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in	2020-09-23 17:55:35 UTC (rev 267490)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in	2020-09-23 18:45:11 UTC (rev 267491)
@@ -112,7 +112,6 @@
 
     NotifyTrackModeChanged()
     TracksChanged()
-    SyncTextTrackBounds()
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     SetWirelessPlaybackTarget(WebCore::MediaPlaybackTargetContext target)

Modified: trunk/Source/WebKit/WebProcess/GPU/GPUProcessConnection.cpp (267490 => 267491)


--- trunk/Source/WebKit/WebProcess/GPU/GPUProcessConnection.cpp	2020-09-23 17:55:35 UTC (rev 267490)
+++ trunk/Source/WebKit/WebProcess/GPU/GPUProcessConnection.cpp	2020-09-23 18:45:11 UTC (rev 267491)
@@ -55,6 +55,11 @@
 #include "RemoteAudioSessionMessages.h"
 #endif
 
+#if PLATFORM(IOS_FAMILY)
+#include "RemoteMediaSessionHelper.h"
+#include "RemoteMediaSessionHelperMessages.h"
+#endif
+
 #if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
 #include "UserMediaCaptureManager.h"
 #include "UserMediaCaptureManagerMessages.h"
@@ -141,6 +146,12 @@
         return true;
     }
 #endif
+#if PLATFORM(IOS_FAMILY)
+    if (decoder.messageReceiverName() == Messages::RemoteMediaSessionHelper::messageReceiverName()) {
+        // FIXME
+        return true;
+    }
+#endif
 #if ENABLE(ENCRYPTED_MEDIA)
     if (decoder.messageReceiverName() == Messages::RemoteCDMInstanceSession::messageReceiverName()) {
         WebProcess::singleton().supplement<RemoteCDMFactory>()->didReceiveSessionMessage(connection, decoder);

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


--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp	2020-09-23 17:55:35 UTC (rev 267490)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp	2020-09-23 18:45:11 UTC (rev 267491)
@@ -651,12 +651,24 @@
 void MediaPlayerPrivateRemote::setVideoFullscreenLayer(PlatformLayer* videoFullscreenLayer, WTF::Function<void()>&& completionHandler)
 {
     if (!videoFullscreenLayer) {
-        connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::ExitFullscreen(), WTFMove(completionHandler), m_id);
+        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(), WTFMove(completionHandler), m_id);
+    connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::EnterFullscreen(), [this, weakThis = makeWeakPtr(*this), completionHandler = WTFMove(completionHandler)]() mutable {
+        if (!weakThis)
+            return;
+
+        m_requiresTextTrackRepresentation = true;
+        completionHandler();
+    }, m_id);
 }
 
 void MediaPlayerPrivateRemote::updateVideoFullscreenInlineImage()
@@ -1009,22 +1021,6 @@
 }
 #endif
 
-bool MediaPlayerPrivateRemote::requiresTextTrackRepresentation() const
-{
-    notImplemented();
-    return false;
-}
-
-void MediaPlayerPrivateRemote::setTextTrackRepresentation(TextTrackRepresentation*)
-{
-    notImplemented();
-}
-
-void MediaPlayerPrivateRemote::syncTextTrackBounds()
-{
-    connection().send(Messages::RemoteMediaPlayerProxy::SyncTextTrackBounds(), m_id);
-}
-
 void MediaPlayerPrivateRemote::tracksChanged()
 {
     connection().send(Messages::RemoteMediaPlayerProxy::TracksChanged(), m_id);

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


--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h	2020-09-23 17:55:35 UTC (rev 267490)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h	2020-09-23 18:45:11 UTC (rev 267491)
@@ -48,6 +48,7 @@
 struct GenericCueData;
 class ISOWebVTTCue;
 class SerializedPlatformDataCueValue;
+class TextTrackRepresentation;
 }
 
 namespace WebKit {
@@ -323,9 +324,11 @@
     void setShouldContinueAfterKeyNeeded(bool) final;
 #endif
 
-    bool requiresTextTrackRepresentation() const final;
+    bool requiresTextTrackRepresentation() const final { return m_requiresTextTrackRepresentation; }
+#if PLATFORM(COCOA)
     void setTextTrackRepresentation(WebCore::TextTrackRepresentation*) final;
     void syncTextTrackBounds() final;
+#endif
     void tracksChanged() final;
 
     void beginSimulatedHDCPError() final;
@@ -356,8 +359,12 @@
 
     WebCore::MediaPlayer* m_player { nullptr };
     RefPtr<WebCore::PlatformMediaResourceLoader> m_mediaResourceLoader;
+    bool m_requiresTextTrackRepresentation { false };
     PlatformLayerContainer m_videoInlineLayer;
     PlatformLayerContainer m_videoFullscreenLayer;
+#if PLATFORM(COCOA)
+    RetainPtr<PlatformLayer> m_textTrackRepresentationLayer;
+#endif
     Optional<LayerHostingContextID> m_fullscreenLayerHostingContextId;
     RemoteMediaPlayerManager& m_manager;
     WebCore::MediaPlayerEnums::MediaEngineIdentifier m_remoteEngineIdentifier;

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


--- trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm	2020-09-23 17:55:35 UTC (rev 267490)
+++ trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm	2020-09-23 18:45:11 UTC (rev 267491)
@@ -29,6 +29,7 @@
 #if ENABLE(GPU_PROCESS) && PLATFORM(COCOA)
 
 #import <WebCore/FloatRect.h>
+#import <WebCore/TextTrackRepresentation.h>
 #import <pal/spi/cocoa/QuartzCoreSPI.h>
 #import <wtf/MachSendRight.h>
 
@@ -65,10 +66,56 @@
     setVideoFullscreenFrameFenced(rect, fenceSendRight);
 
     [CATransaction commit];
+
+    syncTextTrackBounds();
 }
 
 #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