Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: cc/thread_proxy.cc

Issue 11191068: Remove WTF::currentTime() / WTF::monotonicallyIncreasingTime() uses from cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/thread_proxy.h ('k') | webkit/compositor_bindings/web_layer_tree_view_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "cc/thread_proxy.h" 7 #include "cc/thread_proxy.h"
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/delay_based_time_source.h" 10 #include "cc/delay_based_time_source.h"
11 #include "cc/draw_quad.h" 11 #include "cc/draw_quad.h"
12 #include "cc/frame_rate_controller.h" 12 #include "cc/frame_rate_controller.h"
13 #include "cc/graphics_context.h" 13 #include "cc/graphics_context.h"
14 #include "cc/input_handler.h" 14 #include "cc/input_handler.h"
15 #include "cc/layer_tree_host.h" 15 #include "cc/layer_tree_host.h"
16 #include "cc/scheduler.h" 16 #include "cc/scheduler.h"
17 #include "cc/scoped_thread_proxy.h" 17 #include "cc/scoped_thread_proxy.h"
18 #include "cc/thread_task.h" 18 #include "cc/thread_task.h"
19 #include <public/WebSharedGraphicsContext3D.h> 19 #include <public/WebSharedGraphicsContext3D.h>
20 #include <wtf/CurrentTime.h>
21 20
22 using WebKit::WebSharedGraphicsContext3D; 21 using WebKit::WebSharedGraphicsContext3D;
23 22
24 namespace { 23 namespace {
25 24
26 // Measured in seconds. 25 // Measured in seconds.
27 const double contextRecreationTickRate = 0.03; 26 const double contextRecreationTickRate = 0.03;
28 27
29 } // namespace 28 } // namespace
30 29
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 request->success = false; 110 request->success = false;
112 request->completion.signal(); 111 request->completion.signal();
113 return; 112 return;
114 } 113 }
115 114
116 m_readbackRequestOnImplThread = request; 115 m_readbackRequestOnImplThread = request;
117 m_schedulerOnImplThread->setNeedsRedraw(); 116 m_schedulerOnImplThread->setNeedsRedraw();
118 m_schedulerOnImplThread->setNeedsForcedRedraw(); 117 m_schedulerOnImplThread->setNeedsForcedRedraw();
119 } 118 }
120 119
121 void ThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool us eAnchor, float scale, double duration) 120 void ThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool us eAnchor, float scale, base::TimeDelta duration)
122 { 121 {
123 DCHECK(Proxy::isMainThread()); 122 DCHECK(Proxy::isMainThread());
124 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::requestSt artPageScaleAnimationOnImplThread, targetPosition, useAnchor, scale, duration)); 123 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::requestSt artPageScaleAnimationOnImplThread, targetPosition, useAnchor, scale, duration));
125 } 124 }
126 125
127 void ThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPosit ion, bool useAnchor, float scale, double duration) 126 void ThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPosit ion, bool useAnchor, float scale, base::TimeDelta duration)
128 { 127 {
129 DCHECK(Proxy::isImplThread()); 128 DCHECK(Proxy::isImplThread());
130 if (m_layerTreeHostImpl.get()) 129 if (m_layerTreeHostImpl.get())
131 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, monotonicallyIncreasingTime(), duration); 130 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, base::TimeTicks::Now(), duration);
132 } 131 }
133 132
134 void ThreadProxy::finishAllRendering() 133 void ThreadProxy::finishAllRendering()
135 { 134 {
136 DCHECK(Proxy::isMainThread()); 135 DCHECK(Proxy::isMainThread());
137 DCHECK(!m_deferCommits); 136 DCHECK(!m_deferCommits);
138 137
139 // Make sure all GL drawing is finished on the impl thread. 138 // Make sure all GL drawing is finished on the impl thread.
140 DebugScopedSetMainThreadBlocked mainThreadBlocked; 139 DebugScopedSetMainThreadBlocked mainThreadBlocked;
141 CompletionEvent completion; 140 CompletionEvent completion;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 } 306 }
308 307
309 void ThreadProxy::onSwapBuffersCompleteOnImplThread() 308 void ThreadProxy::onSwapBuffersCompleteOnImplThread()
310 { 309 {
311 DCHECK(isImplThread()); 310 DCHECK(isImplThread());
312 TRACE_EVENT0("cc", "ThreadProxy::onSwapBuffersCompleteOnImplThread"); 311 TRACE_EVENT0("cc", "ThreadProxy::onSwapBuffersCompleteOnImplThread");
313 m_schedulerOnImplThread->didSwapBuffersComplete(); 312 m_schedulerOnImplThread->didSwapBuffersComplete();
314 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::didComplete SwapBuffers)); 313 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::didComplete SwapBuffers));
315 } 314 }
316 315
317 void ThreadProxy::onVSyncParametersChanged(double monotonicTimebase, double inte rvalInSeconds) 316 void ThreadProxy::onVSyncParametersChanged(base::TimeTicks timebase, base::TimeD elta interval)
318 { 317 {
319 DCHECK(isImplThread()); 318 DCHECK(isImplThread());
320 TRACE_EVENT2("cc", "ThreadProxy::onVSyncParametersChanged", "monotonicTimeba se", monotonicTimebase, "intervalInSeconds", intervalInSeconds); 319 TRACE_EVENT2("cc", "ThreadProxy::onVSyncParametersChanged", "timebase", (tim ebase - base::TimeTicks()).InMilliseconds(), "interval", interval.InMilliseconds ());
321 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimeb ase * base::Time::kMicrosecondsPerSecond);
322 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalInSecon ds * base::Time::kMicrosecondsPerSecond);
323 m_schedulerOnImplThread->setTimebaseAndInterval(timebase, interval); 320 m_schedulerOnImplThread->setTimebaseAndInterval(timebase, interval);
324 } 321 }
325 322
326 void ThreadProxy::onCanDrawStateChanged(bool canDraw) 323 void ThreadProxy::onCanDrawStateChanged(bool canDraw)
327 { 324 {
328 DCHECK(isImplThread()); 325 DCHECK(isImplThread());
329 TRACE_EVENT1("cc", "ThreadProxy::onCanDrawStateChanged", "canDraw", canDraw) ; 326 TRACE_EVENT1("cc", "ThreadProxy::onCanDrawStateChanged", "canDraw", canDraw) ;
330 m_schedulerOnImplThread->setCanDraw(canDraw); 327 m_schedulerOnImplThread->setCanDraw(canDraw);
331 } 328 }
332 329
333 void ThreadProxy::setNeedsCommitOnImplThread() 330 void ThreadProxy::setNeedsCommitOnImplThread()
334 { 331 {
335 DCHECK(isImplThread()); 332 DCHECK(isImplThread());
336 TRACE_EVENT0("cc", "ThreadProxy::setNeedsCommitOnImplThread"); 333 TRACE_EVENT0("cc", "ThreadProxy::setNeedsCommitOnImplThread");
337 m_schedulerOnImplThread->setNeedsCommit(); 334 m_schedulerOnImplThread->setNeedsCommit();
338 } 335 }
339 336
340 void ThreadProxy::setNeedsForcedCommitOnImplThread() 337 void ThreadProxy::setNeedsForcedCommitOnImplThread()
341 { 338 {
342 DCHECK(isImplThread()); 339 DCHECK(isImplThread());
343 TRACE_EVENT0("cc", "ThreadProxy::setNeedsForcedCommitOnImplThread"); 340 TRACE_EVENT0("cc", "ThreadProxy::setNeedsForcedCommitOnImplThread");
344 m_schedulerOnImplThread->setNeedsCommit(); 341 m_schedulerOnImplThread->setNeedsCommit();
345 m_schedulerOnImplThread->setNeedsForcedCommit(); 342 m_schedulerOnImplThread->setNeedsForcedCommit();
346 } 343 }
347 344
348 void ThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animati onEventsVector> events, double wallClockTime) 345 void ThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animati onEventsVector> events, base::Time wallClockTime)
349 { 346 {
350 DCHECK(isImplThread()); 347 DCHECK(isImplThread());
351 TRACE_EVENT0("cc", "ThreadProxy::postAnimationEventsToMainThreadOnImplThread "); 348 TRACE_EVENT0("cc", "ThreadProxy::postAnimationEventsToMainThreadOnImplThread ");
352 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::setAnimatio nEvents, events.release(), wallClockTime)); 349 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::setAnimatio nEvents, events.release(), wallClockTime));
353 } 350 }
354 351
355 bool ThreadProxy::reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) 352 bool ThreadProxy::reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff)
356 { 353 {
357 DCHECK(isImplThread()); 354 DCHECK(isImplThread());
358 355
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 489
493 m_beginFrameCompletionEventOnImplThread = completion; 490 m_beginFrameCompletionEventOnImplThread = completion;
494 setNeedsForcedCommitOnImplThread(); 491 setNeedsForcedCommitOnImplThread();
495 } 492 }
496 493
497 void ThreadProxy::scheduledActionBeginFrame() 494 void ThreadProxy::scheduledActionBeginFrame()
498 { 495 {
499 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionBeginFrame"); 496 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionBeginFrame");
500 DCHECK(!m_pendingBeginFrameRequest); 497 DCHECK(!m_pendingBeginFrameRequest);
501 m_pendingBeginFrameRequest = make_scoped_ptr(new BeginFrameAndCommitState()) ; 498 m_pendingBeginFrameRequest = make_scoped_ptr(new BeginFrameAndCommitState()) ;
502 m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasin gTime(); 499 m_pendingBeginFrameRequest->monotonicFrameBeginTime = base::TimeTicks::Now() ;
503 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD eltas(); 500 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD eltas();
504 m_pendingBeginFrameRequest->implTransform = m_layerTreeHostImpl->implTransfo rm(); 501 m_pendingBeginFrameRequest->implTransform = m_layerTreeHostImpl->implTransfo rm();
505 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl ->memoryAllocationLimitBytes(); 502 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl ->memoryAllocationLimitBytes();
506 if (m_layerTreeHost->contentsTextureManager()) 503 if (m_layerTreeHost->contentsTextureManager())
507 m_layerTreeHost->contentsTextureManager()->getEvictedBackings(m_pending BeginFrameRequest->evictedContentsTexturesBackings); 504 m_layerTreeHost->contentsTextureManager()->getEvictedBackings(m_pending BeginFrameRequest->evictedContentsTexturesBackings);
508 505
509 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::beginFrame) ); 506 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::beginFrame) );
510 507
511 if (m_beginFrameCompletionEventOnImplThread) { 508 if (m_beginFrameCompletionEventOnImplThread) {
512 m_beginFrameCompletionEventOnImplThread->signal(); 509 m_beginFrameCompletionEventOnImplThread->signal();
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 DCHECK(isImplThread()); 722 DCHECK(isImplThread());
726 DCHECK(m_layerTreeHostImpl.get()); 723 DCHECK(m_layerTreeHostImpl.get());
727 if (!m_layerTreeHostImpl.get()) 724 if (!m_layerTreeHostImpl.get())
728 return result; 725 return result;
729 726
730 DCHECK(m_layerTreeHostImpl->renderer()); 727 DCHECK(m_layerTreeHostImpl->renderer());
731 if (!m_layerTreeHostImpl->renderer()) 728 if (!m_layerTreeHostImpl->renderer())
732 return result; 729 return result;
733 730
734 // FIXME: compute the frame display time more intelligently 731 // FIXME: compute the frame display time more intelligently
735 double monotonicTime = monotonicallyIncreasingTime(); 732 base::TimeTicks monotonicTime = base::TimeTicks::Now();
736 double wallClockTime = currentTime(); 733 base::Time wallClockTime = base::Time::Now();
737 734
738 if (m_inputHandlerOnImplThread.get()) 735 if (m_inputHandlerOnImplThread.get())
739 m_inputHandlerOnImplThread->animate(monotonicTime); 736 m_inputHandlerOnImplThread->animate(monotonicTime);
740 m_layerTreeHostImpl->animate(monotonicTime, wallClockTime); 737 m_layerTreeHostImpl->animate(monotonicTime, wallClockTime);
741 738
742 // This method is called on a forced draw, regardless of whether we are able to produce a frame, 739 // This method is called on a forced draw, regardless of whether we are able to produce a frame,
743 // as the calling site on main thread is blocked until its request completes , and we signal 740 // as the calling site on main thread is blocked until its request completes , and we signal
744 // completion here. If canDraw() is false, we will indicate success=false to the caller, but we 741 // completion here. If canDraw() is false, we will indicate success=false to the caller, but we
745 // must still signal completion to avoid deadlock. 742 // must still signal completion to avoid deadlock.
746 743
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 } 848 }
852 849
853 void ThreadProxy::didCompleteSwapBuffers() 850 void ThreadProxy::didCompleteSwapBuffers()
854 { 851 {
855 DCHECK(isMainThread()); 852 DCHECK(isMainThread());
856 if (!m_layerTreeHost) 853 if (!m_layerTreeHost)
857 return; 854 return;
858 m_layerTreeHost->didCompleteSwapBuffers(); 855 m_layerTreeHost->didCompleteSwapBuffers();
859 } 856 }
860 857
861 void ThreadProxy::setAnimationEvents(AnimationEventsVector* passed_events, doubl e wallClockTime) 858 void ThreadProxy::setAnimationEvents(AnimationEventsVector* passed_events, base: :Time wallClockTime)
862 { 859 {
863 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(passed_events)); 860 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(passed_events));
864 861
865 TRACE_EVENT0("cc", "ThreadProxy::setAnimationEvents"); 862 TRACE_EVENT0("cc", "ThreadProxy::setAnimationEvents");
866 DCHECK(isMainThread()); 863 DCHECK(isMainThread());
867 if (!m_layerTreeHost) 864 if (!m_layerTreeHost)
868 return; 865 return;
869 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime); 866 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime);
870 } 867 }
871 868
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 } 989 }
993 990
994 void ThreadProxy::renderingStatsOnImplThread(CompletionEvent* completion, Render ingStats* stats) 991 void ThreadProxy::renderingStatsOnImplThread(CompletionEvent* completion, Render ingStats* stats)
995 { 992 {
996 DCHECK(isImplThread()); 993 DCHECK(isImplThread());
997 m_layerTreeHostImpl->renderingStats(stats); 994 m_layerTreeHostImpl->renderingStats(stats);
998 completion->signal(); 995 completion->signal();
999 } 996 }
1000 997
1001 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() 998 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState()
1002 : monotonicFrameBeginTime(0)
1003 { 999 {
1004 } 1000 }
1005 1001
1006 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() 1002 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState()
1007 { 1003 {
1008 } 1004 }
1009 1005
1010 } // namespace cc 1006 } // namespace cc
OLDNEW
« no previous file with comments | « cc/thread_proxy.h ('k') | webkit/compositor_bindings/web_layer_tree_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698