Changeset 131131 in webkit
- Timestamp:
- Oct 11, 2012 7:45:10 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r131128 r131131 1 2012-10-11 Nat Duca <nduca@chromium.org> 2 3 Expose high-resolution on requestAnimationFrame callback 4 https://bugs.webkit.org/show_bug.cgi?id=66683 5 6 This changes requestAnimationFrame's animationStartTime argument 7 to be a high resolution DOM timestamp, per disucssion here: 8 http://lists.w3.org/Archives/Public/public-web-perf/2012Apr/0004.html 9 10 Reviewed by James Robinson. 11 12 Covered by existing requestAnimationFrame tests. 13 14 * dom/Document.cpp: 15 (WebCore::Document::serviceScriptedAnimations): 16 * dom/Document.h: 17 (Document): 18 * dom/ScriptedAnimationController.cpp: 19 (WebCore::ScriptedAnimationController::ScriptedAnimationController): 20 (WebCore::ScriptedAnimationController::serviceScriptedAnimations): 21 (WebCore): 22 (WebCore::ScriptedAnimationController::windowScreenDidChange): 23 (WebCore::ScriptedAnimationController::scheduleAnimation): 24 (WebCore::ScriptedAnimationController::animationTimerFired): 25 (WebCore::ScriptedAnimationController::displayRefreshFired): 26 * dom/ScriptedAnimationController.h: 27 (ScriptedAnimationController): 28 * page/FrameView.cpp: 29 (WebCore::FrameView::serviceScriptedAnimations): 30 * page/FrameView.h: 31 (FrameView): 32 * platform/graphics/DisplayRefreshMonitor.cpp: 33 (WebCore::DisplayRefreshMonitor::DisplayRefreshMonitor): 34 (WebCore::DisplayRefreshMonitor::notifyClients): 35 * platform/graphics/DisplayRefreshMonitor.h: 36 (DisplayRefreshMonitor): 37 * platform/graphics/blackberry/DisplayRefreshMonitorBlackBerry.cpp: 38 (WebCore::DisplayRefreshMonitor::displayLinkFired): 39 * platform/graphics/mac/DisplayRefreshMonitorMac.cpp: 40 (WebCore): 41 (WebCore::DisplayRefreshMonitor::requestRefreshCallback): 42 (WebCore::DisplayRefreshMonitor::displayLinkFired): 43 1 44 2012-10-11 Sheriff Bot <webkit.review.bot@gmail.com> 2 45 -
trunk/Source/WebCore/WebCore.exp.in
r131111 r131131 2409 2409 2410 2410 #if ENABLE(REQUEST_ANIMATION_FRAME) 2411 __ZN7WebCore9FrameView25serviceScriptedAnimationsE y2411 __ZN7WebCore9FrameView25serviceScriptedAnimationsEd 2412 2412 #endif 2413 2413 -
trunk/Source/WebCore/bindings/js/JSRequestAnimationFrameCallbackCustom.cpp
r121381 r131131 34 34 namespace WebCore { 35 35 36 bool JSRequestAnimationFrameCallback::handleEvent( DOMTimeStamp time)36 bool JSRequestAnimationFrameCallback::handleEvent(double highResNowMs) 37 37 { 38 38 if (!canInvokeCallback()) … … 44 44 45 45 MarkedArgumentBuffer args; 46 args.append(jsNumber( time));46 args.append(jsNumber(highResNowMs)); 47 47 48 48 bool raisedException = false; -
trunk/Source/WebCore/dom/Document.cpp
r131018 r131131 5567 5567 } 5568 5568 5569 void Document::serviceScriptedAnimations( DOMTimeStamp time)5569 void Document::serviceScriptedAnimations(double monotonicAnimationStartTime) 5570 5570 { 5571 5571 if (!m_scriptedAnimationController) 5572 5572 return; 5573 m_scriptedAnimationController->serviceScriptedAnimations( time);5573 m_scriptedAnimationController->serviceScriptedAnimations(monotonicAnimationStartTime); 5574 5574 } 5575 5575 #endif -
trunk/Source/WebCore/dom/Document.h
r130829 r131131 1094 1094 int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>); 1095 1095 void webkitCancelAnimationFrame(int id); 1096 void serviceScriptedAnimations( DOMTimeStamp);1096 void serviceScriptedAnimations(double monotonicAnimationStartTime); 1097 1097 #endif 1098 1098 -
trunk/Source/WebCore/dom/RequestAnimationFrameCallback.h
r116319 r131131 32 32 #define RequestAnimationFrameCallback_h 33 33 34 #include "DOMTimeStamp.h"35 34 #include <wtf/RefCounted.h> 36 35 … … 40 39 public: 41 40 virtual ~RequestAnimationFrameCallback() { } 42 virtual bool handleEvent( DOMTimeStamp) = 0;41 virtual bool handleEvent(double highResTimeMs) = 0; 43 42 44 43 int m_id; … … 49 48 50 49 #endif // RequestAnimationFrameCallback_h 51 -
trunk/Source/WebCore/dom/RequestAnimationFrameCallback.idl
r116319 r131131 34 34 Conditional=REQUEST_ANIMATION_FRAME, 35 35 ] RequestAnimationFrameCallback{ 36 // highResTime is passed as high resolution timestamp, see 37 // http://www.w3.org/TR/hr-time/ for details. 36 38 #if defined(V8_BINDING) && V8_BINDING 37 boolean handleEvent(in DOMTimeStamp time);39 boolean handleEvent(in double highResTime); 38 40 #else 39 [Custom] boolean handleEvent(in DOMTimeStamp time);41 [Custom] boolean handleEvent(in double highResTime); 40 42 #endif 41 43 42 44 }; 43 45 } -
trunk/Source/WebCore/dom/ScriptedAnimationController.cpp
r125633 r131131 30 30 31 31 #include "Document.h" 32 #include "DocumentLoader.h" 32 33 #include "FrameView.h" 33 34 #include "InspectorInstrumentation.h" … … 53 54 #if USE(REQUEST_ANIMATION_FRAME_TIMER) 54 55 , m_animationTimer(this, &ScriptedAnimationController::animationTimerFired) 55 , m_lastAnimationFrameTime (0)56 , m_lastAnimationFrameTimeMonotonic(0) 56 57 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 57 58 , m_useTimer(false) … … 108 109 } 109 110 110 void ScriptedAnimationController::serviceScriptedAnimations( DOMTimeStamp time)111 void ScriptedAnimationController::serviceScriptedAnimations(double monotonicTimeNow) 111 112 { 112 113 if (!m_callbacks.size() || m_suspendCount || (m_document->settings() && !m_document->settings()->requestAnimationFrameEnabled())) 113 114 return; 115 116 double highResNowMs = 1000.0 * m_document->loader()->timing()->monotonicTimeToZeroBasedDocumentTime(monotonicTimeNow); 114 117 115 118 // First, generate a list of callbacks to consider. Callbacks registered from this point … … 126 129 callback->m_firedOrCancelled = true; 127 130 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireAnimationFrame(m_document, callback->m_id); 128 callback->handleEvent( time);131 callback->handleEvent(highResNowMs); 129 132 InspectorInstrumentation::didFireAnimationFrame(cookie); 130 133 } … … 142 145 scheduleAnimation(); 143 146 } 144 147 145 148 void ScriptedAnimationController::windowScreenDidChange(PlatformDisplayID displayID) 146 149 { … … 151 154 #else 152 155 UNUSED_PARAM(displayID); 153 #endif 156 #endif 154 157 } 155 158 … … 164 167 if (DisplayRefreshMonitorManager::sharedManager()->scheduleAnimation(this)) 165 168 return; 166 169 167 170 m_useTimer = true; 168 171 } … … 170 173 if (m_animationTimer.isActive()) 171 174 return; 172 173 double scheduleDelay = max<double>(MinimumAnimationInterval - ( currentTime() - m_lastAnimationFrameTime), 0);175 176 double scheduleDelay = max<double>(MinimumAnimationInterval - (monotonicallyIncreasingTime() - m_lastAnimationFrameTimeMonotonic), 0); 174 177 m_animationTimer.startOneShot(scheduleDelay); 175 178 #else … … 182 185 void ScriptedAnimationController::animationTimerFired(Timer<ScriptedAnimationController>*) 183 186 { 184 m_lastAnimationFrameTime = currentTime(); 185 serviceScriptedAnimations(convertSecondsToDOMTimeStamp(m_lastAnimationFrameTime)); 186 } 187 #endif 188 189 } 190 191 #endif 192 187 m_lastAnimationFrameTimeMonotonic = monotonicallyIncreasingTime(); 188 serviceScriptedAnimations(m_lastAnimationFrameTimeMonotonic); 189 } 190 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 191 void ScriptedAnimationController::displayRefreshFired(double monotonicTimeNow) 192 { 193 serviceScriptedAnimations(monotonicTimeNow); 194 } 195 #endif 196 #endif 197 198 199 200 } 201 202 #endif -
trunk/Source/WebCore/dom/ScriptedAnimationController.h
r116319 r131131 62 62 CallbackId registerCallback(PassRefPtr<RequestAnimationFrameCallback>); 63 63 void cancelCallback(CallbackId); 64 void serviceScriptedAnimations( DOMTimeStamp);64 void serviceScriptedAnimations(double monotonicTimeNow); 65 65 66 66 void suspend(); … … 71 71 private: 72 72 ScriptedAnimationController(Document*, PlatformDisplayID); 73 73 74 74 typedef Vector<RefPtr<RequestAnimationFrameCallback> > CallbackList; 75 75 CallbackList m_callbacks; … … 84 84 void animationTimerFired(Timer<ScriptedAnimationController>*); 85 85 Timer<ScriptedAnimationController> m_animationTimer; 86 double m_lastAnimationFrameTime ;86 double m_lastAnimationFrameTimeMonotonic; 87 87 88 88 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 89 89 // Override for DisplayRefreshMonitorClient 90 virtual void displayRefreshFired(double timestamp) { serviceScriptedAnimations(convertSecondsToDOMTimeStamp(timestamp)); }90 virtual void displayRefreshFired(double timestamp); 91 91 92 92 bool m_useTimer; … … 100 100 101 101 #endif // ScriptedAnimationController_h 102 -
trunk/Source/WebCore/page/FrameView.cpp
r131111 r131131 2265 2265 2266 2266 #if ENABLE(REQUEST_ANIMATION_FRAME) 2267 void FrameView::serviceScriptedAnimations( DOMTimeStamp time)2267 void FrameView::serviceScriptedAnimations(double monotonicAnimationStartTime) 2268 2268 { 2269 2269 for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNext()) { … … 2277 2277 2278 2278 for (size_t i = 0; i < documents.size(); ++i) 2279 documents[i]->serviceScriptedAnimations( time);2279 documents[i]->serviceScriptedAnimations(monotonicAnimationStartTime); 2280 2280 } 2281 2281 #endif -
trunk/Source/WebCore/page/FrameView.h
r130829 r131131 116 116 117 117 #if ENABLE(REQUEST_ANIMATION_FRAME) 118 void serviceScriptedAnimations( DOMTimeStamp);118 void serviceScriptedAnimations(double monotonicAnimationStartTime); 119 119 #endif 120 120 -
trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp
r130612 r131131 54 54 55 55 DisplayRefreshMonitor::DisplayRefreshMonitor(PlatformDisplayID displayID) 56 : m_ timestamp(0)56 : m_monotonicAnimationStartTime(0) 57 57 , m_active(true) 58 58 , m_scheduled(false) … … 92 92 void DisplayRefreshMonitor::displayDidRefresh() 93 93 { 94 double timestamp;94 double monotonicAnimationStartTime; 95 95 { 96 96 MutexLocker lock(m_mutex); … … 101 101 102 102 m_scheduled = false; 103 timestamp = m_timestamp;103 monotonicAnimationStartTime = m_monotonicAnimationStartTime; 104 104 } 105 105 … … 111 111 copyToVector(m_clients, clients); 112 112 for (size_t i = 0; i < clients.size(); ++i) 113 clients[i]->fireDisplayRefreshIfNeeded( timestamp);113 clients[i]->fireDisplayRefreshIfNeeded(monotonicAnimationStartTime); 114 114 115 115 { -
trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitor.h
r119436 r131131 122 122 static void handleDisplayRefreshedNotificationOnMainThread(void* data); 123 123 124 double m_ timestamp;124 double m_monotonicAnimationStartTime; 125 125 bool m_active; 126 126 bool m_scheduled; -
trunk/Source/WebCore/platform/graphics/blackberry/DisplayRefreshMonitorBlackBerry.cpp
r126227 r131131 85 85 m_previousFrameDone = false; 86 86 87 m_ timestamp = currentTime();87 m_monotonicAnimationStartTime = monotonicallyIncreasingTime(); 88 88 89 89 callOnMainThread(handleDisplayRefreshedNotificationOnMainThread, this); -
trunk/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp
r116792 r131131 46 46 return kCVReturnSuccess; 47 47 } 48 48 49 49 DisplayRefreshMonitor::~DisplayRefreshMonitor() 50 50 { … … 62 62 if (!m_active) 63 63 return false; 64 64 65 65 if (!m_displayLink) { 66 66 m_active = false; … … 79 79 m_active = true; 80 80 } 81 81 82 82 MutexLocker lock(m_mutex); 83 83 m_scheduled = true; … … 93 93 m_previousFrameDone = false; 94 94 95 double webKitNow = currentTime(); 96 m_timestamp = webKitNow - nowSeconds + outputTimeSeconds; 97 95 double webKitMonotonicNow = monotonicallyIncreasingTime(); 96 double timeUntilOutput = outputTimeSeconds - nowSeconds; 97 // FIXME: Should this be using webKitMonotonicNow? 98 m_monotonicAnimationStartTime = webKitMonotonicNow + timeUntilOutput; 99 98 100 callOnMainThread(handleDisplayRefreshedNotificationOnMainThread, this); 99 101 } -
trunk/Source/WebKit/chromium/ChangeLog
r131125 r131131 1 2012-10-11 Nat Duca <nduca@chromium.org> 2 3 Expose high-resolution on requestAnimationFrame callback 4 https://bugs.webkit.org/show_bug.cgi?id=66683 5 6 This changes requestAnimationFrame's animationStartTime argument 7 to be a high resolution DOM timestamp, per disucssion here: 8 http://lists.w3.org/Archives/Public/public-web-perf/2012Apr/0004.html 9 10 Reviewed by James Robinson. 11 12 * src/PageWidgetDelegate.cpp: 13 (WebKit::PageWidgetDelegate::animate): 14 * src/WebViewImpl.cpp: 15 (WebKit::WebViewImpl::updateAnimations): 16 1 17 2012-10-11 Jay Civelli <jcivelli@chromium.org> 2 18 -
trunk/Source/WebKit/chromium/src/PageWidgetDelegate.cpp
r130940 r131131 60 60 if (!view) 61 61 return; 62 double timeShift = currentTime() - monotonicallyIncreasingTime(); 63 view->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(monotonicFrameBeginTime + timeShift)); 62 view->serviceScriptedAnimations(monotonicFrameBeginTime); 64 63 #endif 65 64 } -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r130992 r131131 1744 1744 TRACE_EVENT0("webkit", "WebViewImpl::updateAnimations"); 1745 1745 1746 WebFrameImpl* webframe = mainFrameImpl();1747 if (!webframe)1748 return;1749 FrameView* view = webframe->frameView();1750 if (!view)1751 return;1752 1753 1746 // Create synthetic wheel events as necessary for fling. 1754 1747 if (m_gestureAnimation) { … … 1758 1751 m_gestureAnimation.clear(); 1759 1752 } 1753 1754 if (!m_page) 1755 return; 1760 1756 1761 1757 PageWidgetDelegate::animate(m_page.get(), monotonicFrameBeginTime);
Note: See TracChangeset
for help on using the changeset viewer.