⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 267725 in webkit


Ignore:
Timestamp:
Sep 28, 2020, 9:52:54 PM (6 years ago)
Author:
Peng Liu
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.

Location:
trunk/Source
Files:
15 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r267724 r267725  
     12020-09-28  Peng Liu  <peng.liu6@apple.com>
     2
     3        [Media in GPU Process] Use VideoLayerManager to manage layers of MediaPlayerPrivateRemote
     4        https://bugs.webkit.org/show_bug.cgi?id=216995
     5
     6        Reviewed by Eric Carlson.
     7
     8        No new tests since no functional changes.
     9
     10        * Headers.cmake:
     11        Export TextTrackRepresentation and VideoLayerManager.
     12
     13        * WebCore.xcodeproj/project.pbxproj:
     14        Add VideoLayerManager.h.
     15        Export TextTrackRepresentation, WebVideoContainerLayer and VideoLayerManager.
     16
     17        * platform/graphics/TextTrackRepresentation.cpp:
     18        * platform/graphics/TextTrackRepresentation.h:
     19        Minor clean-up.
     20
     21        * platform/graphics/VideoLayerManager.h: Added.
     22        Add this interface so that we can use VideoLayerManager in the C++ code.
     23
     24        * platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h:
     25        * platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm:
     26        (WebCore::VideoLayerManagerObjC::videoInlineLayer const):
     27        (WebCore::VideoLayerManagerObjC::videoFullscreenLayer const):
     28        (WebCore::VideoLayerManagerObjC::videoFullscreenFrame const):
     29        (WebCore::VideoLayerManagerObjC::updateVideoFullscreenInlineImage):
     30        Fix the issue when RELEASE_LOG_DISABLED is defined and add WEBCORE_EXPORT
     31        to some functions.
     32
    1332020-09-28  Tetsuharu Ohzeki  <tetsuharu.ohzeki@gmail.com>
    234
  • trunk/Source/WebCore/Headers.cmake

    r267697 r267725  
    12141214    platform/graphics/TabSize.h
    12151215    platform/graphics/TextRun.h
     1216    platform/graphics/TextTrackRepresentation.h
    12161217    platform/graphics/TiledBacking.h
    12171218    platform/graphics/TrackPrivateBase.h
    12181219    platform/graphics/VelocityData.h
     1220    platform/graphics/VideoLayerManager.h
    12191221    platform/graphics/VideoTrackPrivate.h
    12201222    platform/graphics/WidthCache.h
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r267697 r267725  
    631631                1D2F8E062344752300993B68 /* PictureInPictureWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DEF06CD233C3D2A00EE228D /* PictureInPictureWindow.h */; settings = {ATTRIBUTES = (Private, ); }; };
    632632                1D9F0FC12122029B005D8FD4 /* ShareData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DC55400211BA8C8004B780E /* ShareData.h */; settings = {ATTRIBUTES = (Private, ); }; };
     633                1DAB3112251D6BF300FC9485 /* WebVideoContainerLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8B31A12379DC8300883FDE /* WebVideoContainerLayer.h */; settings = {ATTRIBUTES = (Private, ); }; };
     634                1DAB3114251D725C00FC9485 /* VideoLayerManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DAB3113251D725C00FC9485 /* VideoLayerManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
     635                1DAB3115251D74DB00FC9485 /* VideoLayerManagerObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = 52D5A18E1C54590300DE34A3 /* VideoLayerManagerObjC.h */; settings = {ATTRIBUTES = (Private, ); }; };
    633636                1DBC1B562347B3D200B901AF /* PictureInPictureObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DBC1B552347B3D200B901AF /* PictureInPictureObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
     637                1DD3B4C6251DA0B80069B24A /* VideoLayerManagerObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52D5A18D1C54590300DE34A3 /* VideoLayerManagerObjC.mm */; };
    634638                1DF7E81F251A9E0600DB8F61 /* TextTrackRepresentation.h in Headers */ = {isa = PBXBuildFile; fileRef = CDD1E525167BA56400CE820B /* TextTrackRepresentation.h */; settings = {ATTRIBUTES = (Private, ); }; };
    635639                1F36EA9C1E21BA1700621E25 /* WebBackgroundTaskController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F36EA9A1E21BA1700621E25 /* WebBackgroundTaskController.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    15891593                52B0D4C01C57FD660077CE53 /* VideoFullscreenChangeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 52B0D4BF1C57FD660077CE53 /* VideoFullscreenChangeObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
    15901594                52B0D4C21C57FF910077CE53 /* VideoFullscreenInterfaceMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 52B0D4C11C57FF910077CE53 /* VideoFullscreenInterfaceMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
    1591                 52D5A18F1C54592300DE34A3 /* VideoLayerManagerObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52D5A18D1C54590300DE34A3 /* VideoLayerManagerObjC.mm */; };
    15921595                52D5A1A71C57489D00DE34A3 /* VideoFullscreenModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 52D5A1A41C57488900DE34A3 /* VideoFullscreenModel.h */; settings = {ATTRIBUTES = (Private, ); }; };
    15931596                52D5A1A81C5748A300DE34A3 /* VideoFullscreenModelVideoElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 52D5A1A51C57488900DE34A3 /* VideoFullscreenModelVideoElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    67286731                1D0026A92374F9D900CA6CDF /* JSEnterPictureInPictureEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEnterPictureInPictureEvent.cpp; sourceTree = "<group>"; };
    67296732                1D2C82B6236A3F6A0055D6C5 /* PictureInPictureSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PictureInPictureSupport.h; sourceTree = "<group>"; };
     6733                1DAB3113251D725C00FC9485 /* VideoLayerManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VideoLayerManager.h; sourceTree = "<group>"; };
    67306734                1DBC1B552347B3D200B901AF /* PictureInPictureObserver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PictureInPictureObserver.h; sourceTree = "<group>"; };
    67316735                1DC553FD211BA12A004B780E /* NavigatorShare.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NavigatorShare.idl; sourceTree = "<group>"; };
     
    87208724                52B0D4C11C57FF910077CE53 /* VideoFullscreenInterfaceMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoFullscreenInterfaceMac.h; sourceTree = "<group>"; };
    87218725                52CB11DB22FDDB2E009F0A64 /* WHLSLDefaultDelete.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLDefaultDelete.h; sourceTree = "<group>"; };
    8722                 52D5A18D1C54590300DE34A3 /* VideoLayerManagerObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoLayerManagerObjC.mm; sourceTree = "<group>"; tabWidth = 8; };
    8723                 52D5A18E1C54590300DE34A3 /* VideoLayerManagerObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoLayerManagerObjC.h; sourceTree = "<group>"; tabWidth = 8; };
     8726                52D5A18D1C54590300DE34A3 /* VideoLayerManagerObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoLayerManagerObjC.mm; sourceTree = "<group>"; };
     8727                52D5A18E1C54590300DE34A3 /* VideoLayerManagerObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoLayerManagerObjC.h; sourceTree = "<group>"; };
    87248728                52D5A1A41C57488900DE34A3 /* VideoFullscreenModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoFullscreenModel.h; sourceTree = "<group>"; };
    87258729                52D5A1A51C57488900DE34A3 /* VideoFullscreenModelVideoElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoFullscreenModelVideoElement.h; sourceTree = "<group>"; };
     
    2619726201                                0F5A57CA229B18AE0025EDA9 /* VelocityData.cpp */,
    2619826202                                0F1A0C36229A481800D37ADB /* VelocityData.h */,
     26203                                1DAB3113251D725C00FC9485 /* VideoLayerManager.h */,
    2619926204                                BEF29EEA1715DD0900C4B4C9 /* VideoTrackPrivate.h */,
    2620026205                                CD6FE5BB24BCE7B6009FCDA4 /* VP9Utilities.cpp */,
     
    2849628501                        isa = PBXGroup;
    2849728502                        children = (
    28498                                 E4A664C72521B779007081DC /* LayoutIntegrationRunIterator.cpp */,
    28499                                 E4A664C62521B778007081DC /* LayoutIntegrationRunIterator.h */,
    28500                                 E4A664C52521B778007081DC /* LayoutIntegrationRunIteratorLegacyPath.h */,
    28501                                 E4A664C42521B777007081DC /* LayoutIntegrationRunIteratorModernPath.h */,
    2850228503                                E418025623D454B500FFB071 /* LayoutIntegrationBoxTree.cpp */,
    2850328504                                E418025323D4549A00FFB071 /* LayoutIntegrationBoxTree.h */,
     
    2850828509                                E4312AB524B3265600678349 /* LayoutIntegrationPagination.cpp */,
    2850928510                                E4312AB724B3265600678349 /* LayoutIntegrationPagination.h */,
     28511                                E4A664C72521B779007081DC /* LayoutIntegrationRunIterator.cpp */,
     28512                                E4A664C62521B778007081DC /* LayoutIntegrationRunIterator.h */,
     28513                                E4A664C52521B778007081DC /* LayoutIntegrationRunIteratorLegacyPath.h */,
     28514                                E4A664C42521B777007081DC /* LayoutIntegrationRunIteratorModernPath.h */,
    2851028515                        );
    2851128516                        path = integration;
     
    3244832453                                07969DB217D14151007FF842 /* JSRTCDTMFToneChangeEvent.h in Headers */,
    3244932454                                07969DB617D14151007FF842 /* JSRTCIceCandidate.h in Headers */,
    32450                                 E4A664CE2521D4C9007081DC /* LayoutIntegrationRunIteratorModernPath.h in Headers */,
    3245132455                                316DCB4C1E7910A6001B5F87 /* JSRTCIceConnectionState.h in Headers */,
    3245232456                                316DCB4E1E7910A6001B5F87 /* JSRTCIceGatheringState.h in Headers */,
     
    3249432498                                B59DD6A911902A71007E9684 /* JSSQLStatementErrorCallback.h in Headers */,
    3249532499                                BC82432A0D0CE8A200460C8F /* JSSQLTransaction.h in Headers */,
    32496                                 E4A664CC2521D4AF007081DC /* LayoutIntegrationRunIterator.h in Headers */,
    3249732500                                B59DD69D11902A42007E9684 /* JSSQLTransactionCallback.h in Headers */,
    3249832501                                B59DD6A111902A52007E9684 /* JSSQLTransactionErrorCallback.h in Headers */,
     
    3278632789                                E4ABABDD236088FE00FA4345 /* LayoutIntegrationLineLayout.h in Headers */,
    3278732790                                E403B7A3251B11C10019E800 /* LayoutIntegrationPagination.h in Headers */,
     32791                                E4A664CC2521D4AF007081DC /* LayoutIntegrationRunIterator.h in Headers */,
     32792                                E4A664CF2521D4E2007081DC /* LayoutIntegrationRunIteratorLegacyPath.h in Headers */,
     32793                                E4A664CE2521D4C9007081DC /* LayoutIntegrationRunIteratorModernPath.h in Headers */,
    3278832794                                11310CF420BA4A3D0065A8D0 /* LayoutIterator.h in Headers */,
    3278932795                                6FFA4C0123F2FED9007E4EBC /* LayoutLineBreakBox.h in Headers */,
     
    3296432970                                C96F5EC51B5872260091EA9D /* MediaSessionInterruptionProviderMac.h in Headers */,
    3296532971                                C90F65561B2253BE002163A1 /* MediaSessionManager.h in Headers */,
    32966                                 E4A664CF2521D4E2007081DC /* LayoutIntegrationRunIteratorLegacyPath.h in Headers */,
    3296732972                                417F7AEF2139BF6F00FBA7EC /* MediaSessionManagerCocoa.h in Headers */,
    3296832973                                07638A991884487200E15A1B /* MediaSessionManagerIOS.h in Headers */,
     
    3438234387                                52D5A1A71C57489D00DE34A3 /* VideoFullscreenModel.h in Headers */,
    3438334388                                52D5A1A81C5748A300DE34A3 /* VideoFullscreenModelVideoElement.h in Headers */,
     34389                                1DAB3114251D725C00FC9485 /* VideoLayerManager.h in Headers */,
     34390                                1DAB3115251D74DB00FC9485 /* VideoLayerManagerObjC.h in Headers */,
    3438434391                                CDE83DB2183C44060031EAA3 /* VideoPlaybackQuality.h in Headers */,
    3438534392                                0757B13E214AE79900794B0D /* VideoPreset.h in Headers */,
     
    3455834565                                31DEA4561B39F4D900F77178 /* WebSystemBackdropLayer.h in Headers */,
    3455934566                                0F580FA31496939100FB5BD8 /* WebTiledBackingLayer.h in Headers */,
     34567                                1DAB3112251D6BF300FC9485 /* WebVideoContainerLayer.h in Headers */,
    3456034568                                3F42B31D1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h in Headers */,
    3456134569                                2D7DA0F22435EB1900F048D1 /* WebViewVisualIdentificationOverlay.h in Headers */,
     
    3582635834                                7C73FB07191EF417007DE061 /* UserMessageHandlersNamespace.cpp in Sources */,
    3582735835                                3FBC4AF3189881560046EE38 /* VideoFullscreenInterfaceAVKit.mm in Sources */,
    35828                                 52D5A18F1C54592300DE34A3 /* VideoLayerManagerObjC.mm in Sources */,
     35836                                1DD3B4C6251DA0B80069B24A /* VideoLayerManagerObjC.mm in Sources */,
    3582935837                                CD336F6717FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.cpp in Sources */,
    3583035838                                CD8B5A42180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.mm in Sources */,
  • trunk/Source/WebCore/platform/graphics/TextTrackRepresentation.cpp

    r262695 r267725  
    2525
    2626#include "config.h"
     27#include "TextTrackRepresentation.h"
    2728
    2829#if ENABLE(VIDEO)
    29 
    30 #include "TextTrackRepresentation.h"
    3130
    3231#include "IntRect.h"
  • trunk/Source/WebCore/platform/graphics/TextTrackRepresentation.h

    r262695 r267725  
    2424 */
    2525
    26 #ifndef TextTrackRepresentation_h
    27 #define TextTrackRepresentation_h
     26#pragma once
    2827
    2928#if ENABLE(VIDEO)
     
    6261
    6362#endif
    64 
    65 #endif // TextTrackRepresentation_h
  • trunk/Source/WebCore/platform/graphics/VideoLayerManager.h

    r267724 r267725  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef TextTrackRepresentation_h
    27 #define TextTrackRepresentation_h
     26#pragma once
    2827
    29 #if ENABLE(VIDEO)
    30 
     28#include "NativeImage.h"
    3129#include "PlatformLayer.h"
    32 #include <wtf/Forward.h>
     30#include <wtf/Function.h>
    3331
    3432namespace WebCore {
    3533
    36 class Image;
    37 class IntRect;
     34class FloatRect;
     35class IntSize;
    3836
    39 class TextTrackRepresentationClient {
     37class VideoLayerManager {
    4038public:
    41     virtual ~TextTrackRepresentationClient() = default;
     39    virtual ~VideoLayerManager() = default;
    4240
    43     virtual RefPtr<Image> createTextTrackRepresentationImage() = 0;
    44     virtual void textTrackRepresentationBoundsChanged(const IntRect&) = 0;
    45 };
     41    virtual PlatformLayer* videoInlineLayer() const = 0;
     42    virtual void setVideoLayer(PlatformLayer*, IntSize) = 0;
     43    virtual void didDestroyVideoLayer() = 0;
    4644
    47 class TextTrackRepresentation {
    48     WTF_MAKE_FAST_ALLOCATED;
    49 public:
    50     static std::unique_ptr<TextTrackRepresentation> create(TextTrackRepresentationClient&);
     45#if ENABLE(VIDEO_PRESENTATION_MODE)
     46    virtual PlatformLayer* videoFullscreenLayer() const = 0;
     47    virtual void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler, NativeImagePtr) = 0;
     48    virtual FloatRect videoFullscreenFrame() const = 0;
     49    virtual void setVideoFullscreenFrame(FloatRect) = 0;
     50    virtual void updateVideoFullscreenInlineImage(NativeImagePtr) = 0;
     51#endif
    5152
    52     virtual ~TextTrackRepresentation() = default;
    53 
    54     virtual void update() = 0;
    55     virtual PlatformLayer* platformLayer() = 0;
    56     virtual void setContentScale(float) = 0;
    57     virtual IntRect bounds() const = 0;
    58     virtual void setHidden(bool) const = 0;
     53    virtual bool requiresTextTrackRepresentation() const = 0;
     54    virtual void setTextTrackRepresentationLayer(PlatformLayer*) = 0;
     55    virtual void syncTextTrackBounds() = 0;
    5956};
    6057
    6158}
    62 
    63 #endif
    64 
    65 #endif // TextTrackRepresentation_h
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h

    r267573 r267725  
    3030#include "NativeImage.h"
    3131#include "PlatformLayer.h"
     32#include "VideoLayerManager.h"
    3233#include "WebVideoContainerLayer.h"
    3334#include <wtf/Function.h>
     
    3839namespace WebCore {
    3940
    40 class TextTrackRepresentation;
    41 
    42 class VideoLayerManagerObjC final : public LoggerHelper {
     41class VideoLayerManagerObjC final
     42    : public VideoLayerManager
     43#if !RELEASE_LOG_DISABLED
     44    , public LoggerHelper
     45#endif
     46{
    4347    WTF_MAKE_NONCOPYABLE(VideoLayerManagerObjC);
    4448    WTF_MAKE_FAST_ALLOCATED;
     49
    4550public:
    46     VideoLayerManagerObjC(const Logger&, const void*);
     51#if !RELEASE_LOG_DISABLED
     52    WEBCORE_EXPORT VideoLayerManagerObjC(const Logger&, const void*);
     53#else
     54    WEBCORE_EXPORT VideoLayerManagerObjC() = default;
     55#endif
    4756
    48     PlatformLayer *videoInlineLayer() const { return m_videoInlineLayer.get(); }
     57    ~VideoLayerManagerObjC() = default;
    4958
    50     void setVideoLayer(PlatformLayer *, IntSize contentSize);
    51     void didDestroyVideoLayer();
     59    WEBCORE_EXPORT PlatformLayer* videoInlineLayer() const final;
     60
     61    WEBCORE_EXPORT void setVideoLayer(PlatformLayer*, IntSize contentSize) final;
     62    WEBCORE_EXPORT void didDestroyVideoLayer() final;
    5263
    5364#if ENABLE(VIDEO_PRESENTATION_MODE)
    54     PlatformLayer *videoFullscreenLayer() const { return m_videoFullscreenLayer.get(); }
    55     void setVideoFullscreenLayer(PlatformLayer *, WTF::Function<void()>&& completionHandler, NativeImagePtr);
    56     FloatRect videoFullscreenFrame() const { return m_videoFullscreenFrame; }
    57     void setVideoFullscreenFrame(FloatRect);
    58     void updateVideoFullscreenInlineImage(NativeImagePtr);
     65    WEBCORE_EXPORT PlatformLayer* videoFullscreenLayer() const final;
     66    WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler, NativeImagePtr) final;
     67    WEBCORE_EXPORT FloatRect videoFullscreenFrame() const final;
     68    WEBCORE_EXPORT void setVideoFullscreenFrame(FloatRect) final;
     69    WEBCORE_EXPORT void updateVideoFullscreenInlineImage(NativeImagePtr) final;
    5970#endif
    6071
    61     bool requiresTextTrackRepresentation() const;
    62     void setTextTrackRepresentationLayer(PlatformLayer*);
    63     void syncTextTrackBounds();
     72    WEBCORE_EXPORT bool requiresTextTrackRepresentation() const final;
     73    WEBCORE_EXPORT void setTextTrackRepresentationLayer(PlatformLayer*) final;
     74    WEBCORE_EXPORT void syncTextTrackBounds() final;
    6475
    6576private:
     77
     78#if !RELEASE_LOG_DISABLED
    6679    const Logger& logger() const final { return m_logger.get(); }
    6780    const void* logIdentifier() const final { return m_logIdentifier; }
     
    7184    Ref<const Logger> m_logger;
    7285    const void* m_logIdentifier;
     86#endif
    7387
    7488    RetainPtr<WebVideoContainerLayer> m_videoInlineLayer;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm

    r267573 r267725  
    4444namespace WebCore {
    4545
     46#if !RELEASE_LOG_DISABLED
    4647VideoLayerManagerObjC::VideoLayerManagerObjC(const Logger& logger, const void* logIdentifier)
    4748    : m_logger(logger)
    4849    , m_logIdentifier(logIdentifier)
    4950{
     51}
     52#endif
     53
     54PlatformLayer* VideoLayerManagerObjC::videoInlineLayer() const
     55{
     56    return m_videoInlineLayer.get();
    5057}
    5158
     
    8895#if ENABLE(VIDEO_PRESENTATION_MODE)
    8996
    90 void VideoLayerManagerObjC::updateVideoFullscreenInlineImage(NativeImagePtr image)
    91 {
    92     if (m_videoInlineLayer)
    93         [m_videoInlineLayer setContents:(__bridge id)image.get()];
     97PlatformLayer* VideoLayerManagerObjC::videoFullscreenLayer() const
     98{
     99    return m_videoFullscreenLayer.get();
    94100}
    95101
     
    141147}
    142148
     149FloatRect VideoLayerManagerObjC::videoFullscreenFrame() const
     150{
     151    return m_videoFullscreenFrame;
     152}
     153
    143154void VideoLayerManagerObjC::setVideoFullscreenFrame(FloatRect videoFullscreenFrame)
    144155{
     
    151162    [m_videoLayer setFrame:m_videoFullscreenFrame];
    152163    syncTextTrackBounds();
     164}
     165
     166void VideoLayerManagerObjC::updateVideoFullscreenInlineImage(NativeImagePtr image)
     167{
     168    if (m_videoInlineLayer)
     169        [m_videoInlineLayer setContents:(__bridge id)image.get()];
    153170}
    154171
  • trunk/Source/WebKit/ChangeLog

    r267713 r267725  
     12020-09-28  Peng Liu  <peng.liu6@apple.com>
     2
     3        [Media in GPU Process] Use VideoLayerManager to manage layers of MediaPlayerPrivateRemote
     4        https://bugs.webkit.org/show_bug.cgi?id=216995
     5
     6        Reviewed by Eric Carlson.
     7
     8        This patch removes the remote hosting layer in the GPU process for video fullscreen and
     9        picture-in-picture. We don't need to keep a layer in the GPU process for video fullscreen
     10        and picture-in-picture because no rendering will be done for that layer. We don't need
     11        EnterFullscreen, ExitFullscreen and SetVideoFullscreenFrameFenced IPC messages after removing
     12        the layer because the RemoteMediaPlayerPrivateRemote in the web process can deal with
     13        the video presentation mode change.
     14
     15        * GPUProcess/media/RemoteMediaPlayerProxy.h:
     16        * GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
     17        * GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm:
     18        (WebKit::RemoteMediaPlayerProxy::prepareForPlayback):
     19        (WebKit::RemoteMediaPlayerProxy::enterFullscreen): Deleted.
     20        (WebKit::RemoteMediaPlayerProxy::exitFullscreen): Deleted.
     21        (WebKit::RemoteMediaPlayerProxy::setVideoFullscreenFrameFenced): Deleted.
     22        Remove unused IPC messages after removing the remote hosting layer for video fullscreen
     23        and picture-in-picture.
     24
     25        * GPUProcess/media/gstreamer/RemoteMediaPlayerProxyGStreamer.cpp:
     26        (WebKit::RemoteMediaPlayerProxy::prepareForPlayback):
     27        (WebKit::RemoteMediaPlayerProxy::enterFullscreen): Deleted.
     28        (WebKit::RemoteMediaPlayerProxy::exitFullscreen): Deleted.
     29        Ditto.
     30
     31        * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
     32        (WebKit::MediaPlayerPrivateRemote::MediaPlayerPrivateRemote):
     33        (WebKit::MediaPlayerPrivateRemote::~MediaPlayerPrivateRemote):
     34        (WebKit::MediaPlayerPrivateRemote::prepareForPlayback):
     35        Remove the code related to the remote hosting layer for video fullscreen and picture-in-picture.
     36        (WebKit::MediaPlayerPrivateRemote::platformLayer const):
     37        (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenLayer):
     38        Use VideoLayerManager to manage the layer.
     39        (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenFrame): Ditto.
     40        (WebKit::MediaPlayerPrivateRemote::requiresTextTrackRepresentation const): Ditto.
     41        (WebKit::MediaPlayerPrivateRemote::setTextTrackRepresentation): Ditto.
     42        (WebKit::MediaPlayerPrivateRemote::syncTextTrackBounds): Ditto.
     43        (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenFrameFenced): Deleted.
     44        * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
     45        Need to move the Logger up in the data members so that other members can use it
     46        in the constructor, e.g., VideoLayerManager.
     47
     48        * WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:
     49        (WebKit::MediaPlayerPrivateRemote::MediaPlayerPrivateRemote):
     50        (WebKit::MediaPlayerPrivateRemote::createVideoFullscreenLayer):
     51        (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenFrame): Deleted.
     52        (WebKit::MediaPlayerPrivateRemote::setTextTrackRepresentation): Deleted.
     53        (WebKit::MediaPlayerPrivateRemote::syncTextTrackBounds): Deleted.
     54        Simplify the implementation by managing layers with VideoLayerManager.
     55
    1562020-09-28  Eric Carlson  <eric.carlson@apple.com>
    257
  • trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h

    r267491 r267725  
    101101    void getConfiguration(RemoteMediaPlayerConfiguration&);
    102102
    103     void prepareForPlayback(bool privateMode, WebCore::MediaPlayerEnums::Preload, bool preservesPitch, bool prepareForRendering, float videoContentScale, CompletionHandler<void(Optional<LayerHostingContextID>&& inlineLayerHostingContextId, Optional<LayerHostingContextID>&& fullscreenLayerHostingContextId)>&&);
     103    void prepareForPlayback(bool privateMode, WebCore::MediaPlayerEnums::Preload, bool preservesPitch, bool prepareForRendering, float videoContentScale, CompletionHandler<void(Optional<LayerHostingContextID>&& inlineLayerHostingContextId)>&&);
    104104    void prepareForRendering();
    105105
     
    125125    void setShouldMaintainAspectRatio(bool);
    126126#if ENABLE(VIDEO_PRESENTATION_MODE)
    127     void enterFullscreen(CompletionHandler<void()>&&);
    128     void exitFullscreen(CompletionHandler<void()>&&);
    129127    void setVideoFullscreenGravity(WebCore::MediaPlayerEnums::VideoGravity);
    130128#endif
     
    139137#if PLATFORM(COCOA)
    140138    void setVideoInlineSizeFenced(const WebCore::IntSize&, const WTF::MachSendRight&);
    141 #if ENABLE(VIDEO_PRESENTATION_MODE)
    142     void setVideoFullscreenFrameFenced(const WebCore::FloatRect&, const WTF::MachSendRight&);
    143 #endif
    144139#endif
    145140
  • trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in

    r267491 r267725  
    2525
    2626messages -> RemoteMediaPlayerProxy NotRefCounted {
    27     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
     27    PrepareForPlayback(bool privateMode, enum:uint8_t WebCore::MediaPlayerEnums::Preload preload, bool preservesPitch, bool prepareForRendering, float videoContentScale) -> (Optional<WebKit::LayerHostingContextID> inlineLayerHostingContextId) Async
    2828
    2929    Load(URL url, Optional<WebKit::SandboxExtension::Handle> sandboxExtension, WebCore::ContentType contentType, String keySystem) -> (struct WebKit::RemoteMediaPlayerConfiguration playerConfiguration) Async
     
    6969#if PLATFORM(COCOA)
    7070    SetVideoInlineSizeFenced(WebCore::IntSize size, MachSendRight machSendRight)
    71 #if ENABLE(VIDEO_PRESENTATION_MODE)
    72     SetVideoFullscreenFrameFenced(WebCore::FloatRect rect, MachSendRight machSendRight)
    73 #endif
    74 #endif
    75 
    76 #if ENABLE(VIDEO_PRESENTATION_MODE)
    77     EnterFullscreen() -> () Async
    78     ExitFullscreen() -> () Async
    7971#endif
    8072
  • trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm

    r260412 r267725  
    3737namespace WebKit {
    3838
    39 void RemoteMediaPlayerProxy::prepareForPlayback(bool privateMode, WebCore::MediaPlayerEnums::Preload preload, bool preservesPitch, bool prepareForRendering, float videoContentScale, CompletionHandler<void(Optional<LayerHostingContextID>&& inlineLayerHostingContextId, Optional<LayerHostingContextID>&& fullscreenLayerHostingContextId)>&& completionHandler)
     39void RemoteMediaPlayerProxy::prepareForPlayback(bool privateMode, WebCore::MediaPlayerEnums::Preload preload, bool preservesPitch, bool prepareForRendering, float videoContentScale, CompletionHandler<void(Optional<LayerHostingContextID>&& inlineLayerHostingContextId)>&& completionHandler)
    4040{
    4141    m_player->setPrivateBrowsingMode(privateMode);
     
    4646    if (!m_inlineLayerHostingContext)
    4747        m_inlineLayerHostingContext = LayerHostingContext::createForExternalHostingProcess();
    48 #if ENABLE(VIDEO_PRESENTATION_MODE)
    49     if (!m_fullscreenLayerHostingContext)
    50         m_fullscreenLayerHostingContext = LayerHostingContext::createForExternalHostingProcess();
    51     completionHandler(m_inlineLayerHostingContext->contextID(), m_fullscreenLayerHostingContext->contextID());
    52 #endif
     48    completionHandler(m_inlineLayerHostingContext->contextID());
    5349}
    5450
     
    7571}
    7672
    77 #if ENABLE(VIDEO_PRESENTATION_MODE)
    78 void RemoteMediaPlayerProxy::enterFullscreen(CompletionHandler<void()>&& completionHandler)
    79 {
    80     auto videoFullscreenLayer = m_player->createVideoFullscreenLayer();
    81     [videoFullscreenLayer setName:@"Web Video Fullscreen Layer (remote)"];
    82     [videoFullscreenLayer setPosition:CGPointZero];
    83     m_fullscreenLayerHostingContext->setRootLayer(videoFullscreenLayer.get());
    84 
    85     m_player->setVideoFullscreenLayer(videoFullscreenLayer.get(), WTFMove(completionHandler));
    86 }
    87 
    88 void RemoteMediaPlayerProxy::exitFullscreen(CompletionHandler<void()>&& completionHandler)
    89 {
    90     m_player->setVideoFullscreenLayer(nullptr, WTFMove(completionHandler));
    91     m_fullscreenLayerHostingContext->setRootLayer(nullptr);
    92 }
    93 
    94 void RemoteMediaPlayerProxy::setVideoFullscreenFrameFenced(const WebCore::FloatRect& rect, const WTF::MachSendRight& machSendRight)
    95 {
    96     m_fullscreenLayerHostingContext->setFencePort(machSendRight.sendRight());
    97     m_player->setVideoFullscreenFrame(rect);
    98 }
    99 #endif
    100 
    10173} // namespace WebKit
    10274
  • trunk/Source/WebKit/GPUProcess/media/gstreamer/RemoteMediaPlayerProxyGStreamer.cpp

    r260899 r267725  
    3434namespace WebKit {
    3535
    36 void RemoteMediaPlayerProxy::prepareForPlayback(bool, WebCore::MediaPlayerEnums::Preload, bool, bool, float videoContentScale, CompletionHandler<void(Optional<LayerHostingContextID>&& inlineLayerHostingContextId, Optional<LayerHostingContextID>&& fullscreenLayerHostingContextId)>&&)
     36void RemoteMediaPlayerProxy::prepareForPlayback(bool, WebCore::MediaPlayerEnums::Preload, bool, bool, float videoContentScale, CompletionHandler<void(Optional<LayerHostingContextID>&& inlineLayerHostingContextId)>&&)
    3737{
    3838    notImplemented();
     
    4949}
    5050
    51 #if ENABLE(VIDEO_PRESENTATION_MODE)
    52 void RemoteMediaPlayerProxy::enterFullscreen(CompletionHandler<void()>&& completionHandler)
    53 {
    54     notImplemented();
    55 }
    56 
    57 void RemoteMediaPlayerProxy::exitFullscreen(CompletionHandler<void()>&& completionHandler)
    58 {
    59     notImplemented();
    60 }
    61 #endif
    62 
    6351} // namespace WebKit
    6452
  • trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp

    r267491 r267725  
    2525
    2626#include "config.h"
     27#include "MediaPlayerPrivateRemote.h"
    2728
    2829#if ENABLE(GPU_PROCESS)
    29 #include "MediaPlayerPrivateRemote.h"
    30 
    31 #include "AudioTrackPrivateRemote.h"
     30
    3231#include "Logging.h"
    3332#include "RemoteLegacyCDM.h"
     
    3736#include "RemoteMediaPlayerProxyMessages.h"
    3837#include "SandboxExtension.h"
    39 #include "TextTrackPrivateRemote.h"
    4038#include "VideoLayerRemote.h"
    41 #include "VideoTrackPrivateRemote.h"
    4239#include "WebCoreArgumentCoders.h"
    4340#include "WebProcess.h"
     
    4946#include <WebCore/PlatformTimeRanges.h>
    5047#include <WebCore/ResourceError.h>
     48#include <WebCore/TextTrackRepresentation.h>
     49#include <WebCore/VideoLayerManager.h>
    5150#include <wtf/HashMap.h>
    5251#include <wtf/MachSendRight.h>
     
    9291#endif
    9392
     93#if !PLATFORM(COCOA)
    9494MediaPlayerPrivateRemote::MediaPlayerPrivateRemote(MediaPlayer* player, MediaPlayerEnums::MediaEngineIdentifier engineIdentifier, MediaPlayerPrivateRemoteIdentifier playerIdentifier, RemoteMediaPlayerManager& manager)
    95     : m_player(player)
    96     , m_mediaResourceLoader(player->createResourceLoader())
     95#if !RELEASE_LOG_DISABLED
     96    : m_logger(player->mediaPlayerLogger())
     97    , m_logIdentifier(player->mediaPlayerLogIdentifier())
     98#endif
     99    , m_player(player)
     100    , m_mediaResourceLoader(*player->createResourceLoader())
    97101    , m_manager(manager)
    98102    , m_remoteEngineIdentifier(engineIdentifier)
    99103    , m_id(playerIdentifier)
    100 #if !RELEASE_LOG_DISABLED
    101     , m_logger(&player->mediaPlayerLogger())
    102     , m_logIdentifier(player->mediaPlayerLogIdentifier())
    103 #endif
    104104{
    105105    INFO_LOG(LOGIDENTIFIER);
     106}
     107#endif
     108
     109MediaPlayerPrivateRemote::~MediaPlayerPrivateRemote()
     110{
     111    INFO_LOG(LOGIDENTIFIER);
     112#if PLATFORM(COCOA)
     113    m_videoLayerManager->didDestroyVideoLayer();
     114#endif
     115    m_manager.deleteRemoteMediaPlayer(m_id);
    106116}
    107117
     
    113123}
    114124
    115 MediaPlayerPrivateRemote::~MediaPlayerPrivateRemote()
    116 {
    117     INFO_LOG(LOGIDENTIFIER);
    118     m_manager.deleteRemoteMediaPlayer(m_id);
    119 }
    120 
    121125void MediaPlayerPrivateRemote::prepareForPlayback(bool privateMode, MediaPlayer::Preload preload, bool preservesPitch, bool prepare)
    122126{
    123127    auto scale = m_player->playerContentsScale();
    124128
    125     connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::PrepareForPlayback(privateMode, preload, preservesPitch, prepare, scale), [weakThis = makeWeakPtr(*this), this](auto inlineLayerHostingContextId, auto fullscreenLayerHostingContextId) mutable {
     129    connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::PrepareForPlayback(privateMode, preload, preservesPitch, prepare, scale), [weakThis = makeWeakPtr(*this), this](auto inlineLayerHostingContextId) mutable {
    126130        if (!weakThis)
    127131            return;
     
    130134            return;
    131135
    132         m_videoInlineLayer = createVideoLayerRemote(this, inlineLayerHostingContextId.value());
    133 #if ENABLE(VIDEO_PRESENTATION_MODE)
    134         m_fullscreenLayerHostingContextId = fullscreenLayerHostingContextId;
     136        m_videoLayer = createVideoLayerRemote(this, inlineLayerHostingContextId.value());
     137#if PLATFORM(COCOA)
     138        m_videoLayerManager->setVideoLayer(m_videoLayer.get(), snappedIntRect(m_player->playerContentBoxRect()).size());
    135139#endif
    136140    }, m_id);
     
    644648PlatformLayer* MediaPlayerPrivateRemote::platformLayer() const
    645649{
    646     return m_videoInlineLayer.get();
     650#if PLATFORM(COCOA)
     651    return m_videoLayerManager->videoInlineLayer();
     652#else
     653    return nullptr;
     654#endif
    647655}
    648656
     
    651659void MediaPlayerPrivateRemote::setVideoFullscreenLayer(PlatformLayer* videoFullscreenLayer, WTF::Function<void()>&& completionHandler)
    652660{
    653     if (!videoFullscreenLayer) {
    654         connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::ExitFullscreen(), [this, weakThis = makeWeakPtr(*this), completionHandler = WTFMove(completionHandler)]() mutable {
    655             if (!weakThis)
    656                 return;
    657 
    658             m_requiresTextTrackRepresentation = false;
    659             completionHandler();
    660         }, m_id);
    661         return;
    662     }
    663 
    664     ASSERT(m_videoFullscreenLayer.get() == videoFullscreenLayer);
    665     connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::EnterFullscreen(), [this, weakThis = makeWeakPtr(*this), completionHandler = WTFMove(completionHandler)]() mutable {
    666         if (!weakThis)
    667             return;
    668 
    669         m_requiresTextTrackRepresentation = true;
    670         completionHandler();
    671     }, m_id);
     661#if PLATFORM(COCOA)
     662    m_videoLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), nullptr);
     663#endif
    672664}
    673665
     
    677669}
    678670
    679 void MediaPlayerPrivateRemote::setVideoFullscreenFrameFenced(const WebCore::FloatRect& rect, const WTF::MachSendRight& sendRight)
    680 {
    681     connection().send(Messages::RemoteMediaPlayerProxy::SetVideoFullscreenFrameFenced(rect, sendRight), m_id);
     671void MediaPlayerPrivateRemote::setVideoFullscreenFrame(WebCore::FloatRect rect)
     672{
     673#if PLATFORM(COCOA)
     674    ALWAYS_LOG(LOGIDENTIFIER, "width = ", rect.size().width(), ", height = ", rect.size().height());
     675    m_videoLayerManager->setVideoFullscreenFrame(rect);
     676#endif
    682677}
    683678
     
    10221017#endif
    10231018
     1019bool MediaPlayerPrivateRemote::requiresTextTrackRepresentation() const
     1020{
     1021#if PLATFORM(COCOA)
     1022    return m_videoLayerManager->requiresTextTrackRepresentation();
     1023#else
     1024    return false;
     1025#endif
     1026}
     1027
     1028void MediaPlayerPrivateRemote::setTextTrackRepresentation(WebCore::TextTrackRepresentation* representation)
     1029{
     1030#if PLATFORM(COCOA)
     1031    auto* representationLayer = representation ? representation->platformLayer() : nil;
     1032    m_videoLayerManager->setTextTrackRepresentationLayer(representationLayer);
     1033#endif
     1034}
     1035
     1036void MediaPlayerPrivateRemote::syncTextTrackBounds()
     1037{
     1038#if PLATFORM(COCOA)
     1039    m_videoLayerManager->syncTextTrackBounds();
     1040#endif
     1041}
     1042
    10241043void MediaPlayerPrivateRemote::tracksChanged()
    10251044{
  • trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h

    r267491 r267725  
    2828#if ENABLE(GPU_PROCESS)
    2929
     30#include "AudioTrackPrivateRemote.h"
    3031#include "LayerHostingContext.h"
    3132#include "RemoteMediaPlayerConfiguration.h"
     
    3435#include "RemoteMediaResourceIdentifier.h"
    3536#include "RemoteMediaResourceProxy.h"
     37#include "TextTrackPrivateRemote.h"
    3638#include "TrackPrivateRemoteIdentifier.h"
     39#include "VideoTrackPrivateRemote.h"
    3740#include <WebCore/MediaPlayerPrivate.h>
    3841#include <WebCore/SecurityOriginData.h>
     
    4952class ISOWebVTTCue;
    5053class SerializedPlatformDataCueValue;
    51 class TextTrackRepresentation;
     54class VideoLayerManager;
    5255}
    5356
    5457namespace WebKit {
    5558
    56 class AudioTrackPrivateRemote;
    57 class TextTrackPrivateRemote;
    5859class UserData;
    59 class VideoTrackPrivateRemote;
    6060struct TextTrackPrivateRemoteConfiguration;
    6161struct TrackPrivateRemoteConfiguration;
     
    102102#if PLATFORM(COCOA)
    103103    void setVideoInlineSizeFenced(const WebCore::IntSize&, const WTF::MachSendRight&);
    104     void setVideoFullscreenFrameFenced(const WebCore::FloatRect&, const WTF::MachSendRight&);
    105104#endif
    106105
     
    150149#endif
    151150
     151private:
     152
    152153#if !RELEASE_LOG_DISABLED
    153     const Logger& logger() const final { return *m_logger; }
     154    const Logger& logger() const final { return m_logger; }
    154155    const char* logClassName() const override { return "MediaPlayerPrivateRemote"; }
    155156    const void* logIdentifier() const final { return reinterpret_cast<const void*>(m_logIdentifier); }
    156157    WTFLogChannel& logChannel() const final;
    157 #endif
    158 
    159 private:
     158
     159    Ref<const Logger> m_logger;
     160    const void* m_logIdentifier;
     161#endif
     162
    160163    void load(const URL&, const WebCore::ContentType&, const String&) final;
    161164    void prepareForPlayback(bool privateMode, WebCore::MediaPlayer::Preload, bool preservesPitch, bool prepare) final;
     
    325328#endif
    326329
    327     bool requiresTextTrackRepresentation() const final { return m_requiresTextTrackRepresentation; }
    328 #if PLATFORM(COCOA)
     330    bool requiresTextTrackRepresentation() const final;
    329331    void setTextTrackRepresentation(WebCore::TextTrackRepresentation*) final;
    330332    void syncTextTrackBounds() final;
    331 #endif
     333
    332334    void tracksChanged() final;
    333335
     
    359361
    360362    WebCore::MediaPlayer* m_player { nullptr };
    361     RefPtr<WebCore::PlatformMediaResourceLoader> m_mediaResourceLoader;
    362     bool m_requiresTextTrackRepresentation { false };
    363     PlatformLayerContainer m_videoInlineLayer;
    364     PlatformLayerContainer m_videoFullscreenLayer;
     363    Ref<WebCore::PlatformMediaResourceLoader> m_mediaResourceLoader;
    365364#if PLATFORM(COCOA)
    366     RetainPtr<PlatformLayer> m_textTrackRepresentationLayer;
    367 #endif
    368     Optional<LayerHostingContextID> m_fullscreenLayerHostingContextId;
     365    UniqueRef<WebCore::VideoLayerManager> m_videoLayerManager;
     366#endif
     367    PlatformLayerContainer m_videoLayer;
     368
    369369    RemoteMediaPlayerManager& m_manager;
    370370    WebCore::MediaPlayerEnums::MediaEngineIdentifier m_remoteEngineIdentifier;
     
    389389    bool m_seeking { false };
    390390    bool m_isCurrentPlaybackTargetWireless { false };
    391 
    392 #if !RELEASE_LOG_DISABLED
    393     RefPtr<const Logger> m_logger;
    394     const void* m_logIdentifier;
    395 #endif
    396 
    397391    bool m_invalid { false };
    398392};
  • trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm

    r267491 r267725  
    2929#if ENABLE(GPU_PROCESS) && PLATFORM(COCOA)
    3030
    31 #import <WebCore/FloatRect.h>
    32 #import <WebCore/TextTrackRepresentation.h>
     31#import <WebCore/VideoLayerManagerObjC.h>
    3332#import <pal/spi/cocoa/QuartzCoreSPI.h>
    34 #import <wtf/MachSendRight.h>
    3533
    3634namespace WebKit {
     35using namespace WebCore;
     36
     37MediaPlayerPrivateRemote::MediaPlayerPrivateRemote(MediaPlayer* player, MediaPlayerEnums::MediaEngineIdentifier engineIdentifier, MediaPlayerPrivateRemoteIdentifier playerIdentifier, RemoteMediaPlayerManager& manager)
     38#if !RELEASE_LOG_DISABLED
     39    : m_logger(player->mediaPlayerLogger())
     40    , m_logIdentifier(player->mediaPlayerLogIdentifier())
     41#endif
     42    , m_player(player)
     43    , m_mediaResourceLoader(*player->createResourceLoader())
     44    , m_videoLayerManager(makeUniqueRef<VideoLayerManagerObjC>(logger(), logIdentifier()))
     45    , m_manager(manager)
     46    , m_remoteEngineIdentifier(engineIdentifier)
     47    , m_id(playerIdentifier)
     48{
     49    INFO_LOG(LOGIDENTIFIER);
     50}
    3751
    3852#if ENABLE(VIDEO_PRESENTATION_MODE)
    39 
    4053PlatformLayerContainer MediaPlayerPrivateRemote::createVideoFullscreenLayer()
    4154{
    42     if (!m_fullscreenLayerHostingContextId)
    43         return nullptr;
    44 
    45     if (!m_videoFullscreenLayer) {
    46         m_videoFullscreenLayer = adoptNS([[CALayer alloc] init]);
    47         auto sublayer = LayerHostingContext::createPlatformLayerForHostingContext(m_fullscreenLayerHostingContextId.value());
    48         [sublayer setName:@"VideoFullscreenLayerSublayer"];
    49         [sublayer setPosition:CGPointMake(0, 0)];
    50         [m_videoFullscreenLayer addSublayer:sublayer.get()];
    51     }
    52 
    53     return m_videoFullscreenLayer;
     55    return adoptNS([[CALayer alloc] init]);
    5456}
    55 
    56 void MediaPlayerPrivateRemote::setVideoFullscreenFrame(WebCore::FloatRect rect)
    57 {
    58     auto context = [m_videoFullscreenLayer context];
    59     if (!context)
    60         return;
    61 
    62     [CATransaction begin];
    63     [CATransaction setDisableActions:YES];
    64 
    65     MachSendRight fenceSendRight = MachSendRight::adopt([context createFencePort]);
    66     setVideoFullscreenFrameFenced(rect, fenceSendRight);
    67 
    68     [CATransaction commit];
    69 
    70     syncTextTrackBounds();
    71 }
    72 
    7357#endif
    74 
    75 void MediaPlayerPrivateRemote::setTextTrackRepresentation(WebCore::TextTrackRepresentation* representation)
    76 {
    77 #if !ENABLE(VIDEO_PRESENTATION_MODE)
    78     UNUSED_PARAM(representation);
    79 #else
    80     PlatformLayer* representationLayer = representation ? representation->platformLayer() : nil;
    81 
    82     if (representationLayer == m_textTrackRepresentationLayer) {
    83         syncTextTrackBounds();
    84         return;
    85     }
    86 
    87     [CATransaction begin];
    88     [CATransaction setDisableActions:YES];
    89 
    90     if (m_textTrackRepresentationLayer)
    91         [m_textTrackRepresentationLayer removeFromSuperlayer];
    92 
    93     m_textTrackRepresentationLayer = representationLayer;
    94 
    95     if (m_videoFullscreenLayer && m_textTrackRepresentationLayer) {
    96         syncTextTrackBounds();
    97         [m_videoFullscreenLayer addSublayer:m_textTrackRepresentationLayer.get()];
    98     }
    99 
    100     [CATransaction commit];
    101 #endif
    102 }
    103 
    104 void MediaPlayerPrivateRemote::syncTextTrackBounds()
    105 {
    106 #if ENABLE(VIDEO_PRESENTATION_MODE)
    107     if (!m_videoFullscreenLayer || !m_textTrackRepresentationLayer)
    108         return;
    109 
    110     [CATransaction begin];
    111     [CATransaction setDisableActions:YES];
    112 
    113     [m_textTrackRepresentationLayer setFrame:m_videoFullscreenLayer.get().bounds];
    114 
    115     [CATransaction commit];
    116 #endif
    117 }
    11858
    11959} // namespace WebKit
Note: See TracChangeset for help on using the changeset viewer.