Chromium Code Reviews| 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 "content/common/gpu/media/rendering_helper.h" | 5 #include "content/common/gpu/media/rendering_helper.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <numeric> | 8 #include <numeric> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/mac/scoped_nsautorelease_pool.h" | 14 #include "base/mac/scoped_nsautorelease_pool.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/run_loop.h" | |
| 16 #include "base/strings/stringize_macros.h" | 17 #include "base/strings/stringize_macros.h" |
| 17 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
| 18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 19 #include "ui/gl/gl_context.h" | 20 #include "ui/gl/gl_context.h" |
| 20 #include "ui/gl/gl_implementation.h" | 21 #include "ui/gl/gl_implementation.h" |
| 21 #include "ui/gl/gl_surface.h" | 22 #include "ui/gl/gl_surface.h" |
| 22 | 23 |
| 23 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
| 24 #include <windows.h> | 25 #include <windows.h> |
| 25 #endif | 26 #endif |
| 26 | 27 |
| 27 #if defined(USE_X11) | 28 #if defined(USE_X11) |
| 28 #include "ui/gfx/x/x11_types.h" | 29 #include "ui/gfx/x/x11_types.h" |
| 29 #endif | 30 #endif |
| 30 | 31 |
| 31 #if defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) | 32 #if defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) |
| 32 #include "ui/gl/gl_surface_glx.h" | 33 #include "ui/gl/gl_surface_glx.h" |
| 33 #define GL_VARIANT_GLX 1 | 34 #define GL_VARIANT_GLX 1 |
| 34 #else | 35 #else |
| 35 #include "ui/gl/gl_surface_egl.h" | 36 #include "ui/gl/gl_surface_egl.h" |
| 36 #define GL_VARIANT_EGL 1 | 37 #define GL_VARIANT_EGL 1 |
| 37 #endif | 38 #endif |
| 38 | 39 |
| 39 #if defined(USE_OZONE) | 40 #if defined(USE_OZONE) |
| 40 #if defined(OS_CHROMEOS) | 41 #if defined(OS_CHROMEOS) |
| 41 #include "ui/display/chromeos/display_configurator.h" | 42 #include "ui/display/chromeos/display_configurator.h" |
| 43 #include "ui/display/types/display_constants.h" | |
| 42 #endif // defined(OS_CHROMEOS) | 44 #endif // defined(OS_CHROMEOS) |
| 43 #include "ui/ozone/public/ozone_platform.h" | 45 #include "ui/ozone/public/ozone_platform.h" |
| 44 #include "ui/ozone/public/ui_thread_gpu.h" | 46 #include "ui/ozone/public/ui_thread_gpu.h" |
| 45 #include "ui/platform_window/platform_window.h" | 47 #include "ui/platform_window/platform_window.h" |
| 46 #include "ui/platform_window/platform_window_delegate.h" | 48 #include "ui/platform_window/platform_window_delegate.h" |
| 47 #endif // defined(USE_OZONE) | 49 #endif // defined(USE_OZONE) |
| 48 | 50 |
| 49 // Helper for Shader creation. | 51 // Helper for Shader creation. |
| 50 static void CreateShader(GLuint program, | 52 static void CreateShader(GLuint program, |
| 51 GLenum type, | 53 GLenum type, |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 XHeightOfScreen(screen), | 223 XHeightOfScreen(screen), |
| 222 0 /* border width */, | 224 0 /* border width */, |
| 223 depth, | 225 depth, |
| 224 CopyFromParent /* class */, | 226 CopyFromParent /* class */, |
| 225 CopyFromParent /* visual */, | 227 CopyFromParent /* visual */, |
| 226 (CWBackPixel | CWOverrideRedirect), | 228 (CWBackPixel | CWOverrideRedirect), |
| 227 &window_attributes); | 229 &window_attributes); |
| 228 XStoreName(display, window_, "VideoDecodeAcceleratorTest"); | 230 XStoreName(display, window_, "VideoDecodeAcceleratorTest"); |
| 229 XSelectInput(display, window_, ExposureMask); | 231 XSelectInput(display, window_, ExposureMask); |
| 230 XMapWindow(display, window_); | 232 XMapWindow(display, window_); |
| 231 #elif defined(USE_OZONE) | 233 #elif defined(USE_OZONE) |
|
dnicoara
2015/01/21 19:21:35
Spoke with spang@ and now I understand what's goin
Owen Lin
2015/01/22 03:46:44
In addition, maybe we can move some code to Initil
llandwerlin-old
2015/01/22 11:03:18
Doing the window creation in InitializeOnOff means
llandwerlin-old
2015/01/22 11:03:18
Thanks for the explanation.
Owen Lin
2015/01/23 08:57:38
Good idea.
| |
| 232 platform_window_delegate_.reset(new RenderingHelper::StubOzoneDelegate()); | 234 platform_window_delegate_.reset(new RenderingHelper::StubOzoneDelegate()); |
| 233 window_ = platform_window_delegate_->accelerated_widget(); | 235 window_ = platform_window_delegate_->accelerated_widget(); |
| 234 #if defined(OS_CHROMEOS) | 236 #if defined(OS_CHROMEOS) |
| 235 display_configurator_.reset(new ui::DisplayConfigurator()); | 237 // We hold onto the main loop here to wait for the DisplayController |
| 238 // to give us the size of the display so we can create a window of | |
| 239 // the same size. | |
| 240 base::MessageLoop::ScopedNestableTaskAllower nest_loop( | |
|
dnicoara
2015/01/21 19:21:35
You shouldn't need this anymore.
llandwerlin-old
2015/01/22 11:03:18
Acknowledged.
| |
| 241 base::MessageLoop::current()); | |
| 242 display_configurator_.reset(new ui::DisplayConfigurator); | |
| 236 display_configurator_->Init(true); | 243 display_configurator_->Init(true); |
| 237 display_configurator_->ForceInitialConfigure(0); | 244 display_configurator_->ForceInitialConfigure(0); |
| 245 // Make sure all the display configuration is applied. | |
| 246 base::RunLoop().RunUntilIdle(); | |
|
Owen Lin
2015/01/22 03:46:44
The correctness of using "RunUntilIdle()" here is
llandwerlin-old
2015/01/22 11:03:18
I agree, posting a message to a different thread a
| |
| 247 display_configurator_->SetDisplayMode(ui::MULTIPLE_DISPLAY_STATE_SINGLE); | |
| 248 // Make sure all the display configuration is applied. | |
| 249 base::RunLoop().RunUntilIdle(); | |
| 238 platform_window_delegate_->platform_window()->SetBounds( | 250 platform_window_delegate_->platform_window()->SetBounds( |
| 239 gfx::Rect(display_configurator_->framebuffer_size())); | 251 gfx::Rect(display_configurator_->framebuffer_size())); |
| 240 #else | 252 #else |
| 241 platform_window_delegate_->platform_window()->SetBounds(gfx::Rect(800, 600)); | 253 platform_window_delegate_->platform_window()->SetBounds(gfx::Rect(800, 600)); |
| 242 #endif | 254 #endif |
| 255 // Wait for the window to be resized. | |
| 256 base::RunLoop().RunUntilIdle(); | |
| 243 #else | 257 #else |
| 244 #error unknown platform | 258 #error unknown platform |
| 245 #endif | 259 #endif |
| 246 CHECK(window_ != gfx::kNullAcceleratedWidget); | 260 CHECK(window_ != gfx::kNullAcceleratedWidget); |
| 247 | 261 |
| 248 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(window_); | 262 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(window_); |
| 249 screen_size_ = gl_surface_->GetSize(); | 263 screen_size_ = gl_surface_->GetSize(); |
| 250 | 264 |
| 251 gl_context_ = gfx::GLContext::CreateGLContext( | 265 gl_context_ = gfx::GLContext::CreateGLContext( |
| 252 NULL, gl_surface_.get(), gfx::PreferIntegratedGpu); | 266 NULL, gl_surface_.get(), gfx::PreferIntegratedGpu); |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 // When the rendering falls behind, drops frames. | 796 // When the rendering falls behind, drops frames. |
| 783 while (scheduled_render_time_ < target) { | 797 while (scheduled_render_time_ < target) { |
| 784 scheduled_render_time_ += frame_duration_; | 798 scheduled_render_time_ += frame_duration_; |
| 785 DropOneFrameForAllVideos(); | 799 DropOneFrameForAllVideos(); |
| 786 } | 800 } |
| 787 | 801 |
| 788 message_loop_->PostDelayedTask( | 802 message_loop_->PostDelayedTask( |
| 789 FROM_HERE, render_task_.callback(), target - now); | 803 FROM_HERE, render_task_.callback(), target - now); |
| 790 } | 804 } |
| 791 } // namespace content | 805 } // namespace content |
| OLD | NEW |