OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CONTENT_BROWSER_COMPOSITOR_GPU_VSYNC_BEGIN_FRAME_SOURCE_H_ | 5 #ifndef CONTENT_BROWSER_COMPOSITOR_GPU_VSYNC_BEGIN_FRAME_SOURCE_H_ |
6 #define CONTENT_BROWSER_COMPOSITOR_GPU_VSYNC_BEGIN_FRAME_SOURCE_H_ | 6 #define CONTENT_BROWSER_COMPOSITOR_GPU_VSYNC_BEGIN_FRAME_SOURCE_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "cc/scheduler/begin_frame_source.h" | 10 #include "cc/scheduler/begin_frame_source.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 // This class is used to control VSync production on GPU side. | 14 // This class is used to control VSync production on GPU side. |
15 class GpuVSyncControl { | 15 class GpuVSyncControl { |
16 public: | 16 public: |
17 virtual void SetNeedsVSync(bool needs_vsync) = 0; | 17 virtual void SetNeedsVSync(bool needs_vsync) = 0; |
18 }; | 18 }; |
19 | 19 |
20 // This is a type of ExternalBeginFrameSource where VSync signals are | 20 // This is a type of ExternalBeginFrameSource where VSync signals are |
21 // generated externally on GPU side. | 21 // generated externally on GPU side. |
22 class GpuVSyncBeginFrameSource : public cc::ExternalBeginFrameSource, | 22 class GpuVSyncBeginFrameSource : public cc::ExternalBeginFrameSource, |
23 cc::ExternalBeginFrameSourceClient { | 23 cc::ExternalBeginFrameSourceClient { |
24 public: | 24 public: |
25 explicit GpuVSyncBeginFrameSource(GpuVSyncControl* vsync_control); | 25 explicit GpuVSyncBeginFrameSource(GpuVSyncControl* vsync_control); |
26 ~GpuVSyncBeginFrameSource() override; | 26 ~GpuVSyncBeginFrameSource() override; |
27 | 27 |
28 // cc::ExternalBeginFrameSourceClient implementation. | 28 // cc::ExternalBeginFrameSourceClient implementation. |
29 void OnNeedsBeginFrames(bool needs_begin_frames) override; | 29 void OnNeedsBeginFrames(bool needs_begin_frames) override; |
30 void OnDidFinishFrame(const cc::BeginFrameAck& ack) override; | |
31 | 30 |
32 void OnVSync(base::TimeTicks timestamp, base::TimeDelta interval); | 31 void OnVSync(base::TimeTicks timestamp, base::TimeDelta interval); |
33 | 32 |
34 private: | 33 private: |
35 GpuVSyncControl* const vsync_control_; | 34 GpuVSyncControl* const vsync_control_; |
36 bool needs_begin_frames_; | 35 bool needs_begin_frames_; |
37 uint64_t next_sequence_number_; | 36 uint64_t next_sequence_number_; |
38 | 37 |
39 DISALLOW_COPY_AND_ASSIGN(GpuVSyncBeginFrameSource); | 38 DISALLOW_COPY_AND_ASSIGN(GpuVSyncBeginFrameSource); |
40 }; | 39 }; |
41 | 40 |
42 } // namespace content | 41 } // namespace content |
43 | 42 |
44 #endif // CONTENT_BROWSER_COMPOSITOR_GPU_VSYNC_BEGIN_FRAME_SOURCE_H_ | 43 #endif // CONTENT_BROWSER_COMPOSITOR_GPU_VSYNC_BEGIN_FRAME_SOURCE_H_ |
OLD | NEW |