Changeset 115525 in webkit
- Timestamp:
- Apr 27, 2012 6:28:07 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r115522 r115525 1 2012-04-27 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-04-27 Kentaro Hara <haraken@chromium.org> 2 45 -
trunk/Source/WebCore/WebCore.exp.in
r115288 r115525 2036 2036 2037 2037 #if ENABLE(REQUEST_ANIMATION_FRAME) 2038 __ZN7WebCore9FrameView25serviceScriptedAnimationsE y2038 __ZN7WebCore9FrameView25serviceScriptedAnimationsEd 2039 2039 #endif 2040 2040 -
trunk/Source/WebCore/bindings/js/JSRequestAnimationFrameCallbackCustom.cpp
r95901 r115525 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
r115250 r115525 5760 5760 } 5761 5761 5762 void Document::serviceScriptedAnimations( DOMTimeStamp time)5762 void Document::serviceScriptedAnimations(double monotonicAnimationStartTime) 5763 5763 { 5764 5764 if (!m_scriptedAnimationController) 5765 5765 return; 5766 m_scriptedAnimationController->serviceScriptedAnimations( time);5766 m_scriptedAnimationController->serviceScriptedAnimations(monotonicAnimationStartTime); 5767 5767 } 5768 5768 #endif -
trunk/Source/WebCore/dom/Document.h
r115250 r115525 1117 1117 int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>); 1118 1118 void webkitCancelAnimationFrame(int id); 1119 void serviceScriptedAnimations( DOMTimeStamp);1119 void serviceScriptedAnimations(double monotonicAnimationStartTime); 1120 1120 #endif 1121 1121 -
trunk/Source/WebCore/dom/RequestAnimationFrameCallback.h
r114042 r115525 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
r108297 r115525 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
r113573 r115525 30 30 31 31 #include "Document.h" 32 #include "DocumentLoader.h" 32 33 #include "FrameView.h" 33 34 #include "InspectorInstrumentation.h" … … 52 53 #if USE(REQUEST_ANIMATION_FRAME_TIMER) 53 54 , m_animationTimer(this, &ScriptedAnimationController::animationTimerFired) 54 , m_lastAnimationFrameTime (0)55 , m_lastAnimationFrameTimeMonotonic(0) 55 56 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 56 57 , m_useTimer(false) … … 107 108 } 108 109 109 void ScriptedAnimationController::serviceScriptedAnimations( DOMTimeStamp time)110 void ScriptedAnimationController::serviceScriptedAnimations(double monotonicTimeNow) 110 111 { 111 112 if (!m_callbacks.size() || m_suspendCount) 112 113 return; 114 115 double highResNowMs = 1000.0 * m_document->loader()->timing()->convertMonotonicTimeToZeroBasedDocumentTime(monotonicTimeNow); 113 116 114 117 // First, generate a list of callbacks to consider. Callbacks registered from this point … … 125 128 callback->m_firedOrCancelled = true; 126 129 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireAnimationFrame(m_document, callback->m_id); 127 callback->handleEvent( time);130 callback->handleEvent(highResNowMs); 128 131 InspectorInstrumentation::didFireAnimationFrame(cookie); 129 132 } … … 141 144 scheduleAnimation(); 142 145 } 143 146 144 147 void ScriptedAnimationController::windowScreenDidChange(PlatformDisplayID displayID) 145 148 { … … 148 151 #else 149 152 UNUSED_PARAM(displayID); 150 #endif 153 #endif 151 154 } 152 155 … … 161 164 if (DisplayRefreshMonitorManager::sharedManager()->scheduleAnimation(this)) 162 165 return; 163 166 164 167 m_useTimer = true; 165 168 } … … 167 170 if (m_animationTimer.isActive()) 168 171 return; 169 170 double scheduleDelay = max<double>(MinimumAnimationInterval - ( currentTime() - m_lastAnimationFrameTime), 0);172 173 double scheduleDelay = max<double>(MinimumAnimationInterval - (monotonicallyIncreasingTime() - m_lastAnimationFrameTimeMonotonic), 0); 171 174 m_animationTimer.startOneShot(scheduleDelay); 172 175 #else … … 179 182 void ScriptedAnimationController::animationTimerFired(Timer<ScriptedAnimationController>*) 180 183 { 181 m_lastAnimationFrameTime = currentTime(); 182 serviceScriptedAnimations(convertSecondsToDOMTimeStamp(m_lastAnimationFrameTime)); 184 m_lastAnimationFrameTimeMonotonic = monotonicallyIncreasingTime(); 185 serviceScriptedAnimations(m_lastAnimationFrameTimeMonotonic); 186 } 187 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 188 void ScriptedAnimationController::displayRefreshFired(double monotonicTimeNow) 189 { 190 serviceScriptedAnimations(monotonicTimeNow); 183 191 } 184 192 #endif 193 #endif 194 195 185 196 186 197 } 187 198 188 199 #endif 189 -
trunk/Source/WebCore/dom/ScriptedAnimationController.h
r113573 r115525 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
r115344 r115525 2162 2162 2163 2163 #if ENABLE(REQUEST_ANIMATION_FRAME) 2164 void FrameView::serviceScriptedAnimations( DOMTimeStamp time)2164 void FrameView::serviceScriptedAnimations(double monotonicAnimationStartTime) 2165 2165 { 2166 2166 for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNext()) { … … 2174 2174 2175 2175 for (size_t i = 0; i < documents.size(); ++i) 2176 documents[i]->serviceScriptedAnimations( time);2176 documents[i]->serviceScriptedAnimations(monotonicAnimationStartTime); 2177 2177 } 2178 2178 #endif -
trunk/Source/WebCore/page/FrameView.h
r114785 r115525 113 113 114 114 #if ENABLE(REQUEST_ANIMATION_FRAME) 115 void serviceScriptedAnimations( DOMTimeStamp);115 void serviceScriptedAnimations(double monotonicAnimationStartTime); 116 116 #endif 117 117 -
trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp
r110709 r115525 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) … … 76 76 void DisplayRefreshMonitor::notifyClients() 77 77 { 78 double timestamp;78 double monotonicAnimationStartTime; 79 79 { 80 80 MutexLocker lock(m_mutex); 81 81 m_scheduled = false; 82 timestamp = m_timestamp;82 monotonicAnimationStartTime = m_monotonicAnimationStartTime; 83 83 } 84 84 85 85 for (size_t i = 0; i < m_clients.size(); ++i) 86 m_clients[i]->fireDisplayRefreshIfNeeded( timestamp);86 m_clients[i]->fireDisplayRefreshIfNeeded(monotonicAnimationStartTime); 87 87 88 88 { -
trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitor.h
r110709 r115525 114 114 static void refreshDisplayOnMainThread(void* data); 115 115 116 double m_ timestamp;116 double m_monotonicAnimationStartTime; 117 117 bool m_active; 118 118 bool m_scheduled; -
trunk/Source/WebCore/platform/graphics/blackberry/DisplayRefreshMonitorBlackBerry.cpp
r113644 r115525 82 82 m_previousFrameDone = false; 83 83 84 m_ timestamp = currentTime();84 m_monotonicAnimationStartTime = monotonicallyIncreasingTime(); 85 85 86 86 callOnMainThread(refreshDisplayOnMainThread, this); -
trunk/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp
r110356 r115525 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(refreshDisplayOnMainThread, this); 99 101 } -
trunk/Source/WebKit/chromium/ChangeLog
r115521 r115525 1 2012-04-27 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-04-27 Mark Pilgrim <pilgrim@chromium.org> 2 18 -
trunk/Source/WebKit/chromium/src/PageWidgetDelegate.cpp
r113948 r115525 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
r115439 r115525 1433 1433 TRACE_EVENT("WebViewImpl::updateAnimations", this, 0); 1434 1434 1435 WebFrameImpl* webframe = mainFrameImpl();1436 if (!webframe)1437 return;1438 FrameView* view = webframe->frameView();1439 if (!view)1440 return;1441 1442 1435 // Create synthetic wheel events as necessary for fling. 1443 1436 if (m_gestureAnimation) { … … 1447 1440 m_gestureAnimation.clear(); 1448 1441 } 1442 1443 if (!m_page) 1444 return; 1449 1445 1450 1446 PageWidgetDelegate::animate(m_page.get(), monotonicFrameBeginTime);
Note: See TracChangeset
for help on using the changeset viewer.