Test upload from mkearney.
[chromium-blink-merge.git] / cc / CCScheduler.h
blob10fce730d954f60088a059faa32cb101e162b2e1
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
3 // found in the LICENSE file.
5 #ifndef CCScheduler_h
6 #define CCScheduler_h
8 #include "CCFrameRateController.h"
9 #include "CCSchedulerStateMachine.h"
11 #include <wtf/Noncopyable.h>
12 #include <wtf/PassOwnPtr.h>
14 namespace WebCore {
16 class CCThread;
18 struct CCScheduledActionDrawAndSwapResult {
19 CCScheduledActionDrawAndSwapResult()
20 : didDraw(false)
21 , didSwap(false)
24 CCScheduledActionDrawAndSwapResult(bool didDraw, bool didSwap)
25 : didDraw(didDraw)
26 , didSwap(didSwap)
29 bool didDraw;
30 bool didSwap;
33 class CCSchedulerClient {
34 public:
35 virtual bool canDraw() = 0;
36 virtual bool hasMoreResourceUpdates() const = 0;
38 virtual void scheduledActionBeginFrame() = 0;
39 virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapIfPossible() = 0;
40 virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapForced() = 0;
41 virtual void scheduledActionUpdateMoreResources(double monotonicTimeLimit) = 0;
42 virtual void scheduledActionCommit() = 0;
43 virtual void scheduledActionBeginContextRecreation() = 0;
44 virtual void scheduledActionAcquireLayerTexturesForMainThread() = 0;
46 protected:
47 virtual ~CCSchedulerClient() { }
50 class CCScheduler : CCFrameRateControllerClient {
51 WTF_MAKE_NONCOPYABLE(CCScheduler);
52 public:
53 static PassOwnPtr<CCScheduler> create(CCSchedulerClient* client, PassOwnPtr<CCFrameRateController> frameRateController)
55 return adoptPtr(new CCScheduler(client, frameRateController));
58 virtual ~CCScheduler();
60 void setCanBeginFrame(bool);
62 void setVisible(bool);
64 void setNeedsCommit();
66 // Like setNeedsCommit(), but ensures a commit will definitely happen even if we are not visible.
67 void setNeedsForcedCommit();
69 void setNeedsRedraw();
71 void setMainThreadNeedsLayerTextures();
73 // Like setNeedsRedraw(), but ensures the draw will definitely happen even if we are not visible.
74 void setNeedsForcedRedraw();
76 void beginFrameComplete();
77 void beginFrameAborted();
79 void setMaxFramesPending(int);
80 void didSwapBuffersComplete();
82 void didLoseContext();
83 void didRecreateContext();
85 bool commitPending() const { return m_stateMachine.commitPending(); }
86 bool redrawPending() const { return m_stateMachine.redrawPending(); }
88 void setTimebaseAndInterval(double timebase, double intervalSeconds);
90 // CCFrameRateControllerClient implementation
91 virtual void vsyncTick() OVERRIDE;
93 private:
94 CCScheduler(CCSchedulerClient*, PassOwnPtr<CCFrameRateController>);
96 CCSchedulerStateMachine::Action nextAction();
97 void processScheduledActions();
99 CCSchedulerClient* m_client;
100 OwnPtr<CCFrameRateController> m_frameRateController;
101 CCSchedulerStateMachine m_stateMachine;
102 bool m_updateMoreResourcesPending;
107 #endif // CCScheduler_h