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

Side by Side Diff: blimp/engine/renderer/frame_scheduler.cc

Issue 2445093002: cc/blimp: Add synchronization for scroll/scale state. (Closed)
Patch Set: test compile Created 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/auto_reset.h" 5 #include "base/auto_reset.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "blimp/engine/renderer/frame_scheduler.h" 7 #include "blimp/engine/renderer/frame_scheduler.h"
8 8
9 namespace blimp { 9 namespace blimp {
10 namespace engine { 10 namespace engine {
11 namespace { 11 namespace {
12 // This is the temporary frame delay to keep pages which make animation requests 12 // This is the temporary frame delay to keep pages which make animation requests
13 // but don't mutate the state on the engine from running main frames 13 // but don't mutate the state on the engine from running main frames
14 // back-to-back. We need smarter throttling of engine updates. See 14 // back-to-back. We need smarter throttling of engine updates. See
15 // crbug.com/597829. 15 // crbug.com/597829.
16 constexpr base::TimeDelta kDefaultFrameDelay = 16 constexpr base::TimeDelta kDefaultFrameDelay =
17 base::TimeDelta::FromMilliseconds(30); 17 base::TimeDelta::FromMilliseconds(30);
18 } // namespace 18 } // namespace
19 19
20 FrameScheduler::FrameScheduler( 20 FrameScheduler::FrameScheduler(
21 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 21 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
22 FrameSchedulerClient* client) 22 FrameSchedulerClient* client)
23 : FrameScheduler(kDefaultFrameDelay, std::move(task_runner), client) {}
24
25 FrameScheduler::FrameScheduler(
26 base::TimeDelta frame_delay,
27 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
28 FrameSchedulerClient* client)
29 : next_frame_time_(base::TimeTicks::Now()), 23 : next_frame_time_(base::TimeTicks::Now()),
30 frame_delay_(frame_delay), 24 frame_delay_(kDefaultFrameDelay),
31 client_(client) { 25 client_(client) {
32 DCHECK(client_); 26 DCHECK(client_);
33 frame_tick_timer_.SetTaskRunner(std::move(task_runner)); 27 frame_tick_timer_.SetTaskRunner(std::move(task_runner));
34 } 28 }
35 29
36 FrameScheduler::~FrameScheduler() = default; 30 FrameScheduler::~FrameScheduler() = default;
37 31
38 void FrameScheduler::ScheduleFrameUpdate() { 32 void FrameScheduler::ScheduleFrameUpdate() {
39 if (needs_frame_update_) 33 if (needs_frame_update_)
40 return; 34 return;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 needs_frame_update_ = false; 84 needs_frame_update_ = false;
91 next_frame_time_ = base::TimeTicks::Now() + frame_delay_; 85 next_frame_time_ = base::TimeTicks::Now() + frame_delay_;
92 { 86 {
93 base::AutoReset<bool> in_frame_update(&in_frame_update_, true); 87 base::AutoReset<bool> in_frame_update(&in_frame_update_, true);
94 client_->StartFrameUpdate(); 88 client_->StartFrameUpdate();
95 } 89 }
96 } 90 }
97 91
98 } // namespace engine 92 } // namespace engine
99 } // namespace blimp 93 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/engine/renderer/frame_scheduler.h ('k') | blimp/engine/renderer/frame_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698