Diff
Modified: branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog (192556 => 192557)
--- branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog 2015-11-18 00:27:12 UTC (rev 192556)
+++ branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog 2015-11-18 00:27:16 UTC (rev 192557)
@@ -1,5 +1,9 @@
2015-11-13 Matthew Hanson <matthew_han...@apple.com>
+ Rollout r192417. rdar://problem/22846841
+
+2015-11-13 Matthew Hanson <matthew_han...@apple.com>
+
Rollout r192418. rdar://problem/22846841
2015-11-13 Matthew Hanson <matthew_han...@apple.com>
@@ -84,47 +88,6 @@
(IPC::ArgumentCoder<TextureMapperAnimation>::encode):
(IPC::ArgumentCoder<TextureMapperAnimation>::decode):
-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 (192556 => 192557)
--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-11-18 00:27:12 UTC (rev 192556)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-11-18 00:27:16 UTC (rev 192557)
@@ -1105,14 +1105,20 @@
- (PassRefPtr<WebKit::ViewSnapshot>)_takeViewSnapshot
{
float deviceScale = WKGetScreenScaleFactor();
- WebCore::FloatSize snapshotSize(self.bounds.size);
- snapshotSize.scale(deviceScale, deviceScale);
+ CGSize snapshotSize = self.bounds.size;
+ snapshotSize.width *= deviceScale;
+ snapshotSize.height *= deviceScale;
+ uint32_t slotID = [WebKit::ViewSnapshotStore::snapshottingContext() createImageSlot:snapshotSize hasAlpha:YES];
+
+ if (!slotID)
+ return nullptr;
+
CATransform3D transform = CATransform3DMakeScale(deviceScale, deviceScale, 1);
- 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);
+ CARenderServerCaptureLayerWithTransform(MACH_PORT_NULL, self.layer.context.contextId, (uint64_t)self.layer, slotID, 0, 0, &transform);
- return WebKit::ViewSnapshot::create(nullptr);
+ WebCore::IntSize imageSize = WebCore::expandedIntSize(WebCore::FloatSize(snapshotSize));
+ return WebKit::ViewSnapshot::create(slotID, imageSize, imageSize.width() * imageSize.height() * 4);
}
- (void)_zoomToPoint:(WebCore::FloatPoint)point atScale:(double)scale animated:(BOOL)animated
Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h (192556 => 192557)
--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h 2015-11-18 00:27:12 UTC (rev 192556)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h 2015-11-18 00:27:16 UTC (rev 192557)
@@ -41,6 +41,14 @@
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;
}
@@ -53,7 +61,11 @@
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();
@@ -70,20 +82,29 @@
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;
};
@@ -100,6 +121,10 @@
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 (192556 => 192557)
--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm 2015-11-18 00:27:12 UTC (rev 192556)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm 2015-11-18 00:27:16 UTC (rev 192557)
@@ -37,10 +37,11 @@
using namespace WebCore;
-#if PLATFORM(IOS)
+#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.
static const size_t maximumSnapshotCacheSize = 50 * (1024 * 1024);
-#else
-static const size_t maximumSnapshotCacheSize = 400 * (1024 * 1024);
#endif
namespace WebKit {
@@ -61,6 +62,24 @@
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;
@@ -113,13 +132,30 @@
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);
@@ -130,21 +166,13 @@
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()
@@ -154,11 +182,18 @@
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;
@@ -168,6 +203,9 @@
}
return (id)m_surface->surface();
+#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
+ return [CAContext objectForSlot:m_slotID];
+#endif
}
} // namespace WebKit