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> |
11 #include <numeric> | 11 #include <numeric> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/callback_helpers.h" | 15 #include "base/callback_helpers.h" |
16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/mac/scoped_nsautorelease_pool.h" | 17 #include "base/mac/scoped_nsautorelease_pool.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
21 #include "base/strings/stringize_macros.h" | 21 #include "base/strings/stringize_macros.h" |
22 #include "base/synchronization/waitable_event.h" | 22 #include "base/synchronization/waitable_event.h" |
23 #include "base/time/time.h" | 23 #include "base/time/time.h" |
24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
25 #include "ui/gl/gl_context.h" | 25 #include "ui/gl/gl_context.h" |
26 #include "ui/gl/gl_implementation.h" | 26 #include "ui/gl/gl_implementation.h" |
27 #include "ui/gl/gl_surface.h" | 27 #include "ui/gl/gl_surface.h" |
| 28 #include "ui/gl/init/gl_factory.h" |
28 | 29 |
29 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
30 #include <windows.h> | 31 #include <windows.h> |
31 #endif | 32 #endif |
32 | 33 |
33 #if defined(USE_X11) | 34 #if defined(USE_X11) |
34 #include "ui/gfx/x/x11_types.h" | 35 #include "ui/gfx/x/x11_types.h" |
35 #endif | 36 #endif |
36 | 37 |
37 #if defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) | 38 #if defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // static | 188 // static |
188 void RenderingHelper::InitializeOneOff(base::WaitableEvent* done) { | 189 void RenderingHelper::InitializeOneOff(base::WaitableEvent* done) { |
189 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 190 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
190 #if GL_VARIANT_GLX | 191 #if GL_VARIANT_GLX |
191 cmd_line->AppendSwitchASCII(switches::kUseGL, | 192 cmd_line->AppendSwitchASCII(switches::kUseGL, |
192 gfx::kGLImplementationDesktopName); | 193 gfx::kGLImplementationDesktopName); |
193 #else | 194 #else |
194 cmd_line->AppendSwitchASCII(switches::kUseGL, gfx::kGLImplementationEGLName); | 195 cmd_line->AppendSwitchASCII(switches::kUseGL, gfx::kGLImplementationEGLName); |
195 #endif | 196 #endif |
196 | 197 |
197 if (!gfx::GLSurface::InitializeOneOff()) | 198 if (!gl::init::InitializeGLOneOff()) |
198 LOG(FATAL) << "Could not initialize GL"; | 199 LOG(FATAL) << "Could not initialize GL"; |
199 done->Signal(); | 200 done->Signal(); |
200 } | 201 } |
201 | 202 |
202 RenderingHelper::RenderingHelper() : ignore_vsync_(false) { | 203 RenderingHelper::RenderingHelper() : ignore_vsync_(false) { |
203 window_ = gfx::kNullAcceleratedWidget; | 204 window_ = gfx::kNullAcceleratedWidget; |
204 Clear(); | 205 Clear(); |
205 } | 206 } |
206 | 207 |
207 RenderingHelper::~RenderingHelper() { | 208 RenderingHelper::~RenderingHelper() { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 render_task_.Reset( | 323 render_task_.Reset( |
323 base::Bind(&RenderingHelper::RenderContent, base::Unretained(this))); | 324 base::Bind(&RenderingHelper::RenderContent, base::Unretained(this))); |
324 | 325 |
325 frame_duration_ = params.rendering_fps > 0 | 326 frame_duration_ = params.rendering_fps > 0 |
326 ? base::TimeDelta::FromSeconds(1) / params.rendering_fps | 327 ? base::TimeDelta::FromSeconds(1) / params.rendering_fps |
327 : base::TimeDelta(); | 328 : base::TimeDelta(); |
328 | 329 |
329 render_as_thumbnails_ = params.render_as_thumbnails; | 330 render_as_thumbnails_ = params.render_as_thumbnails; |
330 message_loop_ = base::MessageLoop::current(); | 331 message_loop_ = base::MessageLoop::current(); |
331 | 332 |
332 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(window_); | 333 gl_surface_ = gl::init::CreateViewGLSurface(window_); |
333 #if defined(USE_OZONE) | 334 #if defined(USE_OZONE) |
334 gl_surface_->Resize(platform_window_delegate_->GetSize(), 1.f, true); | 335 gl_surface_->Resize(platform_window_delegate_->GetSize(), 1.f, true); |
335 #endif // defined(USE_OZONE) | 336 #endif // defined(USE_OZONE) |
336 screen_size_ = gl_surface_->GetSize(); | 337 screen_size_ = gl_surface_->GetSize(); |
337 | 338 |
338 gl_context_ = gfx::GLContext::CreateGLContext(NULL, gl_surface_.get(), | 339 gl_context_ = gl::init::CreateGLContext(nullptr, gl_surface_.get(), |
339 gfx::PreferIntegratedGpu); | 340 gfx::PreferIntegratedGpu); |
340 CHECK(gl_context_->MakeCurrent(gl_surface_.get())); | 341 CHECK(gl_context_->MakeCurrent(gl_surface_.get())); |
341 | 342 |
342 CHECK_GT(params.window_sizes.size(), 0U); | 343 CHECK_GT(params.window_sizes.size(), 0U); |
343 videos_.resize(params.window_sizes.size()); | 344 videos_.resize(params.window_sizes.size()); |
344 LayoutRenderingAreas(params.window_sizes); | 345 LayoutRenderingAreas(params.window_sizes); |
345 | 346 |
346 if (render_as_thumbnails_) { | 347 if (render_as_thumbnails_) { |
347 CHECK_EQ(videos_.size(), 1U); | 348 CHECK_EQ(videos_.size(), 1U); |
348 | 349 |
349 GLint max_texture_size; | 350 GLint max_texture_size; |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 // When the rendering falls behind, drops frames. | 841 // When the rendering falls behind, drops frames. |
841 while (scheduled_render_time_ < target) { | 842 while (scheduled_render_time_ < target) { |
842 scheduled_render_time_ += frame_duration_; | 843 scheduled_render_time_ += frame_duration_; |
843 DropOneFrameForAllVideos(); | 844 DropOneFrameForAllVideos(); |
844 } | 845 } |
845 | 846 |
846 message_loop_->PostDelayedTask(FROM_HERE, render_task_.callback(), | 847 message_loop_->PostDelayedTask(FROM_HERE, render_task_.callback(), |
847 target - now); | 848 target - now); |
848 } | 849 } |
849 } // namespace media | 850 } // namespace media |
OLD | NEW |