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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 RenderingHelper::RenderedVideo::RenderedVideo(const RenderedVideo& other) = | 183 RenderingHelper::RenderedVideo::RenderedVideo(const RenderedVideo& other) = |
184 default; | 184 default; |
185 | 185 |
186 RenderingHelper::RenderedVideo::~RenderedVideo() {} | 186 RenderingHelper::RenderedVideo::~RenderedVideo() {} |
187 | 187 |
188 // static | 188 // static |
189 void RenderingHelper::InitializeOneOff(base::WaitableEvent* done) { | 189 void RenderingHelper::InitializeOneOff(base::WaitableEvent* done) { |
190 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 190 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
191 #if GL_VARIANT_GLX | 191 #if GL_VARIANT_GLX |
192 cmd_line->AppendSwitchASCII(switches::kUseGL, | 192 cmd_line->AppendSwitchASCII(switches::kUseGL, |
193 gfx::kGLImplementationDesktopName); | 193 gl::kGLImplementationDesktopName); |
194 #else | 194 #else |
195 cmd_line->AppendSwitchASCII(switches::kUseGL, gfx::kGLImplementationEGLName); | 195 cmd_line->AppendSwitchASCII(switches::kUseGL, gl::kGLImplementationEGLName); |
196 #endif | 196 #endif |
197 | 197 |
198 if (!gl::init::InitializeGLOneOff()) | 198 if (!gl::init::InitializeGLOneOff()) |
199 LOG(FATAL) << "Could not initialize GL"; | 199 LOG(FATAL) << "Could not initialize GL"; |
200 done->Signal(); | 200 done->Signal(); |
201 } | 201 } |
202 | 202 |
203 RenderingHelper::RenderingHelper() : ignore_vsync_(false) { | 203 RenderingHelper::RenderingHelper() : ignore_vsync_(false) { |
204 window_ = gfx::kNullAcceleratedWidget; | 204 window_ = gfx::kNullAcceleratedWidget; |
205 Clear(); | 205 Clear(); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 render_as_thumbnails_ = params.render_as_thumbnails; | 340 render_as_thumbnails_ = params.render_as_thumbnails; |
341 message_loop_ = base::MessageLoop::current(); | 341 message_loop_ = base::MessageLoop::current(); |
342 | 342 |
343 gl_surface_ = gl::init::CreateViewGLSurface(window_); | 343 gl_surface_ = gl::init::CreateViewGLSurface(window_); |
344 #if defined(USE_OZONE) | 344 #if defined(USE_OZONE) |
345 gl_surface_->Resize(platform_window_delegate_->GetSize(), 1.f, true); | 345 gl_surface_->Resize(platform_window_delegate_->GetSize(), 1.f, true); |
346 #endif // defined(USE_OZONE) | 346 #endif // defined(USE_OZONE) |
347 screen_size_ = gl_surface_->GetSize(); | 347 screen_size_ = gl_surface_->GetSize(); |
348 | 348 |
349 gl_context_ = gl::init::CreateGLContext(nullptr, gl_surface_.get(), | 349 gl_context_ = gl::init::CreateGLContext(nullptr, gl_surface_.get(), |
350 gfx::PreferIntegratedGpu); | 350 gl::PreferIntegratedGpu); |
351 CHECK(gl_context_->MakeCurrent(gl_surface_.get())); | 351 CHECK(gl_context_->MakeCurrent(gl_surface_.get())); |
352 | 352 |
353 CHECK_GT(params.window_sizes.size(), 0U); | 353 CHECK_GT(params.window_sizes.size(), 0U); |
354 videos_.resize(params.window_sizes.size()); | 354 videos_.resize(params.window_sizes.size()); |
355 LayoutRenderingAreas(params.window_sizes); | 355 LayoutRenderingAreas(params.window_sizes); |
356 | 356 |
357 if (render_as_thumbnails_) { | 357 if (render_as_thumbnails_) { |
358 CHECK_EQ(videos_.size(), 1U); | 358 CHECK_EQ(videos_.size(), 1U); |
359 | 359 |
360 GLint max_texture_size; | 360 GLint max_texture_size; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 glBindTexture(texture_target, 0); | 648 glBindTexture(texture_target, 0); |
649 CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); | 649 CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); |
650 } | 650 } |
651 | 651 |
652 void RenderingHelper::DeleteTexture(uint32_t texture_id) { | 652 void RenderingHelper::DeleteTexture(uint32_t texture_id) { |
653 CHECK_EQ(base::MessageLoop::current(), message_loop_); | 653 CHECK_EQ(base::MessageLoop::current(), message_loop_); |
654 glDeleteTextures(1, &texture_id); | 654 glDeleteTextures(1, &texture_id); |
655 CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); | 655 CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); |
656 } | 656 } |
657 | 657 |
658 gfx::GLContext* RenderingHelper::GetGLContext() { | 658 gl::GLContext* RenderingHelper::GetGLContext() { |
659 return gl_context_.get(); | 659 return gl_context_.get(); |
660 } | 660 } |
661 | 661 |
662 void* RenderingHelper::GetGLDisplay() { | 662 void* RenderingHelper::GetGLDisplay() { |
663 return gl_surface_->GetDisplay(); | 663 return gl_surface_->GetDisplay(); |
664 } | 664 } |
665 | 665 |
666 void RenderingHelper::Clear() { | 666 void RenderingHelper::Clear() { |
667 videos_.clear(); | 667 videos_.clear(); |
668 message_loop_ = NULL; | 668 message_loop_ = NULL; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 // When the rendering falls behind, drops frames. | 872 // When the rendering falls behind, drops frames. |
873 while (scheduled_render_time_ < target) { | 873 while (scheduled_render_time_ < target) { |
874 scheduled_render_time_ += frame_duration_; | 874 scheduled_render_time_ += frame_duration_; |
875 DropOneFrameForAllVideos(); | 875 DropOneFrameForAllVideos(); |
876 } | 876 } |
877 | 877 |
878 message_loop_->PostDelayedTask(FROM_HERE, render_task_.callback(), | 878 message_loop_->PostDelayedTask(FROM_HERE, render_task_.callback(), |
879 target - now); | 879 target - now); |
880 } | 880 } |
881 } // namespace media | 881 } // namespace media |
OLD | NEW |