OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 CCScheduler_h | 5 // Temporary forwarding header |
6 #define CCScheduler_h | 6 #include "cc/scheduler.h" |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/time.h" | |
11 #include "CCFrameRateController.h" | |
12 #include "CCSchedulerStateMachine.h" | |
13 #include <wtf/PassOwnPtr.h> | |
14 | |
15 namespace cc { | |
16 | |
17 class CCThread; | |
18 | |
19 struct CCScheduledActionDrawAndSwapResult { | |
20 CCScheduledActionDrawAndSwapResult() | |
21 : didDraw(false) | |
22 , didSwap(false) | |
23 { | |
24 } | |
25 CCScheduledActionDrawAndSwapResult(bool didDraw, bool didSwap) | |
26 : didDraw(didDraw) | |
27 , didSwap(didSwap) | |
28 { | |
29 } | |
30 bool didDraw; | |
31 bool didSwap; | |
32 }; | |
33 | |
34 class CCSchedulerClient { | |
35 public: | |
36 virtual void scheduledActionBeginFrame() = 0; | |
37 virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapIfPossi
ble() = 0; | |
38 virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapForced(
) = 0; | |
39 virtual void scheduledActionCommit() = 0; | |
40 virtual void scheduledActionBeginContextRecreation() = 0; | |
41 virtual void scheduledActionAcquireLayerTexturesForMainThread() = 0; | |
42 virtual void didAnticipatedDrawTimeChange(base::TimeTicks) = 0; | |
43 | |
44 protected: | |
45 virtual ~CCSchedulerClient() { } | |
46 }; | |
47 | |
48 class CCScheduler : CCFrameRateControllerClient { | |
49 public: | |
50 static PassOwnPtr<CCScheduler> create(CCSchedulerClient* client, scoped_ptr<
CCFrameRateController> frameRateController) | |
51 { | |
52 return adoptPtr(new CCScheduler(client, frameRateController.Pass())); | |
53 } | |
54 | |
55 virtual ~CCScheduler(); | |
56 | |
57 void setCanBeginFrame(bool); | |
58 | |
59 void setVisible(bool); | |
60 void setCanDraw(bool); | |
61 | |
62 void setNeedsCommit(); | |
63 | |
64 // Like setNeedsCommit(), but ensures a commit will definitely happen even i
f we are not visible. | |
65 void setNeedsForcedCommit(); | |
66 | |
67 void setNeedsRedraw(); | |
68 | |
69 void setMainThreadNeedsLayerTextures(); | |
70 | |
71 // Like setNeedsRedraw(), but ensures the draw will definitely happen even i
f we are not visible. | |
72 void setNeedsForcedRedraw(); | |
73 | |
74 void beginFrameComplete(); | |
75 void beginFrameAborted(); | |
76 | |
77 void setMaxFramesPending(int); | |
78 void setSwapBuffersCompleteSupported(bool); | |
79 void didSwapBuffersComplete(); | |
80 | |
81 void didLoseContext(); | |
82 void didRecreateContext(); | |
83 | |
84 bool commitPending() const { return m_stateMachine.commitPending(); } | |
85 bool redrawPending() const { return m_stateMachine.redrawPending(); } | |
86 | |
87 void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelta interv
al); | |
88 | |
89 base::TimeTicks anticipatedDrawTime(); | |
90 | |
91 // CCFrameRateControllerClient implementation | |
92 virtual void vsyncTick(bool throttled) OVERRIDE; | |
93 | |
94 private: | |
95 CCScheduler(CCSchedulerClient*, scoped_ptr<CCFrameRateController>); | |
96 | |
97 void processScheduledActions(); | |
98 | |
99 CCSchedulerClient* m_client; | |
100 scoped_ptr<CCFrameRateController> m_frameRateController; | |
101 CCSchedulerStateMachine m_stateMachine; | |
102 bool m_insideProcessScheduledActions; | |
103 | |
104 DISALLOW_COPY_AND_ASSIGN(CCScheduler); | |
105 }; | |
106 | |
107 } // namespace cc | |
108 | |
109 #endif // CCScheduler_h | |
OLD | NEW |