Changeset 165748 in webkit
- Timestamp:
- Mar 17, 2014, 1:04:47 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 17 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/WebCore.exp.in (modified) (1 diff)
-
WebKit2/ChangeLog (modified) (1 diff)
-
WebKit2/UIProcess/API/Cocoa/WKThumbnailView.h (modified) (1 diff)
-
WebKit2/UIProcess/API/Cocoa/WKThumbnailView.mm (modified) (5 diffs)
-
WebKit2/UIProcess/API/Cocoa/WKThumbnailViewInternal.h (modified) (1 diff)
-
WebKit2/UIProcess/API/mac/WKView.mm (modified) (5 diffs)
-
WebKit2/UIProcess/API/mac/WKViewInternal.h (modified) (1 diff)
-
WebKit2/UIProcess/WebPageProxy.cpp (modified) (1 diff)
-
WebKit2/UIProcess/WebPageProxy.h (modified) (1 diff)
-
WebKit2/WebProcess/WebPage/DrawingArea.cpp (modified) (3 diffs)
-
WebKit2/WebProcess/WebPage/DrawingArea.h (modified) (1 diff)
-
WebKit2/WebProcess/WebPage/WebPage.cpp (modified) (3 diffs)
-
WebKit2/WebProcess/WebPage/WebPage.h (modified) (1 diff)
-
WebKit2/WebProcess/WebPage/WebPage.messages.in (modified) (1 diff)
-
WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (modified) (1 diff)
-
WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r165742 r165748 1 2014-03-17 Tim Horton <timothy_horton@apple.com> 2 3 WKThumbnailView should support snapshots 4 https://bugs.webkit.org/show_bug.cgi?id=130335 5 <rdar://problem/16255139> 6 7 Reviewed by Simon Fraser. 8 9 * WebCore.exp.in: 10 1 11 2014-01-29 Sergio Villar Senin <svillar@igalia.com> 2 12 -
trunk/Source/WebCore/WebCore.exp.in
r165653 r165748 1731 1731 __ZNK7WebCore20ResourceResponseBase6isHTTPEv 1732 1732 __ZNK7WebCore20ResourceResponseBase8mimeTypeEv 1733 __ZNK7WebCore20TransformationMatrix7inverseEv 1734 __ZNK7WebCore20TransformationMatrix7mapRectERKNS_7IntRectE 1733 1735 __ZNK7WebCore20TransformationMatrixcv13CATransform3DEv 1734 1736 __ZNK7WebCore21BackForwardController12forwardCountEv -
trunk/Source/WebKit2/ChangeLog
r165746 r165748 1 2014-03-17 Tim Horton <timothy_horton@apple.com> 2 3 WKThumbnailView should support snapshots 4 https://bugs.webkit.org/show_bug.cgi?id=130335 5 <rdar://problem/16255139> 6 7 Reviewed by Simon Fraser. 8 9 Add a mode where WKThumbnailView takes a software snapshot of the web content, 10 replacing the live layer tree with said snapshot once it returns from the 11 web process. This may improve animation performance in cases where the 12 layer tree would otherwise be very complex. 13 14 * UIProcess/API/Cocoa/WKThumbnailView.h: 15 Add a property, usesSnapshot, which determines whether the thumbnail view 16 should use the live layer tree or a snapshot of the content. 17 18 * UIProcess/API/Cocoa/WKThumbnailView.mm: 19 (-[WKThumbnailView initWithFrame:fromWKView:]): 20 (-[WKThumbnailView _viewWasUnparented]): 21 Clear the snapshot when unparented. 22 23 (-[WKThumbnailView _viewWasParented]): 24 Take a snapshot of the web content when parented, if needed. 25 26 (-[WKThumbnailView _requestSnapshotIfNeeded]): 27 If we're using snapshots, and haven't already dispatched an async snapshot request, 28 and don't already have a snapshot, request a snapshot from the web process. 29 30 When it returns, use it as the contents of the WKThumbnailView layer, and 31 unparent the live layer tree. 32 33 (-[WKThumbnailView setScale:]): 34 (-[WKThumbnailView setUsesSnapshot:]): 35 (-[WKThumbnailView _setThumbnailLayer:]): 36 (-[WKThumbnailView _thumbnailLayer]): 37 * UIProcess/API/Cocoa/WKThumbnailViewInternal.h: 38 39 * UIProcess/API/mac/WKView.mm: 40 (-[WKView _setAcceleratedCompositingModeRootLayer:]): 41 (-[WKView _acceleratedCompositingModeRootLayer]): 42 WKView should always keep track of the current root layer, instead of totally 43 handing control over to WKThumbnailView when it is used. 44 45 (-[WKView _setThumbnailView:]): 46 (-[WKView _updateThumbnailViewLayer]): 47 (-[WKView _reparentLayerTreeInThumbnailView]): 48 If needed (either we're not using snapshots, or still waiting for the snapshot to be painted), 49 push the WKView's live layer tree into the thumbnail view. 50 51 * UIProcess/API/mac/WKViewInternal.h: 52 * UIProcess/WebPageProxy.cpp: 53 (WebKit::WebPageProxy::internalShowContextMenu): 54 * UIProcess/WebPageProxy.h: 55 * WebProcess/WebPage/WebPage.h: 56 * WebProcess/WebPage/WebPage.messages.in: 57 * WebProcess/WebPage/WebPage.cpp: 58 (WebKit::WebPage::takeThumbnailSnapshot): 59 Add a message that asynchronously returns a snapshot that respects the 60 current thumbnail scale and position. 61 62 (WebKit::WebPage::scaledSnapshotWithOptions): 63 Use some nullptr. 64 65 * WebProcess/WebPage/DrawingArea.cpp: 66 (WebKit::DrawingArea::transform): 67 * WebProcess/WebPage/DrawingArea.h: 68 * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h: 69 Add a getter for the DrawingArea's transform. 70 Rename it to rootLayerTransform. 71 1 72 2014-03-17 Zan Dobersek <zdobersek@igalia.com> 2 73 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKThumbnailView.h
r164776 r165748 40 40 41 41 @property (nonatomic) CGFloat scale; 42 @property (nonatomic) BOOL usesSnapshot; 42 43 43 44 @end -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKThumbnailView.mm
r164776 r165748 55 55 } 56 56 57 @synthesize _waitingForSnapshot = _waitingForSnapshot; 58 57 59 - (instancetype)initWithFrame:(NSRect)frame fromWKView:(WKView *)wkView 58 60 { … … 77 79 78 80 [_wkView _setThumbnailView:nil]; 81 82 self.layer.contents = nil; 83 79 84 _webPageProxy->setMayStartMediaWhenInWindow(_originalMayStartMediaWhenInWindow); 80 85 } … … 91 96 _webPageProxy->setMayStartMediaWhenInWindow(false); 92 97 98 [self _requestSnapshotIfNeeded]; 93 99 [_wkView _setThumbnailView:self]; 100 } 101 102 - (void)_requestSnapshotIfNeeded 103 { 104 if (!_usesSnapshot || _waitingForSnapshot || self.layer.contents) 105 return; 106 107 _waitingForSnapshot = YES; 108 109 RetainPtr<WKThumbnailView> thumbnailView = self; 110 _webPageProxy->takeThumbnailSnapshot([thumbnailView](bool, const ShareableBitmap::Handle& imageHandle) { 111 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(imageHandle, SharedMemory::ReadOnly); 112 RetainPtr<CGImageRef> cgImage = bitmap->makeCGImage(); 113 [thumbnailView _didTakeSnapshot:cgImage.get()]; 114 }); 115 } 116 117 - (void)_didTakeSnapshot:(CGImageRef)image 118 { 119 _waitingForSnapshot = NO; 120 self.layer.sublayers = @[]; 121 self.layer.contents = (id)image; 94 122 } 95 123 … … 104 132 - (void)setScale:(CGFloat)scale 105 133 { 134 if (_scale == scale) 135 return; 136 106 137 _scale = scale; 107 138 … … 110 141 } 111 142 112 - (void)setThumbnailLayer:(CALayer *)layer 143 - (void)setUsesSnapshot:(BOOL)usesSnapshot 144 { 145 if (_usesSnapshot == usesSnapshot) 146 return; 147 148 _usesSnapshot = usesSnapshot; 149 150 if (!self.window) 151 return; 152 153 if (usesSnapshot) 154 [self _requestSnapshotIfNeeded]; 155 else 156 [_wkView _reparentLayerTreeInThumbnailView]; 157 } 158 159 - (void)_setThumbnailLayer:(CALayer *)layer 113 160 { 114 161 self.layer.sublayers = layer ? @[ layer ] : @[ ]; 115 162 } 116 163 117 - (CALayer *) thumbnailLayer164 - (CALayer *)_thumbnailLayer 118 165 { 119 166 if (!self.layer.sublayers.count) -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKThumbnailViewInternal.h
r164776 r165748 32 32 @interface WKThumbnailView () 33 33 34 @property (nonatomic, assign) CALayer *thumbnailLayer; 34 @property (nonatomic, assign, setter = _setThumbnailLayer:) CALayer *_thumbnailLayer; 35 @property (nonatomic, assign, setter = _setWaitingForSnapshot:) BOOL _waitingForSnapshot; 35 36 36 37 @end -
trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm
r165477 r165748 225 225 BOOL _allowsMagnification; 226 226 BOOL _allowsBackForwardNavigationGestures; 227 228 RetainPtr<CALayer> _rootLayer; 227 229 228 230 #if WK_API_ENABLED … … 2499 2501 [rootLayer web_disableAllActions]; 2500 2502 2503 _data->_rootLayer = rootLayer; 2504 2501 2505 #if WK_API_ENABLED 2502 2506 if (_data->_thumbnailView) { 2503 _data->_thumbnailView.thumbnailLayer = rootLayer;2507 [self _updateThumbnailViewLayer]; 2504 2508 return; 2505 2509 } … … 2545 2549 - (CALayer *)_acceleratedCompositingModeRootLayer 2546 2550 { 2547 NSView *hostView = _data->_layerHostingView.get(); 2548 2549 if (!hostView) 2550 return nullptr; 2551 2552 if (!hostView.layer.sublayers.count) 2553 return nullptr; 2554 2555 return [hostView.layer.sublayers objectAtIndex:0]; 2551 return _data->_rootLayer.get(); 2556 2552 } 2557 2553 … … 2975 2971 ASSERT(!_data->_thumbnailView || !thumbnailView); 2976 2972 2977 RetainPtr<CALayer> thumbnailLayer = _data->_thumbnailView.thumbnailLayer;2978 2979 2973 _data->_thumbnailView = thumbnailView; 2980 2974 2981 2975 if (thumbnailView) 2982 thumbnailView.thumbnailLayer = [self _acceleratedCompositingModeRootLayer];2976 [self _updateThumbnailViewLayer]; 2983 2977 else 2984 [self _setAcceleratedCompositingModeRootLayer: thumbnailLayer.get()];2978 [self _setAcceleratedCompositingModeRootLayer:_data->_rootLayer.get()]; 2985 2979 2986 2980 _data->_page->viewStateDidChange(ViewState::WindowIsActive | ViewState::IsInWindow | ViewState::IsVisible); … … 2990 2984 { 2991 2985 return _data->_thumbnailView; 2986 } 2987 2988 - (void)_updateThumbnailViewLayer 2989 { 2990 WKThumbnailView *thumbnailView = _data->_thumbnailView; 2991 ASSERT(thumbnailView); 2992 2993 if (!thumbnailView.usesSnapshot || thumbnailView._waitingForSnapshot) 2994 [self _reparentLayerTreeInThumbnailView]; 2995 } 2996 2997 - (void)_reparentLayerTreeInThumbnailView 2998 { 2999 _data->_thumbnailView._thumbnailLayer = _data->_rootLayer.get(); 2992 3000 } 2993 3001 #endif // WK_API_ENABLED -
trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
r164341 r165748 110 110 #if WK_API_ENABLED 111 111 @property (nonatomic, setter=_setThumbnailView:) WKThumbnailView *_thumbnailView; 112 - (void)_reparentLayerTreeInThumbnailView; 112 113 #endif 113 114 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r165692 r165748 4568 4568 } 4569 4569 4570 void WebPageProxy::takeThumbnailSnapshot(ImageCallback::CallbackFunction callbackFunction) 4571 { 4572 if (!isValid()) 4573 return; 4574 4575 RefPtr<ImageCallback> callback = ImageCallback::create(callbackFunction); 4576 4577 uint64_t callbackID = callback->callbackID(); 4578 m_imageCallbacks.set(callbackID, callback.get()); 4579 4580 m_process->send(Messages::WebPage::TakeThumbnailSnapshot(callbackID), m_pageID); 4581 } 4582 4570 4583 } // namespace WebKit -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r165577 r165748 918 918 void setThumbnailScale(double); 919 919 920 void takeThumbnailSnapshot(ImageCallback::CallbackFunction); 921 920 922 private: 921 923 WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, const WebPageConfiguration&); -
trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp
r164192 r165748 26 26 #include "config.h" 27 27 #include "DrawingArea.h" 28 #include <WebCore/TransformationMatrix.h> 28 29 #include <wtf/Functional.h> 29 30 … … 41 42 42 43 #include "WebPageCreationParameters.h" 44 45 using namespace WebCore; 43 46 44 47 namespace WebKit { … … 84 87 } 85 88 89 TransformationMatrix DrawingArea::rootLayerTransform() const 90 { 91 return TransformationMatrix(); 92 } 93 86 94 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h
r165235 r165748 108 108 virtual void scheduleCompositingLayerFlush() = 0; 109 109 110 virtual void setTransform(const WebCore::TransformationMatrix&) { } 110 virtual WebCore::TransformationMatrix rootLayerTransform() const; 111 virtual void setRootLayerTransform(const WebCore::TransformationMatrix&) { } 111 112 112 113 #if USE(COORDINATED_GRAPHICS) -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r165746 r165748 1514 1514 #endif // !PLATFORM(IOS) 1515 1515 1516 void WebPage::takeThumbnailSnapshot(uint64_t callbackID) 1517 { 1518 IntRect snapshotRect(IntPoint(), m_viewSize); 1519 snapshotRect = m_drawingArea->rootLayerTransform().inverse().mapRect(snapshotRect); 1520 1521 RefPtr<WebImage> image = scaledSnapshotWithOptions(snapshotRect, 1, SnapshotOptionsShareable | SnapshotOptionsInViewCoordinates); 1522 1523 ShareableBitmap::Handle handle; 1524 if (image) 1525 image->bitmap()->createHandle(handle, SharedMemory::ReadOnly); 1526 1527 send(Messages::WebPageProxy::ImageCallback(handle, callbackID)); 1528 } 1529 1516 1530 PassRefPtr<WebImage> WebPage::scaledSnapshotWithOptions(const IntRect& rect, double scaleFactor, SnapshotOptions options) 1517 1531 { 1518 1532 Frame* coreFrame = m_mainFrame->coreFrame(); 1519 1533 if (!coreFrame) 1520 return 0;1534 return nullptr; 1521 1535 1522 1536 FrameView* frameView = coreFrame->view(); 1523 1537 if (!frameView) 1524 return 0;1538 return nullptr; 1525 1539 1526 1540 IntSize bitmapSize = rect.size(); … … 1530 1544 RefPtr<WebImage> snapshot = WebImage::create(bitmapSize, snapshotOptionsToImageOptions(options)); 1531 1545 if (!snapshot->bitmap()) 1532 return 0;1546 return nullptr; 1533 1547 1534 1548 auto graphicsContext = snapshot->bitmap()->createGraphicsContext(); … … 4308 4322 transform.scale(inverseScale); 4309 4323 4310 drawingArea()->set Transform(transform);4324 drawingArea()->setRootLayerTransform(transform); 4311 4325 } 4312 4326 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r165577 r165748 847 847 void runJavaScriptInMainFrame(const String&, uint64_t callbackID); 848 848 void forceRepaint(uint64_t callbackID); 849 void takeThumbnailSnapshot(uint64_t callbackID); 849 850 850 851 void preferencesDidChange(const WebPreferencesStore&); -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r165303 r165748 337 337 338 338 GetBytecodeProfile(uint64_t callbackID) 339 340 TakeThumbnailSnapshot(uint64_t callbackID) 339 341 340 342 } -
trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h
r165235 r165748 113 113 void applyTransientZoomToPage(double scale, WebCore::FloatPoint origin); 114 114 115 virtual void setTransform(const WebCore::TransformationMatrix&) override; 115 virtual WebCore::TransformationMatrix rootLayerTransform() const override { return m_transform; } 116 virtual void setRootLayerTransform(const WebCore::TransformationMatrix&) override; 116 117 117 118 void updateLayerHostingContext(); -
trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm
r165404 r165748 827 827 } 828 828 829 void TiledCoreAnimationDrawingArea::set Transform(const TransformationMatrix& transform)829 void TiledCoreAnimationDrawingArea::setRootLayerTransform(const TransformationMatrix& transform) 830 830 { 831 831 m_transform = transform;
Note:
See TracChangeset
for help on using the changeset viewer.