Changeset 261948 in webkit
- Timestamp:
- May 20, 2020 1:23:38 PM (4 years ago)
- Location:
- trunk/Source
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r261946 r261948 1 2020-05-20 Simon Fraser <simon.fraser@apple.com> 2 3 Plumb the display's nominal refresh rate down to ScrollingTree for use in scroll synchronization 4 https://bugs.webkit.org/show_bug.cgi?id=212159 5 6 Reviewed by Tim Horton. 7 8 Plumb an Optional<unsigned> down windowScreenDidChange, which contains the nominal 9 display refresh rate (as frames per second) if available. On macOS, we get this 10 from CVDisplayLinkGetNominalOutputVideoRefreshPeriod(). 11 12 To read it, WebProcessPool::nominalFramesPerSecondForDisplay() makes a DisplayLink 13 that doesn't get any observers, but that DisplayLink will very likely get used 14 as soon as we schedule a rendering update. 15 16 * page/Chrome.cpp: 17 (WebCore::Chrome::windowScreenDidChange): 18 * page/Chrome.h: 19 * page/Page.cpp: 20 (WebCore::Page::scrollingCoordinator): 21 (WebCore::Page::windowScreenDidChange): 22 * page/Page.h: 23 (WebCore::Page::displayNominalFramesPerSecond const): 24 * page/scrolling/AsyncScrollingCoordinator.cpp: 25 (WebCore::AsyncScrollingCoordinator::windowScreenDidChange): 26 * page/scrolling/AsyncScrollingCoordinator.h: 27 * page/scrolling/ScrollingCoordinator.h: 28 (WebCore::ScrollingCoordinator::windowScreenDidChange): 29 * page/scrolling/ScrollingTree.cpp: 30 (WebCore::ScrollingTree::windowScreenDidChange): 31 * page/scrolling/ScrollingTree.h: 32 * platform/HostWindow.h: 33 1 34 2020-05-20 Chris Dumez <cdumez@apple.com> 2 35 -
trunk/Source/WebCore/page/Chrome.cpp
r260616 r261948 513 513 } 514 514 515 void Chrome::windowScreenDidChange(PlatformDisplayID displayID )516 { 517 if (displayID == m_page.displayID() )515 void Chrome::windowScreenDidChange(PlatformDisplayID displayID, Optional<unsigned> nominalFrameInterval) 516 { 517 if (displayID == m_page.displayID() && nominalFrameInterval == m_page.displayNominalFramesPerSecond()) 518 518 return; 519 519 520 m_page.windowScreenDidChange(displayID );520 m_page.windowScreenDidChange(displayID, nominalFrameInterval); 521 521 522 522 #if PLATFORM(MAC) && ENABLE(GRAPHICS_CONTEXT_GL) -
trunk/Source/WebCore/page/Chrome.h
r260616 r261948 89 89 90 90 PlatformDisplayID displayID() const override; 91 void windowScreenDidChange(PlatformDisplayID ) override;91 void windowScreenDidChange(PlatformDisplayID, Optional<unsigned>) override; 92 92 93 93 FloatSize screenSize() const override; -
trunk/Source/WebCore/page/Page.cpp
r261876 r261948 436 436 m_scrollingCoordinator = ScrollingCoordinator::create(this); 437 437 438 m_scrollingCoordinator->windowScreenDidChange(m_displayID );438 m_scrollingCoordinator->windowScreenDidChange(m_displayID, m_displayNominalFramesPerSecond); 439 439 } 440 440 … … 1111 1111 } 1112 1112 1113 void Page::windowScreenDidChange(PlatformDisplayID displayID )1114 { 1115 if (displayID == m_displayID )1113 void Page::windowScreenDidChange(PlatformDisplayID displayID, Optional<unsigned> nominalFramesPerSecond) 1114 { 1115 if (displayID == m_displayID && nominalFramesPerSecond == m_displayNominalFramesPerSecond) 1116 1116 return; 1117 1117 1118 1118 m_displayID = displayID; 1119 m_displayNominalFramesPerSecond = nominalFramesPerSecond; 1119 1120 1120 1121 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) { … … 1124 1125 1125 1126 if (m_scrollingCoordinator) 1126 m_scrollingCoordinator->windowScreenDidChange(displayID );1127 m_scrollingCoordinator->windowScreenDidChange(displayID, nominalFramesPerSecond); 1127 1128 1128 1129 renderingUpdateScheduler().windowScreenDidChange(displayID); -
trunk/Source/WebCore/page/Page.h
r261663 r261948 363 363 WEBCORE_EXPORT void setInitialScaleIgnoringContentSize(float); 364 364 365 void windowScreenDidChange(PlatformDisplayID );365 void windowScreenDidChange(PlatformDisplayID, Optional<unsigned> nominalFramesPerSecond); 366 366 PlatformDisplayID displayID() const { return m_displayID; } 367 Optional<unsigned> displayNominalFramesPerSecond() const { return m_displayNominalFramesPerSecond; } 367 368 368 369 float topContentInset() const { return m_topContentInset; } … … 846 847 847 848 PlatformDisplayID m_displayID { 0 }; 849 Optional<unsigned> m_displayNominalFramesPerSecond; 848 850 849 851 int m_nestedRunLoopCount { 0 }; -
trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
r261876 r261948 817 817 } 818 818 819 void AsyncScrollingCoordinator::windowScreenDidChange(PlatformDisplayID displayID )819 void AsyncScrollingCoordinator::windowScreenDidChange(PlatformDisplayID displayID, Optional<unsigned> nominalFramesPerSecond) 820 820 { 821 821 if (m_scrollingTree) 822 m_scrollingTree->windowScreenDidChange(displayID );822 m_scrollingTree->windowScreenDidChange(displayID, nominalFramesPerSecond); 823 823 } 824 824 -
trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h
r261876 r261948 139 139 WEBCORE_EXPORT bool hasSynchronousScrollingReasons(ScrollingNodeID) const final; 140 140 141 WEBCORE_EXPORT void windowScreenDidChange(PlatformDisplayID ) final;141 WEBCORE_EXPORT void windowScreenDidChange(PlatformDisplayID, Optional<unsigned> nominalFramesPerSecond) final; 142 142 143 143 virtual void scheduleTreeStateCommit() = 0; -
trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h
r261876 r261948 182 182 virtual void scrollableAreaScrollbarLayerDidChange(ScrollableArea&, ScrollbarOrientation) { } 183 183 184 virtual void windowScreenDidChange(PlatformDisplayID ) { }184 virtual void windowScreenDidChange(PlatformDisplayID, Optional<unsigned> /* nominalFramesPerSecond */) { } 185 185 186 186 static String synchronousScrollingReasonsAsText(OptionSet<SynchronousScrollingReason>); -
trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp
r261876 r261948 528 528 } 529 529 530 void ScrollingTree::windowScreenDidChange(PlatformDisplayID displayID )530 void ScrollingTree::windowScreenDidChange(PlatformDisplayID displayID, Optional<unsigned> nominalFramesPerSecond) 531 531 { 532 532 LockHolder locker(m_treeStateMutex); 533 533 m_treeState.displayID = displayID; 534 m_treeState.nominalFramesPerSecond = nominalFramesPerSecond; 534 535 } 535 536 -
trunk/Source/WebCore/page/scrolling/ScrollingTree.h
r261876 r261948 180 180 virtual void unlockLayersForHitTesting() { } 181 181 182 void windowScreenDidChange(PlatformDisplayID );182 void windowScreenDidChange(PlatformDisplayID, Optional<unsigned> nominalFramesPerSecond); 183 183 PlatformDisplayID displayID(); 184 184 … … 222 222 FloatPoint mainFrameScrollPosition; 223 223 PlatformDisplayID displayID { 0 }; 224 Optional<unsigned> nominalFramesPerSecond; 224 225 bool mainFrameIsRubberBanding { false }; 225 226 bool mainFrameIsScrollSnapping { false }; -
trunk/Source/WebCore/platform/HostWindow.h
r257677 r261948 77 77 78 78 virtual PlatformDisplayID displayID() const = 0; 79 virtual void windowScreenDidChange(PlatformDisplayID ) = 0;79 virtual void windowScreenDidChange(PlatformDisplayID, Optional<unsigned> nominalFramesPerSecond) = 0; 80 80 81 81 virtual FloatSize screenSize() const = 0; -
trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm
r261546 r261948 49 49 { 50 50 ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer)); 51 return [[ [screen deviceDescription]objectForKey:@"NSScreenNumber"] intValue];51 return [[screen.deviceDescription objectForKey:@"NSScreenNumber"] intValue]; 52 52 } 53 53 -
trunk/Source/WebKit/ChangeLog
r261940 r261948 1 2020-05-20 Simon Fraser <simon.fraser@apple.com> 2 3 Plumb the display's nominal refresh rate down to ScrollingTree for use in scroll synchronization 4 https://bugs.webkit.org/show_bug.cgi?id=212159 5 6 Reviewed by Tim Horton. 7 8 Plumb an Optional<unsigned> down windowScreenDidChange, which contains the nominal 9 display refresh rate (as frames per second) if available. On macOS, we get this 10 from CVDisplayLinkGetNominalOutputVideoRefreshPeriod(). 11 12 To read it, WebProcessPool::nominalFramesPerSecondForDisplay() makes a DisplayLink 13 that doesn't get any observers, but that DisplayLink will very likely get used 14 as soon as we schedule a rendering update. 15 16 * UIProcess/Cocoa/WebProcessPoolCocoa.mm: 17 (WebKit::WebProcessPool::nominalFramesPerSecondForDisplay): 18 * UIProcess/Cocoa/WebViewImpl.mm: 19 (WebKit::WebViewImpl::windowDidChangeScreen): 20 * UIProcess/WebPageProxy.cpp: 21 (WebKit::WebPageProxy::windowScreenDidChange): 22 * UIProcess/WebPageProxy.h: 23 * UIProcess/WebProcessPool.h: 24 * UIProcess/mac/DisplayLink.cpp: 25 (WebKit::DisplayLink::DisplayLink): 26 (WebKit::DisplayLink::nominalFramesPerSecond const): 27 * UIProcess/mac/DisplayLink.h: 28 * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm: 29 (WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea): 30 * WebProcess/WebPage/WebPage.cpp: 31 (WebKit::WebPage::windowScreenDidChange): 32 * WebProcess/WebPage/WebPage.h: 33 * WebProcess/WebPage/WebPage.messages.in: 34 1 35 2020-05-20 Myles C. Maxfield <mmaxfield@apple.com> 2 36 -
trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
r261900 r261948 792 792 793 793 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 794 Optional<unsigned> WebProcessPool::nominalFramesPerSecondForDisplay(WebCore::PlatformDisplayID displayID) 795 { 796 for (auto& displayLink : m_displayLinks) { 797 if (displayLink->displayID() == displayID) 798 return displayLink->nominalFramesPerSecond(); 799 } 800 801 // Note that this creates a DisplayLink with no observers, but it's highly likely that we'll soon call startDisplayLink() for it. 802 auto displayLink = makeUnique<DisplayLink>(displayID); 803 auto frameRate = displayLink->nominalFramesPerSecond(); 804 m_displayLinks.append(WTFMove(displayLink)); 805 return frameRate; 806 } 807 794 808 void WebProcessPool::startDisplayLink(IPC::Connection& connection, DisplayLinkObserverID observerID, PlatformDisplayID displayID) 795 809 { -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r261875 r261948 97 97 #import <WebCore/Pasteboard.h> 98 98 #import <WebCore/PlatformEventFactoryMac.h> 99 #import <WebCore/PlatformScreen.h> 99 100 #import <WebCore/PromisedAttachmentInfo.h> 100 101 #import <WebCore/TextAlternativeWithRange.h> … … 2123 2124 { 2124 2125 NSWindow *window = m_targetWindowForMovePreparation ? m_targetWindowForMovePreparation.get() : [m_view window]; 2125 m_page->windowScreenDidChange([[[[window screen] deviceDescription] objectForKey:@"NSScreenNumber"] intValue]); 2126 PlatformDisplayID displayID = WebCore::displayID(window.screen); 2127 auto framesPerSecond = m_page->process().processPool().nominalFramesPerSecondForDisplay(displayID); 2128 m_page->windowScreenDidChange(displayID, framesPerSecond); 2126 2129 } 2127 2130 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r261875 r261948 3706 3706 } 3707 3707 3708 void WebPageProxy::windowScreenDidChange(PlatformDisplayID displayID )3709 { 3710 if (!hasRunningProcess()) 3711 return; 3712 3713 send(Messages::WebPage::WindowScreenDidChange(displayID ));3708 void WebPageProxy::windowScreenDidChange(PlatformDisplayID displayID, Optional<unsigned> nominalFramesPerSecond) 3709 { 3710 if (!hasRunningProcess()) 3711 return; 3712 3713 send(Messages::WebPage::WindowScreenDidChange(displayID, nominalFramesPerSecond)); 3714 3714 } 3715 3715 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r261875 r261948 993 993 void setIntrinsicDeviceScaleFactor(float); 994 994 void setCustomDeviceScaleFactor(float); 995 void windowScreenDidChange(WebCore::PlatformDisplayID );995 void windowScreenDidChange(WebCore::PlatformDisplayID, Optional<unsigned> nominalFramesPerSecond); 996 996 void accessibilitySettingsDidChange(); 997 997 -
trunk/Source/WebKit/UIProcess/WebProcessPool.h
r261900 r261948 250 250 251 251 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 252 Optional<unsigned> nominalFramesPerSecondForDisplay(WebCore::PlatformDisplayID); 252 253 void startDisplayLink(IPC::Connection&, DisplayLinkObserverID, WebCore::PlatformDisplayID); 253 254 void stopDisplayLink(IPC::Connection&, DisplayLinkObserverID, WebCore::PlatformDisplayID); -
trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp
r261900 r261948 37 37 : m_displayID(displayID) 38 38 { 39 // FIXME: We can get here with displayID == 0 (webkit.org/b/212120), in which case CVDisplayLinkCreateWithCGDisplay() 40 // probably defaults to the main screen. 39 41 ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer)); 40 42 CVReturn error = CVDisplayLinkCreateWithCGDisplay(displayID, &m_displayLink); 41 43 if (error) { 42 WTFLogAlways("Could not create a display link : %d", error);44 WTFLogAlways("Could not create a display link for display %u: error %d", displayID, error); 43 45 return; 44 46 } … … 46 48 error = CVDisplayLinkSetOutputCallback(m_displayLink, displayLinkCallback, this); 47 49 if (error) { 48 WTFLogAlways("Could not set the display link output callback : %d", error);50 WTFLogAlways("Could not set the display link output callback for display %u: error %d", displayID, error); 49 51 return; 50 52 } … … 60 62 CVDisplayLinkStop(m_displayLink); 61 63 CVDisplayLinkRelease(m_displayLink); 64 } 65 66 Optional<unsigned> DisplayLink::nominalFramesPerSecond() const 67 { 68 CVTime refreshPeriod = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(m_displayLink); 69 return round((double)refreshPeriod.timeScale / (double)refreshPeriod.timeValue); 62 70 } 63 71 -
trunk/Source/WebKit/UIProcess/mac/DisplayLink.h
r261900 r261948 52 52 53 53 WebCore::PlatformDisplayID displayID() const { return m_displayID; } 54 55 Optional<unsigned> nominalFramesPerSecond() const; 54 56 55 57 private: -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp
r261333 r261948 577 577 // In order to ensure that we get a unique DisplayRefreshMonitor per-DrawingArea (necessary because ThreadedDisplayRefreshMonitor 578 578 // is driven by the ThreadedCompositor of the drawing area), give each page a unique DisplayID derived from WebPage's unique ID. 579 m_webPage.windowScreenDidChange(m_layerTreeHost->displayID() );579 m_webPage.windowScreenDidChange(m_layerTreeHost->displayID(), WTF::nullopt); 580 580 }; 581 581 … … 633 633 634 634 // Always use the primary display ID (0) when not in accelerated compositing mode. 635 m_webPage.windowScreenDidChange(0 );635 m_webPage.windowScreenDidChange(0, WTF::nullopt); 636 636 637 637 m_dirtyRegion = m_webPage.bounds(); -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm
r261254 r261948 73 73 // DisplayIDs less likely, it is not entirely safe to have a RemoteLayerTreeDrawingArea and TiledCoreAnimationDrawingArea 74 74 // coeexist in the same process. 75 webPage.windowScreenDidChange(std::numeric_limits<uint32_t>::max() - webPage.identifier().toUInt64() );75 webPage.windowScreenDidChange(std::numeric_limits<uint32_t>::max() - webPage.identifier().toUInt64(), WTF::nullopt); 76 76 77 77 if (auto viewExposedRect = parameters.viewExposedRect) -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r261802 r261948 1972 1972 } 1973 1973 1974 void WebPage::windowScreenDidChange( uint32_t displayID)1975 { 1976 m_page->chrome().windowScreenDidChange( static_cast<PlatformDisplayID>(displayID));1974 void WebPage::windowScreenDidChange(PlatformDisplayID displayID, Optional<unsigned> nominalFramesPerSecond) 1975 { 1976 m_page->chrome().windowScreenDidChange(displayID, nominalFramesPerSecond); 1977 1977 1978 1978 #if PLATFORM(MAC) -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r261802 r261948 205 205 enum class WritingDirection : uint8_t; 206 206 207 using PlatformDisplayID = uint32_t; 208 207 209 struct AttributedString; 208 210 struct BackForwardItemIdentifier; … … 518 520 void setPageZoomFactor(double); 519 521 void setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor); 520 void windowScreenDidChange( uint32_t);522 void windowScreenDidChange(WebCore::PlatformDisplayID, Optional<unsigned> nominalFramesPerSecond); 521 523 String dumpHistoryForTesting(const String& directory); 522 524 void clearHistory(); -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r261802 r261948 268 268 SetPageZoomFactor(double zoomFactor) 269 269 SetTextZoomFactor(double zoomFactor) 270 WindowScreenDidChange(uint32_t displayID )270 WindowScreenDidChange(uint32_t displayID, Optional<unsigned> nominalFramesPerSecond) 271 271 272 272 AccessibilitySettingsDidChange() -
trunk/Source/WebKitLegacy/mac/ChangeLog
r261848 r261948 1 2020-05-20 Simon Fraser <simon.fraser@apple.com> 2 3 Plumb the display's nominal refresh rate down to ScrollingTree for use in scroll synchronization 4 https://bugs.webkit.org/show_bug.cgi?id=212159 5 6 Reviewed by Tim Horton. 7 8 Plumb an Optional<unsigned> down windowScreenDidChange, which contains the nominal 9 display refresh rate (as frames per second) if available. On macOS, we get this 10 from CVDisplayLinkGetNominalOutputVideoRefreshPeriod(). 11 12 To read it, WebProcessPool::nominalFramesPerSecondForDisplay() makes a DisplayLink 13 that doesn't get any observers, but that DisplayLink will very likely get used 14 as soon as we schedule a rendering update. 15 16 * WebView/WebView.mm: 17 (-[WebView doWindowDidChangeScreen]): 18 1 19 2020-05-18 David Kilzer <ddkilzer@apple.com> 2 20 -
trunk/Source/WebKitLegacy/mac/WebView/WebView.mm
r261848 r261948 193 193 #import <WebCore/PathUtilities.h> 194 194 #import <WebCore/PlatformEventFactoryMac.h> 195 #import <WebCore/PlatformScreen.h> 195 196 #import <WebCore/ProgressTracker.h> 196 197 #import <WebCore/RenderTheme.h> … … 6047 6048 { 6048 6049 if (_private && _private->page) 6049 _private->page->chrome().windowScreenDidChange( (WebCore::PlatformDisplayID)[[[[[self window] screen] deviceDescription] objectForKey:@"NSScreenNumber"] intValue]);6050 _private->page->chrome().windowScreenDidChange(WebCore::displayID(self.window.screen), WTF::nullopt); 6050 6051 } 6051 6052
Note: See TracChangeset
for help on using the changeset viewer.