| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "media/gpu/rendering_helper.h" | 5 #include "media/gpu/rendering_helper.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 #endif | 318 #endif |
| 319 #endif | 319 #endif |
| 320 window_ = gfx::kNullAcceleratedWidget; | 320 window_ = gfx::kNullAcceleratedWidget; |
| 321 } | 321 } |
| 322 | 322 |
| 323 void RenderingHelper::Initialize(const RenderingHelperParams& params, | 323 void RenderingHelper::Initialize(const RenderingHelperParams& params, |
| 324 base::WaitableEvent* done) { | 324 base::WaitableEvent* done) { |
| 325 // Use videos_.size() != 0 as a proxy for the class having already been | 325 // Use videos_.size() != 0 as a proxy for the class having already been |
| 326 // Initialize()'d, and UnInitialize() before continuing. | 326 // Initialize()'d, and UnInitialize() before continuing. |
| 327 if (videos_.size()) { | 327 if (videos_.size()) { |
| 328 base::WaitableEvent done(false, false); | 328 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 329 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 329 UnInitialize(&done); | 330 UnInitialize(&done); |
| 330 done.Wait(); | 331 done.Wait(); |
| 331 } | 332 } |
| 332 | 333 |
| 333 render_task_.Reset( | 334 render_task_.Reset( |
| 334 base::Bind(&RenderingHelper::RenderContent, base::Unretained(this))); | 335 base::Bind(&RenderingHelper::RenderContent, base::Unretained(this))); |
| 335 | 336 |
| 336 frame_duration_ = params.rendering_fps > 0 | 337 frame_duration_ = params.rendering_fps > 0 |
| 337 ? base::TimeDelta::FromSeconds(1) / params.rendering_fps | 338 ? base::TimeDelta::FromSeconds(1) / params.rendering_fps |
| 338 : base::TimeDelta(); | 339 : base::TimeDelta(); |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 // When the rendering falls behind, drops frames. | 873 // When the rendering falls behind, drops frames. |
| 873 while (scheduled_render_time_ < target) { | 874 while (scheduled_render_time_ < target) { |
| 874 scheduled_render_time_ += frame_duration_; | 875 scheduled_render_time_ += frame_duration_; |
| 875 DropOneFrameForAllVideos(); | 876 DropOneFrameForAllVideos(); |
| 876 } | 877 } |
| 877 | 878 |
| 878 message_loop_->PostDelayedTask(FROM_HERE, render_task_.callback(), | 879 message_loop_->PostDelayedTask(FROM_HERE, render_task_.callback(), |
| 879 target - now); | 880 target - now); |
| 880 } | 881 } |
| 881 } // namespace media | 882 } // namespace media |
| OLD | NEW |