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 PaintSingleFrame(const scoped_refptr<VideoFrame>& frame) override; | 78 void PaintSingleFrame(const scoped_refptr<VideoFrame>& frame, |
| 79 bool repaint_duplicate_frame = false) override; |
79 | 80 |
80 // Returns |current_frame_| if |client_| is set. If no |client_| is set, | 81 // Returns |current_frame_| if |client_| is set. If no |client_| is set, |
81 // |is_background_rendering_| is true, and |callback_| is set, it requests a | 82 // |is_background_rendering_| is true, and |callback_| is set, it requests a |
82 // new frame from |callback_|, using the elapsed time between calls to this | 83 // new frame from |callback_|, using the elapsed time between calls to this |
83 // function as the render interval; defaulting to 16.6ms if no prior calls | 84 // function as the render interval; defaulting to 16.6ms if no prior calls |
84 // have been made. A cap of 250Hz (4ms) is in place to prevent clients from | 85 // have been made. A cap of 250Hz (4ms) is in place to prevent clients from |
85 // accidentally (or intentionally) spamming the rendering pipeline. | 86 // accidentally (or intentionally) spamming the rendering pipeline. |
86 // | 87 // |
87 // This method is primarily to facilitate canvas and WebGL based applications | 88 // This method is primarily to facilitate canvas and WebGL based applications |
88 // where the <video> tag is invisible (possibly not even in the DOM) and thus | 89 // where the <video> tag is invisible (possibly not even in the DOM) and thus |
(...skipping 20 matching lines...) Expand all Loading... |
109 void set_background_rendering_for_testing(bool enabled) { | 110 void set_background_rendering_for_testing(bool enabled) { |
110 background_rendering_enabled_ = enabled; | 111 background_rendering_enabled_ = enabled; |
111 } | 112 } |
112 | 113 |
113 private: | 114 private: |
114 // Called on the compositor thread in response to Start() or Stop() calls; | 115 // Called on the compositor thread in response to Start() or Stop() calls; |
115 // must be used to change |rendering_| state. | 116 // must be used to change |rendering_| state. |
116 void OnRendererStateUpdate(bool new_state); | 117 void OnRendererStateUpdate(bool new_state); |
117 | 118 |
118 // Handles setting of |current_frame_|. | 119 // Handles setting of |current_frame_|. |
119 bool ProcessNewFrame(const scoped_refptr<VideoFrame>& frame); | 120 bool ProcessNewFrame(const scoped_refptr<VideoFrame>& frame, |
| 121 bool repaint_duplicate_frame); |
120 | 122 |
121 // Called by |background_rendering_timer_| when enough time elapses where we | 123 // Called by |background_rendering_timer_| when enough time elapses where we |
122 // haven't seen a Render() call. | 124 // haven't seen a Render() call. |
123 void BackgroundRender(); | 125 void BackgroundRender(); |
124 | 126 |
125 // If |callback_| is available, calls Render() with the provided properties. | 127 // If |callback_| is available, calls Render() with the provided properties. |
126 // Updates |is_background_rendering_|, |last_interval_|, and resets | 128 // Updates |is_background_rendering_|, |last_interval_|, and resets |
127 // |background_rendering_timer_|. Returns true if there's a new frame | 129 // |background_rendering_timer_|. Returns true if there's a new frame |
128 // available via GetCurrentFrame(). | 130 // available via GetCurrentFrame(). |
129 bool CallRender(base::TimeTicks deadline_min, | 131 bool CallRender(base::TimeTicks deadline_min, |
(...skipping 27 matching lines...) Expand all Loading... |
157 // These values are updated and read from the media and compositor threads. | 159 // These values are updated and read from the media and compositor threads. |
158 base::Lock callback_lock_; | 160 base::Lock callback_lock_; |
159 VideoRendererSink::RenderCallback* callback_; | 161 VideoRendererSink::RenderCallback* callback_; |
160 | 162 |
161 DISALLOW_COPY_AND_ASSIGN(VideoFrameCompositor); | 163 DISALLOW_COPY_AND_ASSIGN(VideoFrameCompositor); |
162 }; | 164 }; |
163 | 165 |
164 } // namespace media | 166 } // namespace media |
165 | 167 |
166 #endif // MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ | 168 #endif // MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ |
OLD | NEW |