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

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

Issue 2971613002: Add command-line flag to force compositor framerate. (Closed)
Patch Set: change flag name to limit-fps Created 3 years, 5 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/compositor_switches.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>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
17 #include "base/stl_util.h" 17 #include "base/stl_util.h"
18 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/string_split.h" 19 #include "base/strings/string_split.h"
19 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
20 #include "base/sys_info.h" 21 #include "base/sys_info.h"
21 #include "base/trace_event/trace_event.h" 22 #include "base/trace_event/trace_event.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 #include "cc/animation/animation_host.h" 24 #include "cc/animation/animation_host.h"
24 #include "cc/animation/animation_id_provider.h" 25 #include "cc/animation/animation_id_provider.h"
25 #include "cc/animation/animation_timeline.h" 26 #include "cc/animation/animation_timeline.h"
26 #include "cc/base/switches.h" 27 #include "cc/base/switches.h"
27 #include "cc/input/input_handler.h" 28 #include "cc/input/input_handler.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 77
77 // This will ensure PictureLayers always can have LCD text, to match the 78 // This will ensure PictureLayers always can have LCD text, to match the
78 // previous behaviour with ContentLayers, where LCD-not-allowed notifications 79 // previous behaviour with ContentLayers, where LCD-not-allowed notifications
79 // were ignored. 80 // were ignored.
80 settings.layers_always_allowed_lcd_text = true; 81 settings.layers_always_allowed_lcd_text = true;
81 // Use occlusion to allow more overlapping windows to take less memory. 82 // Use occlusion to allow more overlapping windows to take less memory.
82 settings.use_occlusion_for_tile_prioritization = true; 83 settings.use_occlusion_for_tile_prioritization = true;
83 refresh_rate_ = context_factory_->GetRefreshRate(); 84 refresh_rate_ = context_factory_->GetRefreshRate();
84 settings.main_frame_before_activation_enabled = false; 85 settings.main_frame_before_activation_enabled = false;
85 86
87 if (command_line->HasSwitch(switches::kLimitFps)) {
88 std::string fps_str =
89 command_line->GetSwitchValueASCII(switches::kLimitFps);
90 double fps;
91 if (base::StringToDouble(fps_str, &fps) && fps > 0) {
92 forced_refresh_rate_ = fps;
93 }
94 }
95
86 if (command_line->HasSwitch(cc::switches::kUIShowCompositedLayerBorders)) { 96 if (command_line->HasSwitch(cc::switches::kUIShowCompositedLayerBorders)) {
87 std::string layer_borders_string = command_line->GetSwitchValueASCII( 97 std::string layer_borders_string = command_line->GetSwitchValueASCII(
88 cc::switches::kUIShowCompositedLayerBorders); 98 cc::switches::kUIShowCompositedLayerBorders);
89 std::vector<base::StringPiece> entries = base::SplitStringPiece( 99 std::vector<base::StringPiece> entries = base::SplitStringPiece(
90 layer_borders_string, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 100 layer_borders_string, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
91 if (entries.empty()) { 101 if (entries.empty()) {
92 settings.initial_debug_state.show_debug_borders.set(); 102 settings.initial_debug_state.show_debug_borders.set();
93 } else { 103 } else {
94 for (const auto& entry : entries) { 104 for (const auto& entry : entries) {
95 const struct { 105 const struct {
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 DCHECK_GT(interval.InMillisecondsF(), 0); 374 DCHECK_GT(interval.InMillisecondsF(), 0);
365 refresh_rate_ = 375 refresh_rate_ =
366 base::Time::kMillisecondsPerSecond / interval.InMillisecondsF(); 376 base::Time::kMillisecondsPerSecond / interval.InMillisecondsF();
367 if (context_factory_private_) 377 if (context_factory_private_)
368 context_factory_private_->SetAuthoritativeVSyncInterval(this, interval); 378 context_factory_private_->SetAuthoritativeVSyncInterval(this, interval);
369 vsync_manager_->SetAuthoritativeVSyncInterval(interval); 379 vsync_manager_->SetAuthoritativeVSyncInterval(interval);
370 } 380 }
371 381
372 void Compositor::SetDisplayVSyncParameters(base::TimeTicks timebase, 382 void Compositor::SetDisplayVSyncParameters(base::TimeTicks timebase,
373 base::TimeDelta interval) { 383 base::TimeDelta interval) {
384 if (forced_refresh_rate_) {
385 timebase = base::TimeTicks();
386 interval = base::TimeDelta::FromSeconds(1) / forced_refresh_rate_;
387 }
374 if (interval.is_zero()) { 388 if (interval.is_zero()) {
375 // TODO(brianderson): We should not be receiving 0 intervals. 389 // TODO(brianderson): We should not be receiving 0 intervals.
376 interval = cc::BeginFrameArgs::DefaultInterval(); 390 interval = cc::BeginFrameArgs::DefaultInterval();
377 } 391 }
378 DCHECK_GT(interval.InMillisecondsF(), 0); 392 DCHECK_GT(interval.InMillisecondsF(), 0);
379 refresh_rate_ = 393 refresh_rate_ =
380 base::Time::kMillisecondsPerSecond / interval.InMillisecondsF(); 394 base::Time::kMillisecondsPerSecond / interval.InMillisecondsF();
381 395
382 if (context_factory_private_) { 396 if (context_factory_private_) {
383 context_factory_private_->SetDisplayVSyncParameters(this, timebase, 397 context_factory_private_->SetDisplayVSyncParameters(this, timebase,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 void Compositor::TimeoutLocks() { 582 void Compositor::TimeoutLocks() {
569 // Make a copy, we're going to cause |active_locks_| to become 583 // Make a copy, we're going to cause |active_locks_| to become
570 // empty. 584 // empty.
571 std::vector<CompositorLock*> locks = active_locks_; 585 std::vector<CompositorLock*> locks = active_locks_;
572 for (auto* lock : locks) 586 for (auto* lock : locks)
573 lock->TimeoutLock(); 587 lock->TimeoutLock();
574 DCHECK(active_locks_.empty()); 588 DCHECK(active_locks_.empty());
575 } 589 }
576 590
577 } // namespace ui 591 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/compositor_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698