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

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

Issue 16833003: cc: Emulate BeginFrame in OutputSurfaces that don't support it natively (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
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
« no previous file with comments | « cc/scheduler/frame_rate_controller_unittest.cc ('k') | cc/scheduler/scheduler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
15 #include "cc/scheduler/scheduler_settings.h" 14 #include "cc/scheduler/scheduler_settings.h"
16 #include "cc/scheduler/scheduler_state_machine.h" 15 #include "cc/scheduler/scheduler_state_machine.h"
17 #include "cc/trees/layer_tree_host.h" 16 #include "cc/trees/layer_tree_host.h"
18 17
19 namespace cc { 18 namespace cc {
20 19
21 class Thread; 20 class Thread;
22 21
23 struct ScheduledActionDrawAndSwapResult { 22 struct ScheduledActionDrawAndSwapResult {
24 ScheduledActionDrawAndSwapResult() 23 ScheduledActionDrawAndSwapResult()
25 : did_draw(false), 24 : did_draw(false),
26 did_swap(false) {} 25 did_swap(false) {}
27 ScheduledActionDrawAndSwapResult(bool did_draw, bool did_swap) 26 ScheduledActionDrawAndSwapResult(bool did_draw, bool did_swap)
28 : did_draw(did_draw), 27 : did_draw(did_draw),
29 did_swap(did_swap) {} 28 did_swap(did_swap) {}
30 bool did_draw; 29 bool did_draw;
31 bool did_swap; 30 bool did_swap;
32 }; 31 };
33 32
34 class SchedulerClient { 33 class SchedulerClient {
35 public: 34 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 : FrameRateControllerClient { 52 class CC_EXPORT Scheduler {
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,
57 const SchedulerSettings& scheduler_settings) { 56 const SchedulerSettings& scheduler_settings) {
58 return make_scoped_ptr(new Scheduler( 57 return make_scoped_ptr(new Scheduler(client, scheduler_settings));
59 client, frame_rate_controller.Pass(), scheduler_settings));
60 } 58 }
61 59
62 virtual ~Scheduler(); 60 virtual ~Scheduler();
63 61
64 void SetCanStart(); 62 void SetCanStart();
65 63
66 void SetVisible(bool visible); 64 void SetVisible(bool visible);
67 void SetCanDraw(bool can_draw); 65 void SetCanDraw(bool can_draw);
68 void SetHasPendingTree(bool has_pending_tree); 66 void SetHasPendingTree(bool has_pending_tree);
69 67
70 void SetNeedsCommit(); 68 void SetNeedsCommit();
71 69
72 // Like SetNeedsCommit(), but ensures a commit will definitely happen even if 70 // Like SetNeedsCommit(), but ensures a commit will definitely happen even if
73 // we are not visible. 71 // we are not visible.
74 void SetNeedsForcedCommit(); 72 void SetNeedsForcedCommit();
75 73
76 void SetNeedsRedraw(); 74 void SetNeedsRedraw();
77 75
78 void SetMainThreadNeedsLayerTextures(); 76 void SetMainThreadNeedsLayerTextures();
79 77
80 // Like SetNeedsRedraw(), but ensures the draw will definitely happen even if 78 // Like SetNeedsRedraw(), but ensures the draw will definitely happen even if
81 // we are not visible. 79 // we are not visible.
82 void SetNeedsForcedRedraw(); 80 void SetNeedsForcedRedraw();
83 81
84 void DidSwapUseIncompleteTile(); 82 void DidSwapUseIncompleteTile();
85 83
86 void FinishCommit(); 84 void FinishCommit();
87 void BeginFrameAbortedByMainThread(); 85 void BeginFrameAbortedByMainThread();
88 86
89 void SetMaxFramesPending(int max);
90 int MaxFramesPending() const;
91 int NumFramesPendingForTesting() const;
92
93 void DidSwapBuffersComplete();
94
95 void DidLoseOutputSurface(); 87 void DidLoseOutputSurface();
96 void DidCreateAndInitializeOutputSurface(); 88 void DidCreateAndInitializeOutputSurface();
97 bool HasInitializedOutputSurface() const { 89 bool HasInitializedOutputSurface() const {
98 return state_machine_.HasInitializedOutputSurface(); 90 return state_machine_.HasInitializedOutputSurface();
99 } 91 }
100 92
101 bool CommitPending() const { return state_machine_.CommitPending(); } 93 bool CommitPending() const { return state_machine_.CommitPending(); }
102 bool RedrawPending() const { return state_machine_.RedrawPending(); } 94 bool RedrawPending() const { return state_machine_.RedrawPending(); }
103 95
104 bool WillDrawIfNeeded() const; 96 bool WillDrawIfNeeded() const;
105 97
106 void SetTimebaseAndInterval(base::TimeTicks timebase,
107 base::TimeDelta interval);
108
109 base::TimeTicks AnticipatedDrawTime(); 98 base::TimeTicks AnticipatedDrawTime();
110 99
111 base::TimeTicks LastBeginFrameOnImplThreadTime(); 100 base::TimeTicks LastBeginFrameOnImplThreadTime();
112 101
113 // FrameRateControllerClient implementation 102 void BeginFrame(base::TimeTicks frame_time);
114 virtual void BeginFrame(bool throttled) OVERRIDE;
115 103
116 std::string StateAsStringForTesting() { return state_machine_.ToString(); } 104 std::string StateAsStringForTesting() { return state_machine_.ToString(); }
117 105
118 private: 106 private:
119 Scheduler(SchedulerClient* client, 107 Scheduler(SchedulerClient* client,
120 scoped_ptr<FrameRateController> frame_rate_controller,
121 const SchedulerSettings& scheduler_settings); 108 const SchedulerSettings& scheduler_settings);
122 109
110 void SetupNextBeginFrameIfNeeded();
111 void DrawAndSwapIfPossible();
112 void DrawAndSwapForced();
123 void ProcessScheduledActions(); 113 void ProcessScheduledActions();
124 114
125 const SchedulerSettings settings_; 115 const SchedulerSettings settings_;
126 SchedulerClient* client_; 116 SchedulerClient* client_;
127 scoped_ptr<FrameRateController> frame_rate_controller_; 117
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
128 SchedulerStateMachine state_machine_; 124 SchedulerStateMachine state_machine_;
129 bool inside_process_scheduled_actions_; 125 bool inside_process_scheduled_actions_;
130 126
131 DISALLOW_COPY_AND_ASSIGN(Scheduler); 127 DISALLOW_COPY_AND_ASSIGN(Scheduler);
132 }; 128 };
133 129
134 } // namespace cc 130 } // namespace cc
135 131
136 #endif // CC_SCHEDULER_SCHEDULER_H_ 132 #endif // CC_SCHEDULER_SCHEDULER_H_
OLDNEW
« no previous file with comments | « cc/scheduler/frame_rate_controller_unittest.cc ('k') | cc/scheduler/scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698