Title: [192417] branches/safari-601.1.46-branch/Source/WebKit2

Diff

Modified: branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog (192416 => 192417)


--- branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog	2015-11-13 15:59:27 UTC (rev 192416)
+++ branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog	2015-11-13 17:02:40 UTC (rev 192417)
@@ -1,3 +1,44 @@
+2015-11-12  Matthew Hanson  <matthew_han...@apple.com>
+
+        Merge r189628. rdar://problem/22846841
+
+    2015-09-11  Beth Dakin  <bda...@apple.com>
+
+            Should use CARenderServerRenderLayerWithTransform for snapshots on iOS
+            https://bugs.webkit.org/show_bug.cgi?id=149069
+            -and corresponding-
+            rdar://problem/19726953
+
+            Reviewed by Tim Horton.
+
+            This will let us own the backing IOSurface, which will let us share more code
+            with Mac.
+
+            Use CARenderServerRenderLayerWithTransform
+            * UIProcess/API/Cocoa/WKWebView.mm:
+            (-[WKWebView _takeViewSnapshot]):
+            (-[WKWebView _zoomToPoint:atScale:animated:]):
+
+            We can eliminate things needed for the slot-based API.
+            * UIProcess/mac/ViewSnapshotStore.h:
+            (WebKit::ViewSnapshot::setDeviceScaleFactor):
+            (WebKit::ViewSnapshot::deviceScaleFactor):
+            (WebKit::ViewSnapshot::surface):
+            (WebKit::ViewSnapshot::imageSizeInBytes):
+            (WebKit::ViewSnapshot::size):
+            * UIProcess/mac/ViewSnapshotStore.mm:
+            (WebKit::ViewSnapshotStore::singleton):
+            (WebKit::ViewSnapshotStore::didAddImageToSnapshot):
+            (WebKit::ViewSnapshotStore::discardSnapshotImages):
+            (WebKit::ViewSnapshot::create):
+            (WebKit::ViewSnapshot::ViewSnapshot):
+            (WebKit::ViewSnapshot::~ViewSnapshot):
+            (WebKit::ViewSnapshot::setSurface):
+            (WebKit::ViewSnapshot::hasImage):
+            (WebKit::ViewSnapshot::clearImage):
+            (WebKit::ViewSnapshot::asLayerContents):
+            (WebKit::ViewSnapshotStore::snapshottingContext): Deleted.
+
 2015-11-06  Babak Shafiei  <bshaf...@apple.com>
 
         Merge r189753.

Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (192416 => 192417)


--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-11-13 15:59:27 UTC (rev 192416)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-11-13 17:02:40 UTC (rev 192417)
@@ -1105,20 +1105,14 @@
 - (PassRefPtr<WebKit::ViewSnapshot>)_takeViewSnapshot
 {
     float deviceScale = WKGetScreenScaleFactor();
-    CGSize snapshotSize = self.bounds.size;
-    snapshotSize.width *= deviceScale;
-    snapshotSize.height *= deviceScale;
+    WebCore::FloatSize snapshotSize(self.bounds.size);
+    snapshotSize.scale(deviceScale, deviceScale);
 
-    uint32_t slotID = [WebKit::ViewSnapshotStore::snapshottingContext() createImageSlot:snapshotSize hasAlpha:YES];
-
-    if (!slotID)
-        return nullptr;
-
     CATransform3D transform = CATransform3DMakeScale(deviceScale, deviceScale, 1);
-    CARenderServerCaptureLayerWithTransform(MACH_PORT_NULL, self.layer.context.contextId, (uint64_t)self.layer, slotID, 0, 0, &transform);
+    auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(snapshotSize), WebCore::ColorSpaceDeviceRGB);
+    CARenderServerRenderLayerWithTransform(MACH_PORT_NULL, self.layer.context.contextId, reinterpret_cast<uint64_t>(self.layer), surface->surface(), 0, 0, &transform);
 
-    WebCore::IntSize imageSize = WebCore::expandedIntSize(WebCore::FloatSize(snapshotSize));
-    return WebKit::ViewSnapshot::create(slotID, imageSize, imageSize.width() * imageSize.height() * 4);
+    return WebKit::ViewSnapshot::create(nullptr);
 }
 
 - (void)_zoomToPoint:(WebCore::FloatPoint)point atScale:(double)scale animated:(BOOL)animated

Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h (192416 => 192417)


--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h	2015-11-13 15:59:27 UTC (rev 192416)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h	2015-11-13 17:02:40 UTC (rev 192417)
@@ -41,14 +41,6 @@
 
 OBJC_CLASS CAContext;
 
-#if PLATFORM(MAC)
-#define USE_IOSURFACE_VIEW_SNAPSHOTS 1
-#define USE_RENDER_SERVER_VIEW_SNAPSHOTS 0
-#else
-#define USE_IOSURFACE_VIEW_SNAPSHOTS 0
-#define USE_RENDER_SERVER_VIEW_SNAPSHOTS 1
-#endif
-
 namespace WebCore {
 class IOSurface;
 }
@@ -61,11 +53,7 @@
 
 class ViewSnapshot : public RefCounted<ViewSnapshot> {
 public:
-#if USE_IOSURFACE_VIEW_SNAPSHOTS
     static Ref<ViewSnapshot> create(std::unique_ptr<WebCore::IOSurface>);
-#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
-    static Ref<ViewSnapshot> create(uint32_t slotID, WebCore::IntSize, size_t imageSizeInBytes);
-#endif
 
     ~ViewSnapshot();
 
@@ -82,29 +70,20 @@
     void setDeviceScaleFactor(float deviceScaleFactor) { m_deviceScaleFactor = deviceScaleFactor; }
     float deviceScaleFactor() const { return m_deviceScaleFactor; }
 
-    size_t imageSizeInBytes() const { return m_imageSizeInBytes; }
-#if USE_IOSURFACE_VIEW_SNAPSHOTS
     WebCore::IOSurface* surface() const { return m_surface.get(); }
-#endif
-    WebCore::IntSize size() const { return m_size; }
 
+    size_t imageSizeInBytes() const { return m_surface ? m_surface->totalBytes() : 0; }
+    WebCore::IntSize size() const { return m_surface ? m_surface->size() : WebCore::IntSize(); }
+
+    void setSurface(std::unique_ptr<WebCore::IOSurface>);
+
 private:
-#if USE_IOSURFACE_VIEW_SNAPSHOTS
     explicit ViewSnapshot(std::unique_ptr<WebCore::IOSurface>);
-#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
-    explicit ViewSnapshot(uint32_t slotID, WebCore::IntSize, size_t imageSizeInBytes);
-#endif
 
-#if USE_IOSURFACE_VIEW_SNAPSHOTS
     std::unique_ptr<WebCore::IOSurface> m_surface;
-#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
-    uint32_t m_slotID;
-#endif
 
-    size_t m_imageSizeInBytes;
     uint64_t m_renderTreeSize;
     float m_deviceScaleFactor;
-    WebCore::IntSize m_size;
     WebCore::Color m_backgroundColor;
 };
 
@@ -121,10 +100,6 @@
 
     void discardSnapshotImages();
 
-#if USE_RENDER_SERVER_VIEW_SNAPSHOTS
-    static CAContext *snapshottingContext();
-#endif
-
 private:
     void didAddImageToSnapshot(ViewSnapshot&);
     void willRemoveImageFromSnapshot(ViewSnapshot&);

Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm (192416 => 192417)


--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm	2015-11-13 15:59:27 UTC (rev 192416)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm	2015-11-13 17:02:40 UTC (rev 192417)
@@ -37,11 +37,10 @@
 
 using namespace WebCore;
 
-#if USE_IOSURFACE_VIEW_SNAPSHOTS
-static const size_t maximumSnapshotCacheSize = 400 * (1024 * 1024);
-#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
-// Because render server snapshots are not purgeable, we should keep fewer around.
+#if PLATFORM(IOS)
 static const size_t maximumSnapshotCacheSize = 50 * (1024 * 1024);
+#else
+static const size_t maximumSnapshotCacheSize = 400 * (1024 * 1024);
 #endif
 
 namespace WebKit {
@@ -62,24 +61,6 @@
     return store;
 }
 
-#if USE_RENDER_SERVER_VIEW_SNAPSHOTS
-CAContext *ViewSnapshotStore::snapshottingContext()
-{
-    static CAContext *context;
-    static dispatch_once_t onceToken;
-    dispatch_once(&onceToken, ^{
-        NSDictionary *options = @{
-            kCAContextDisplayName: @"WebKitSnapshotting",
-            kCAContextIgnoresHitTest: @YES,
-            kCAContextDisplayId : @20000
-        };
-        context = [[CAContext remoteContextWithOptions:options] retain];
-    });
-
-    return context;
-}
-#endif
-
 void ViewSnapshotStore::didAddImageToSnapshot(ViewSnapshot& snapshot)
 {
     bool isNewEntry = m_snapshotsWithImages.add(&snapshot).isNewEntry;
@@ -132,30 +113,13 @@
         m_snapshotsWithImages.first()->clearImage();
 }
 
-
-#if USE_IOSURFACE_VIEW_SNAPSHOTS
 Ref<ViewSnapshot> ViewSnapshot::create(std::unique_ptr<IOSurface> surface)
 {
     return adoptRef(*new ViewSnapshot(WTF::move(surface)));
 }
-#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
-Ref<ViewSnapshot> ViewSnapshot::create(uint32_t slotID, IntSize size, size_t imageSizeInBytes)
-{
-    return adoptRef(*new ViewSnapshot(slotID, size, imageSizeInBytes));
-}
-#endif
 
-#if USE_IOSURFACE_VIEW_SNAPSHOTS
 ViewSnapshot::ViewSnapshot(std::unique_ptr<IOSurface> surface)
     : m_surface(WTF::move(surface))
-    , m_imageSizeInBytes(m_surface->totalBytes())
-    , m_size(m_surface->size())
-#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
-ViewSnapshot::ViewSnapshot(uint32_t slotID, IntSize size, size_t imageSizeInBytes)
-    : m_slotID(slotID)
-    , m_imageSizeInBytes(imageSizeInBytes)
-    , m_size(size)
-#endif
 {
     if (hasImage())
         ViewSnapshotStore::singleton().didAddImageToSnapshot(*this);
@@ -166,13 +130,21 @@
     clearImage();
 }
 
+void ViewSnapshot::setSurface(std::unique_ptr<WebCore::IOSurface> surface)
+{
+    ASSERT(!m_surface);
+    if (!surface) {
+        clearImage();
+        return;
+    }
+
+    m_surface = WTF::move(surface);
+    ViewSnapshotStore::singleton().didAddImageToSnapshot(*this);
+}
+
 bool ViewSnapshot::hasImage() const
 {
-#if USE_IOSURFACE_VIEW_SNAPSHOTS
     return !!m_surface;
-#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
-    return m_slotID;
-#endif
 }
 
 void ViewSnapshot::clearImage()
@@ -182,18 +154,11 @@
 
     ViewSnapshotStore::singleton().willRemoveImageFromSnapshot(*this);
 
-#if USE_IOSURFACE_VIEW_SNAPSHOTS
     m_surface = nullptr;
-#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
-    [ViewSnapshotStore::snapshottingContext() deleteSlot:m_slotID];
-    m_slotID = 0;
-#endif
-    m_imageSizeInBytes = 0;
 }
 
 id ViewSnapshot::asLayerContents()
 {
-#if USE_IOSURFACE_VIEW_SNAPSHOTS
     if (!m_surface)
         return nullptr;
 
@@ -203,9 +168,6 @@
     }
 
     return (id)m_surface->surface();
-#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
-    return [CAContext objectForSlot:m_slotID];
-#endif
 }
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to