| 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 #include "content/common/content_export.h" | |
| 12 | 11 |
| 13 namespace content { | 12 namespace content { |
| 14 | 13 |
| 15 // This class is used to control VSync production on GPU side. | 14 // This class is used to control VSync production on GPU side. |
| 16 class CONTENT_EXPORT GpuVSyncControl { | 15 class GpuVSyncControl { |
| 17 public: | 16 public: |
| 18 virtual void SetNeedsVSync(bool needs_vsync) = 0; | 17 virtual void SetNeedsVSync(bool needs_vsync) = 0; |
| 19 }; | 18 }; |
| 20 | 19 |
| 21 // This is a type of ExternalBeginFrameSource where VSync signals are | 20 // This is a type of ExternalBeginFrameSource where VSync signals are |
| 22 // generated externally on GPU side. | 21 // generated externally on GPU side. |
| 23 class CONTENT_EXPORT GpuVSyncBeginFrameSource | 22 class GpuVSyncBeginFrameSource : public cc::ExternalBeginFrameSource, |
| 24 : public cc::ExternalBeginFrameSource, | 23 cc::ExternalBeginFrameSourceClient { |
| 25 public cc::ExternalBeginFrameSourceClient { | |
| 26 public: | 24 public: |
| 27 explicit GpuVSyncBeginFrameSource(GpuVSyncControl* vsync_control); | 25 explicit GpuVSyncBeginFrameSource(GpuVSyncControl* vsync_control); |
| 28 ~GpuVSyncBeginFrameSource() override; | 26 ~GpuVSyncBeginFrameSource() override; |
| 29 | 27 |
| 30 // cc::ExternalBeginFrameSourceClient implementation. | 28 // cc::ExternalBeginFrameSourceClient implementation. |
| 31 void OnNeedsBeginFrames(bool needs_begin_frames) override; | 29 void OnNeedsBeginFrames(bool needs_begin_frames) override; |
| 32 | 30 |
| 33 void OnVSync(base::TimeTicks timestamp, base::TimeDelta interval); | 31 void OnVSync(base::TimeTicks timestamp, base::TimeDelta interval); |
| 34 | 32 |
| 35 protected: | |
| 36 // Virtual for testing. | |
| 37 virtual base::TimeTicks Now() const; | |
| 38 | |
| 39 private: | 33 private: |
| 40 cc::BeginFrameArgs GetMissedBeginFrameArgs( | |
| 41 cc::BeginFrameObserver* obs) override; | |
| 42 | |
| 43 GpuVSyncControl* const vsync_control_; | 34 GpuVSyncControl* const vsync_control_; |
| 44 bool needs_begin_frames_; | 35 bool needs_begin_frames_; |
| 45 uint64_t next_sequence_number_; | 36 uint64_t next_sequence_number_; |
| 46 | 37 |
| 47 DISALLOW_COPY_AND_ASSIGN(GpuVSyncBeginFrameSource); | 38 DISALLOW_COPY_AND_ASSIGN(GpuVSyncBeginFrameSource); |
| 48 }; | 39 }; |
| 49 | 40 |
| 50 } // namespace content | 41 } // namespace content |
| 51 | 42 |
| 52 #endif // CONTENT_BROWSER_COMPOSITOR_GPU_VSYNC_BEGIN_FRAME_SOURCE_H_ | 43 #endif // CONTENT_BROWSER_COMPOSITOR_GPU_VSYNC_BEGIN_FRAME_SOURCE_H_ |
| OLD | NEW |