Index: content/browser/compositor/gpu_vsync_begin_frame_source.h |
diff --git a/content/browser/compositor/gpu_vsync_begin_frame_source.h b/content/browser/compositor/gpu_vsync_begin_frame_source.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..732a1f4c9e8f94dc062be7bab771538c7b58256f |
--- /dev/null |
+++ b/content/browser/compositor/gpu_vsync_begin_frame_source.h |
@@ -0,0 +1,57 @@ |
+// Copyright 2016 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 CONTENT_BROWSER_COMPOSITOR_GPU_VSYNC_BEGIN_FRAME_SOURCE_H_ |
+#define CONTENT_BROWSER_COMPOSITOR_GPU_VSYNC_BEGIN_FRAME_SOURCE_H_ |
+ |
+#include "base/memory/weak_ptr.h" |
+#include "base/time/time.h" |
+#include "cc/scheduler/begin_frame_source.h" |
+ |
+namespace content { |
+ |
+class GpuVSyncControl { |
+ public: |
+ virtual void EnableVSync(bool enabled) = 0; |
+}; |
+ |
+// TODO: this should derive from ExternalBeginFrameSource but existing |
+// implementation of gpu_process_transport_factory makes it difficult. |
+// Therefore the current solution is to duplicate some of |
+// ExternalBeginFrameSource implementation here. |
+class GpuVSyncBeginFrameSource : public cc::SyntheticBeginFrameSource { |
+ public: |
+ explicit GpuVSyncBeginFrameSource(GpuVSyncControl* vsync_control); |
+ ~GpuVSyncBeginFrameSource() override; |
+ |
+ // cc::BeginFrameSource implementation. |
+ void AddObserver(cc::BeginFrameObserver* obs) override; |
+ void RemoveObserver(cc::BeginFrameObserver* obs) override; |
+ void DidFinishFrame(cc::BeginFrameObserver* obs, |
+ const cc::BeginFrameAck& ack) override; |
+ bool IsThrottled() const override; |
+ |
+ // cc::SyntheticBeginFrameSource implementation. |
+ void OnUpdateVSyncParameters(base::TimeTicks timebase, |
+ base::TimeDelta interval) override; |
+ void SetAuthoritativeVSyncInterval(base::TimeDelta interval) override; |
+ |
+ private: |
+ void OnBeginFrame(const cc::BeginFrameArgs& args); |
+ static void OnBeginFrame(cc::BeginFrameObserver* obs, |
+ const cc::BeginFrameArgs& args); |
+ void EnableVSync(bool enabled); |
+ |
+ GpuVSyncControl* const vsync_control_; |
+ bool enabled_; |
+ uint64_t next_sequence_number_; |
+ cc::BeginFrameArgs previous_begin_frame_args_; |
+ std::unordered_set<cc::BeginFrameObserver*> observers_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(GpuVSyncBeginFrameSource); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_COMPOSITOR_GPU_VSYNC_BEGIN_FRAME_SOURCE_H_ |