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

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

Issue 17125004: Revert 206020 "cc: Emulate BeginFrame in OutputSurfaces that don..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
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/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "cc/base/cc_export.h" 13 #include "cc/base/cc_export.h"
14 #include "cc/scheduler/frame_rate_controller.h"
14 #include "cc/scheduler/scheduler_settings.h" 15 #include "cc/scheduler/scheduler_settings.h"
15 #include "cc/scheduler/scheduler_state_machine.h" 16 #include "cc/scheduler/scheduler_state_machine.h"
16 #include "cc/trees/layer_tree_host.h" 17 #include "cc/trees/layer_tree_host.h"
17 18
18 namespace cc { 19 namespace cc {
19 20
20 class Thread; 21 class Thread;
21 22
22 struct ScheduledActionDrawAndSwapResult { 23 struct ScheduledActionDrawAndSwapResult {
23 ScheduledActionDrawAndSwapResult() 24 ScheduledActionDrawAndSwapResult()
24 : did_draw(false), 25 : did_draw(false),
25 did_swap(false) {} 26 did_swap(false) {}
26 ScheduledActionDrawAndSwapResult(bool did_draw, bool did_swap) 27 ScheduledActionDrawAndSwapResult(bool did_draw, bool did_swap)
27 : did_draw(did_draw), 28 : did_draw(did_draw),
28 did_swap(did_swap) {} 29 did_swap(did_swap) {}
29 bool did_draw; 30 bool did_draw;
30 bool did_swap; 31 bool did_swap;
31 }; 32 };
32 33
33 class SchedulerClient { 34 class SchedulerClient {
34 public: 35 public:
35 virtual void SetNeedsBeginFrameOnImplThread(bool enable) = 0;
36 virtual void ScheduledActionSendBeginFrameToMainThread() = 0; 36 virtual void ScheduledActionSendBeginFrameToMainThread() = 0;
37 virtual ScheduledActionDrawAndSwapResult 37 virtual ScheduledActionDrawAndSwapResult
38 ScheduledActionDrawAndSwapIfPossible() = 0; 38 ScheduledActionDrawAndSwapIfPossible() = 0;
39 virtual ScheduledActionDrawAndSwapResult 39 virtual ScheduledActionDrawAndSwapResult
40 ScheduledActionDrawAndSwapForced() = 0; 40 ScheduledActionDrawAndSwapForced() = 0;
41 virtual void ScheduledActionCommit() = 0; 41 virtual void ScheduledActionCommit() = 0;
42 virtual void ScheduledActionCheckForCompletedTileUploads() = 0; 42 virtual void ScheduledActionCheckForCompletedTileUploads() = 0;
43 virtual void ScheduledActionActivatePendingTreeIfNeeded() = 0; 43 virtual void ScheduledActionActivatePendingTreeIfNeeded() = 0;
44 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0; 44 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0;
45 virtual void ScheduledActionAcquireLayerTexturesForMainThread() = 0; 45 virtual void ScheduledActionAcquireLayerTexturesForMainThread() = 0;
46 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0; 46 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0;
47 47
48 protected: 48 protected:
49 virtual ~SchedulerClient() {} 49 virtual ~SchedulerClient() {}
50 }; 50 };
51 51
52 class CC_EXPORT Scheduler { 52 class CC_EXPORT Scheduler : FrameRateControllerClient {
53 public: 53 public:
54 static scoped_ptr<Scheduler> Create( 54 static scoped_ptr<Scheduler> Create(
55 SchedulerClient* client, 55 SchedulerClient* client,
56 scoped_ptr<FrameRateController> frame_rate_controller,
56 const SchedulerSettings& scheduler_settings) { 57 const SchedulerSettings& scheduler_settings) {
57 return make_scoped_ptr(new Scheduler(client, scheduler_settings)); 58 return make_scoped_ptr(new Scheduler(
59 client, frame_rate_controller.Pass(), scheduler_settings));
58 } 60 }
59 61
60 virtual ~Scheduler(); 62 virtual ~Scheduler();
61 63
62 void SetCanStart(); 64 void SetCanStart();
63 65
64 void SetVisible(bool visible); 66 void SetVisible(bool visible);
65 void SetCanDraw(bool can_draw); 67 void SetCanDraw(bool can_draw);
66 void SetHasPendingTree(bool has_pending_tree); 68 void SetHasPendingTree(bool has_pending_tree);
67 69
68 void SetNeedsCommit(); 70 void SetNeedsCommit();
69 71
70 // Like SetNeedsCommit(), but ensures a commit will definitely happen even if 72 // Like SetNeedsCommit(), but ensures a commit will definitely happen even if
71 // we are not visible. 73 // we are not visible.
72 void SetNeedsForcedCommit(); 74 void SetNeedsForcedCommit();
73 75
74 void SetNeedsRedraw(); 76 void SetNeedsRedraw();
75 77
76 void SetMainThreadNeedsLayerTextures(); 78 void SetMainThreadNeedsLayerTextures();
77 79
78 // Like SetNeedsRedraw(), but ensures the draw will definitely happen even if 80 // Like SetNeedsRedraw(), but ensures the draw will definitely happen even if
79 // we are not visible. 81 // we are not visible.
80 void SetNeedsForcedRedraw(); 82 void SetNeedsForcedRedraw();
81 83
82 void DidSwapUseIncompleteTile(); 84 void DidSwapUseIncompleteTile();
83 85
84 void FinishCommit(); 86 void FinishCommit();
85 void BeginFrameAbortedByMainThread(); 87 void BeginFrameAbortedByMainThread();
86 88
89 void SetMaxFramesPending(int max);
90 int MaxFramesPending() const;
91 int NumFramesPendingForTesting() const;
92
93 void DidSwapBuffersComplete();
94
87 void DidLoseOutputSurface(); 95 void DidLoseOutputSurface();
88 void DidCreateAndInitializeOutputSurface(); 96 void DidCreateAndInitializeOutputSurface();
89 bool HasInitializedOutputSurface() const { 97 bool HasInitializedOutputSurface() const {
90 return state_machine_.HasInitializedOutputSurface(); 98 return state_machine_.HasInitializedOutputSurface();
91 } 99 }
92 100
93 bool CommitPending() const { return state_machine_.CommitPending(); } 101 bool CommitPending() const { return state_machine_.CommitPending(); }
94 bool RedrawPending() const { return state_machine_.RedrawPending(); } 102 bool RedrawPending() const { return state_machine_.RedrawPending(); }
95 103
96 bool WillDrawIfNeeded() const; 104 bool WillDrawIfNeeded() const;
97 105
106 void SetTimebaseAndInterval(base::TimeTicks timebase,
107 base::TimeDelta interval);
108
98 base::TimeTicks AnticipatedDrawTime(); 109 base::TimeTicks AnticipatedDrawTime();
99 110
100 base::TimeTicks LastBeginFrameOnImplThreadTime(); 111 base::TimeTicks LastBeginFrameOnImplThreadTime();
101 112
102 void BeginFrame(base::TimeTicks frame_time); 113 // FrameRateControllerClient implementation
114 virtual void BeginFrame(bool throttled) OVERRIDE;
103 115
104 std::string StateAsStringForTesting() { return state_machine_.ToString(); } 116 std::string StateAsStringForTesting() { return state_machine_.ToString(); }
105 117
106 private: 118 private:
107 Scheduler(SchedulerClient* client, 119 Scheduler(SchedulerClient* client,
120 scoped_ptr<FrameRateController> frame_rate_controller,
108 const SchedulerSettings& scheduler_settings); 121 const SchedulerSettings& scheduler_settings);
109 122
110 void SetupNextBeginFrameIfNeeded();
111 void DrawAndSwapIfPossible();
112 void DrawAndSwapForced();
113 void ProcessScheduledActions(); 123 void ProcessScheduledActions();
114 124
115 const SchedulerSettings settings_; 125 const SchedulerSettings settings_;
116 SchedulerClient* client_; 126 SchedulerClient* client_;
117 127 scoped_ptr<FrameRateController> frame_rate_controller_;
118 base::WeakPtrFactory<Scheduler> weak_factory_;
119 bool last_set_needs_begin_frame_;
120 bool has_pending_begin_frame_;
121 base::TimeTicks last_begin_frame_time_;
122 base::TimeDelta interval_;
123
124 SchedulerStateMachine state_machine_; 128 SchedulerStateMachine state_machine_;
125 bool inside_process_scheduled_actions_; 129 bool inside_process_scheduled_actions_;
126 130
127 DISALLOW_COPY_AND_ASSIGN(Scheduler); 131 DISALLOW_COPY_AND_ASSIGN(Scheduler);
128 }; 132 };
129 133
130 } // namespace cc 134 } // namespace cc
131 135
132 #endif // CC_SCHEDULER_SCHEDULER_H_ 136 #endif // CC_SCHEDULER_SCHEDULER_H_
OLDNEW
« no previous file with comments | « trunk/src/cc/scheduler/frame_rate_controller_unittest.cc ('k') | trunk/src/cc/scheduler/scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698