Title: [209369] trunk/Source
Revision
209369
Author
[email protected]
Date
2016-12-05 17:07:04 -0800 (Mon, 05 Dec 2016)

Log Message

Adopt CAMachPort-as-layer-contents
https://bugs.webkit.org/show_bug.cgi?id=141687
<rdar://problem/19393233>

Reviewed by Darin Adler.

No new tests, just a performance bump.

* platform/spi/cocoa/QuartzCoreSPI.h:
Add some SPI.

* Shared/mac/RemoteLayerBackingStore.h:
* Shared/mac/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::decode):
On the UI process side, instead of actually looking up the surface,
just keep the MachSendRight around, to later be turned into a CAMachPort.

(WebKit::RemoteLayerBackingStore::applyBackingStoreToLayer):
Make a CAMachPort and leak our send right into it. CAMachPort
will adopt the port and destroy it when needed.

(WebKit::RemoteLayerBackingStore::setBufferVolatility):
Tiny style fix.

* Shared/mac/RemoteLayerTreePropertyApplier.h:
* Shared/mac/RemoteLayerTreePropertyApplier.mm:
(WebKit::applyPropertiesToLayer):
(WebKit::RemoteLayerTreePropertyApplier::applyProperties):
* UIProcess/DrawingAreaProxy.h:
(WebKit::DrawingAreaProxy::prepareForAppSuspension):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::applicationDidFinishSnapshottingAfterEnteringBackground):
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::prepareForAppSuspension):
* UIProcess/mac/RemoteLayerTreeHost.h:
* UIProcess/mac/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::updateLayerTree):
(WebKit::RemoteLayerTreeHost::mapAllIOSurfaceBackingStore):
* WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::recursiveBuildTransaction):
Two supporting changes in order to fix the two regressions that this
caused when we tried to land it two years ago:

When an app is being suspended, resolve all CAMachPort backing store
into actual IOSurfaces. Otherwise, any live CAMachPorts will keep a
+1 on their respective IOSurface's use count, causing us to fail to
mark them volatile, keeping the app alive for more time (re-trying the
volatility change), and increasing the likelihood of background jetsam.

If the debugging tile map is enabled, do not use CAMachPort, because
we don't have a great way to plumb the same CAMachPort to two layers
(and it doesn't seem to work even if you do). Instead, just map the
IOSurface into the UI process like we used to.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (209368 => 209369)


--- trunk/Source/WebCore/ChangeLog	2016-12-06 01:04:59 UTC (rev 209368)
+++ trunk/Source/WebCore/ChangeLog	2016-12-06 01:07:04 UTC (rev 209369)
@@ -1,3 +1,16 @@
+2016-12-05  Tim Horton  <[email protected]>
+
+        Adopt CAMachPort-as-layer-contents
+        https://bugs.webkit.org/show_bug.cgi?id=141687
+        <rdar://problem/19393233>
+
+        Reviewed by Darin Adler.
+
+        No new tests, just a performance bump.
+
+        * platform/spi/cocoa/QuartzCoreSPI.h:
+        Add some SPI.
+
 2016-12-05  Dave Hyatt  <[email protected]>
 
         [CSS Parser] calcs on column-width that resolve to 0 should be discarded

Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h (209368 => 209369)


--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h	2016-12-06 01:04:59 UTC (rev 209368)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h	2016-12-06 01:07:04 UTC (rev 209369)
@@ -47,7 +47,7 @@
 
     WEBCORE_EXPORT static std::unique_ptr<IOSurface> create(IntSize, CGColorSpaceRef, Format = Format::RGBA);
     WEBCORE_EXPORT static std::unique_ptr<IOSurface> create(IntSize, IntSize contextSize, CGColorSpaceRef, Format = Format::RGBA);
-    WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromSendRight(const MachSendRight&, CGColorSpaceRef);
+    WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromSendRight(const MachSendRight&&, CGColorSpaceRef);
     static std::unique_ptr<IOSurface> createFromSurface(IOSurfaceRef, CGColorSpaceRef);
     WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromImage(CGImageRef);
     

Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm (209368 => 209369)


--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm	2016-12-06 01:04:59 UTC (rev 209368)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm	2016-12-06 01:07:04 UTC (rev 209369)
@@ -72,7 +72,7 @@
     return surface;
 }
 
-std::unique_ptr<WebCore::IOSurface> WebCore::IOSurface::createFromSendRight(const MachSendRight& sendRight, CGColorSpaceRef colorSpace)
+std::unique_ptr<WebCore::IOSurface> WebCore::IOSurface::createFromSendRight(const MachSendRight&& sendRight, CGColorSpaceRef colorSpace)
 {
     auto surface = adoptCF(IOSurfaceLookupFromMachPort(sendRight.sendRight()));
     return IOSurface::createFromSurface(surface.get(), colorSpace);

Modified: trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h (209368 => 209369)


--- trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h	2016-12-06 01:04:59 UTC (rev 209368)
+++ trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h	2016-12-06 01:07:04 UTC (rev 209369)
@@ -191,6 +191,11 @@
 #endif
 #endif
 
+typedef struct _CAMachPort *CAMachPortRef;
+CAMachPortRef CAMachPortCreate(mach_port_t);
+mach_port_t CAMachPortGetPort(CAMachPortRef);
+CFTypeID CAMachPortGetTypeID(void);
+
 WTF_EXTERN_C_END
 
 // FIXME: Move this into the APPLE_INTERNAL_SDK block once it's in an SDK.

Modified: trunk/Source/WebKit2/ChangeLog (209368 => 209369)


--- trunk/Source/WebKit2/ChangeLog	2016-12-06 01:04:59 UTC (rev 209368)
+++ trunk/Source/WebKit2/ChangeLog	2016-12-06 01:07:04 UTC (rev 209369)
@@ -1,3 +1,55 @@
+2016-12-05  Tim Horton  <[email protected]>
+
+        Adopt CAMachPort-as-layer-contents
+        https://bugs.webkit.org/show_bug.cgi?id=141687
+        <rdar://problem/19393233>
+
+        Reviewed by Darin Adler.
+
+        * Shared/mac/RemoteLayerBackingStore.h:
+        * Shared/mac/RemoteLayerBackingStore.mm:
+        (WebKit::RemoteLayerBackingStore::decode):
+        On the UI process side, instead of actually looking up the surface,
+        just keep the MachSendRight around, to later be turned into a CAMachPort.
+
+        (WebKit::RemoteLayerBackingStore::applyBackingStoreToLayer):
+        Make a CAMachPort and leak our send right into it. CAMachPort
+        will adopt the port and destroy it when needed.
+
+        (WebKit::RemoteLayerBackingStore::setBufferVolatility):
+        Tiny style fix.
+
+        * Shared/mac/RemoteLayerTreePropertyApplier.h:
+        * Shared/mac/RemoteLayerTreePropertyApplier.mm:
+        (WebKit::applyPropertiesToLayer):
+        (WebKit::RemoteLayerTreePropertyApplier::applyProperties):
+        * UIProcess/DrawingAreaProxy.h:
+        (WebKit::DrawingAreaProxy::prepareForAppSuspension):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::applicationDidFinishSnapshottingAfterEnteringBackground):
+        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
+        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::prepareForAppSuspension):
+        * UIProcess/mac/RemoteLayerTreeHost.h:
+        * UIProcess/mac/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::updateLayerTree):
+        (WebKit::RemoteLayerTreeHost::mapAllIOSurfaceBackingStore):
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+        (WebKit::PlatformCALayerRemote::recursiveBuildTransaction):
+        Two supporting changes in order to fix the two regressions that this
+        caused when we tried to land it two years ago:
+
+        When an app is being suspended, resolve all CAMachPort backing store
+        into actual IOSurfaces. Otherwise, any live CAMachPorts will keep a
+        +1 on their respective IOSurface's use count, causing us to fail to
+        mark them volatile, keeping the app alive for more time (re-trying the
+        volatility change), and increasing the likelihood of background jetsam.
+
+        If the debugging tile map is enabled, do not use CAMachPort, because
+        we don't have a great way to plumb the same CAMachPort to two layers
+        (and it doesn't seem to work even if you do). Instead, just map the
+        IOSurface into the UI process like we used to.
+
 2016-12-05  Dean Jackson  <[email protected]>
 
         pointer lock needs to be feature detectable

Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h (209368 => 209369)


--- trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h	2016-12-06 01:04:59 UTC (rev 209368)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h	2016-12-06 01:07:04 UTC (rev 209369)
@@ -29,6 +29,7 @@
 #include "ShareableBitmap.h"
 #include <WebCore/FloatRect.h>
 #include <WebCore/IOSurface.h>
+#include <WebCore/MachSendRight.h>
 #include <WebCore/Region.h>
 #include <chrono>
 
@@ -65,7 +66,8 @@
 
     PlatformCALayerRemote* layer() const { return m_layer; }
 
-    void applyBackingStoreToLayer(CALayer *);
+    enum class LayerContentsType { IOSurface, CAMachPort };
+    void applyBackingStoreToLayer(CALayer *, LayerContentsType);
 
     void encode(IPC::Encoder&) const;
     static bool decode(IPC::Decoder&, RemoteLayerBackingStore&);
@@ -134,6 +136,7 @@
     Buffer m_backBuffer;
 #if USE(IOSURFACE)
     Buffer m_secondaryBackBuffer;
+    WebCore::MachSendRight m_frontBufferSendRight;
 #endif
 
     RetainPtr<CGContextRef> m_frontContextPendingFlush;

Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm (209368 => 209369)


--- trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm	2016-12-06 01:04:59 UTC (rev 209368)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm	2016-12-06 01:07:04 UTC (rev 209369)
@@ -36,7 +36,6 @@
 #import <QuartzCore/QuartzCore.h>
 #import <WebCore/GraphicsContextCG.h>
 #import <WebCore/IOSurface.h>
-#import <WebCore/MachSendRight.h>
 #import <WebCore/PlatformCALayerClient.h>
 #import <WebCore/PlatformScreen.h>
 #import <WebCore/QuartzCoreSPI.h>
@@ -153,7 +152,7 @@
         MachSendRight sendRight;
         if (!decoder.decode(sendRight))
             return false;
-        result.m_frontBuffer.surface = WebCore::IOSurface::createFromSendRight(sendRight, sRGBColorSpaceRef());
+        result.m_frontBufferSendRight = WTFMove(sendRight);
         return true;
     }
 #endif
@@ -399,13 +398,25 @@
     }
 }
 
-void RemoteLayerBackingStore::applyBackingStoreToLayer(CALayer *layer)
+void RemoteLayerBackingStore::applyBackingStoreToLayer(CALayer *layer, LayerContentsType contentsType)
 {
     layer.contentsOpaque = m_isOpaque;
 
 #if USE(IOSURFACE)
     if (acceleratesDrawing()) {
-        layer.contents = m_frontBuffer.surface ? m_frontBuffer.surface->asLayerContents() : nil;
+        switch (contentsType) {
+        case LayerContentsType::IOSurface:
+            if (!m_frontBuffer.surface) {
+                ASSERT(m_frontBufferSendRight);
+                m_frontBuffer.surface = WebCore::IOSurface::createFromSendRight(WTFMove(m_frontBufferSendRight), sRGBColorSpaceRef());
+            }
+            layer.contents = m_frontBuffer.surface ? m_frontBuffer.surface->asLayerContents() : nil;
+            break;
+        case LayerContentsType::CAMachPort:
+            ASSERT(m_frontBufferSendRight);
+            layer.contents = (id)adoptCF(CAMachPortCreate(m_frontBufferSendRight.leakSendRight())).get();
+            break;
+        }
         return;
     }
 #endif
@@ -422,7 +433,7 @@
 #if USE(IOSURFACE)
 bool RemoteLayerBackingStore::setBufferVolatility(BufferType type, bool isVolatile)
 {
-    switch(type) {
+    switch (type) {
     case BufferType::Front:
         if (m_frontBuffer.surface && m_frontBuffer.isVolatile != isVolatile) {
             if (isVolatile)

Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.h (209368 => 209369)


--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.h	2016-12-06 01:04:59 UTC (rev 209368)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.h	2016-12-06 01:07:04 UTC (rev 209369)
@@ -37,9 +37,9 @@
 class RemoteLayerTreePropertyApplier {
 public:
     typedef HashMap<WebCore::GraphicsLayer::PlatformLayerID, LayerOrView *> RelatedLayerMap;
-    static void applyProperties(CALayer *, RemoteLayerTreeHost*, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
+    static void applyProperties(CALayer *, RemoteLayerTreeHost*, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&, RemoteLayerBackingStore::LayerContentsType);
 #if PLATFORM(IOS)
-    static void applyProperties(UIView *, RemoteLayerTreeHost*, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
+    static void applyProperties(UIView *, RemoteLayerTreeHost*, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&, RemoteLayerBackingStore::LayerContentsType);
 #endif
 };
 

Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm (209368 => 209369)


--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm	2016-12-06 01:04:59 UTC (rev 209368)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm	2016-12-06 01:07:04 UTC (rev 209369)
@@ -126,7 +126,7 @@
 #endif
 }
 
-static void applyPropertiesToLayer(CALayer *layer, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties)
+static void applyPropertiesToLayer(CALayer *layer, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties, RemoteLayerBackingStore::LayerContentsType layerContentsType)
 {
     if (properties.changedProperties & RemoteLayerTreeTransaction::NameChanged)
         layer.name = properties.name;
@@ -234,7 +234,7 @@
     {
         RemoteLayerBackingStore* backingStore = properties.backingStore.get();
         if (backingStore && properties.backingStoreAttached)
-            backingStore->applyBackingStoreToLayer(layer);
+            backingStore->applyBackingStoreToLayer(layer, layerContentsType);
         else {
             layer.contents = nil;
             layer.contentsOpaque = NO;
@@ -254,10 +254,10 @@
         updateCustomAppearance(layer, properties.customAppearance);
 }
 
-void RemoteLayerTreePropertyApplier::applyProperties(CALayer *layer, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
+void RemoteLayerTreePropertyApplier::applyProperties(CALayer *layer, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers, RemoteLayerBackingStore::LayerContentsType layerContentsType)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    applyPropertiesToLayer(layer, layerTreeHost, properties);
+    applyPropertiesToLayer(layer, layerTreeHost, properties, layerContentsType);
 
     if (properties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged) {
         RetainPtr<NSMutableArray> children = adoptNS([[NSMutableArray alloc] initWithCapacity:properties.children.size()]);
@@ -291,10 +291,10 @@
 }
 
 #if PLATFORM(IOS)
-void RemoteLayerTreePropertyApplier::applyProperties(UIView *view, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
+void RemoteLayerTreePropertyApplier::applyProperties(UIView *view, RemoteLayerTreeHost* layerTreeHost, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers, RemoteLayerBackingStore::LayerContentsType layerContentsType)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    applyPropertiesToLayer(view.layer, layerTreeHost, properties);
+    applyPropertiesToLayer(view.layer, layerTreeHost, properties, layerContentsType);
 
     if (properties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged) {
         RetainPtr<NSMutableArray> children = adoptNS([[NSMutableArray alloc] initWithCapacity:properties.children.size()]);

Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h (209368 => 209369)


--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h	2016-12-06 01:04:59 UTC (rev 209368)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h	2016-12-06 01:07:04 UTC (rev 209369)
@@ -103,6 +103,8 @@
 
     virtual void willSendUpdateGeometry() { }
 
+    virtual void prepareForAppSuspension() { }
+
 #if PLATFORM(COCOA)
     virtual WebCore::MachSendRight createFence();
 #endif

Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (209368 => 209369)


--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm	2016-12-06 01:04:59 UTC (rev 209368)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm	2016-12-06 01:07:04 UTC (rev 209369)
@@ -673,6 +673,7 @@
 
 void WebPageProxy::applicationDidFinishSnapshottingAfterEnteringBackground()
 {
+    m_drawingArea->prepareForAppSuspension();
     m_process->send(Messages::WebPage::ApplicationDidFinishSnapshottingAfterEnteringBackground(), m_pageID);
 }
 

Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h (209368 => 209369)


--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h	2016-12-06 01:04:59 UTC (rev 209368)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h	2016-12-06 01:07:04 UTC (rev 209369)
@@ -56,6 +56,8 @@
     
     uint32_t contentUpdateFrequency() const;
 
+    bool hasDebugIndicator() const { return !!m_debugIndicatorLayerTreeHost; }
+
 private:
     void sizeDidChange() override;
     void deviceScaleFactorDidChange() override;
@@ -79,6 +81,8 @@
     void hideContentUntilPendingUpdate() override;
     void hideContentUntilAnyUpdate() override;
     bool hasVisibleContent() const override;
+
+    void prepareForAppSuspension() final;
     
     WebCore::FloatPoint indicatorLocation() const;
 

Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm (209368 => 209369)


--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm	2016-12-06 01:04:59 UTC (rev 209368)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm	2016-12-06 01:07:04 UTC (rev 209369)
@@ -474,6 +474,11 @@
     m_remoteLayerTreeHost.detachRootLayer();
 }
 
+void RemoteLayerTreeDrawingAreaProxy::prepareForAppSuspension()
+{
+    m_remoteLayerTreeHost.mapAllIOSurfaceBackingStore();
+}
+
 bool RemoteLayerTreeDrawingAreaProxy::hasVisibleContent() const
 {
     return m_remoteLayerTreeHost.rootLayer();

Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.h (209368 => 209369)


--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.h	2016-12-06 01:04:59 UTC (rev 209368)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.h	2016-12-06 01:07:04 UTC (rev 209369)
@@ -67,6 +67,10 @@
     // Detach the root layer; it will be reattached upon the next incoming commit.
     void detachRootLayer();
 
+    // Turn all CAMachPort objects in layer contents into actual IOSurfaces.
+    // This avoids keeping an outstanding InUse reference when suspended.
+    void mapAllIOSurfaceBackingStore();
+
 private:
     LayerOrView *createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties&, const RemoteLayerTreeTransaction::LayerProperties*);
     static void setLayerID(CALayer *, WebCore::GraphicsLayer::PlatformLayerID);

Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm (209368 => 209369)


--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm	2016-12-06 01:04:59 UTC (rev 209368)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm	2016-12-06 01:07:04 UTC (rev 209369)
@@ -33,7 +33,10 @@
 #import "WebPageProxy.h"
 #import "WebProcessProxy.h"
 #import <QuartzCore/QuartzCore.h>
+#import <WebCore/GraphicsContextCG.h>
+#import <WebCore/IOSurface.h>
 #import <WebCore/PlatformLayer.h>
+#import <WebCore/QuartzCoreSPI.h>
 #import <WebCore/WebActionDisablingCALayerDelegate.h>
 #import <WebKitSystemInterface.h>
 
@@ -76,6 +79,8 @@
 
     typedef std::pair<GraphicsLayer::PlatformLayerID, GraphicsLayer::PlatformLayerID> LayerIDPair;
     Vector<LayerIDPair> clonesToUpdate;
+
+    auto layerContentsType = m_drawingArea.hasDebugIndicator() ? RemoteLayerBackingStore::LayerContentsType::IOSurface : RemoteLayerBackingStore::LayerContentsType::CAMachPort;
     
     for (auto& changedLayer : transaction.changedLayerProperties()) {
         auto layerID = changedLayer.key;
@@ -97,13 +102,13 @@
             clonesToUpdate.append(LayerIDPair(layerID, properties.clonedLayerID));
 
         if (m_isDebugLayerTreeHost) {
-            RemoteLayerTreePropertyApplier::applyProperties(layer, this, properties, relatedLayers);
+            RemoteLayerTreePropertyApplier::applyProperties(layer, this, properties, relatedLayers, layerContentsType);
 
             if (properties.changedProperties & RemoteLayerTreeTransaction::BorderWidthChanged)
                 asLayer(layer).borderWidth = properties.borderWidth / indicatorScaleFactor;
             asLayer(layer).masksToBounds = false;
         } else
-            RemoteLayerTreePropertyApplier::applyProperties(layer, this, properties, relatedLayers);
+            RemoteLayerTreePropertyApplier::applyProperties(layer, this, properties, relatedLayers, layerContentsType);
     }
     
     for (const auto& layerPair : clonesToUpdate) {
@@ -269,4 +274,21 @@
     m_rootLayer = nullptr;
 }
 
+static void recursivelyMapIOSurfaceBackingStore(CALayer *layer)
+{
+    if (layer.contents && CFGetTypeID(layer.contents) == CAMachPortGetTypeID()) {
+        MachSendRight port = MachSendRight::create(CAMachPortGetPort((CAMachPortRef)layer.contents));
+        auto surface = WebCore::IOSurface::createFromSendRight(WTFMove(port), sRGBColorSpaceRef());
+        layer.contents = surface ? surface->asLayerContents() : nil;
+    }
+
+    for (CALayer *sublayer in layer.sublayers)
+        recursivelyMapIOSurfaceBackingStore(sublayer);
+}
+
+void RemoteLayerTreeHost::mapAllIOSurfaceBackingStore()
+{
+    recursivelyMapIOSurfaceBackingStore(asLayer(m_rootLayer));
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp (209368 => 209369)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp	2016-12-06 01:04:59 UTC (rev 209368)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp	2016-12-06 01:07:04 UTC (rev 209369)
@@ -166,7 +166,7 @@
         }
 
         if (isPlatformCALayerRemoteCustom()) {
-            RemoteLayerTreePropertyApplier::applyProperties(platformLayer(), nullptr, m_properties, RemoteLayerTreePropertyApplier::RelatedLayerMap());
+            RemoteLayerTreePropertyApplier::applyProperties(platformLayer(), nullptr, m_properties, RemoteLayerTreePropertyApplier::RelatedLayerMap(), RemoteLayerBackingStore::LayerContentsType::CAMachPort);
             didCommit();
             return;
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to