| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| 11 #include "CCFrameRateController.h" | 11 #include "CCFrameRateController.h" |
| 12 #include "CCSchedulerStateMachine.h" | 12 #include "CCSchedulerStateMachine.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 class CCThread; | 16 class Thread; |
| 17 | 17 |
| 18 struct CCScheduledActionDrawAndSwapResult { | 18 struct ScheduledActionDrawAndSwapResult { |
| 19 CCScheduledActionDrawAndSwapResult() | 19 ScheduledActionDrawAndSwapResult() |
| 20 : didDraw(false) | 20 : didDraw(false) |
| 21 , didSwap(false) | 21 , didSwap(false) |
| 22 { | 22 { |
| 23 } | 23 } |
| 24 CCScheduledActionDrawAndSwapResult(bool didDraw, bool didSwap) | 24 ScheduledActionDrawAndSwapResult(bool didDraw, bool didSwap) |
| 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 SchedulerClient { |
| 34 public: | 34 public: |
| 35 virtual void scheduledActionBeginFrame() = 0; | 35 virtual void scheduledActionBeginFrame() = 0; |
| 36 virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapIfPossi
ble() = 0; | 36 virtual ScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapIfPossibl
e() = 0; |
| 37 virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapForced(
) = 0; | 37 virtual ScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapForced()
= 0; |
| 38 virtual void scheduledActionCommit() = 0; | 38 virtual void scheduledActionCommit() = 0; |
| 39 virtual void scheduledActionBeginContextRecreation() = 0; | 39 virtual void scheduledActionBeginContextRecreation() = 0; |
| 40 virtual void scheduledActionAcquireLayerTexturesForMainThread() = 0; | 40 virtual void scheduledActionAcquireLayerTexturesForMainThread() = 0; |
| 41 virtual void didAnticipatedDrawTimeChange(base::TimeTicks) = 0; | 41 virtual void didAnticipatedDrawTimeChange(base::TimeTicks) = 0; |
| 42 | 42 |
| 43 protected: | 43 protected: |
| 44 virtual ~CCSchedulerClient() { } | 44 virtual ~SchedulerClient() { } |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class CCScheduler : CCFrameRateControllerClient { | 47 class Scheduler : FrameRateControllerClient { |
| 48 public: | 48 public: |
| 49 static scoped_ptr<CCScheduler> create(CCSchedulerClient* client, scoped_ptr<
CCFrameRateController> frameRateController) | 49 static scoped_ptr<Scheduler> create(SchedulerClient* client, scoped_ptr<Fram
eRateController> frameRateController) |
| 50 { | 50 { |
| 51 return make_scoped_ptr(new CCScheduler(client, frameRateController.Pass(
))); | 51 return make_scoped_ptr(new Scheduler(client, frameRateController.Pass())
); |
| 52 } | 52 } |
| 53 | 53 |
| 54 virtual ~CCScheduler(); | 54 virtual ~Scheduler(); |
| 55 | 55 |
| 56 void setCanBeginFrame(bool); | 56 void setCanBeginFrame(bool); |
| 57 | 57 |
| 58 void setVisible(bool); | 58 void setVisible(bool); |
| 59 void setCanDraw(bool); | 59 void setCanDraw(bool); |
| 60 | 60 |
| 61 void setNeedsCommit(); | 61 void setNeedsCommit(); |
| 62 | 62 |
| 63 // Like setNeedsCommit(), but ensures a commit will definitely happen even i
f we are not visible. | 63 // Like setNeedsCommit(), but ensures a commit will definitely happen even i
f we are not visible. |
| 64 void setNeedsForcedCommit(); | 64 void setNeedsForcedCommit(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 80 void didLoseContext(); | 80 void didLoseContext(); |
| 81 void didRecreateContext(); | 81 void didRecreateContext(); |
| 82 | 82 |
| 83 bool commitPending() const { return m_stateMachine.commitPending(); } | 83 bool commitPending() const { return m_stateMachine.commitPending(); } |
| 84 bool redrawPending() const { return m_stateMachine.redrawPending(); } | 84 bool redrawPending() const { return m_stateMachine.redrawPending(); } |
| 85 | 85 |
| 86 void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelta interv
al); | 86 void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelta interv
al); |
| 87 | 87 |
| 88 base::TimeTicks anticipatedDrawTime(); | 88 base::TimeTicks anticipatedDrawTime(); |
| 89 | 89 |
| 90 // CCFrameRateControllerClient implementation | 90 // FrameRateControllerClient implementation |
| 91 virtual void vsyncTick(bool throttled) OVERRIDE; | 91 virtual void vsyncTick(bool throttled) OVERRIDE; |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 CCScheduler(CCSchedulerClient*, scoped_ptr<CCFrameRateController>); | 94 Scheduler(SchedulerClient*, scoped_ptr<FrameRateController>); |
| 95 | 95 |
| 96 void processScheduledActions(); | 96 void processScheduledActions(); |
| 97 | 97 |
| 98 CCSchedulerClient* m_client; | 98 SchedulerClient* m_client; |
| 99 scoped_ptr<CCFrameRateController> m_frameRateController; | 99 scoped_ptr<FrameRateController> m_frameRateController; |
| 100 CCSchedulerStateMachine m_stateMachine; | 100 SchedulerStateMachine m_stateMachine; |
| 101 bool m_insideProcessScheduledActions; | 101 bool m_insideProcessScheduledActions; |
| 102 | 102 |
| 103 DISALLOW_COPY_AND_ASSIGN(CCScheduler); | 103 DISALLOW_COPY_AND_ASSIGN(Scheduler); |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 } // namespace cc | 106 } // namespace cc |
| 107 | 107 |
| 108 #endif // CCScheduler_h | 108 #endif // CCScheduler_h |
| OLD | NEW |