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

Side by Side Diff: cc/scheduler/scheduler.h

Issue 16871016: cc: Use BeginFrameArgs (Closed) Base URL: http://git.chromium.org/chromium/src.git@bfargs2
Patch Set: Fixed all existing tests! New tests pending... Created 7 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
OLDNEW
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
21 class Thread; 22 class Thread;
22 23
23 struct ScheduledActionDrawAndSwapResult { 24 struct DrawSwapReadbackResult {
24 ScheduledActionDrawAndSwapResult() 25 DrawSwapReadbackResult()
25 : did_draw(false), 26 : did_draw(false),
26 did_swap(false) {} 27 did_swap(false),
27 ScheduledActionDrawAndSwapResult(bool did_draw, bool did_swap) 28 did_readback(false) {}
29 DrawSwapReadbackResult(bool did_draw, bool did_swap, bool did_readback)
28 : did_draw(did_draw), 30 : did_draw(did_draw),
29 did_swap(did_swap) {} 31 did_swap(did_swap),
32 did_readback(did_readback) {}
30 bool did_draw; 33 bool did_draw;
31 bool did_swap; 34 bool did_swap;
35 bool did_readback;
32 }; 36 };
33 37
34 class SchedulerClient { 38 class SchedulerClient {
35 public: 39 public:
36 virtual void SetNeedsBeginFrameOnImplThread(bool enable) = 0; 40 virtual void SetNeedsBeginFrameOnImplThread(bool enable) = 0;
37 virtual void ScheduledActionSendBeginFrameToMainThread() = 0; 41 virtual void ScheduledActionSendBeginFrameToMainThread() = 0;
38 virtual ScheduledActionDrawAndSwapResult 42 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() = 0;
39 ScheduledActionDrawAndSwapIfPossible() = 0; 43 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapForced() = 0;
40 virtual ScheduledActionDrawAndSwapResult 44 virtual DrawSwapReadbackResult ScheduledActionDrawAndReadback() = 0;
41 ScheduledActionDrawAndSwapForced() = 0;
42 virtual void ScheduledActionCommit() = 0; 45 virtual void ScheduledActionCommit() = 0;
43 virtual void ScheduledActionCheckForCompletedTileUploads() = 0; 46 virtual void ScheduledActionCheckForCompletedTileUploads() = 0;
44 virtual void ScheduledActionActivatePendingTreeIfNeeded() = 0; 47 virtual void ScheduledActionActivatePendingTreeIfNeeded() = 0;
45 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0; 48 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0;
46 virtual void ScheduledActionAcquireLayerTexturesForMainThread() = 0; 49 virtual void ScheduledActionAcquireLayerTexturesForMainThread() = 0;
47 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0; 50 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0;
48 virtual base::TimeDelta DrawDurationEstimate() = 0; 51 virtual base::TimeDelta DrawDurationEstimate() = 0;
49 virtual base::TimeDelta BeginFrameToCommitDurationEstimate() = 0; 52 virtual base::TimeDelta BeginFrameToCommitDurationEstimate() = 0;
50 virtual base::TimeDelta CommitToActivateDurationEstimate() = 0; 53 virtual base::TimeDelta CommitToActivateDurationEstimate() = 0;
54 virtual void PostBeginFrameDeadline(const base::Closure& closure,
55 base::TimeTicks deadline) = 0;
56 virtual void DidBeginFrameDeadlineOnImplThread() = 0;
51 57
52 protected: 58 protected:
53 virtual ~SchedulerClient() {} 59 virtual ~SchedulerClient() {}
54 }; 60 };
55 61
56 class CC_EXPORT Scheduler { 62 class CC_EXPORT Scheduler {
57 public: 63 public:
58 static scoped_ptr<Scheduler> Create( 64 static scoped_ptr<Scheduler> Create(
59 SchedulerClient* client, 65 SchedulerClient* client,
60 const SchedulerSettings& scheduler_settings) { 66 const SchedulerSettings& scheduler_settings) {
61 return make_scoped_ptr(new Scheduler(client, scheduler_settings)); 67 return make_scoped_ptr(new Scheduler(client, scheduler_settings));
62 } 68 }
63 69
64 virtual ~Scheduler(); 70 virtual ~Scheduler();
65 71
66 void SetCanStart(); 72 void SetCanStart();
67 73
68 void SetVisible(bool visible); 74 void SetVisible(bool visible);
69 void SetCanDraw(bool can_draw); 75 void SetCanDraw(bool can_draw);
70 void SetHasPendingTree(bool has_pending_tree); 76 void SetHasTrees(bool has_pending_tree, bool active_tree_is_null);
71 77
72 void SetNeedsCommit(); 78 void SetNeedsCommit();
73 79
74 // Like SetNeedsCommit(), but ensures a commit will definitely happen even if 80 // Like SetNeedsCommit(), but ensures a commit will definitely happen even if
75 // we are not visible. 81 // we are not visible. Will eventually result in a forced draw internally.
76 void SetNeedsForcedCommit(); 82 void SetNeedsForcedCommitForReadback();
77 83
78 void SetNeedsRedraw(); 84 void SetNeedsRedraw();
79 85
80 void SetMainThreadNeedsLayerTextures(); 86 void SetMainThreadNeedsLayerTextures();
81 87
82 // Like SetNeedsRedraw(), but ensures the draw will definitely happen even if
83 // we are not visible.
84 void SetNeedsForcedRedraw();
brianderson 2013/07/18 02:02:49 I got rid of this method because the state machine
85
86 void DidSwapUseIncompleteTile(); 88 void DidSwapUseIncompleteTile();
87 89
88 void FinishCommit(); 90 void FinishCommit();
89 void BeginFrameAbortedByMainThread(); 91 void BeginFrameAbortedByMainThread();
90 92
91 void DidLoseOutputSurface(); 93 void DidLoseOutputSurface();
92 void DidCreateAndInitializeOutputSurface(); 94 void DidCreateAndInitializeOutputSurface();
93 bool HasInitializedOutputSurface() const { 95 bool HasInitializedOutputSurface() const {
94 return state_machine_.HasInitializedOutputSurface(); 96 return state_machine_.HasInitializedOutputSurface();
95 } 97 }
96 98
97 bool CommitPending() const { return state_machine_.CommitPending(); } 99 bool CommitPending() const { return state_machine_.CommitPending(); }
98 bool RedrawPending() const { return state_machine_.RedrawPending(); } 100 bool RedrawPending() const { return state_machine_.RedrawPending(); }
99 101
100 bool WillDrawIfNeeded() const; 102 bool WillDrawIfNeeded() const;
101 103
102 base::TimeTicks AnticipatedDrawTime(); 104 base::TimeTicks AnticipatedDrawTime();
103 105
104 base::TimeTicks LastBeginFrameOnImplThreadTime(); 106 base::TimeTicks LastBeginFrameOnImplThreadTime();
105 107
106 void BeginFrame(const BeginFrameArgs& args); 108 void BeginFrame(const BeginFrameArgs& args);
109 void OnBeginFrameDeadline();
107 110
108 std::string StateAsStringForTesting() { return state_machine_.ToString(); } 111 std::string StateAsStringForTesting() { return state_machine_.ToString(); }
109 112
110 private: 113 private:
111 Scheduler(SchedulerClient* client, 114 Scheduler(SchedulerClient* client,
112 const SchedulerSettings& scheduler_settings); 115 const SchedulerSettings& scheduler_settings);
113 116
117 void PostBeginFrameDeadline(base::TimeTicks deadline);
114 void SetupNextBeginFrameIfNeeded(); 118 void SetupNextBeginFrameIfNeeded();
115 void DrawAndSwapIfPossible(); 119 void DrawAndSwapIfPossible();
116 void DrawAndSwapForced(); 120 void DrawAndSwapForced();
121 void DrawAndReadback();
117 void ProcessScheduledActions(); 122 void ProcessScheduledActions();
118 123
119 const SchedulerSettings settings_; 124 const SchedulerSettings settings_;
120 SchedulerClient* client_; 125 SchedulerClient* client_;
121 126
122 base::WeakPtrFactory<Scheduler> weak_factory_; 127 base::WeakPtrFactory<Scheduler> weak_factory_;
123 bool last_set_needs_begin_frame_; 128 bool last_set_needs_begin_frame_;
124 bool has_pending_begin_frame_; 129 bool has_pending_begin_frame_;
125 // TODO(brianderson): crbug.com/249806 : Remove safe_to_expect_begin_frame_ 130 // TODO(brianderson): crbug.com/249806 : Remove safe_to_expect_begin_frame_
126 // workaround. 131 // workaround.
127 bool safe_to_expect_begin_frame_; 132 bool safe_to_expect_begin_frame_;
128 BeginFrameArgs last_begin_frame_args_; 133 BeginFrameArgs last_begin_frame_args_;
134 base::CancelableClosure begin_frame_deadline_closure_;
129 135
130 SchedulerStateMachine state_machine_; 136 SchedulerStateMachine state_machine_;
131 bool inside_process_scheduled_actions_; 137 bool inside_process_scheduled_actions_;
132 138
133 DISALLOW_COPY_AND_ASSIGN(Scheduler); 139 DISALLOW_COPY_AND_ASSIGN(Scheduler);
134 }; 140 };
135 141
136 } // namespace cc 142 } // namespace cc
137 143
138 #endif // CC_SCHEDULER_SCHEDULER_H_ 144 #endif // CC_SCHEDULER_SCHEDULER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698