Changeset 170864 in webkit


Ignore:
Timestamp:
Jul 7, 2014 4:44:58 PM (10 years ago)
Author:
Simon Fraser
Message:

[UI-side compositing] Support reflections on custom layers like video
https://bugs.webkit.org/show_bug.cgi?id=134701

Reviewed by Tim Horton.

Source/WebCore:

Add a LayerTypeWebGLLayer layer type, and support casting to PlatformCALayerRemoteCustom.

  • WebCore.exp.in: Export PlatformCALayerMac::layerTypeForPlatformLayer(CALayer*), and sort.
  • platform/graphics/ca/PlatformCALayer.h:

(WebCore::PlatformCALayer::isPlatformCALayerRemoteCustom):

  • platform/graphics/ca/mac/PlatformCALayerMac.h:
  • platform/graphics/ca/mac/PlatformCALayerMac.mm:

(PlatformCALayerMac::layerTypeForPlatformLayer):
(PlatformCALayerMac::PlatformCALayerMac):
(PlatformCALayerMac::commonInit):

Source/WebKit2:

For video reflections, we have to support cloning of PlatformCALayerRemoteCustom
in the web process. Do so by implementing PlatformCALayerRemoteCustom::clone(),
which does the right gyrations to get AVPlayerLayers cloned, then makes a
new PlatformCALayerRemoteCustom to wrap the new layer. This ends up getting
its own context hosting ID, allowing the clone to show in the UI process.

Attempt to do the same for WebGL, but turn it off because it breaks.

  • Shared/mac/RemoteLayerBackingStore.mm:

(WebKit::RemoteLayerBackingStore::drawInContext):

  • Shared/mac/RemoteLayerTreeTransaction.mm:

(WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::encode): Unconditionally encode/decode
the hostingContextID. It will be 0 for most layers.
(WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::decode):
(WebKit::RemoteLayerTreeTransaction::description):

  • UIProcess/ios/RemoteLayerTreeHostIOS.mm:

(WebKit::RemoteLayerTreeHost::createLayer):

  • UIProcess/mac/RemoteLayerTreeHost.mm:

(WebKit::RemoteLayerTreeHost::createLayer):

  • WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:

(WebKit::PlatformCALayerRemote::create): Creation with a custom PlatformLayer* always
creates a PlatformCALayerRemoteCustom.
(WebKit::PlatformCALayerRemote::clone): Factor some code.
(WebKit::PlatformCALayerRemote::updateClonedLayerProperties):
(WebKit::PlatformCALayerRemote::recursiveBuildTransaction):

  • WebProcess/WebPage/mac/PlatformCALayerRemote.h:
  • WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h:
  • WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:

(WebKit::PlatformCALayerRemoteCustom::create):
(WebKit::PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom):
(WebKit::PlatformCALayerRemoteCustom::clone): Clone by making an instance of the
correct type of platform layer when possible, then wrapping a PlatformCALayerRemoteCustom
around it.
(WebKit::PlatformCALayerRemoteCustom::contents):
(WebKit::PlatformCALayerRemoteCustom::setContents):

  • WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:

(WebKit::RemoteLayerTreeContext::layerWasCreated):
(WebKit::RemoteLayerTreeContext::layerWillBeDestroyed):

Location:
trunk/Source
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r170862 r170864  
     12014-07-07  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [UI-side compositing] Support reflections on custom layers like video
     4        https://bugs.webkit.org/show_bug.cgi?id=134701
     5
     6        Reviewed by Tim Horton.
     7
     8        Add a LayerTypeWebGLLayer layer type, and support casting to PlatformCALayerRemoteCustom.
     9
     10        * WebCore.exp.in: Export PlatformCALayerMac::layerTypeForPlatformLayer(CALayer*), and sort.
     11        * platform/graphics/ca/PlatformCALayer.h:
     12        (WebCore::PlatformCALayer::isPlatformCALayerRemoteCustom):
     13        * platform/graphics/ca/mac/PlatformCALayerMac.h:
     14        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
     15        (PlatformCALayerMac::layerTypeForPlatformLayer):
     16        (PlatformCALayerMac::PlatformCALayerMac):
     17        (PlatformCALayerMac::commonInit):
     18
    1192014-07-07  Simon Fraser  <simon.fraser@apple.com>
    220
  • trunk/Source/WebCore/WebCore.exp.in

    r170818 r170864  
    159159__ZN7WebCore11HistoryItem14addRedirectURLERKN3WTF6StringE
    160160__ZN7WebCore11HistoryItem14setScrollPointERKNS_8IntPointE
     161__ZN7WebCore11HistoryItem14setStateObjectEN3WTF10PassRefPtrINS_21SerializedScriptValueEEE
    161162__ZN7WebCore11HistoryItem15setIsTargetItemEb
    162163__ZN7WebCore11HistoryItem15setRedirectURLsENSt3__110unique_ptrIN3WTF6VectorINS3_6StringELm0ENS3_15CrashOnOverflowEEENS1_14default_deleteIS7_EEEE
    163164__ZN7WebCore11HistoryItem16setDocumentStateERKN3WTF6VectorINS1_6StringELm0ENS1_15CrashOnOverflowEEE
    164165__ZN7WebCore11HistoryItem17setAlternateTitleERKN3WTF6StringE
     166__ZN7WebCore11HistoryItem18setFormContentTypeERKN3WTF6StringE
     167__ZN7WebCore11HistoryItem18setPageScaleFactorEf
    165168__ZN7WebCore11HistoryItem20setOriginalURLStringERKN3WTF6StringE
    166169__ZN7WebCore11HistoryItem20setTransientPropertyERKN3WTF6StringEP11objc_object
    167170__ZN7WebCore11HistoryItem8formDataEv
    168171__ZN7WebCore11HistoryItem8setTitleERKN3WTF6StringE
     172__ZN7WebCore11HistoryItem9setTargetERKN3WTF6StringE
    169173__ZN7WebCore11HistoryItemC1ERKN3WTF6StringES4_
    170174__ZN7WebCore11HistoryItemC1ERKN3WTF6StringES4_S4_
     
    596600__ZN7WebCore15GraphicsLayerCAC2ERNS_19GraphicsLayerClientE
    597601__ZN7WebCore15GraphicsLayerCAD2Ev
    598 __ZN7WebCore11HistoryItem14setStateObjectEN3WTF10PassRefPtrINS_21SerializedScriptValueEEE
    599 __ZN7WebCore11HistoryItem18setFormContentTypeERKN3WTF6StringE
    600 __ZN7WebCore11HistoryItem18setPageScaleFactorEf
    601 __ZN7WebCore11HistoryItem9setTargetERKN3WTF6StringE
    602602__ZN7WebCore15HitTestLocation12rectForPointERKNS_11LayoutPointEjjjj
    603603__ZN7WebCore15HitTestLocationC1ERKNS_10FloatPointE
     
    775775__ZN7WebCore18PlatformCALayerMac18setGeometryFlippedEb
    776776__ZN7WebCore18PlatformCALayerMac22filtersCanBeCompositedERKNS_16FilterOperationsE
     777__ZN7WebCore18PlatformCALayerMac25layerTypeForPlatformLayerEP7CALayer
    777778__ZN7WebCore18PlatformPasteboard10uniqueNameEv
    778779__ZN7WebCore18PlatformPasteboard13bufferForTypeERKN3WTF6StringE
     
    13011302__ZN7WebCore8FormData10appendDataEPKvm
    13021303__ZN7WebCore8FormData15appendFileRangeERKN3WTF6StringExxdb
     1304__ZN7WebCore8FormData6createEPKvm
    13031305__ZN7WebCore8FormData6createEv
    1304 __ZN7WebCore8FormData6createEPKvm
    13051306__ZN7WebCore8FormDataD1Ev
    13061307__ZN7WebCore8Gradient12addColorStopEfRKNS_5ColorE
  • trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h

    r170179 r170864  
    7676        LayerTypeRootLayer,
    7777        LayerTypeAVPlayerLayer,
     78        LayerTypeWebGLLayer,
    7879        LayerTypeCustom
    7980    };
     
    8889    virtual bool isPlatformCALayerMac() const { return false; }
    8990    virtual bool isPlatformCALayerRemote() const { return false; }
     91    virtual bool isPlatformCALayerRemoteCustom() const { return false; }
    9092
    9193    // This function passes the layer as a void* rather than a PlatformLayer because PlatformLayer
  • trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h

    r170071 r170864  
    4040    // is defined differently for Obj C and C++. This allows callers from both languages.
    4141    static PassRefPtr<PlatformCALayer> create(void* platformLayer, PlatformCALayerClient*);
     42
     43    static LayerType layerTypeForPlatformLayer(PlatformLayer*);
    4244
    4345    ~PlatformCALayerMac();
  • trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm

    r170862 r170864  
    4343#import "WebCoreCALayerExtras.h"
    4444#import "WebLayer.h"
     45#import "WebGLLayer.h"
    4546#import "WebTiledBackingLayer.h"
    4647#import <objc/objc-auto.h>
     
    176177}
    177178
     179PlatformCALayer::LayerType PlatformCALayerMac::layerTypeForPlatformLayer(PlatformLayer* layer)
     180{
     181    if ([layer isKindOfClass:getAVPlayerLayerClass()])
     182        return LayerTypeAVPlayerLayer;
     183
     184    if ([layer isKindOfClass:[WebGLLayer class]])
     185        return LayerTypeWebGLLayer;
     186
     187    return LayerTypeCustom;
     188}
     189
    178190PlatformCALayerMac::PlatformCALayerMac(LayerType layerType, PlatformCALayerClient* owner)
    179191    : PlatformCALayer(layerType, owner)
     
    207219        layerClass = getAVPlayerLayerClass();
    208220        break;
     221    case LayerTypeWebGLLayer:
     222        // We don't create PlatformCALayerMacs wrapped around WebGLLayers.
     223        ASSERT_NOT_REACHED();
     224        break;
    209225    case LayerTypeCustom:
    210226        break;
     
    218234
    219235PlatformCALayerMac::PlatformCALayerMac(PlatformLayer* layer, PlatformCALayerClient* owner)
    220     : PlatformCALayer([layer isKindOfClass:getAVPlayerLayerClass()] ? LayerTypeAVPlayerLayer : LayerTypeCustom, owner)
     236    : PlatformCALayer(layerTypeForPlatformLayer(layer), owner)
    221237    , m_customAppearance(GraphicsLayer::NoCustomAppearance)
    222238    , m_customBehavior(GraphicsLayer::NoCustomBehavior)
     
    233249   
    234250    // Clear all the implicit animations on the CALayer
    235     if (m_layerType == LayerTypeAVPlayerLayer || m_layerType == LayerTypeCustom)
     251    if (m_layerType == LayerTypeAVPlayerLayer || m_layerType == LayerTypeWebGLLayer || m_layerType == LayerTypeCustom)
    236252        [m_layer web_disableAllActions];
    237253    else
  • trunk/Source/WebKit2/ChangeLog

    r170862 r170864  
     12014-07-07  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [UI-side compositing] Support reflections on custom layers like video
     4        https://bugs.webkit.org/show_bug.cgi?id=134701
     5
     6        Reviewed by Tim Horton.
     7       
     8        For video reflections, we have to support cloning of PlatformCALayerRemoteCustom
     9        in the web process. Do so by implementing PlatformCALayerRemoteCustom::clone(),
     10        which does the right gyrations to get AVPlayerLayers cloned, then makes a
     11        new PlatformCALayerRemoteCustom to wrap the new layer. This ends up getting
     12        its own context hosting ID, allowing the clone to show in the UI process.
     13       
     14        Attempt to do the same for WebGL, but turn it off because it breaks.
     15
     16        * Shared/mac/RemoteLayerBackingStore.mm:
     17        (WebKit::RemoteLayerBackingStore::drawInContext):
     18        * Shared/mac/RemoteLayerTreeTransaction.mm:
     19        (WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::encode): Unconditionally encode/decode
     20        the hostingContextID. It will be 0 for most layers.
     21        (WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::decode):
     22        (WebKit::RemoteLayerTreeTransaction::description):
     23        * UIProcess/ios/RemoteLayerTreeHostIOS.mm:
     24        (WebKit::RemoteLayerTreeHost::createLayer):
     25        * UIProcess/mac/RemoteLayerTreeHost.mm:
     26        (WebKit::RemoteLayerTreeHost::createLayer):
     27        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
     28        (WebKit::PlatformCALayerRemote::create): Creation with a custom PlatformLayer* always
     29        creates a PlatformCALayerRemoteCustom.
     30        (WebKit::PlatformCALayerRemote::clone): Factor some code.
     31        (WebKit::PlatformCALayerRemote::updateClonedLayerProperties):
     32        (WebKit::PlatformCALayerRemote::recursiveBuildTransaction):
     33        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
     34        * WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h:
     35        * WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:
     36        (WebKit::PlatformCALayerRemoteCustom::create):
     37        (WebKit::PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom):
     38        (WebKit::PlatformCALayerRemoteCustom::clone): Clone by making an instance of the
     39        correct type of platform layer when possible, then wrapping a PlatformCALayerRemoteCustom
     40        around it.
     41        (WebKit::PlatformCALayerRemoteCustom::contents):
     42        (WebKit::PlatformCALayerRemoteCustom::setContents):
     43        * WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:
     44        (WebKit::RemoteLayerTreeContext::layerWasCreated):
     45        (WebKit::RemoteLayerTreeContext::layerWillBeDestroyed):
     46
    1472014-07-07  Simon Fraser  <simon.fraser@apple.com>
    248
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm

    r170774 r170864  
    338338    case PlatformCALayer::LayerTypeRootLayer:
    339339    case PlatformCALayer::LayerTypeAVPlayerLayer:
     340    case PlatformCALayer::LayerTypeWebGLLayer:
    340341    case PlatformCALayer::LayerTypeCustom:
    341342        ASSERT_NOT_REACHED();
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm

    r170774 r170864  
    5555    encoder << layerID;
    5656    encoder.encodeEnum(type);
    57 
    58     if (type == PlatformCALayer::LayerTypeCustom)
    59         encoder << hostingContextID;
     57    encoder << hostingContextID;
    6058}
    6159
     
    6866        return false;
    6967
    70     if (result.type == PlatformCALayer::LayerTypeCustom) {
    71         if (!decoder.decode(result.hostingContextID))
    72             return false;
    73     }
     68    if (!decoder.decode(result.hostingContextID))
     69        return false;
    7470
    7571    return true;
     
    11811177                break;
    11821178            case PlatformCALayer::LayerTypeAVPlayerLayer:
    1183                 ts << "av-player-layer";
     1179                ts << "av-player-layer (context-id " << createdLayer.hostingContextID << ")";
     1180                break;
     1181            case PlatformCALayer::LayerTypeWebGLLayer:
     1182                ts << "web-gl-layer (context-id " << createdLayer.hostingContextID << ")";
    11841183                break;
    11851184            case PlatformCALayer::LayerTypeCustom:
  • trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm

    r170610 r170864  
    153153        break;
    154154    case PlatformCALayer::LayerTypeCustom:
     155    case PlatformCALayer::LayerTypeAVPlayerLayer:
     156    case PlatformCALayer::LayerTypeWebGLLayer:
    155157        if (!m_isDebugLayerTreeHost)
    156158            view = adoptNS([[WKRemoteView alloc] initWithFrame:CGRectZero contextID:properties.hostingContextID]);
  • trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm

    r170862 r170864  
    203203        break;
    204204    case PlatformCALayer::LayerTypeCustom:
     205    case PlatformCALayer::LayerTypeAVPlayerLayer:
     206    case PlatformCALayer::LayerTypeWebGLLayer:
    205207        if (!m_isDebugLayerTreeHost)
    206208            layer = WKMakeRenderLayer(properties.hostingContextID);
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp

    r170862 r170864  
    6262PassRefPtr<PlatformCALayerRemote> PlatformCALayerRemote::create(PlatformLayer *platformLayer, PlatformCALayerClient* owner, RemoteLayerTreeContext& context)
    6363{
    64     RefPtr<PlatformCALayerRemote> layer = adoptRef(new PlatformCALayerRemoteCustom(static_cast<PlatformLayer*>(platformLayer), owner, context));
    65 
    66     context.layerWasCreated(*layer, LayerTypeCustom);
    67 
    68     return layer.release();
     64    return PlatformCALayerRemoteCustom::create(platformLayer, owner, context);
    6965}
    7066
     
    9894}
    9995
    100 PassRefPtr<PlatformCALayer> PlatformCALayerRemote::clone(PlatformCALayerClient* client) const
    101 {
    102     RefPtr<PlatformCALayerRemote> clone = PlatformCALayerRemote::create(*this, client, *m_context);
    103 
    104     clone->setPosition(position());
    105     clone->setBounds(bounds());
    106     clone->setAnchorPoint(anchorPoint());
     96PassRefPtr<PlatformCALayer> PlatformCALayerRemote::clone(PlatformCALayerClient* owner) const
     97{
     98    RefPtr<PlatformCALayerRemote> clone = PlatformCALayerRemote::create(*this, owner, *m_context);
     99
     100    updateClonedLayerProperties(*clone);
     101
     102    clone->setClonedLayer(this);
     103    return clone.release();
     104}
     105
     106PlatformCALayerRemote::~PlatformCALayerRemote()
     107{
     108    for (const auto& layer : m_children)
     109        toPlatformCALayerRemote(layer.get())->m_superlayer = nullptr;
     110
     111    if (m_context)
     112        m_context->layerWillBeDestroyed(*this);
     113}
     114
     115void PlatformCALayerRemote::updateClonedLayerProperties(PlatformCALayerRemote& clone, bool copyContents) const
     116{
     117    clone.setPosition(position());
     118    clone.setBounds(bounds());
     119    clone.setAnchorPoint(anchorPoint());
    107120
    108121    if (m_properties.transform)
    109         clone->setTransform(*m_properties.transform);
     122        clone.setTransform(*m_properties.transform);
    110123
    111124    if (m_properties.sublayerTransform)
    112         clone->setSublayerTransform(*m_properties.sublayerTransform);
    113 
    114     clone->setContents(contents());
    115     clone->setMasksToBounds(masksToBounds());
    116     clone->setDoubleSided(isDoubleSided());
    117     clone->setOpaque(isOpaque());
    118     clone->setBackgroundColor(backgroundColor());
    119     clone->setContentsScale(contentsScale());
     125        clone.setSublayerTransform(*m_properties.sublayerTransform);
     126
     127    if (copyContents)
     128        clone.setContents(contents());
     129
     130    clone.setMasksToBounds(masksToBounds());
     131    clone.setDoubleSided(isDoubleSided());
     132    clone.setOpaque(isOpaque());
     133    clone.setBackgroundColor(backgroundColor());
     134    clone.setContentsScale(contentsScale());
    120135#if ENABLE(CSS_FILTERS)
    121136    if (m_properties.filters)
    122         clone->copyFiltersFrom(this);
     137        clone.copyFiltersFrom(this);
    123138#endif
    124     clone->updateCustomAppearance(customAppearance());
    125 
    126     clone->setClonedLayer(this);
    127     return clone.release();
    128 }
    129 
    130 PlatformCALayerRemote::~PlatformCALayerRemote()
    131 {
    132     for (const auto& layer : m_children)
    133         toPlatformCALayerRemote(layer.get())->m_superlayer = nullptr;
    134 
    135     if (m_context)
    136         m_context->layerWillBeDestroyed(*this);
     139    clone.updateCustomAppearance(customAppearance());
    137140}
    138141
     
    157160        }
    158161
    159         if (m_layerType == LayerTypeCustom) {
     162        if (isPlatformCALayerRemoteCustom()) {
    160163            RemoteLayerTreePropertyApplier::applyProperties(platformLayer(), nullptr, m_properties, RemoteLayerTreePropertyApplier::RelatedLayerMap());
    161164            didCommit();
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h

    r170274 r170864  
    172172    PlatformCALayerRemote(const PlatformCALayerRemote&, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext&);
    173173
     174    void updateClonedLayerProperties(PlatformCALayerRemote& clone, bool copyContents = true) const;
     175
    174176private:
    175177    virtual bool isPlatformCALayerRemote() const override { return true; }
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h

    r170274 r170864  
    3333class LayerHostingContext;
    3434
     35// PlatformCALayerRemoteCustom is used for CALayers that live in the web process and are hosted into the UI process via remote context.
    3536class PlatformCALayerRemoteCustom final : public PlatformCALayerRemote {
    3637    friend class PlatformCALayerRemote;
    3738public:
     39    static PassRefPtr<PlatformCALayerRemote> create(PlatformLayer *, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext&);
     40
    3841    virtual ~PlatformCALayerRemoteCustom();
    3942
     
    4548
    4649private:
    47     PlatformCALayerRemoteCustom(PlatformLayer*, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext&);
     50    PlatformCALayerRemoteCustom(WebCore::PlatformCALayer::LayerType, PlatformLayer *, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext&);
     51
     52    virtual PassRefPtr<WebCore::PlatformCALayer> clone(WebCore::PlatformCALayerClient* owner) const override;
     53
     54    virtual bool isPlatformCALayerRemoteCustom() const { return true; }
     55
     56    virtual CFTypeRef contents() const override;
     57    virtual void setContents(CFTypeRef) override;
    4858
    4959    std::unique_ptr<LayerHostingContext> m_layerHostingContext;
     
    5262};
    5363
     64PLATFORM_CALAYER_TYPE_CASTS(PlatformCALayerRemoteCustom, isPlatformCALayerRemote())
     65
    5466} // namespace WebKit
    5567
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm

    r170274 r170864  
    3131#import "RemoteLayerTreePropertyApplier.h"
    3232#import "WebProcess.h"
     33#import <AVFoundation/AVFoundation.h>
    3334#import <WebCore/GraphicsLayerCA.h>
    3435#import <WebCore/PlatformCALayerMac.h>
     
    3738#import <wtf/RetainPtr.h>
    3839
     40SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
     41SOFT_LINK_CLASS(AVFoundation, AVPlayerLayer)
     42
    3943using namespace WebCore;
    4044
     
    4246
    4347static NSString * const platformCALayerPointer = @"WKPlatformCALayer";
    44 PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom(PlatformLayer* customLayer, PlatformCALayerClient* owner, RemoteLayerTreeContext& context)
    45     : PlatformCALayerRemote(LayerTypeCustom, owner, context)
     48
     49PassRefPtr<PlatformCALayerRemote> PlatformCALayerRemoteCustom::create(PlatformLayer *platformLayer, PlatformCALayerClient* owner, RemoteLayerTreeContext& context)
     50{
     51    RefPtr<PlatformCALayerRemote> layer = adoptRef(new PlatformCALayerRemoteCustom(PlatformCALayerMac::layerTypeForPlatformLayer(platformLayer), platformLayer, owner, context));
     52    context.layerWasCreated(*layer, layer->layerType());
     53
     54    return layer.release();
     55}
     56
     57PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom(LayerType layerType, PlatformLayer * customLayer, PlatformCALayerClient* owner, RemoteLayerTreeContext& context)
     58    : PlatformCALayerRemote(layerType, owner, context)
    4659{
    4760    switch (context.layerHostingMode()) {
     
    6275    [customLayer web_disableAllActions];
    6376
    64     m_providesContents = [customLayer isKindOfClass:NSClassFromString(@"WebGLLayer")];
     77    m_providesContents = layerType == LayerTypeWebGLLayer;
    6578
    6679    properties().position = FloatPoint3D(customLayer.position.x, customLayer.position.y, customLayer.zPosition);
     
    8093}
    8194
     95PassRefPtr<WebCore::PlatformCALayer> PlatformCALayerRemoteCustom::clone(PlatformCALayerClient* owner) const
     96{
     97    RetainPtr<CALayer *> clonedLayer;
     98    bool copyContents = true;
     99
     100    if (layerType() == LayerTypeAVPlayerLayer) {
     101        clonedLayer = adoptNS([[getAVPlayerLayerClass() alloc] init]);
     102
     103        AVPlayerLayer* destinationPlayerLayer = static_cast<AVPlayerLayer *>(clonedLayer.get());
     104        AVPlayerLayer* sourcePlayerLayer = static_cast<AVPlayerLayer *>(platformLayer());
     105        dispatch_async(dispatch_get_main_queue(), ^{
     106            [destinationPlayerLayer setPlayer:[sourcePlayerLayer player]];
     107        });
     108        copyContents = false;
     109    } else if (layerType() == LayerTypeWebGLLayer) {
     110        clonedLayer = adoptNS([[CALayer alloc] init]);
     111        // FIXME: currently copying WebGL contents breaks the original layer.
     112        copyContents = false;
     113    }
     114
     115    RefPtr<PlatformCALayerRemote> clone = adoptRef(new PlatformCALayerRemoteCustom(layerType(), clonedLayer.get(), owner, *context()));
     116    context()->layerWasCreated(*clone, clone->layerType());
     117
     118    updateClonedLayerProperties(*clone, copyContents);
     119
     120    clone->setClonedLayer(this);
     121    return clone.release();
     122}
     123
     124CFTypeRef PlatformCALayerRemoteCustom::contents() const
     125{
     126    return [m_platformLayer contents];
     127}
     128
     129void PlatformCALayerRemoteCustom::setContents(CFTypeRef contents)
     130{
     131    [m_platformLayer setContents:(id)contents];
     132}
     133
    82134void PlatformCALayerRemoteCustom::setNeedsDisplay(const FloatRect* rect)
    83135{
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.mm

    r170774 r170864  
    6262    creationProperties.type = type;
    6363
    64     if (type == PlatformCALayer::LayerTypeCustom)
     64    if (layer.isPlatformCALayerRemoteCustom())
    6565        creationProperties.hostingContextID = layer.hostingContextID();
    6666
     
    7171void RemoteLayerTreeContext::layerWillBeDestroyed(PlatformCALayerRemote& layer)
    7272{
     73    ASSERT(layer.layerID());
    7374    GraphicsLayer::PlatformLayerID layerID = layer.layerID();
    7475
Note: See TracChangeset for help on using the changeset viewer.