[iOS WebKit2] Swipe snapshots should be taken asynchronously
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 May 2014 07:37:35 +0000 (07:37 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 May 2014 07:37:35 +0000 (07:37 +0000)
commitc87e3310ad0b15455dce5d8ba2278f175ba56cc7
tree91ea91ded12cb4c20c373883609675e1682b7013
parent494e50845efecc29165304dabf8580425b384e7e
[iOS WebKit2] Swipe snapshots should be taken asynchronously
https://bugs.webkit.org/show_bug.cgi?id=132417
<rdar://problem/16535921>

Reviewed by Anders Carlsson.

Reorganize takeViewSnapshot to return a ViewSnaphot with the image
filled in (the other properties are filled in by ViewSnapshotStore).

Make ViewSnapshotStore use a fixed size instead of count for the snapshot cache.
iOS doesn't use purgeable snapshots, so make the cache much smaller there.

Use CARenderServerCaptureLayerWithTransform to achieve async snapshotting.

Rename WebKit::ViewSnapshotStore::Snapshot to WebKit::ViewSnapshot so that
it can be forward-declared in a bunch of places.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _takeViewSnapshot:]):
Use CARenderServerCaptureLayerWithTransform.

* UIProcess/API/Cocoa/WKWebViewInternal.h:
* UIProcess/API/mac/WKView.mm:
(createIOSurfaceFromImage):
(-[WKView _takeViewSnapshot:]):
Adjust to the new push model.

* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::takeViewSnapshot):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::takeViewSnapshot):
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::takeViewSnapshot):
Plumbing.

* UIProcess/ios/ViewGestureControllerIOS.mm:
(WebKit::ViewGestureController::beginSwipeGesture):
(WebKit::ViewGestureController::endSwipeGesture):
Realize an object that can be used as the layer contents from the slot ID.

* UIProcess/ios/WebMemoryPressureHandlerIOS.cpp:
(WebKit::WebMemoryPressureHandler::sharedHandler):
(WebKit::WebMemoryPressureHandler::WebMemoryPressureHandler):
* UIProcess/WebMemoryPressureHandlerIOS.h:
Add a memory pressure handler for the UI process. This does not use
WebCore's platform independent memory pressure handler because that
mechanism only allows for one handler per process, and we don't want to
stomp on any handlers installed by WebKit1 in a process where the WebKits coexist.

* UIProcess/ios/WKContentView.h:
* UIProcess/ios/WKContentView.mm:
(-[WKContentView _takeViewSnapshot]): Deleted.
Get rid of an unnecessary bounce through WKContentView.

* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::retrieveSnapshotForItem):
(WebKit::ViewGestureController::endSwipeGesture):
Use the new name, ViewSnapshot.

* UIProcess/mac/ViewSnapshotStore.h:
(WebKit::ViewSnapshot::ViewSnapshot):
* UIProcess/mac/ViewSnapshotStore.mm:
(WebKit::ViewSnapshotStore::ViewSnapshotStore):
(WebKit::ViewSnapshotStore::~ViewSnapshotStore):
(WebKit::ViewSnapshotStore::snapshottingContext):
Use a custom CAContext for snapshotting so that snapshots don't
disappear when the main context is destroyed on hibernation.

(WebKit::ViewSnapshotStore::removeSnapshotImage):
(WebKit::ViewSnapshotStore::pruneSnapshots):
(WebKit::ViewSnapshotStore::recordSnapshot):
(WebKit::ViewSnapshotStore::getSnapshot):
(WebKit::ViewSnapshotStore::discardSnapshots):
(WebKit::ViewSnapshot::clearImage):
(WebKit::ViewSnapshot::hasImage):
(WebKit::createIOSurfaceFromImage): Deleted.
(WebKit::ViewSnapshotStore::Snapshot::clearImage): Deleted.
(WebKit::ViewSnapshotStore::Snapshot::hasImage): Deleted.
Cache by image size instead of counts.

* WebKit2.xcodeproj/project.pbxproj:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168260 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm
Source/WebKit2/UIProcess/ios/WKContentView.h
Source/WebKit2/UIProcess/ios/WKContentView.mm
Source/WebKit2/UIProcess/ios/WebMemoryPressureHandlerIOS.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/ios/WebMemoryPressureHandlerIOS.h [new file with mode: 0644]
Source/WebKit2/UIProcess/mac/PageClientImpl.h
Source/WebKit2/UIProcess/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm
Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h
Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm
Source/WebKit2/UIProcess/mac/WebContextMac.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj