Diff
Modified: branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog (192417 => 192418)
--- branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog 2015-11-13 17:02:40 UTC (rev 192417)
+++ branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog 2015-11-13 17:02:44 UTC (rev 192418)
@@ -1,5 +1,42 @@
2015-11-12 Matthew Hanson <matthew_han...@apple.com>
+ Merge r189635. rdar://problem/22846841
+
+ 2015-09-11 Beth Dakin <bda...@apple.com>
+
+ Still need view snapshotting code for non-IOSurface for the sim
+ https://bugs.webkit.org/show_bug.cgi?id=149077
+
+ Reviewed by Tim Horton.
+
+ This fixes the simulator build.
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _takeViewSnapshot]):
+ (-[WKWebView _zoomToPoint:atScale:animated:]):
+ * UIProcess/mac/ViewGestureControllerMac.mm:
+ (WebKit::ViewGestureController::beginSwipeGesture):
+ (WebKit::ViewGestureController::removeSwipeSnapshot):
+ * 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::snapshottingContext):
+ (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):
+
+2015-11-12 Matthew Hanson <matthew_han...@apple.com>
+
Merge r189628. rdar://problem/22846841
2015-09-11 Beth Dakin <bda...@apple.com>
Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (192417 => 192418)
--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-11-13 17:02:40 UTC (rev 192417)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-11-13 17:02:44 UTC (rev 192418)
@@ -1109,10 +1109,22 @@
snapshotSize.scale(deviceScale, deviceScale);
CATransform3D transform = CATransform3DMakeScale(deviceScale, deviceScale, 1);
+
+#if USE(IOSURFACE)
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);
return WebKit::ViewSnapshot::create(nullptr);
+#else
+ uint32_t slotID = [WebKit::ViewSnapshotStore::snapshottingContext() createImageSlot:snapshotSize hasAlpha:YES];
+
+ if (!slotID)
+ return nullptr;
+
+ CARenderServerCaptureLayerWithTransform(MACH_PORT_NULL, self.layer.context.contextId, (uint64_t)self.layer, slotID, 0, 0, &transform);
+ WebCore::IntSize imageSize = WebCore::expandedIntSize(WebCore::FloatSize(snapshotSize));
+ return WebKit::ViewSnapshot::create(slotID, imageSize, imageSize.width() * imageSize.height() * 4);
+#endif
}
- (void)_zoomToPoint:(WebCore::FloatPoint)point atScale:(double)scale animated:(BOOL)animated
Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h (192417 => 192418)
--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h 2015-11-13 17:02:40 UTC (rev 192417)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h 2015-11-13 17:02:44 UTC (rev 192418)
@@ -53,7 +53,11 @@
class ViewSnapshot : public RefCounted<ViewSnapshot> {
public:
+#if USE(IOSURFACE)
static Ref<ViewSnapshot> create(std::unique_ptr<WebCore::IOSurface>);
+#else
+ static Ref<ViewSnapshot> create(uint32_t slotID, WebCore::IntSize, size_t imageSizeInBytes);
+#endif
~ViewSnapshot();
@@ -70,18 +74,30 @@
void setDeviceScaleFactor(float deviceScaleFactor) { m_deviceScaleFactor = deviceScaleFactor; }
float deviceScaleFactor() const { return m_deviceScaleFactor; }
+#if USE(IOSURFACE)
WebCore::IOSurface* surface() const { return m_surface.get(); }
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>);
+#else
+ WebCore::IntSize size() const { return m_size; }
+#endif
private:
+#if USE(IOSURFACE)
explicit ViewSnapshot(std::unique_ptr<WebCore::IOSurface>);
std::unique_ptr<WebCore::IOSurface> m_surface;
+#else
+ explicit ViewSnapshot(uint32_t slotID, WebCore::IntSize, size_t imageSizeInBytes);
+ uint32_t m_slotID;
+ size_t m_imageSizeInBytes;
+ WebCore::IntSize m_size;
+#endif
+
uint64_t m_renderTreeSize;
float m_deviceScaleFactor;
WebCore::Color m_backgroundColor;
@@ -100,6 +116,10 @@
void discardSnapshotImages();
+#if !USE(IOSURFACE)
+ static CAContext *snapshottingContext();
+#endif
+
private:
void didAddImageToSnapshot(ViewSnapshot&);
void willRemoveImageFromSnapshot(ViewSnapshot&);
Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm (192417 => 192418)
--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm 2015-11-13 17:02:40 UTC (rev 192417)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm 2015-11-13 17:02:44 UTC (rev 192418)
@@ -61,6 +61,24 @@
return store;
}
+#if !USE(IOSURFACE)
+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 +131,27 @@
m_snapshotsWithImages.first()->clearImage();
}
+#if USE(IOSURFACE)
Ref<ViewSnapshot> ViewSnapshot::create(std::unique_ptr<IOSurface> surface)
{
return adoptRef(*new ViewSnapshot(WTF::move(surface)));
}
+#else
+Ref<ViewSnapshot> ViewSnapshot::create(uint32_t slotID, IntSize size, size_t imageSizeInBytes)
+{
+ return adoptRef(*new ViewSnapshot(slotID, size, imageSizeInBytes));
+}
+#endif
+#if USE(IOSURFACE)
ViewSnapshot::ViewSnapshot(std::unique_ptr<IOSurface> surface)
: m_surface(WTF::move(surface))
+#else
+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,6 +162,7 @@
clearImage();
}
+#if USE(IOSURFACE)
void ViewSnapshot::setSurface(std::unique_ptr<WebCore::IOSurface> surface)
{
ASSERT(!m_surface);
@@ -141,10 +174,15 @@
m_surface = WTF::move(surface);
ViewSnapshotStore::singleton().didAddImageToSnapshot(*this);
}
+#endif
bool ViewSnapshot::hasImage() const
{
+#if USE(IOSURFACE)
return !!m_surface;
+#else
+ return m_slotID;
+#endif
}
void ViewSnapshot::clearImage()
@@ -154,11 +192,18 @@
ViewSnapshotStore::singleton().willRemoveImageFromSnapshot(*this);
+#if USE(IOSURFACE)
m_surface = nullptr;
+#else
+ [ViewSnapshotStore::snapshottingContext() deleteSlot:m_slotID];
+ m_slotID = 0;
+ m_imageSizeInBytes = 0;
+#endif
}
id ViewSnapshot::asLayerContents()
{
+#if USE(IOSURFACE)
if (!m_surface)
return nullptr;
@@ -168,6 +213,9 @@
}
return (id)m_surface->surface();
+#else
+ return [CAContext objectForSlot:m_slotID];
+#endif
}
} // namespace WebKit