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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // does not receive a |client_|. In this case, frame acquisition is driven by | 104 // does not receive a |client_|. In this case, frame acquisition is driven by |
105 // the frequency of canvas or WebGL paints requested via JavaScript. | 105 // the frequency of canvas or WebGL paints requested via JavaScript. |
106 scoped_refptr<VideoFrame> GetCurrentFrameAndUpdateIfStale(); | 106 scoped_refptr<VideoFrame> GetCurrentFrameAndUpdateIfStale(); |
107 | 107 |
108 // Returns the timestamp of the current (possibly stale) frame, or | 108 // Returns the timestamp of the current (possibly stale) frame, or |
109 // base::TimeDelta() if there is no current frame. This method may be called | 109 // base::TimeDelta() if there is no current frame. This method may be called |
110 // from the media thread as long as the VFC is stopped. (Assuming that | 110 // from the media thread as long as the VFC is stopped. (Assuming that |
111 // PaintFrameUsingOldRenderingPath() is not also called while stopped.) | 111 // PaintFrameUsingOldRenderingPath() is not also called while stopped.) |
112 base::TimeDelta GetCurrentFrameTimestamp() const; | 112 base::TimeDelta GetCurrentFrameTimestamp() const; |
113 | 113 |
114 void set_tick_clock_for_testing(scoped_ptr<base::TickClock> tick_clock) { | 114 void set_tick_clock_for_testing(std::unique_ptr<base::TickClock> tick_clock) { |
115 tick_clock_ = std::move(tick_clock); | 115 tick_clock_ = std::move(tick_clock); |
116 } | 116 } |
117 | 117 |
118 void clear_current_frame_for_testing() { current_frame_ = nullptr; } | 118 void clear_current_frame_for_testing() { current_frame_ = nullptr; } |
119 | 119 |
120 // Enables or disables background rendering. If |enabled|, |timeout| is the | 120 // Enables or disables background rendering. If |enabled|, |timeout| is the |
121 // amount of time to wait after the last Render() call before starting the | 121 // amount of time to wait after the last Render() call before starting the |
122 // background rendering mode. Note, this can not disable the background | 122 // background rendering mode. Note, this can not disable the background |
123 // rendering call issues when a sink is started. | 123 // rendering call issues when a sink is started. |
124 void set_background_rendering_for_testing(bool enabled) { | 124 void set_background_rendering_for_testing(bool enabled) { |
(...skipping 16 matching lines...) Expand all Loading... |
141 // If |callback_| is available, calls Render() with the provided properties. | 141 // If |callback_| is available, calls Render() with the provided properties. |
142 // Updates |is_background_rendering_|, |last_interval_|, and resets | 142 // Updates |is_background_rendering_|, |last_interval_|, and resets |
143 // |background_rendering_timer_|. Ensures that natural size and opacity | 143 // |background_rendering_timer_|. Ensures that natural size and opacity |
144 // changes are correctly fired. Returns true if there's a new frame available | 144 // changes are correctly fired. Returns true if there's a new frame available |
145 // via GetCurrentFrame(). | 145 // via GetCurrentFrame(). |
146 bool CallRender(base::TimeTicks deadline_min, | 146 bool CallRender(base::TimeTicks deadline_min, |
147 base::TimeTicks deadline_max, | 147 base::TimeTicks deadline_max, |
148 bool background_rendering); | 148 bool background_rendering); |
149 | 149 |
150 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; | 150 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; |
151 scoped_ptr<base::TickClock> tick_clock_; | 151 std::unique_ptr<base::TickClock> tick_clock_; |
152 | 152 |
153 // These callbacks are executed on the compositor thread. | 153 // These callbacks are executed on the compositor thread. |
154 const base::Callback<void(gfx::Size)> natural_size_changed_cb_; | 154 const base::Callback<void(gfx::Size)> natural_size_changed_cb_; |
155 const base::Callback<void(bool)> opacity_changed_cb_; | 155 const base::Callback<void(bool)> opacity_changed_cb_; |
156 | 156 |
157 // Allows tests to disable the background rendering task. | 157 // Allows tests to disable the background rendering task. |
158 bool background_rendering_enabled_; | 158 bool background_rendering_enabled_; |
159 | 159 |
160 // Manages UpdateCurrentFrame() callbacks if |client_| has stopped sending | 160 // Manages UpdateCurrentFrame() callbacks if |client_| has stopped sending |
161 // them for various reasons. Runs on |compositor_task_runner_| and is reset | 161 // them for various reasons. Runs on |compositor_task_runner_| and is reset |
(...skipping 16 matching lines...) Expand all Loading... |
178 // These values are updated and read from the media and compositor threads. | 178 // These values are updated and read from the media and compositor threads. |
179 base::Lock callback_lock_; | 179 base::Lock callback_lock_; |
180 VideoRendererSink::RenderCallback* callback_; | 180 VideoRendererSink::RenderCallback* callback_; |
181 | 181 |
182 DISALLOW_COPY_AND_ASSIGN(VideoFrameCompositor); | 182 DISALLOW_COPY_AND_ASSIGN(VideoFrameCompositor); |
183 }; | 183 }; |
184 | 184 |
185 } // namespace media | 185 } // namespace media |
186 | 186 |
187 #endif // MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ | 187 #endif // MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ |
OLD | NEW |