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

Side by Side Diff: cc/trees/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: Updated all 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
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | cc/trees/tree_synchronizer_unittest.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 "cc/trees/thread_proxy.h" 5 #include "cc/trees/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/base/thread.h" 10 #include "cc/base/thread.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 weak_factory_on_impl_thread_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 53 weak_factory_on_impl_thread_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
54 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 54 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
55 begin_frame_completion_event_on_impl_thread_(NULL), 55 begin_frame_completion_event_on_impl_thread_(NULL),
56 readback_request_on_impl_thread_(NULL), 56 readback_request_on_impl_thread_(NULL),
57 commit_completion_event_on_impl_thread_(NULL), 57 commit_completion_event_on_impl_thread_(NULL),
58 completion_event_for_commit_held_on_tree_activation_(NULL), 58 completion_event_for_commit_held_on_tree_activation_(NULL),
59 texture_acquisition_completion_event_on_impl_thread_(NULL), 59 texture_acquisition_completion_event_on_impl_thread_(NULL),
60 next_frame_is_newly_committed_frame_on_impl_thread_(false), 60 next_frame_is_newly_committed_frame_on_impl_thread_(false),
61 render_vsync_enabled_(layer_tree_host->settings().render_vsync_enabled), 61 render_vsync_enabled_(layer_tree_host->settings().render_vsync_enabled),
62 inside_draw_(false), 62 inside_draw_(false),
63 total_commit_count_(0),
64 defer_commits_(false), 63 defer_commits_(false),
65 renew_tree_priority_on_impl_thread_pending_(false) { 64 renew_tree_priority_on_impl_thread_pending_(false) {
66 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); 65 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy");
67 DCHECK(IsMainThread()); 66 DCHECK(IsMainThread());
68 } 67 }
69 68
70 ThreadProxy::~ThreadProxy() { 69 ThreadProxy::~ThreadProxy() {
71 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); 70 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy");
72 DCHECK(IsMainThread()); 71 DCHECK(IsMainThread());
73 DCHECK(!started_); 72 DCHECK(!started_);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 offscreen_context_provider, 270 offscreen_context_provider,
272 &recreate_succeeded, 271 &recreate_succeeded,
273 &capabilities)); 272 &capabilities));
274 completion.Wait(); 273 completion.Wait();
275 274
276 if (recreate_succeeded) 275 if (recreate_succeeded)
277 renderer_capabilities_main_thread_copy_ = capabilities; 276 renderer_capabilities_main_thread_copy_ = capabilities;
278 return recreate_succeeded; 277 return recreate_succeeded;
279 } 278 }
280 279
281 void ThreadProxy::CollectRenderingStats(RenderingStats* stats) {
282 DCHECK(IsMainThread());
283
284 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
285 CompletionEvent completion;
286 Proxy::ImplThread()->PostTask(
287 base::Bind(&ThreadProxy::RenderingStatsOnImplThread,
288 impl_thread_weak_ptr_,
289 &completion,
290 stats));
291 stats->totalCommitTime = total_commit_time_;
292 stats->totalCommitCount = total_commit_count_;
293
294 completion.Wait();
295 }
296
297 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const { 280 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const {
298 DCHECK(renderer_initialized_); 281 DCHECK(renderer_initialized_);
299 return renderer_capabilities_main_thread_copy_; 282 return renderer_capabilities_main_thread_copy_;
300 } 283 }
301 284
302 void ThreadProxy::SetNeedsAnimate() { 285 void ThreadProxy::SetNeedsAnimate() {
303 DCHECK(IsMainThread()); 286 DCHECK(IsMainThread());
304 if (animate_requested_) 287 if (animate_requested_)
305 return; 288 return;
306 289
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 718
736 // Notify the impl thread that the beginFrame has completed. This will 719 // Notify the impl thread that the beginFrame has completed. This will
737 // begin the commit process, which is blocking from the main thread's 720 // begin the commit process, which is blocking from the main thread's
738 // point of view, but asynchronously performed on the impl thread, 721 // point of view, but asynchronously performed on the impl thread,
739 // coordinated by the Scheduler. 722 // coordinated by the Scheduler.
740 { 723 {
741 TRACE_EVENT0("cc", "commit"); 724 TRACE_EVENT0("cc", "commit");
742 725
743 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 726 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
744 727
745 base::TimeTicks start_time = base::TimeTicks::HighResNow(); 728 RenderingStatsInstrumentation* stats_instrumentation =
729 layer_tree_host_->rendering_stats_instrumentation();
730 base::TimeTicks start_time = stats_instrumentation->StartRecording();
731
746 CompletionEvent completion; 732 CompletionEvent completion;
747 Proxy::ImplThread()->PostTask( 733 Proxy::ImplThread()->PostTask(
748 base::Bind(&ThreadProxy::BeginFrameCompleteOnImplThread, 734 base::Bind(&ThreadProxy::BeginFrameCompleteOnImplThread,
749 impl_thread_weak_ptr_, 735 impl_thread_weak_ptr_,
750 &completion, 736 &completion,
751 queue.release(), 737 queue.release(),
752 offscreen_context_provider)); 738 offscreen_context_provider));
753 completion.Wait(); 739 completion.Wait();
754 740
755 base::TimeTicks end_time = base::TimeTicks::HighResNow(); 741 base::TimeDelta duration = stats_instrumentation->EndRecording(start_time);
756 total_commit_time_ += end_time - start_time; 742 stats_instrumentation->AddCommit(duration);
757 total_commit_count_++;
758 } 743 }
759 744
760 layer_tree_host_->CommitComplete(); 745 layer_tree_host_->CommitComplete();
761 layer_tree_host_->DidBeginFrame(); 746 layer_tree_host_->DidBeginFrame();
762 } 747 }
763 748
764 void ThreadProxy::BeginFrameCompleteOnImplThread( 749 void ThreadProxy::BeginFrameCompleteOnImplThread(
765 CompletionEvent* completion, 750 CompletionEvent* completion,
766 ResourceUpdateQueue* raw_queue, 751 ResourceUpdateQueue* raw_queue,
767 scoped_refptr<cc::ContextProvider> offscreen_context_provider) { 752 scoped_refptr<cc::ContextProvider> offscreen_context_provider) {
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 *capabilities = layer_tree_host_impl_->GetRendererCapabilities(); 1162 *capabilities = layer_tree_host_impl_->GetRendererCapabilities();
1178 layer_tree_host_impl_->resource_provider()-> 1163 layer_tree_host_impl_->resource_provider()->
1179 set_offscreen_context_provider(offscreen_context_provider); 1164 set_offscreen_context_provider(offscreen_context_provider);
1180 scheduler_on_impl_thread_->DidRecreateOutputSurface(); 1165 scheduler_on_impl_thread_->DidRecreateOutputSurface();
1181 } else if (offscreen_context_provider) { 1166 } else if (offscreen_context_provider) {
1182 offscreen_context_provider->VerifyContexts(); 1167 offscreen_context_provider->VerifyContexts();
1183 } 1168 }
1184 completion->Signal(); 1169 completion->Signal();
1185 } 1170 }
1186 1171
1187 void ThreadProxy::RenderingStatsOnImplThread(CompletionEvent* completion,
1188 RenderingStats* stats) {
1189 DCHECK(IsImplThread());
1190 layer_tree_host_impl_->CollectRenderingStats(stats);
1191 completion->Signal();
1192 }
1193
1194 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() 1172 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState()
1195 : memory_allocation_limit_bytes(0) {} 1173 : memory_allocation_limit_bytes(0) {}
1196 1174
1197 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() {} 1175 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() {}
1198 1176
1199 scoped_ptr<base::Value> ThreadProxy::AsValue() const { 1177 scoped_ptr<base::Value> ThreadProxy::AsValue() const {
1200 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 1178 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
1201 1179
1202 CompletionEvent completion; 1180 CompletionEvent completion;
1203 { 1181 {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, 1311 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread,
1334 impl_thread_weak_ptr_), 1312 impl_thread_weak_ptr_),
1335 delay); 1313 delay);
1336 } 1314 }
1337 1315
1338 void ThreadProxy::StartScrollbarAnimationOnImplThread() { 1316 void ThreadProxy::StartScrollbarAnimationOnImplThread() {
1339 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now()); 1317 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now());
1340 } 1318 }
1341 1319
1342 } // namespace cc 1320 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | cc/trees/tree_synchronizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698