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

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

Issue 15836005: cc: Emulate BeginFrame in OutputSurfaces that don't support it natively (Closed) Base URL: http://git.chromium.org/chromium/src.git@nofrc
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
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"
(...skipping 15 matching lines...) Expand all
26 did_swap(false) {} 26 did_swap(false) {}
27 ScheduledActionDrawAndSwapResult(bool did_draw, bool did_swap) 27 ScheduledActionDrawAndSwapResult(bool did_draw, bool did_swap)
28 : did_draw(did_draw), 28 : did_draw(did_draw),
29 did_swap(did_swap) {} 29 did_swap(did_swap) {}
30 bool did_draw; 30 bool did_draw;
31 bool did_swap; 31 bool did_swap;
32 }; 32 };
33 33
34 class SchedulerClient { 34 class SchedulerClient {
35 public: 35 public:
36 virtual void SetNeedsBeginFrameOnImplThread(bool enable) = 0;
36 virtual void ScheduledActionSendBeginFrameToMainThread() = 0; 37 virtual void ScheduledActionSendBeginFrameToMainThread() = 0;
37 virtual ScheduledActionDrawAndSwapResult 38 virtual ScheduledActionDrawAndSwapResult
38 ScheduledActionDrawAndSwapIfPossible() = 0; 39 ScheduledActionDrawAndSwapIfPossible() = 0;
39 virtual ScheduledActionDrawAndSwapResult 40 virtual ScheduledActionDrawAndSwapResult
40 ScheduledActionDrawAndSwapForced() = 0; 41 ScheduledActionDrawAndSwapForced() = 0;
41 virtual void ScheduledActionCommit() = 0; 42 virtual void ScheduledActionCommit() = 0;
42 virtual void ScheduledActionCheckForCompletedTileUploads() = 0; 43 virtual void ScheduledActionCheckForCompletedTileUploads() = 0;
43 virtual void ScheduledActionActivatePendingTreeIfNeeded() = 0; 44 virtual void ScheduledActionActivatePendingTreeIfNeeded() = 0;
44 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0; 45 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0;
45 virtual void ScheduledActionAcquireLayerTexturesForMainThread() = 0; 46 virtual void ScheduledActionAcquireLayerTexturesForMainThread() = 0;
46 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0; 47 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0;
47 48
48 protected: 49 protected:
49 virtual ~SchedulerClient() {} 50 virtual ~SchedulerClient() {}
50 }; 51 };
51 52
52 class CC_EXPORT Scheduler : FrameRateControllerClient { 53 class CC_EXPORT Scheduler {
53 public: 54 public:
54 static scoped_ptr<Scheduler> Create( 55 static scoped_ptr<Scheduler> Create(
55 SchedulerClient* client, 56 SchedulerClient* client,
56 scoped_ptr<FrameRateController> frame_rate_controller, 57 const SchedulerSettings& scheduler_settings,
57 const SchedulerSettings& scheduler_settings) { 58 Thread* thread) {
58 return make_scoped_ptr(new Scheduler( 59 return make_scoped_ptr(new Scheduler(client, scheduler_settings, thread));
59 client, frame_rate_controller.Pass(), scheduler_settings));
60 } 60 }
61 61
62 virtual ~Scheduler(); 62 virtual ~Scheduler();
63 63
64 void SetCanStart(); 64 void SetCanStart();
65 65
66 void SetVisible(bool visible); 66 void SetVisible(bool visible);
67 void SetCanDraw(bool can_draw); 67 void SetCanDraw(bool can_draw);
68 void SetHasPendingTree(bool has_pending_tree); 68 void SetHasPendingTree(bool has_pending_tree);
69 69
70 void SetNeedsCommit(); 70 void SetNeedsCommit();
71 71
72 // Like SetNeedsCommit(), but ensures a commit will definitely happen even if 72 // Like SetNeedsCommit(), but ensures a commit will definitely happen even if
73 // we are not visible. 73 // we are not visible.
74 void SetNeedsForcedCommit(); 74 void SetNeedsForcedCommit();
75 75
76 void SetNeedsRedraw(); 76 void SetNeedsRedraw();
77 77
78 void SetMainThreadNeedsLayerTextures(); 78 void SetMainThreadNeedsLayerTextures();
79 79
80 // Like SetNeedsRedraw(), but ensures the draw will definitely happen even if 80 // Like SetNeedsRedraw(), but ensures the draw will definitely happen even if
81 // we are not visible. 81 // we are not visible.
82 void SetNeedsForcedRedraw(); 82 void SetNeedsForcedRedraw();
83 83
84 void DidSwapUseIncompleteTile(); 84 void DidSwapUseIncompleteTile();
85 85
86 void FinishCommit(); 86 void FinishCommit();
87 void BeginFrameAbortedByMainThread(); 87 void BeginFrameAbortedByMainThread();
88 88
89 void SetMaxFramesPending(int max);
90 int MaxFramesPending() const;
91 int NumFramesPendingForTesting() const;
92
93 void SetSwapBuffersCompleteSupported(bool supported);
94 void DidSwapBuffersComplete();
95
96 void DidLoseOutputSurface(); 89 void DidLoseOutputSurface();
97 void DidCreateAndInitializeOutputSurface(); 90 void DidCreateAndInitializeOutputSurface();
98 bool HasInitializedOutputSurface() const { 91 bool HasInitializedOutputSurface() const {
99 return state_machine_.HasInitializedOutputSurface(); 92 return state_machine_.HasInitializedOutputSurface();
100 } 93 }
101 94
102 bool CommitPending() const { return state_machine_.CommitPending(); } 95 bool CommitPending() const { return state_machine_.CommitPending(); }
103 bool RedrawPending() const { return state_machine_.RedrawPending(); } 96 bool RedrawPending() const { return state_machine_.RedrawPending(); }
104 97
105 bool WillDrawIfNeeded() const; 98 bool WillDrawIfNeeded() const;
106 99
107 void SetTimebaseAndInterval(base::TimeTicks timebase,
108 base::TimeDelta interval);
109
110 base::TimeTicks AnticipatedDrawTime(); 100 base::TimeTicks AnticipatedDrawTime();
111 101
112 base::TimeTicks LastBeginFrameOnImplThreadTime(); 102 base::TimeTicks LastBeginFrameOnImplThreadTime();
113 103
114 // FrameRateControllerClient implementation 104 void BeginFrame(base::TimeTicks frame_time);
115 virtual void BeginFrame(bool throttled) OVERRIDE; 105 void BeginFrameRetry();
116 106
117 std::string StateAsStringForTesting() { return state_machine_.ToString(); } 107 std::string StateAsStringForTesting() { return state_machine_.ToString(); }
118 108
119 private: 109 private:
120 Scheduler(SchedulerClient* client, 110 Scheduler(SchedulerClient* client,
121 scoped_ptr<FrameRateController> frame_rate_controller, 111 const SchedulerSettings& scheduler_settings,
122 const SchedulerSettings& scheduler_settings); 112 Thread* thread);
123 113
114 void DidSwapBuffers();
115 void SetNeedsBeginFrameIfNeeded();
124 void ProcessScheduledActions(); 116 void ProcessScheduledActions();
125 117
126 const SchedulerSettings settings_; 118 const SchedulerSettings settings_;
127 SchedulerClient* client_; 119 SchedulerClient* client_;
128 scoped_ptr<FrameRateController> frame_rate_controller_; 120
121 base::WeakPtrFactory<Scheduler> weak_factory_;
brianderson 2013/06/01 04:30:29 I'll probably move these into the StateMachine so
122 Thread* thread_;
123 bool last_set_needs_begin_frame_;
124 int pending_begin_frames_;
Sami 2013/06/03 17:30:33 Does it ever make sense to have more than one of t
brianderson 2013/06/03 18:51:40 Currently, it does not make sense: one BeginFrame
125 base::TimeTicks last_begin_frame_time_;
126 base::TimeDelta interval_;
127
129 SchedulerStateMachine state_machine_; 128 SchedulerStateMachine state_machine_;
130 bool inside_process_scheduled_actions_; 129 bool inside_process_scheduled_actions_;
131 130
132 DISALLOW_COPY_AND_ASSIGN(Scheduler); 131 DISALLOW_COPY_AND_ASSIGN(Scheduler);
133 }; 132 };
134 133
135 } // namespace cc 134 } // namespace cc
136 135
137 #endif // CC_SCHEDULER_SCHEDULER_H_ 136 #endif // CC_SCHEDULER_SCHEDULER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698