Changeset 40543 in webkit
- Timestamp:
- Feb 3, 2009 12:14:37 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r40542 r40543 1 2009-02-03 Simon Fraser <simon.fraser@apple.com> 2 3 Reviewed by Dave Hyatt 4 5 https://bugs.webkit.org/show_bug.cgi?id=23365 6 7 Hook up accelerated compositing layers the native 8 view system on Mac. 9 10 * WebCore.base.exp: 11 Export new Page methods. 12 13 * page/ChromeClient.h: 14 (WebCore::ChromeClient::attachRootGraphicsLayer): 15 (WebCore::ChromeClient::setNeedsOneShotDrawingSynchronization): 16 New methods for attaching/detaching the root GraphicsLayer, and 17 synchronizing layer changes with window drawing. 18 19 * page/FrameView.h: 20 * page/FrameView.cpp: 21 (WebCore::FrameView::updateCompositingLayers): 22 (WebCore::FrameView::setNeedsOneShotDrawingSynchronization): 23 (WebCore::FrameView::didMoveOnscreen): 24 (WebCore::FrameView::willMoveOffscreen): 25 New methods to update the compositing layer hierarchy, 26 and pass-throughs to the RenderLayerCompositor. 27 28 (WebCore::FrameView::layout): 29 Update compositing layers after layout() and updateLayerPositions(). 30 31 * page/Page.cpp: 32 (WebCore::Page::didMoveOnscreen): 33 (WebCore::Page::willMoveOffscreen): 34 * page/Page.h: 35 New methods to allow the native view system to tell the Page when it 36 starts to be presented on-screen, and when it will be hidden. 37 38 * rendering/RenderLayerCompositor.h: 39 * rendering/RenderLayerCompositor.cpp: 40 (WebCore::RenderLayerCompositor::updateLayerCompositingState): 41 (WebCore::RenderLayerCompositor::didMoveOnscreen): 42 (WebCore::RenderLayerCompositor::willMoveOffscreen): 43 (WebCore::RenderLayerCompositor::ensureRootPlatformLayer): 44 Rename 'attached' methods to 'moveOnscreen/moveOffscreen' to match 45 the calls through from Page, FrameView. 46 47 (WebCore::RenderLayerCompositor::layerWillBeRemoved): 48 Dont' try to repaint or update layers if the document is being torn 49 down. 50 51 * rendering/RenderView.cpp: 52 (WebCore::RenderView::didMoveOnscreen): 53 (WebCore::RenderView::willMoveOffscreen): 54 * rendering/RenderView.h: 55 New methods. 56 1 57 2009-02-03 Dirk Schulze <krit@webkit.org> 2 58 -
trunk/WebCore/WebCore.base.exp
r40514 r40543 814 814 __ZNK7WebCore4Page10pluginDataEv 815 815 __ZNK7WebCore4Page34inLowQualityImageInterpolationModeEv 816 __ZN7WebCore4Page17willMoveOffscreenEv 817 __ZN7WebCore4Page15didMoveOnscreenEv 816 818 __ZNK7WebCore4Page9groupNameEv 817 819 __ZNK7WebCore5Frame11currentFormEv -
trunk/WebCore/page/ChromeClient.h
r39717 r40543 52 52 struct FrameLoadRequest; 53 53 struct WindowFeatures; 54 55 #if USE(ACCELERATED_COMPOSITING) 56 class GraphicsLayer; 57 #endif 54 58 55 59 class ChromeClient { … … 155 159 virtual void formStateDidChange(const Node*) = 0; 156 160 161 #if USE(ACCELERATED_COMPOSITING) 162 // Pass 0 as the GraphicsLayer to detatch the root layer. 163 virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) { } 164 // Sets a flag to specify that the next time content is drawn to the window, 165 // the changes appear on the screen in synchrony with updates to GraphicsLayers. 166 virtual void setNeedsOneShotDrawingSynchronization() { } 167 #endif 168 157 169 #if PLATFORM(MAC) 158 170 virtual KeyboardUIMode keyboardUIMode() { return KeyboardAccessDefault; } -
trunk/WebCore/page/FrameView.cpp
r40473 r40543 51 51 #include "Settings.h" 52 52 #include <wtf/CurrentTime.h> 53 54 #if USE(ACCELERATED_COMPOSITING) 55 #include "RenderLayerCompositor.h" 56 #endif 53 57 54 58 namespace WebCore { … … 364 368 } 365 369 370 #if USE(ACCELERATED_COMPOSITING) 371 void FrameView::updateCompositingLayers(CompositingUpdate updateType) 372 { 373 RenderView* view = m_frame->contentRenderer(); 374 if (!view || !view->usesCompositing()) 375 return; 376 377 if (updateType == ForcedUpdate) 378 view->compositor()->setCompositingLayersNeedUpdate(); 379 380 view->compositor()->updateCompositingLayers(); 381 } 382 383 void FrameView::setNeedsOneShotDrawingSynchronization() 384 { 385 Page* page = frame() ? frame()->page() : 0; 386 if (page) 387 page->chrome()->client()->setNeedsOneShotDrawingSynchronization(); 388 } 389 #endif // USE(ACCELERATED_COMPOSITING) 390 391 void FrameView::didMoveOnscreen() 392 { 393 RenderView* view = m_frame->contentRenderer(); 394 if (view) 395 view->didMoveOnscreen(); 396 } 397 398 void FrameView::willMoveOffscreen() 399 { 400 RenderView* view = m_frame->contentRenderer(); 401 if (view) 402 view->willMoveOffscreen(); 403 } 404 366 405 RenderObject* FrameView::layoutRoot(bool onlyDuringLayout) const 367 406 { … … 538 577 layer->updateLayerPositions(m_doFullRepaint); 539 578 endDeferredRepaints(); 579 580 #if USE(ACCELERATED_COMPOSITING) 581 updateCompositingLayers(); 582 #endif 540 583 541 584 m_layoutCount++; -
trunk/WebCore/page/FrameView.h
r40473 r40543 98 98 bool needsFullRepaint() const { return m_doFullRepaint; } 99 99 100 #if USE(ACCELERATED_COMPOSITING) 101 enum CompositingUpdate { NormalCompositingUpdate, ForcedCompositingUpdate }; 102 void updateCompositingLayers(CompositingUpdate updateType = NormalCompositingUpdate); 103 104 // Called when changes to the GraphicsLayer hierarchy have to be synchronized with 105 // content rendered via the normal painting path. 106 void setNeedsOneShotDrawingSynchronization(); 107 #endif 108 109 void didMoveOnscreen(); 110 void willMoveOffscreen(); 111 100 112 void resetScrollbars(); 101 113 -
trunk/WebCore/page/Page.cpp
r39969 r40543 410 410 } 411 411 412 void Page::didMoveOnscreen() 413 { 414 for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) { 415 if (frame->view()) 416 frame->view()->didMoveOnscreen(); 417 } 418 } 419 420 void Page::willMoveOffscreen() 421 { 422 for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) { 423 if (frame->view()) 424 frame->view()->willMoveOffscreen(); 425 } 426 } 427 412 428 void Page::userStyleSheetLocationChanged() 413 429 { -
trunk/WebCore/page/Page.h
r39818 r40543 154 154 void setMediaVolume(float volume); 155 155 156 // Notifications when the Page starts and stops being presented via a native window. 157 void didMoveOnscreen(); 158 void willMoveOffscreen(); 159 156 160 void userStyleSheetLocationChanged(); 157 161 const String& userStyleSheet() const; -
trunk/WebCore/rendering/RenderLayerCompositor.cpp
r40434 r40543 180 180 // and a GraphicsLayer, so we need to make sure the window system 181 181 // synchronizes those changes on the screen. 182 m_renderView->frameView()->setNeeds SynchronizedGraphicsFlush();182 m_renderView->frameView()->setNeedsOneShotDrawingSynchronization(); 183 183 } 184 184 … … 268 268 setCompositingParent(child, 0); 269 269 270 // If the document is being torn down (document's renderer() is null), then there's 271 // no need to do any layer updating. 272 if (parent->renderer()->documentBeingDestroyed()) 273 return; 274 270 275 RenderLayer* compLayer = enclosingCompositingLayer(parent, false); 271 276 if (compLayer) { … … 274 279 // The contents of this layer may be moving from a GraphicsLayer to the window, 275 280 // so we need to make sure the window system synchronizes those changes on the screen. 276 m_renderView->frameView()->setNeeds SynchronizedGraphicsFlush();281 m_renderView->frameView()->setNeedsOneShotDrawingSynchronization(); 277 282 } 278 283 … … 586 591 } 587 592 588 void RenderLayerCompositor:: willBeDetached()589 { 590 if (!m_rootPlatformLayer ||! m_rootLayerAttached)593 void RenderLayerCompositor::didMoveOnscreen() 594 { 595 if (!m_rootPlatformLayer) 591 596 return; 592 597 … … 596 601 return; 597 602 598 page->chrome()->client()->attachRootGraphicsLayer(frame, 0);599 m_rootLayerAttached = false;600 } 601 602 void RenderLayerCompositor::w asAttached()603 { 604 if (!m_rootPlatformLayer )603 page->chrome()->client()->attachRootGraphicsLayer(frame, m_rootPlatformLayer); 604 m_rootLayerAttached = true; 605 } 606 607 void RenderLayerCompositor::willMoveOffscreen() 608 { 609 if (!m_rootPlatformLayer || !m_rootLayerAttached) 605 610 return; 606 611 … … 610 615 return; 611 616 612 page->chrome()->client()->attachRootGraphicsLayer(frame, m_rootPlatformLayer);613 m_rootLayerAttached = true;617 page->chrome()->client()->attachRootGraphicsLayer(frame, 0); 618 m_rootLayerAttached = false; 614 619 } 615 620 … … 743 748 m_rootPlatformLayer->setMasksToBounds(true); 744 749 745 wasAttached();750 didMoveOnscreen(); 746 751 } 747 752 -
trunk/WebCore/rendering/RenderLayerCompositor.h
r40434 r40543 84 84 GraphicsLayer* rootPlatformLayer() const; 85 85 86 void willBeDetached(); 87 void wasAttached(); 86 void didMoveOnscreen(); 87 void willMoveOffscreen(); 88 88 89 void updateRootLayerPosition(); 89 90 -
trunk/WebCore/rendering/RenderView.cpp
r40312 r40543 627 627 } 628 628 629 void RenderView::didMoveOnscreen() 630 { 631 // FIXME: will call into RenderLayerCompositor 632 } 633 634 void RenderView::willMoveOffscreen() 635 { 636 // FIXME: will call into RenderLayerCompositor 637 } 638 629 639 } // namespace WebCore -
trunk/WebCore/rendering/RenderView.h
r40417 r40543 146 146 147 147 virtual void updateHitTestResult(HitTestResult&, const IntPoint&); 148 149 void didMoveOnscreen(); 150 void willMoveOffscreen(); 148 151 149 152 protected: -
trunk/WebKit/mac/ChangeLog
r40514 r40543 1 2009-02-03 Simon Fraser <simon.fraser@apple.com> 2 3 Reviewed by Dave Hyatt 4 5 https://bugs.webkit.org/show_bug.cgi?id=23365 6 7 Hook up accelerated compositing layers the native 8 view system on Mac. 9 10 * WebCoreSupport/WebChromeClient.h: 11 * WebCoreSupport/WebChromeClient.mm: 12 (WebChromeClient::attachRootGraphicsLayer): 13 (WebChromeClient::setNeedsOneShotDrawingSynchronization): 14 New methods to hook up the root GraphicsLayer to the native 15 view system, and to synchronize layer changes with view-based 16 drawing when layers come and go. 17 18 * WebView/WebHTMLView.mm: 19 (-[WebHTMLViewPrivate clear]): 20 Clear the pointer to layerHostingView. 21 22 (-[WebHTMLView _setAsideSubviews]): 23 (-[WebHTMLView willRemoveSubview:]): 24 Keep the special layer-hosting view in the subviews even 25 when the rest of the subviews are ripped out for 26 painting. 27 28 (-[WebHTMLView _isUsingAcceleratedCompositing]): 29 New utility method for DumpRenderTree to know if we're 30 hosting layers. 31 32 (-[WebHTMLView drawRect:]): 33 Call -disableScreenUpdatesUntilFlush if we have to 34 synchronize layer changes with painting. 35 36 (-[WebHTMLView attachRootLayer:]): 37 (-[WebHTMLView detachRootLayer]): 38 Attach and detach the root GraphicsLayer. 39 40 * WebView/WebViewInternal.h: 41 * WebView/WebHTMLViewInternal.h: 42 * WebView/WebHTMLViewPrivate.h: 43 New method declarations. 44 45 * WebView/WebView.mm: 46 (-[WebView _needsOneShotDrawingSynchronization]): 47 (-[WebView _setNeedsOneShotDrawingSynchronization:]): 48 Set the flag to say if we need to synchronize layer 49 changes and painting on the next -drawRect: call. 50 51 (-[WebView viewWillMoveToWindow:]): 52 (-[WebView viewDidMoveToWindow]): 53 Call new notifications that the view was added to or removed from 54 the window, which are required by the layer hosting mechanism. 55 1 56 2009-02-02 Geoffrey Garen <ggaren@apple.com> 2 57 -
trunk/WebKit/mac/WebCoreSupport/WebChromeClient.h
r39717 r40543 136 136 virtual void formStateDidChange(const WebCore::Node*) { } 137 137 138 #if USE(ACCELERATED_COMPOSITING) 139 virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*); 140 virtual void setNeedsOneShotDrawingSynchronization(); 141 #endif 142 138 143 private: 139 144 WebView *m_webView; -
trunk/WebKit/mac/WebCoreSupport/WebChromeClient.mm
r39717 r40543 61 61 #import <wtf/PassRefPtr.h> 62 62 #import <wtf/Vector.h> 63 64 #if USE(ACCELERATED_COMPOSITING) 65 #import <WebCore/GraphicsLayer.h> 66 #endif 63 67 64 68 @interface NSView (WebNSViewDetails) … … 644 648 } 645 649 650 #if USE(ACCELERATED_COMPOSITING) 651 void WebChromeClient::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer) 652 { 653 WebFrameView *frameView = [kit(frame) frameView]; 654 WebHTMLView *docView = (WebHTMLView *)[frameView documentView]; 655 if (graphicsLayer) 656 [docView attachRootLayer:graphicsLayer->nativeLayer()]; 657 else 658 [docView detachRootLayer]; 659 } 660 661 void WebChromeClient::setNeedsOneShotDrawingSynchronization() 662 { 663 [m_webView _setNeedsOneShotDrawingSynchronization:YES]; 664 } 665 #endif 666 646 667 @implementation WebOpenPanelResultListener 647 668 -
trunk/WebKit/mac/WebView/WebHTMLView.mm
r40498 r40543 114 114 #import <runtime/InitializeThreading.h> 115 115 116 #if USE(ACCELERATED_COMPOSITING) 117 #import <QuartzCore/QuartzCore.h> 118 #endif 119 116 120 using namespace WebCore; 117 121 using namespace HTMLNames; … … 381 385 id savedSubviews; 382 386 BOOL subviewsSetAside; 387 388 #if USE(ACCELERATED_COMPOSITING) 389 NSView *layerHostingView; 390 #endif 383 391 384 392 NSEvent *mouseDownEvent; // Kept after handling the event. … … 529 537 highlighters = nil; 530 538 promisedDragTIFFDataSource = 0; 539 540 #if USE(ACCELERATED_COMPOSITING) 541 layerHostingView = nil; 542 #endif 531 543 } 532 544 … … 1137 1149 ASSERT(_private->savedSubviews == nil); 1138 1150 _private->savedSubviews = _subviews; 1151 #if USE(ACCELERATED_COMPOSITING) 1152 // We need to keep the layer-hosting view in the subviews, otherwise the layers flash. 1153 if (_private->layerHostingView) { 1154 NSArray* newSubviews = [[NSArray alloc] initWithObjects:_private->layerHostingView, nil]; 1155 _subviews = newSubviews; 1156 } else 1157 _subviews = nil; 1158 #else 1139 1159 _subviews = nil; 1160 #endif 1140 1161 _private->subviewsSetAside = YES; 1141 1162 } … … 1144 1165 { 1145 1166 ASSERT(_private->subviewsSetAside); 1167 #if USE(ACCELERATED_COMPOSITING) 1168 if (_private->layerHostingView) { 1169 [_subviews release]; 1170 _subviews = _private->savedSubviews; 1171 } else { 1172 ASSERT(_subviews == nil); 1173 _subviews = _private->savedSubviews; 1174 } 1175 #else 1146 1176 ASSERT(_subviews == nil); 1147 1177 _subviews = _private->savedSubviews; 1178 #endif 1148 1179 _private->savedSubviews = nil; 1149 1180 _private->subviewsSetAside = NO; … … 1160 1191 - (void)willRemoveSubview:(NSView *)subview 1161 1192 { 1162 if (_private->enumeratingSubviews) 1193 // Have to null-check _private, since this can be called via -dealloc when 1194 // cleaning up the the layerHostingView. 1195 if (_private && _private->enumeratingSubviews) 1163 1196 LOG(View, "A view of class %s was removed during subview enumeration for layout or printing mode change. We will still do layout or the printing mode change even though this view is no longer in the view hierarchy.", object_getClassName([subview class])); 1164 1197 } … … 2071 2104 } 2072 2105 #endif 2106 2107 - (BOOL)_isUsingAcceleratedCompositing 2108 { 2109 #if USE(ACCELERATED_COMPOSITING) 2110 return _private->layerHostingView != nil; 2111 #else 2112 return NO; 2113 #endif 2114 } 2073 2115 2074 2116 @end … … 3022 3064 if (subviewsWereSetAside) 3023 3065 [self _setAsideSubviews]; 3066 3067 #if USE(ACCELERATED_COMPOSITING) 3068 if ([[self _webView] _needsOneShotDrawingSynchronization]) { 3069 // Disable screen updates so that drawing into the NSView and 3070 // CALayer updates appear on the screen at the same time. 3071 [[self window] disableScreenUpdatesUntilFlush]; 3072 [CATransaction flush]; 3073 [[self _webView] _setNeedsOneShotDrawingSynchronization:NO]; 3074 } 3075 #endif 3024 3076 } 3025 3077 … … 4974 5026 } 4975 5027 5028 #if USE(ACCELERATED_COMPOSITING) 5029 - (void)attachRootLayer:(CALayer*)layer 5030 { 5031 if (!_private->layerHostingView) { 5032 NSView* hostingView = [[NSView alloc] initWithFrame:[self bounds]]; 5033 [hostingView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; 5034 [self addSubview:hostingView]; 5035 [hostingView release]; 5036 // hostingView is owned by being a subview of self 5037 _private->layerHostingView = hostingView; 5038 } 5039 5040 // Make a container layer, which will get sized/positioned by AppKit and CA 5041 CALayer* viewLayer = [CALayer layer]; 5042 [_private->layerHostingView setLayer:viewLayer]; 5043 [_private->layerHostingView setWantsLayer:YES]; 5044 5045 // Parent our root layer in the container layer 5046 [viewLayer addSublayer:layer]; 5047 } 5048 5049 - (void)detachRootLayer 5050 { 5051 if (_private->layerHostingView) { 5052 [_private->layerHostingView setLayer:nil]; 5053 [_private->layerHostingView setWantsLayer:NO]; 5054 [_private->layerHostingView removeFromSuperview]; 5055 _private->layerHostingView = nil; 5056 } 5057 } 5058 #endif 5059 4976 5060 @end 4977 5061 -
trunk/WebKit/mac/WebView/WebHTMLViewInternal.h
r34608 r40543 59 59 - (void)_web_layoutIfNeededRecursive; 60 60 - (void)_destroyAllWebPlugins; 61 62 #if USE(ACCELERATED_COMPOSITING) 63 - (void)attachRootLayer:(CALayer*)layer; 64 - (void)detachRootLayer; 65 #endif 66 61 67 @end -
trunk/WebKit/mac/WebView/WebHTMLViewPrivate.h
r34608 r40543 120 120 // SPI for DumpRenderTree 121 121 - (void)_updateFocusedAndActiveState; 122 - (BOOL)_isUsingAcceleratedCompositing; 122 123 123 124 // SPI for printing (should be converted to API someday). When the WebHTMLView isn't being printed -
trunk/WebKit/mac/WebView/WebView.mm
r40449 r40543 407 407 // When this flag is set, we will not make any subviews underneath this WebView. This means no WebFrameViews and no WebHTMLViews. 408 408 BOOL useDocumentViews; 409 410 #if USE(ACCELERATED_COMPOSITING) 411 // When this flag is set, next time a WebHTMLView draws, it needs to temporarily disable screen updates 412 // so that the NSView drawing is visually synchronized with CALayer updates. 413 BOOL needsOneShotDrawingSynchronization; 414 #endif 409 415 } 410 416 @end … … 2070 2076 } 2071 2077 2078 #if USE(ACCELERATED_COMPOSITING) 2079 - (BOOL)_needsOneShotDrawingSynchronization 2080 { 2081 return _private->needsOneShotDrawingSynchronization; 2082 } 2083 2084 - (void)_setNeedsOneShotDrawingSynchronization:(BOOL)needsSynchronization 2085 { 2086 _private->needsOneShotDrawingSynchronization = needsSynchronization; 2087 } 2088 #endif 2089 2072 2090 @end 2073 2091 … … 2499 2517 [self removeWindowObservers]; 2500 2518 [self removeSizeObservers]; 2501 } 2519 } else 2520 _private->page->willMoveOffscreen(); 2502 2521 } 2503 2522 … … 2514 2533 [self addWindowObservers]; 2515 2534 [self addSizeObservers]; 2535 _private->page->didMoveOnscreen(); 2516 2536 } 2517 2537 } -
trunk/WebKit/mac/WebView/WebViewInternal.h
r39393 r40543 146 146 + (BOOL)_canHandleRequest:(NSURLRequest *)request forMainFrame:(BOOL)forMainFrame; 147 147 148 #if USE(ACCELERATED_COMPOSITING) 149 - (BOOL)_needsOneShotDrawingSynchronization; 150 - (void)_setNeedsOneShotDrawingSynchronization:(BOOL)needsSynchronization; 151 #endif 152 148 153 @end 149 154
Note: See TracChangeset
for help on using the changeset viewer.