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

Side by Side Diff: ui/compositor/compositor.cc

Issue 2631333002: [animations] Adds metrics for jank on selected layer animations (Closed)
Patch Set: Adds UMA reporting for ripples and overview mode (query refresh rate) Created 3 years, 10 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 | « ui/compositor/compositor.h ('k') | ui/compositor/layer.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/compositor/compositor.h" 5 #include "ui/compositor/compositor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <deque> 10 #include <deque>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 Compositor::Compositor(const cc::FrameSinkId& frame_sink_id, 75 Compositor::Compositor(const cc::FrameSinkId& frame_sink_id,
76 ui::ContextFactory* context_factory, 76 ui::ContextFactory* context_factory,
77 ui::ContextFactoryPrivate* context_factory_private, 77 ui::ContextFactoryPrivate* context_factory_private,
78 scoped_refptr<base::SingleThreadTaskRunner> task_runner) 78 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
79 : context_factory_(context_factory), 79 : context_factory_(context_factory),
80 context_factory_private_(context_factory_private), 80 context_factory_private_(context_factory_private),
81 root_layer_(NULL), 81 root_layer_(NULL),
82 widget_(gfx::kNullAcceleratedWidget), 82 widget_(gfx::kNullAcceleratedWidget),
83 committed_frame_number_(0),
83 widget_valid_(false), 84 widget_valid_(false),
84 compositor_frame_sink_requested_(false), 85 compositor_frame_sink_requested_(false),
85 frame_sink_id_(frame_sink_id), 86 frame_sink_id_(frame_sink_id),
86 task_runner_(task_runner), 87 task_runner_(task_runner),
87 vsync_manager_(new CompositorVSyncManager()), 88 vsync_manager_(new CompositorVSyncManager()),
88 device_scale_factor_(0.0f), 89 device_scale_factor_(0.0f),
89 locks_will_time_out_(true), 90 locks_will_time_out_(true),
90 compositor_lock_(NULL), 91 compositor_lock_(NULL),
91 layer_animator_collection_(this), 92 layer_animator_collection_(this),
92 weak_ptr_factory_(this) { 93 weak_ptr_factory_(this) {
93 if (context_factory_private) { 94 if (context_factory_private) {
94 context_factory_private->GetSurfaceManager()->RegisterFrameSinkId( 95 context_factory_private->GetSurfaceManager()->RegisterFrameSinkId(
95 frame_sink_id_); 96 frame_sink_id_);
96 } 97 }
97 root_web_layer_ = cc::Layer::Create(); 98 root_web_layer_ = cc::Layer::Create();
98 99
99 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 100 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
100 101
101 cc::LayerTreeSettings settings; 102 cc::LayerTreeSettings settings;
102 103
103 // This will ensure PictureLayers always can have LCD text, to match the 104 // This will ensure PictureLayers always can have LCD text, to match the
104 // previous behaviour with ContentLayers, where LCD-not-allowed notifications 105 // previous behaviour with ContentLayers, where LCD-not-allowed notifications
105 // were ignored. 106 // were ignored.
106 settings.layers_always_allowed_lcd_text = true; 107 settings.layers_always_allowed_lcd_text = true;
107 // Use occlusion to allow more overlapping windows to take less memory. 108 // Use occlusion to allow more overlapping windows to take less memory.
108 settings.use_occlusion_for_tile_prioritization = true; 109 settings.use_occlusion_for_tile_prioritization = true;
109 settings.renderer_settings.refresh_rate = 110 refresh_rate_ = settings.renderer_settings.refresh_rate =
110 context_factory_->DoesCreateTestContexts() ? kTestRefreshRate 111 context_factory_->DoesCreateTestContexts() ? kTestRefreshRate
111 : kDefaultRefreshRate; 112 : kDefaultRefreshRate;
112 settings.main_frame_before_activation_enabled = false; 113 settings.main_frame_before_activation_enabled = false;
113 if (command_line->HasSwitch(switches::kDisableGpuVsync)) { 114 if (command_line->HasSwitch(switches::kDisableGpuVsync)) {
114 std::string display_vsync_string = 115 std::string display_vsync_string =
115 command_line->GetSwitchValueASCII(switches::kDisableGpuVsync); 116 command_line->GetSwitchValueASCII(switches::kDisableGpuVsync);
116 // See comments in gl_switches about this flag. The browser compositor 117 // See comments in gl_switches about this flag. The browser compositor
117 // is only unthrottled when "gpu" or no switch value is passed, as it 118 // is only unthrottled when "gpu" or no switch value is passed, as it
118 // is driven directly by the display compositor. 119 // is driven directly by the display compositor.
119 if (display_vsync_string != "beginframe") { 120 if (display_vsync_string != "beginframe") {
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 return host_->GetInputHandler()->ScrollLayerTo(layer_id, offset); 383 return host_->GetInputHandler()->ScrollLayerTo(layer_id, offset);
383 } 384 }
384 385
385 bool Compositor::GetScrollOffsetForLayer(int layer_id, 386 bool Compositor::GetScrollOffsetForLayer(int layer_id,
386 gfx::ScrollOffset* offset) const { 387 gfx::ScrollOffset* offset) const {
387 return host_->GetInputHandler()->GetScrollOffsetForLayer(layer_id, offset); 388 return host_->GetInputHandler()->GetScrollOffsetForLayer(layer_id, offset);
388 } 389 }
389 390
390 void Compositor::SetAuthoritativeVSyncInterval( 391 void Compositor::SetAuthoritativeVSyncInterval(
391 const base::TimeDelta& interval) { 392 const base::TimeDelta& interval) {
393 DCHECK_GT(interval.InMillisecondsF(), 0);
394 refresh_rate_ =
395 base::Time::kMillisecondsPerSecond / interval.InMillisecondsF();
392 if (context_factory_private_) 396 if (context_factory_private_)
393 context_factory_private_->SetAuthoritativeVSyncInterval(this, interval); 397 context_factory_private_->SetAuthoritativeVSyncInterval(this, interval);
394 vsync_manager_->SetAuthoritativeVSyncInterval(interval); 398 vsync_manager_->SetAuthoritativeVSyncInterval(interval);
395 } 399 }
396 400
397 void Compositor::SetDisplayVSyncParameters(base::TimeTicks timebase, 401 void Compositor::SetDisplayVSyncParameters(base::TimeTicks timebase,
398 base::TimeDelta interval) { 402 base::TimeDelta interval) {
399 if (interval.is_zero()) { 403 if (interval.is_zero()) {
400 // TODO(brianderson): We should not be receiving 0 intervals. 404 // TODO(brianderson): We should not be receiving 0 intervals.
401 interval = cc::BeginFrameArgs::DefaultInterval(); 405 interval = cc::BeginFrameArgs::DefaultInterval();
402 } 406 }
407 DCHECK_GT(interval.InMillisecondsF(), 0);
408 refresh_rate_ =
409 base::Time::kMillisecondsPerSecond / interval.InMillisecondsF();
403 410
404 if (context_factory_private_) { 411 if (context_factory_private_) {
405 context_factory_private_->SetDisplayVSyncParameters(this, timebase, 412 context_factory_private_->SetDisplayVSyncParameters(this, timebase,
406 interval); 413 interval);
407 } 414 }
408 vsync_manager_->UpdateVSyncParameters(timebase, interval); 415 vsync_manager_->UpdateVSyncParameters(timebase, interval);
409 } 416 }
410 417
411 void Compositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) { 418 void Compositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) {
412 // This function should only get called once. 419 // This function should only get called once.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 NOTREACHED(); 506 NOTREACHED();
500 } 507 }
501 508
502 void Compositor::DidCommit() { 509 void Compositor::DidCommit() {
503 DCHECK(!IsLocked()); 510 DCHECK(!IsLocked());
504 for (auto& observer : observer_list_) 511 for (auto& observer : observer_list_)
505 observer.OnCompositingDidCommit(this); 512 observer.OnCompositingDidCommit(this);
506 } 513 }
507 514
508 void Compositor::DidReceiveCompositorFrameAck() { 515 void Compositor::DidReceiveCompositorFrameAck() {
516 ++committed_frame_number_;
509 for (auto& observer : observer_list_) 517 for (auto& observer : observer_list_)
510 observer.OnCompositingEnded(this); 518 observer.OnCompositingEnded(this);
511 } 519 }
512 520
513 void Compositor::DidSubmitCompositorFrame() { 521 void Compositor::DidSubmitCompositorFrame() {
514 base::TimeTicks start_time = base::TimeTicks::Now(); 522 base::TimeTicks start_time = base::TimeTicks::Now();
515 for (auto& observer : observer_list_) 523 for (auto& observer : observer_list_)
516 observer.OnCompositingStarted(this, start_time); 524 observer.OnCompositingStarted(this, start_time);
517 } 525 }
518 526
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 for (auto& observer : observer_list_) 559 for (auto& observer : observer_list_)
552 observer.OnCompositingLockStateChanged(this); 560 observer.OnCompositingLockStateChanged(this);
553 } 561 }
554 562
555 void Compositor::CancelCompositorLock() { 563 void Compositor::CancelCompositorLock() {
556 if (compositor_lock_) 564 if (compositor_lock_)
557 compositor_lock_->CancelLock(); 565 compositor_lock_->CancelLock();
558 } 566 }
559 567
560 } // namespace ui 568 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698