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(); |
| 117 void ActivatePendingTree(); |
111 void DrawAndSwapIfPossible(); | 118 void DrawAndSwapIfPossible(); |
112 void DrawAndSwapForced(); | 119 void DrawAndSwapForced(); |
113 void DrawAndReadback(); | 120 void DrawAndReadback(); |
114 void ProcessScheduledActions(); | 121 void ProcessScheduledActions(); |
115 | 122 |
116 const SchedulerSettings settings_; | 123 const SchedulerSettings settings_; |
117 SchedulerClient* client_; | 124 SchedulerClient* client_; |
118 | 125 |
119 base::WeakPtrFactory<Scheduler> weak_factory_; | 126 base::WeakPtrFactory<Scheduler> weak_factory_; |
120 bool last_set_needs_begin_frame_; | 127 bool last_set_needs_begin_frame_; |
121 bool has_pending_begin_frame_; | 128 bool has_pending_begin_frame_; |
122 // TODO(brianderson): crbug.com/249806 : Remove safe_to_expect_begin_frame_ | 129 // TODO(brianderson): crbug.com/249806 : Remove safe_to_expect_begin_frame_ |
123 // workaround. | 130 // workaround. |
124 bool safe_to_expect_begin_frame_; | 131 bool safe_to_expect_begin_frame_; |
125 BeginFrameArgs last_begin_frame_args_; | 132 BeginFrameArgs last_begin_frame_args_; |
| 133 base::CancelableClosure begin_frame_deadline_closure_; |
126 | 134 |
127 SchedulerStateMachine state_machine_; | 135 SchedulerStateMachine state_machine_; |
128 bool inside_process_scheduled_actions_; | 136 bool inside_process_scheduled_actions_; |
129 | 137 |
130 DISALLOW_COPY_AND_ASSIGN(Scheduler); | 138 DISALLOW_COPY_AND_ASSIGN(Scheduler); |
131 }; | 139 }; |
132 | 140 |
133 } // namespace cc | 141 } // namespace cc |
134 | 142 |
135 #endif // CC_SCHEDULER_SCHEDULER_H_ | 143 #endif // CC_SCHEDULER_SCHEDULER_H_ |
OLD | NEW |