OLD | NEW |
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 #ifndef CC_SCHEDULER_SCHEDULER_H_ | 5 #ifndef CC_SCHEDULER_SCHEDULER_H_ |
6 #define CC_SCHEDULER_SCHEDULER_H_ | 6 #define CC_SCHEDULER_SCHEDULER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/cancelable_callback.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
13 #include "cc/base/cc_export.h" | 14 #include "cc/base/cc_export.h" |
14 #include "cc/output/begin_frame_args.h" | 15 #include "cc/output/begin_frame_args.h" |
15 #include "cc/scheduler/scheduler_settings.h" | 16 #include "cc/scheduler/scheduler_settings.h" |
16 #include "cc/scheduler/scheduler_state_machine.h" | 17 #include "cc/scheduler/scheduler_state_machine.h" |
17 #include "cc/trees/layer_tree_host.h" | 18 #include "cc/trees/layer_tree_host.h" |
18 | 19 |
19 namespace cc { | 20 namespace cc { |
20 | 21 |
(...skipping 18 matching lines...) Expand all Loading... |
39 virtual DrawSwapReadbackResult ScheduledActionDrawAndReadback() = 0; | 40 virtual DrawSwapReadbackResult ScheduledActionDrawAndReadback() = 0; |
40 virtual void ScheduledActionCommit() = 0; | 41 virtual void ScheduledActionCommit() = 0; |
41 virtual void ScheduledActionUpdateVisibleTiles() = 0; | 42 virtual void ScheduledActionUpdateVisibleTiles() = 0; |
42 virtual void ScheduledActionActivatePendingTree() = 0; | 43 virtual void ScheduledActionActivatePendingTree() = 0; |
43 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0; | 44 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0; |
44 virtual void ScheduledActionAcquireLayerTexturesForMainThread() = 0; | 45 virtual void ScheduledActionAcquireLayerTexturesForMainThread() = 0; |
45 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0; | 46 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0; |
46 virtual base::TimeDelta DrawDurationEstimate() = 0; | 47 virtual base::TimeDelta DrawDurationEstimate() = 0; |
47 virtual base::TimeDelta BeginFrameToCommitDurationEstimate() = 0; | 48 virtual base::TimeDelta BeginFrameToCommitDurationEstimate() = 0; |
48 virtual base::TimeDelta CommitToActivateDurationEstimate() = 0; | 49 virtual base::TimeDelta CommitToActivateDurationEstimate() = 0; |
| 50 virtual void PostBeginFrameDeadline(const base::Closure& closure, |
| 51 base::TimeTicks deadline) = 0; |
| 52 virtual void DidBeginFrameDeadlineOnImplThread() = 0; |
49 | 53 |
50 protected: | 54 protected: |
51 virtual ~SchedulerClient() {} | 55 virtual ~SchedulerClient() {} |
52 }; | 56 }; |
53 | 57 |
54 class CC_EXPORT Scheduler { | 58 class CC_EXPORT Scheduler { |
55 public: | 59 public: |
56 static scoped_ptr<Scheduler> Create( | 60 static scoped_ptr<Scheduler> Create( |
57 SchedulerClient* client, | 61 SchedulerClient* client, |
58 const SchedulerSettings& scheduler_settings) { | 62 const SchedulerSettings& scheduler_settings) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 bool CommitPending() const { return state_machine_.CommitPending(); } | 95 bool CommitPending() const { return state_machine_.CommitPending(); } |
92 bool RedrawPending() const { return state_machine_.RedrawPending(); } | 96 bool RedrawPending() const { return state_machine_.RedrawPending(); } |
93 | 97 |
94 bool WillDrawIfNeeded() const; | 98 bool WillDrawIfNeeded() const; |
95 | 99 |
96 base::TimeTicks AnticipatedDrawTime(); | 100 base::TimeTicks AnticipatedDrawTime(); |
97 | 101 |
98 base::TimeTicks LastBeginFrameOnImplThreadTime(); | 102 base::TimeTicks LastBeginFrameOnImplThreadTime(); |
99 | 103 |
100 void BeginFrame(const BeginFrameArgs& args); | 104 void BeginFrame(const BeginFrameArgs& args); |
| 105 void OnBeginFrameDeadline(); |
101 | 106 |
102 scoped_ptr<base::Value> StateAsValue() { | 107 scoped_ptr<base::Value> StateAsValue() { |
103 return state_machine_.AsValue().Pass(); | 108 return state_machine_.AsValue().Pass(); |
104 } | 109 } |
105 | 110 |
106 private: | 111 private: |
107 Scheduler(SchedulerClient* client, | 112 Scheduler(SchedulerClient* client, |
108 const SchedulerSettings& scheduler_settings); | 113 const SchedulerSettings& scheduler_settings); |
109 | 114 |
| 115 void PostBeginFrameDeadline(base::TimeTicks deadline); |
110 void SetupNextBeginFrameIfNeeded(); | 116 void SetupNextBeginFrameIfNeeded(); |
111 void DrawAndSwapIfPossible(); | 117 void DrawAndSwapIfPossible(); |
112 void DrawAndSwapForced(); | 118 void DrawAndSwapForced(); |
113 void ProcessScheduledActions(); | 119 void ProcessScheduledActions(); |
114 | 120 |
115 const SchedulerSettings settings_; | 121 const SchedulerSettings settings_; |
116 SchedulerClient* client_; | 122 SchedulerClient* client_; |
117 | 123 |
118 base::WeakPtrFactory<Scheduler> weak_factory_; | 124 base::WeakPtrFactory<Scheduler> weak_factory_; |
119 bool last_set_needs_begin_frame_; | 125 bool last_set_needs_begin_frame_; |
120 bool has_pending_begin_frame_; | 126 bool has_pending_begin_frame_; |
121 // TODO(brianderson): crbug.com/249806 : Remove safe_to_expect_begin_frame_ | 127 // TODO(brianderson): crbug.com/249806 : Remove safe_to_expect_begin_frame_ |
122 // workaround. | 128 // workaround. |
123 bool safe_to_expect_begin_frame_; | 129 bool safe_to_expect_begin_frame_; |
124 BeginFrameArgs last_begin_frame_args_; | 130 BeginFrameArgs last_begin_frame_args_; |
| 131 base::CancelableClosure begin_frame_deadline_closure_; |
125 | 132 |
126 SchedulerStateMachine state_machine_; | 133 SchedulerStateMachine state_machine_; |
127 bool inside_process_scheduled_actions_; | 134 bool inside_process_scheduled_actions_; |
128 | 135 |
129 DISALLOW_COPY_AND_ASSIGN(Scheduler); | 136 DISALLOW_COPY_AND_ASSIGN(Scheduler); |
130 }; | 137 }; |
131 | 138 |
132 } // namespace cc | 139 } // namespace cc |
133 | 140 |
134 #endif // CC_SCHEDULER_SCHEDULER_H_ | 141 #endif // CC_SCHEDULER_SCHEDULER_H_ |
OLD | NEW |