| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // The bulk of this file is support code; sorry about that. Here's an overview | 5 // The bulk of this file is support code; sorry about that. Here's an overview |
| 6 // to hopefully help readers of this code: | 6 // to hopefully help readers of this code: |
| 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or | 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or |
| 8 // Win/EGL. | 8 // Win/EGL. |
| 9 // - ClientState is an enum for the state of the decode client used by the test. | 9 // - ClientState is an enum for the state of the decode client used by the test. |
| 10 // - ClientStateNotification is a barrier abstraction that allows the test code | 10 // - ClientStateNotification is a barrier abstraction that allows the test code |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #include "ui/gfx/codec/png_codec.h" | 53 #include "ui/gfx/codec/png_codec.h" |
| 54 | 54 |
| 55 #if defined(OS_WIN) | 55 #if defined(OS_WIN) |
| 56 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" | 56 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
| 57 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 57 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 58 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" | 58 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" |
| 59 #include "content/common/gpu/media/v4l2_video_device.h" | 59 #include "content/common/gpu/media/v4l2_video_device.h" |
| 60 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 60 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 61 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" | 61 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" |
| 62 #include "content/common/gpu/media/vaapi_wrapper.h" | 62 #include "content/common/gpu/media/vaapi_wrapper.h" |
| 63 #if defined(USE_X11) | |
| 64 #include "ui/gl/gl_implementation.h" | |
| 65 #endif // USE_X11 | |
| 66 #else | 63 #else |
| 67 #error The VideoAccelerator tests are not supported on this platform. | 64 #error The VideoAccelerator tests are not supported on this platform. |
| 68 #endif // OS_WIN | 65 #endif // OS_WIN |
| 69 | 66 |
| 70 using media::VideoDecodeAccelerator; | 67 using media::VideoDecodeAccelerator; |
| 71 | 68 |
| 72 namespace content { | 69 namespace content { |
| 73 namespace { | 70 namespace { |
| 74 | 71 |
| 75 // Values optionally filled in from flags; see main() below. | 72 // Values optionally filled in from flags; see main() below. |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 new DXVAVideoDecodeAccelerator(base::Bind(&DoNothingReturnTrue))); | 395 new DXVAVideoDecodeAccelerator(base::Bind(&DoNothingReturnTrue))); |
| 399 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 396 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 400 | 397 |
| 401 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); | 398 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); |
| 402 if (!device.get()) { | 399 if (!device.get()) { |
| 403 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 400 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 404 return; | 401 return; |
| 405 } | 402 } |
| 406 decoder_.reset(new V4L2VideoDecodeAccelerator( | 403 decoder_.reset(new V4L2VideoDecodeAccelerator( |
| 407 static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()), | 404 static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()), |
| 408 static_cast<EGLContext>(rendering_helper_->GetGLContext()), | 405 static_cast<EGLContext>(rendering_helper_->GetGLContextHandle()), |
| 409 weak_client, | 406 weak_client, base::Bind(&DoNothingReturnTrue), device.Pass(), |
| 410 base::Bind(&DoNothingReturnTrue), | |
| 411 device.Pass(), | |
| 412 base::MessageLoopProxy::current())); | 407 base::MessageLoopProxy::current())); |
| 413 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 408 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 414 CHECK_EQ(gfx::kGLImplementationDesktopGL, gfx::GetGLImplementation()) | 409 decoder_.reset( |
| 415 << "Hardware video decode does not work with OSMesa"; | 410 new VaapiVideoDecodeAccelerator(rendering_helper_->GetGLContext().get(), |
| 416 decoder_.reset(new VaapiVideoDecodeAccelerator( | 411 base::Bind(&DoNothingReturnTrue))); |
| 417 static_cast<Display*>(rendering_helper_->GetGLDisplay()), | |
| 418 base::Bind(&DoNothingReturnTrue))); | |
| 419 #endif // OS_WIN | 412 #endif // OS_WIN |
| 420 CHECK(decoder_.get()); | 413 CHECK(decoder_.get()); |
| 421 weak_decoder_factory_.reset( | 414 weak_decoder_factory_.reset( |
| 422 new base::WeakPtrFactory<VideoDecodeAccelerator>(decoder_.get())); | 415 new base::WeakPtrFactory<VideoDecodeAccelerator>(decoder_.get())); |
| 423 SetState(CS_DECODER_SET); | 416 SetState(CS_DECODER_SET); |
| 424 if (decoder_deleted()) | 417 if (decoder_deleted()) |
| 425 return; | 418 return; |
| 426 | 419 |
| 427 CHECK(decoder_->Initialize(profile_, client)); | 420 CHECK(decoder_->Initialize(profile_, client)); |
| 428 FinishInitialization(); | 421 FinishInitialization(); |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 | 859 |
| 867 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() | 860 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() |
| 868 : rendering_thread_("GLRenderingVDAClientThread") {} | 861 : rendering_thread_("GLRenderingVDAClientThread") {} |
| 869 | 862 |
| 870 void VideoDecodeAcceleratorTest::SetUp() { | 863 void VideoDecodeAcceleratorTest::SetUp() { |
| 871 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); | 864 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); |
| 872 | 865 |
| 873 // Initialize the rendering thread. | 866 // Initialize the rendering thread. |
| 874 base::Thread::Options options; | 867 base::Thread::Options options; |
| 875 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; | 868 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; |
| 876 #if defined(OS_WIN) | 869 #if defined(OS_WIN) || defined(USE_OZONE) |
| 877 // For windows the decoding thread initializes the media foundation decoder | 870 // For windows the decoding thread initializes the media foundation decoder |
| 878 // which uses COM. We need the thread to be a UI thread. | 871 // which uses COM. We need the thread to be a UI thread. |
| 872 // On Ozone, the backend initializes the event system using a UI |
| 873 // thread. |
| 879 options.message_loop_type = base::MessageLoop::TYPE_UI; | 874 options.message_loop_type = base::MessageLoop::TYPE_UI; |
| 880 #endif // OS_WIN | 875 #endif // OS_WIN || USE_OZONE |
| 881 | 876 |
| 882 rendering_thread_.StartWithOptions(options); | 877 rendering_thread_.StartWithOptions(options); |
| 883 rendering_loop_proxy_ = rendering_thread_.message_loop_proxy(); | 878 rendering_loop_proxy_ = rendering_thread_.message_loop_proxy(); |
| 884 } | 879 } |
| 885 | 880 |
| 886 void VideoDecodeAcceleratorTest::TearDown() { | 881 void VideoDecodeAcceleratorTest::TearDown() { |
| 887 rendering_loop_proxy_->PostTask( | 882 rendering_loop_proxy_->PostTask( |
| 888 FROM_HERE, | 883 FROM_HERE, |
| 889 base::Bind(&STLDeleteElements<std::vector<TestVideoFile*> >, | 884 base::Bind(&STLDeleteElements<std::vector<TestVideoFile*> >, |
| 890 &test_video_files_)); | 885 &test_video_files_)); |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 CHECK(base::StringToInt(input, &content::g_rendering_warm_up)); | 1426 CHECK(base::StringToInt(input, &content::g_rendering_warm_up)); |
| 1432 continue; | 1427 continue; |
| 1433 } | 1428 } |
| 1434 // TODO(owenlin): Remove this flag once it is not used in autotest. | 1429 // TODO(owenlin): Remove this flag once it is not used in autotest. |
| 1435 if (it->first == "disable_rendering") { | 1430 if (it->first == "disable_rendering") { |
| 1436 content::g_rendering_fps = 0; | 1431 content::g_rendering_fps = 0; |
| 1437 continue; | 1432 continue; |
| 1438 } | 1433 } |
| 1439 if (it->first == "v" || it->first == "vmodule") | 1434 if (it->first == "v" || it->first == "vmodule") |
| 1440 continue; | 1435 continue; |
| 1436 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless") |
| 1437 continue; |
| 1441 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; | 1438 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; |
| 1442 } | 1439 } |
| 1443 | 1440 |
| 1444 base::ShadowingAtExitManager at_exit_manager; | 1441 base::ShadowingAtExitManager at_exit_manager; |
| 1445 content::RenderingHelper::InitializeOneOff(); | 1442 content::RenderingHelper::InitializeOneOff(); |
| 1446 | 1443 |
| 1447 return RUN_ALL_TESTS(); | 1444 return RUN_ALL_TESTS(); |
| 1448 } | 1445 } |
| OLD | NEW |