| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ | 5 #ifndef MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ |
| 6 #define MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ | 6 #define MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 bool UpdateCurrentFrame(base::TimeTicks deadline_min, | 68 bool UpdateCurrentFrame(base::TimeTicks deadline_min, |
| 69 base::TimeTicks deadline_max) override; | 69 base::TimeTicks deadline_max) override; |
| 70 bool HasCurrentFrame() override; | 70 bool HasCurrentFrame() override; |
| 71 scoped_refptr<VideoFrame> GetCurrentFrame() override; | 71 scoped_refptr<VideoFrame> GetCurrentFrame() override; |
| 72 void PutCurrentFrame() override; | 72 void PutCurrentFrame() override; |
| 73 | 73 |
| 74 // VideoRendererSink implementation. These methods must be called from the | 74 // VideoRendererSink implementation. These methods must be called from the |
| 75 // same thread (typically the media thread). | 75 // same thread (typically the media thread). |
| 76 void Start(RenderCallback* callback) override; | 76 void Start(RenderCallback* callback) override; |
| 77 void Stop() override; | 77 void Stop() override; |
| 78 void PaintFrameUsingOldRenderingPath( | 78 void PaintSingleFrame(const scoped_refptr<VideoFrame>& frame) override; |
| 79 const scoped_refptr<VideoFrame>& frame) override; | |
| 80 | 79 |
| 81 // Returns |current_frame_| if |client_| is set. If no |client_| is set, | 80 // Returns |current_frame_| if |client_| is set. If no |client_| is set, |
| 82 // |is_background_rendering_| is true, and |callback_| is set, it requests a | 81 // |is_background_rendering_| is true, and |callback_| is set, it requests a |
| 83 // new frame from |callback_|, using the elapsed time between calls to this | 82 // new frame from |callback_|, using the elapsed time between calls to this |
| 84 // function as the render interval; defaulting to 16.6ms if no prior calls | 83 // function as the render interval; defaulting to 16.6ms if no prior calls |
| 85 // have been made. A cap of 250Hz (4ms) is in place to prevent clients from | 84 // have been made. A cap of 250Hz (4ms) is in place to prevent clients from |
| 86 // accidentally (or intentionally) spamming the rendering pipeline. | 85 // accidentally (or intentionally) spamming the rendering pipeline. |
| 87 // | 86 // |
| 88 // This method is primarily to facilitate canvas and WebGL based applications | 87 // This method is primarily to facilitate canvas and WebGL based applications |
| 89 // where the <video> tag is invisible (possibly not even in the DOM) and thus | 88 // where the <video> tag is invisible (possibly not even in the DOM) and thus |
| 90 // does not receive a |client_|. In this case, frame acquisition is driven by | 89 // does not receive a |client_|. In this case, frame acquisition is driven by |
| 91 // the frequency of canvas or WebGL paints requested via JavaScript. | 90 // the frequency of canvas or WebGL paints requested via JavaScript. |
| 92 scoped_refptr<VideoFrame> GetCurrentFrameAndUpdateIfStale(); | 91 scoped_refptr<VideoFrame> GetCurrentFrameAndUpdateIfStale(); |
| 93 | 92 |
| 94 // Returns the timestamp of the current (possibly stale) frame, or | 93 // Returns the timestamp of the current (possibly stale) frame, or |
| 95 // base::TimeDelta() if there is no current frame. This method may be called | 94 // base::TimeDelta() if there is no current frame. This method may be called |
| 96 // from the media thread as long as the VFC is stopped. (Assuming that | 95 // from the media thread as long as the VFC is stopped. (Assuming that |
| 97 // PaintFrameUsingOldRenderingPath() is not also called while stopped.) | 96 // PaintSingleFrame() is not also called while stopped.) |
| 98 base::TimeDelta GetCurrentFrameTimestamp() const; | 97 base::TimeDelta GetCurrentFrameTimestamp() const; |
| 99 | 98 |
| 100 void set_tick_clock_for_testing(std::unique_ptr<base::TickClock> tick_clock) { | 99 void set_tick_clock_for_testing(std::unique_ptr<base::TickClock> tick_clock) { |
| 101 tick_clock_ = std::move(tick_clock); | 100 tick_clock_ = std::move(tick_clock); |
| 102 } | 101 } |
| 103 | 102 |
| 104 void clear_current_frame_for_testing() { current_frame_ = nullptr; } | 103 void clear_current_frame_for_testing() { current_frame_ = nullptr; } |
| 105 | 104 |
| 106 // Enables or disables background rendering. If |enabled|, |timeout| is the | 105 // Enables or disables background rendering. If |enabled|, |timeout| is the |
| 107 // amount of time to wait after the last Render() call before starting the | 106 // amount of time to wait after the last Render() call before starting the |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 // These values are updated and read from the media and compositor threads. | 157 // These values are updated and read from the media and compositor threads. |
| 159 base::Lock callback_lock_; | 158 base::Lock callback_lock_; |
| 160 VideoRendererSink::RenderCallback* callback_; | 159 VideoRendererSink::RenderCallback* callback_; |
| 161 | 160 |
| 162 DISALLOW_COPY_AND_ASSIGN(VideoFrameCompositor); | 161 DISALLOW_COPY_AND_ASSIGN(VideoFrameCompositor); |
| 163 }; | 162 }; |
| 164 | 163 |
| 165 } // namespace media | 164 } // namespace media |
| 166 | 165 |
| 167 #endif // MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ | 166 #endif // MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ |
| OLD | NEW |