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

Side by Side Diff: cc/thread_proxy.cc

Issue 12519006: cc:: Add RenderingStatsInstrumentation to manage collection of RenderingStats (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Early out in methods, pass raw pointers, updated tests Created 7 years, 9 months 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
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 "cc/thread_proxy.h" 5 #include "cc/thread_proxy.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/context_provider.h" 10 #include "cc/context_provider.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 , m_weakFactoryOnImplThread(ALLOW_THIS_IN_INITIALIZER_LIST(this)) 51 , m_weakFactoryOnImplThread(ALLOW_THIS_IN_INITIALIZER_LIST(this))
52 , m_weakFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)) 52 , m_weakFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this))
53 , m_beginFrameCompletionEventOnImplThread(0) 53 , m_beginFrameCompletionEventOnImplThread(0)
54 , m_readbackRequestOnImplThread(0) 54 , m_readbackRequestOnImplThread(0)
55 , m_commitCompletionEventOnImplThread(0) 55 , m_commitCompletionEventOnImplThread(0)
56 , m_completionEventForCommitHeldOnTreeActivation(0) 56 , m_completionEventForCommitHeldOnTreeActivation(0)
57 , m_textureAcquisitionCompletionEventOnImplThread(0) 57 , m_textureAcquisitionCompletionEventOnImplThread(0)
58 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) 58 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false)
59 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) 59 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled)
60 , m_insideDraw(false) 60 , m_insideDraw(false)
61 , m_totalCommitCount(0)
62 , m_deferCommits(false) 61 , m_deferCommits(false)
63 , m_renewTreePriorityOnImplThreadPending(false) 62 , m_renewTreePriorityOnImplThreadPending(false)
64 { 63 {
65 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); 64 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy");
66 DCHECK(IsMainThread()); 65 DCHECK(IsMainThread());
67 } 66 }
68 67
69 ThreadProxy::~ThreadProxy() 68 ThreadProxy::~ThreadProxy()
70 { 69 {
71 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); 70 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy");
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 offscreenContextProvider, 247 offscreenContextProvider,
249 &recreateSucceeded, 248 &recreateSucceeded,
250 &capabilities)); 249 &capabilities));
251 completion.wait(); 250 completion.wait();
252 251
253 if (recreateSucceeded) 252 if (recreateSucceeded)
254 m_RendererCapabilitiesMainThreadCopy = capabilities; 253 m_RendererCapabilitiesMainThreadCopy = capabilities;
255 return recreateSucceeded; 254 return recreateSucceeded;
256 } 255 }
257 256
258 void ThreadProxy::GetRenderingStats(RenderingStats* stats)
259 {
260 DCHECK(IsMainThread());
261
262 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
263 CompletionEvent completion;
264 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::renderingStatsOnImplT hread,
265 m_implThreadWeakPtr, &completion, stats));
266 stats->totalCommitTime = m_totalCommitTime;
267 stats->totalCommitCount = m_totalCommitCount;
268
269 completion.wait();
270 }
271
272 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const 257 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const
273 { 258 {
274 DCHECK(m_rendererInitialized); 259 DCHECK(m_rendererInitialized);
275 return m_RendererCapabilitiesMainThreadCopy; 260 return m_RendererCapabilitiesMainThreadCopy;
276 } 261 }
277 262
278 void ThreadProxy::SetNeedsAnimate() 263 void ThreadProxy::SetNeedsAnimate()
279 { 264 {
280 DCHECK(IsMainThread()); 265 DCHECK(IsMainThread());
281 if (m_animateRequested) 266 if (m_animateRequested)
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 669
685 // Notify the impl thread that the beginFrame has completed. This will 670 // Notify the impl thread that the beginFrame has completed. This will
686 // begin the commit process, which is blocking from the main thread's 671 // begin the commit process, which is blocking from the main thread's
687 // point of view, but asynchronously performed on the impl thread, 672 // point of view, but asynchronously performed on the impl thread,
688 // coordinated by the Scheduler. 673 // coordinated by the Scheduler.
689 { 674 {
690 TRACE_EVENT0("cc", "commit"); 675 TRACE_EVENT0("cc", "commit");
691 676
692 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); 677 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
693 678
694 base::TimeTicks startTime = base::TimeTicks::HighResNow(); 679 RenderingStatsRecorder* statsRecorder = m_layerTreeHost->renderingStatsR ecorder();
680 base::TimeTicks startTime = statsRecorder->StartRecording();
681
695 CompletionEvent completion; 682 CompletionEvent completion;
696 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::beginFrameComplet eOnImplThread, m_implThreadWeakPtr, &completion, queue.release(), offscreenConte xtProvider)); 683 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::beginFrameComplet eOnImplThread, m_implThreadWeakPtr, &completion, queue.release(), offscreenConte xtProvider));
697 completion.wait(); 684 completion.wait();
698 base::TimeTicks endTime = base::TimeTicks::HighResNow();
699 685
700 m_totalCommitTime += endTime - startTime; 686 base::TimeDelta duration = statsRecorder->EndRecording(startTime);
701 m_totalCommitCount++; 687 statsRecorder->AddCommit(duration);
702 } 688 }
703 689
704 m_layerTreeHost->commitComplete(); 690 m_layerTreeHost->commitComplete();
705 m_layerTreeHost->didBeginFrame(); 691 m_layerTreeHost->didBeginFrame();
706 } 692 }
707 693
708 void ThreadProxy::beginFrameCompleteOnImplThread(CompletionEvent* completion, Re sourceUpdateQueue* rawQueue, scoped_refptr<cc::ContextProvider> offscreenContext Provider) 694 void ThreadProxy::beginFrameCompleteOnImplThread(CompletionEvent* completion, Re sourceUpdateQueue* rawQueue, scoped_refptr<cc::ContextProvider> offscreenContext Provider)
709 { 695 {
710 scoped_ptr<ResourceUpdateQueue> queue(rawQueue); 696 scoped_ptr<ResourceUpdateQueue> queue(rawQueue);
711 697
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 if (*recreateSucceeded) { 1067 if (*recreateSucceeded) {
1082 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); 1068 *capabilities = m_layerTreeHostImpl->rendererCapabilities();
1083 m_layerTreeHostImpl->resourceProvider()->SetOffscreenContextProvider(off screenContextProvider); 1069 m_layerTreeHostImpl->resourceProvider()->SetOffscreenContextProvider(off screenContextProvider);
1084 m_schedulerOnImplThread->didRecreateOutputSurface(); 1070 m_schedulerOnImplThread->didRecreateOutputSurface();
1085 } else if (offscreenContextProvider) { 1071 } else if (offscreenContextProvider) {
1086 offscreenContextProvider->VerifyContexts(); 1072 offscreenContextProvider->VerifyContexts();
1087 } 1073 }
1088 completion->signal(); 1074 completion->signal();
1089 } 1075 }
1090 1076
1091 void ThreadProxy::renderingStatsOnImplThread(CompletionEvent* completion, Render ingStats* stats)
1092 {
1093 DCHECK(IsImplThread());
1094 m_layerTreeHostImpl->renderingStats(stats);
1095 completion->signal();
1096 }
1097
1098 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() 1077 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState()
1099 : memoryAllocationLimitBytes(0) 1078 : memoryAllocationLimitBytes(0)
1100 { 1079 {
1101 } 1080 }
1102 1081
1103 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() 1082 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState()
1104 { 1083 {
1105 } 1084 }
1106 1085
1107 scoped_ptr<base::Value> ThreadProxy::AsValue() const 1086 scoped_ptr<base::Value> ThreadProxy::AsValue() const
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 1208
1230 void ThreadProxy::renewTreePriorityOnImplThread() 1209 void ThreadProxy::renewTreePriorityOnImplThread()
1231 { 1210 {
1232 DCHECK(m_renewTreePriorityOnImplThreadPending); 1211 DCHECK(m_renewTreePriorityOnImplThreadPending);
1233 m_renewTreePriorityOnImplThreadPending = false; 1212 m_renewTreePriorityOnImplThreadPending = false;
1234 1213
1235 renewTreePriority(); 1214 renewTreePriority();
1236 } 1215 }
1237 1216
1238 } // namespace cc 1217 } // namespace cc
OLDNEW
« cc/rendering_stats_recorder.cc ('K') | « cc/thread_proxy.h ('k') | cc/tile_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698