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.h" | 13 #include "base/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 ScheduledActionDrawAndSwapIfPossible() = 0; | 40 ScheduledActionDrawAndSwapIfPossible() = 0; |
40 virtual ScheduledActionDrawAndSwapResult | 41 virtual ScheduledActionDrawAndSwapResult |
41 ScheduledActionDrawAndSwapForced() = 0; | 42 ScheduledActionDrawAndSwapForced() = 0; |
42 virtual void ScheduledActionCommit() = 0; | 43 virtual void ScheduledActionCommit() = 0; |
43 virtual void ScheduledActionCheckForCompletedTileUploads() = 0; | 44 virtual void ScheduledActionCheckForCompletedTileUploads() = 0; |
44 virtual void ScheduledActionActivatePendingTreeIfNeeded() = 0; | 45 virtual void ScheduledActionActivatePendingTreeIfNeeded() = 0; |
45 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0; | 46 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0; |
46 virtual void ScheduledActionAcquireLayerTexturesForMainThread() = 0; | 47 virtual void ScheduledActionAcquireLayerTexturesForMainThread() = 0; |
47 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0; | 48 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0; |
48 virtual base::TimeDelta DrawDurationEstimate() = 0; | 49 virtual base::TimeDelta DrawDurationEstimate() = 0; |
| 50 virtual void PostBeginFrameDeadline(const base::Closure& closure, |
| 51 base::TimeTicks deadline) = 0; |
| 52 virtual void DidFinishBeginFrameOnImplThread() = 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) { |
59 return make_scoped_ptr(new Scheduler(client, scheduler_settings)); | 63 return make_scoped_ptr(new Scheduler(client, scheduler_settings)); |
60 } | 64 } |
61 | 65 |
62 virtual ~Scheduler(); | 66 virtual ~Scheduler(); |
63 | 67 |
64 void SetCanStart(); | 68 void SetCanStart(); |
65 | 69 |
66 void SetVisible(bool visible); | 70 void SetVisible(bool visible); |
67 void SetCanDraw(bool can_draw); | 71 void SetCanDraw(bool can_draw); |
68 void SetHasPendingTree(bool has_pending_tree); | 72 void SetHasTrees(bool has_pending_tree, bool active_tree_is_null); |
69 | 73 |
70 void SetNeedsCommit(); | 74 void SetNeedsCommit(); |
71 | 75 |
72 // Like SetNeedsCommit(), but ensures a commit will definitely happen even if | 76 // Like SetNeedsCommit(), but ensures a commit will definitely happen even if |
73 // we are not visible. | 77 // we are not visible. |
74 void SetNeedsForcedCommit(); | 78 void SetNeedsForcedCommit(); |
75 | 79 |
76 void SetNeedsRedraw(); | 80 void SetNeedsRedraw(); |
77 | 81 |
78 void SetMainThreadNeedsLayerTextures(); | 82 void SetMainThreadNeedsLayerTextures(); |
(...skipping 16 matching lines...) Expand all Loading... |
95 bool CommitPending() const { return state_machine_.CommitPending(); } | 99 bool CommitPending() const { return state_machine_.CommitPending(); } |
96 bool RedrawPending() const { return state_machine_.RedrawPending(); } | 100 bool RedrawPending() const { return state_machine_.RedrawPending(); } |
97 | 101 |
98 bool WillDrawIfNeeded() const; | 102 bool WillDrawIfNeeded() const; |
99 | 103 |
100 base::TimeTicks AnticipatedDrawTime(); | 104 base::TimeTicks AnticipatedDrawTime(); |
101 | 105 |
102 base::TimeTicks LastBeginFrameOnImplThreadTime(); | 106 base::TimeTicks LastBeginFrameOnImplThreadTime(); |
103 | 107 |
104 void BeginFrame(const BeginFrameArgs& args); | 108 void BeginFrame(const BeginFrameArgs& args); |
| 109 void OnBeginFrameDeadline(); |
105 | 110 |
106 std::string StateAsStringForTesting() { return state_machine_.ToString(); } | 111 std::string StateAsStringForTesting() { return state_machine_.ToString(); } |
107 | 112 |
108 private: | 113 private: |
109 Scheduler(SchedulerClient* client, | 114 Scheduler(SchedulerClient* client, |
110 const SchedulerSettings& scheduler_settings); | 115 const SchedulerSettings& scheduler_settings); |
111 | 116 |
| 117 void PostBeginFrameDeadline(base::TimeTicks deadline); |
112 void SetupNextBeginFrameIfNeeded(); | 118 void SetupNextBeginFrameIfNeeded(); |
113 void DrawAndSwapIfPossible(); | 119 void DrawAndSwapIfPossible(); |
114 void DrawAndSwapForced(); | 120 void DrawAndSwapForced(); |
115 void ProcessScheduledActions(); | 121 void ProcessScheduledActions(); |
116 | 122 |
117 const SchedulerSettings settings_; | 123 const SchedulerSettings settings_; |
118 SchedulerClient* client_; | 124 SchedulerClient* client_; |
119 | 125 |
120 base::WeakPtrFactory<Scheduler> weak_factory_; | 126 base::WeakPtrFactory<Scheduler> weak_factory_; |
121 bool last_set_needs_begin_frame_; | 127 bool last_set_needs_begin_frame_; |
122 bool has_pending_begin_frame_; | 128 bool has_pending_begin_frame_; |
123 // TODO(brianderson): crbug.com/249806 : Remove safe_to_expect_begin_frame_ | 129 // TODO(brianderson): crbug.com/249806 : Remove safe_to_expect_begin_frame_ |
124 // workaround. | 130 // workaround. |
125 bool safe_to_expect_begin_frame_; | 131 bool safe_to_expect_begin_frame_; |
126 BeginFrameArgs last_begin_frame_args_; | 132 BeginFrameArgs last_begin_frame_args_; |
| 133 base::CancelableClosure begin_frame_deadline_closure_; |
127 | 134 |
128 SchedulerStateMachine state_machine_; | 135 SchedulerStateMachine state_machine_; |
129 bool inside_process_scheduled_actions_; | 136 bool inside_process_scheduled_actions_; |
130 | 137 |
131 DISALLOW_COPY_AND_ASSIGN(Scheduler); | 138 DISALLOW_COPY_AND_ASSIGN(Scheduler); |
132 }; | 139 }; |
133 | 140 |
134 } // namespace cc | 141 } // namespace cc |
135 | 142 |
136 #endif // CC_SCHEDULER_SCHEDULER_H_ | 143 #endif // CC_SCHEDULER_SCHEDULER_H_ |
OLD | NEW |