summaryrefslogtreecommitdiffstats
path: root/cc/scheduler/frame_rate_controller.h
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-18 08:36:31 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-18 08:36:31 +0000
commitbe4655a91f88479e913499a8587e47453dda308f (patch)
treec337ce7463df87ab3f50ec80964b5893ad6bbaef /cc/scheduler/frame_rate_controller.h
parente12dd0e802b2a80112cb40e01fabcc5c0475f05b (diff)
downloadchromium_src-be4655a91f88479e913499a8587e47453dda308f.zip
chromium_src-be4655a91f88479e913499a8587e47453dda308f.tar.gz
chromium_src-be4655a91f88479e913499a8587e47453dda308f.tar.bz2
Part 9 of cc/ directory shuffles: scheduler
Continuation of https://src.chromium.org/viewvc/chrome?view=rev&revision=188681 BUG=190824 TBR=enne@chromium.org Review URL: https://codereview.chromium.org/12471008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188697 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/scheduler/frame_rate_controller.h')
-rw-r--r--cc/scheduler/frame_rate_controller.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/cc/scheduler/frame_rate_controller.h b/cc/scheduler/frame_rate_controller.h
new file mode 100644
index 0000000..46fa592
--- /dev/null
+++ b/cc/scheduler/frame_rate_controller.h
@@ -0,0 +1,91 @@
+// Copyright 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_
+#define CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/time.h"
+#include "cc/base/cc_export.h"
+
+namespace cc {
+
+class Thread;
+class TimeSource;
+
+class CC_EXPORT FrameRateControllerClient {
+public:
+ // Throttled is true when we have a maximum number of frames pending.
+ virtual void vsyncTick(bool throttled) = 0;
+
+protected:
+ virtual ~FrameRateControllerClient() {}
+};
+
+class FrameRateControllerTimeSourceAdapter;
+
+class CC_EXPORT FrameRateController {
+public:
+ enum {
+ kDefaultMaxFramesPending = 2
+ };
+
+ explicit FrameRateController(scoped_refptr<TimeSource>);
+ // Alternate form of FrameRateController with unthrottled frame-rate.
+ explicit FrameRateController(Thread*);
+ virtual ~FrameRateController();
+
+ void setClient(FrameRateControllerClient* client) { m_client = client; }
+
+ void setActive(bool);
+
+ // Use the following methods to adjust target frame rate.
+ //
+ // Multiple frames can be in-progress, but for every didBeginFrame, a
+ // didFinishFrame should be posted.
+ //
+ // If the rendering pipeline crashes, call didAbortAllPendingFrames.
+ void didBeginFrame();
+ void didFinishFrame();
+ void didAbortAllPendingFrames();
+ void setMaxFramesPending(int); // 0 for unlimited.
+ int maxFramesPending() const { return m_maxFramesPending; }
+
+ // This returns null for unthrottled frame-rate.
+ base::TimeTicks nextTickTime();
+
+ // This returns now for unthrottled frame-rate.
+ base::TimeTicks lastTickTime();
+
+ void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelta interval);
+ void setSwapBuffersCompleteSupported(bool);
+
+protected:
+ friend class FrameRateControllerTimeSourceAdapter;
+ void onTimerTick();
+
+ void postManualTick();
+ void manualTick();
+
+ FrameRateControllerClient* m_client;
+ int m_numFramesPending;
+ int m_maxFramesPending;
+ scoped_refptr<TimeSource> m_timeSource;
+ scoped_ptr<FrameRateControllerTimeSourceAdapter> m_timeSourceClientAdapter;
+ bool m_active;
+ bool m_swapBuffersCompleteSupported;
+
+ // Members for unthrottled frame-rate.
+ bool m_isTimeSourceThrottling;
+ base::WeakPtrFactory<FrameRateController> m_weakFactory;
+ Thread* m_thread;
+
+ DISALLOW_COPY_AND_ASSIGN(FrameRateController);
+};
+
+} // namespace cc
+
+#endif // CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_