OLD | NEW |
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 CCScheduler_h | 5 #ifndef CCScheduler_h |
6 #define CCScheduler_h | 6 #define CCScheduler_h |
7 | 7 |
8 #include "CCFrameRateController.h" | 8 #include "CCFrameRateController.h" |
9 #include "CCSchedulerStateMachine.h" | 9 #include "CCSchedulerStateMachine.h" |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 : didDraw(didDraw) | 25 : didDraw(didDraw) |
26 , didSwap(didSwap) | 26 , didSwap(didSwap) |
27 { | 27 { |
28 } | 28 } |
29 bool didDraw; | 29 bool didDraw; |
30 bool didSwap; | 30 bool didSwap; |
31 }; | 31 }; |
32 | 32 |
33 class CCSchedulerClient { | 33 class CCSchedulerClient { |
34 public: | 34 public: |
35 virtual bool canDraw() = 0; | |
36 virtual bool hasMoreResourceUpdates() const = 0; | 35 virtual bool hasMoreResourceUpdates() const = 0; |
37 | 36 |
38 virtual void scheduledActionBeginFrame() = 0; | 37 virtual void scheduledActionBeginFrame() = 0; |
39 virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapIfPossi
ble() = 0; | 38 virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapIfPossi
ble() = 0; |
40 virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapForced(
) = 0; | 39 virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapForced(
) = 0; |
41 virtual void scheduledActionUpdateMoreResources(double monotonicTimeLimit) =
0; | 40 virtual void scheduledActionUpdateMoreResources(double monotonicTimeLimit) =
0; |
42 virtual void scheduledActionCommit() = 0; | 41 virtual void scheduledActionCommit() = 0; |
43 virtual void scheduledActionBeginContextRecreation() = 0; | 42 virtual void scheduledActionBeginContextRecreation() = 0; |
44 virtual void scheduledActionAcquireLayerTexturesForMainThread() = 0; | 43 virtual void scheduledActionAcquireLayerTexturesForMainThread() = 0; |
45 | 44 |
46 protected: | 45 protected: |
47 virtual ~CCSchedulerClient() { } | 46 virtual ~CCSchedulerClient() { } |
48 }; | 47 }; |
49 | 48 |
50 class CCScheduler : CCFrameRateControllerClient { | 49 class CCScheduler : CCFrameRateControllerClient { |
51 WTF_MAKE_NONCOPYABLE(CCScheduler); | 50 WTF_MAKE_NONCOPYABLE(CCScheduler); |
52 public: | 51 public: |
53 static PassOwnPtr<CCScheduler> create(CCSchedulerClient* client, PassOwnPtr<
CCFrameRateController> frameRateController) | 52 static PassOwnPtr<CCScheduler> create(CCSchedulerClient* client, PassOwnPtr<
CCFrameRateController> frameRateController) |
54 { | 53 { |
55 return adoptPtr(new CCScheduler(client, frameRateController)); | 54 return adoptPtr(new CCScheduler(client, frameRateController)); |
56 } | 55 } |
57 | 56 |
58 virtual ~CCScheduler(); | 57 virtual ~CCScheduler(); |
59 | 58 |
60 void setCanBeginFrame(bool); | 59 void setCanBeginFrame(bool); |
61 | 60 |
62 void setVisible(bool); | 61 void setVisible(bool); |
| 62 void setCanDraw(bool); |
63 | 63 |
64 void setNeedsCommit(); | 64 void setNeedsCommit(); |
65 | 65 |
66 // Like setNeedsCommit(), but ensures a commit will definitely happen even i
f we are not visible. | 66 // Like setNeedsCommit(), but ensures a commit will definitely happen even i
f we are not visible. |
67 void setNeedsForcedCommit(); | 67 void setNeedsForcedCommit(); |
68 | 68 |
69 void setNeedsRedraw(); | 69 void setNeedsRedraw(); |
70 | 70 |
71 void setMainThreadNeedsLayerTextures(); | 71 void setMainThreadNeedsLayerTextures(); |
72 | 72 |
73 // Like setNeedsRedraw(), but ensures the draw will definitely happen even i
f we are not visible. | 73 // Like setNeedsRedraw(), but ensures the draw will definitely happen even i
f we are not visible. |
74 void setNeedsForcedRedraw(); | 74 void setNeedsForcedRedraw(); |
75 | 75 |
76 void beginFrameComplete(); | 76 void beginFrameComplete(); |
77 void beginFrameAborted(); | 77 void beginFrameAborted(); |
78 | 78 |
79 void setMaxFramesPending(int); | 79 void setMaxFramesPending(int); |
| 80 void setSwapBuffersCompleteSupported(bool); |
80 void didSwapBuffersComplete(); | 81 void didSwapBuffersComplete(); |
81 | 82 |
82 void didLoseContext(); | 83 void didLoseContext(); |
83 void didRecreateContext(); | 84 void didRecreateContext(); |
84 | 85 |
85 bool commitPending() const { return m_stateMachine.commitPending(); } | 86 bool commitPending() const { return m_stateMachine.commitPending(); } |
86 bool redrawPending() const { return m_stateMachine.redrawPending(); } | 87 bool redrawPending() const { return m_stateMachine.redrawPending(); } |
87 | 88 |
88 void setTimebaseAndInterval(double timebase, double intervalSeconds); | 89 void setTimebaseAndInterval(double timebase, double intervalSeconds); |
89 | 90 |
90 // CCFrameRateControllerClient implementation | 91 // CCFrameRateControllerClient implementation |
91 virtual void vsyncTick() OVERRIDE; | 92 virtual void vsyncTick() OVERRIDE; |
92 | 93 |
93 private: | 94 private: |
94 CCScheduler(CCSchedulerClient*, PassOwnPtr<CCFrameRateController>); | 95 CCScheduler(CCSchedulerClient*, PassOwnPtr<CCFrameRateController>); |
95 | 96 |
96 CCSchedulerStateMachine::Action nextAction(); | |
97 void processScheduledActions(); | 97 void processScheduledActions(); |
98 | 98 |
99 CCSchedulerClient* m_client; | 99 CCSchedulerClient* m_client; |
100 OwnPtr<CCFrameRateController> m_frameRateController; | 100 OwnPtr<CCFrameRateController> m_frameRateController; |
101 CCSchedulerStateMachine m_stateMachine; | 101 CCSchedulerStateMachine m_stateMachine; |
102 bool m_updateMoreResourcesPending; | 102 bool m_updateMoreResourcesPending; |
103 }; | 103 }; |
104 | 104 |
105 } | 105 } |
106 | 106 |
107 #endif // CCScheduler_h | 107 #endif // CCScheduler_h |
OLD | NEW |