| 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 28 matching lines...) Expand all Loading... |
| 39 #include "base/process/process_handle.h" | 39 #include "base/process/process_handle.h" |
| 40 #include "base/stl_util.h" | 40 #include "base/stl_util.h" |
| 41 #include "base/strings/string_number_conversions.h" | 41 #include "base/strings/string_number_conversions.h" |
| 42 #include "base/strings/string_split.h" | 42 #include "base/strings/string_split.h" |
| 43 #include "base/strings/stringize_macros.h" | 43 #include "base/strings/stringize_macros.h" |
| 44 #include "base/strings/stringprintf.h" | 44 #include "base/strings/stringprintf.h" |
| 45 #include "base/strings/utf_string_conversions.h" | 45 #include "base/strings/utf_string_conversions.h" |
| 46 #include "base/synchronization/condition_variable.h" | 46 #include "base/synchronization/condition_variable.h" |
| 47 #include "base/synchronization/lock.h" | 47 #include "base/synchronization/lock.h" |
| 48 #include "base/synchronization/waitable_event.h" | 48 #include "base/synchronization/waitable_event.h" |
| 49 #include "base/thread_task_runner_handle.h" |
| 49 #include "base/threading/thread.h" | 50 #include "base/threading/thread.h" |
| 50 #include "content/common/gpu/media/fake_video_decode_accelerator.h" | 51 #include "content/common/gpu/media/fake_video_decode_accelerator.h" |
| 51 #include "content/common/gpu/media/rendering_helper.h" | 52 #include "content/common/gpu/media/rendering_helper.h" |
| 52 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h" | 53 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h" |
| 53 #include "content/public/common/content_switches.h" | 54 #include "content/public/common/content_switches.h" |
| 54 #include "media/filters/h264_parser.h" | 55 #include "media/filters/h264_parser.h" |
| 55 #include "ui/gfx/codec/png_codec.h" | 56 #include "ui/gfx/codec/png_codec.h" |
| 56 #include "ui/gl/gl_image.h" | 57 #include "ui/gl/gl_image.h" |
| 57 | 58 |
| 58 #if defined(OS_WIN) | 59 #if defined(OS_WIN) |
| 59 #include "base/win/windows_version.h" | 60 #include "base/win/windows_version.h" |
| 60 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" | 61 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
| 61 #elif defined(OS_CHROMEOS) | 62 #elif defined(OS_CHROMEOS) |
| 62 #if defined(USE_V4L2_CODEC) | 63 #if defined(USE_V4L2_CODEC) |
| 63 #include "content/common/gpu/media/v4l2_slice_video_decode_accelerator.h" | 64 #include "content/common/gpu/media/v4l2_slice_video_decode_accelerator.h" |
| 64 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" | 65 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" |
| 65 #include "content/common/gpu/media/v4l2_video_device.h" | 66 #include "content/common/gpu/media/v4l2_video_device.h" |
| 66 #endif | 67 #endif |
| 67 #if defined(ARCH_CPU_X86_FAMILY) | 68 #if defined(ARCH_CPU_X86_FAMILY) |
| 68 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" | 69 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" |
| 69 #include "content/common/gpu/media/vaapi_wrapper.h" | 70 #include "content/common/gpu/media/vaapi_wrapper.h" |
| 70 #endif // defined(ARCH_CPU_X86_FAMILY) | 71 #endif // defined(ARCH_CPU_X86_FAMILY) |
| 71 #else | 72 #else |
| 72 #error The VideoAccelerator tests are not supported on this platform. | 73 #error The VideoAccelerator tests are not supported on this platform. |
| 73 #endif // OS_WIN | 74 #endif // OS_WIN |
| 74 | 75 |
| 75 #if defined(USE_OZONE) | 76 #if defined(USE_OZONE) |
| 77 #include "ui/ozone/public/ozone_gpu_test_helper.h" |
| 76 #include "ui/ozone/public/ozone_platform.h" | 78 #include "ui/ozone/public/ozone_platform.h" |
| 77 #endif // defined(USE_OZONE) | 79 #endif // defined(USE_OZONE) |
| 78 | 80 |
| 79 using media::VideoDecodeAccelerator; | 81 using media::VideoDecodeAccelerator; |
| 80 | 82 |
| 81 namespace content { | 83 namespace content { |
| 82 namespace { | 84 namespace { |
| 83 | 85 |
| 84 // Values optionally filled in from flags; see main() below. | 86 // Values optionally filled in from flags; see main() below. |
| 85 // The syntax of multiple test videos is: | 87 // The syntax of multiple test videos is: |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 VideoDecodeAcceleratorTestEnvironment() | 222 VideoDecodeAcceleratorTestEnvironment() |
| 221 : rendering_thread_("GLRenderingVDAClientThread") {} | 223 : rendering_thread_("GLRenderingVDAClientThread") {} |
| 222 | 224 |
| 223 void SetUp() override { | 225 void SetUp() override { |
| 224 rendering_thread_.Start(); | 226 rendering_thread_.Start(); |
| 225 | 227 |
| 226 base::WaitableEvent done(false, false); | 228 base::WaitableEvent done(false, false); |
| 227 rendering_thread_.task_runner()->PostTask( | 229 rendering_thread_.task_runner()->PostTask( |
| 228 FROM_HERE, base::Bind(&RenderingHelper::InitializeOneOff, &done)); | 230 FROM_HERE, base::Bind(&RenderingHelper::InitializeOneOff, &done)); |
| 229 done.Wait(); | 231 done.Wait(); |
| 232 |
| 233 #if defined(USE_OZONE) |
| 234 // Need to initialize after the rendering side since the rendering side |
| 235 // initializes the "GPU" parts of Ozone. |
| 236 // |
| 237 // This also needs to be done in the test environment since this shouldn't |
| 238 // be initialized multiple times for the same Ozone platform. |
| 239 gpu_helper_.Initialize(base::ThreadTaskRunnerHandle::Get(), |
| 240 GetRenderingTaskRunner()); |
| 241 #endif |
| 230 } | 242 } |
| 231 | 243 |
| 232 void TearDown() override { rendering_thread_.Stop(); } | 244 void TearDown() override { rendering_thread_.Stop(); } |
| 233 | 245 |
| 234 scoped_refptr<base::SingleThreadTaskRunner> GetRenderingTaskRunner() const { | 246 scoped_refptr<base::SingleThreadTaskRunner> GetRenderingTaskRunner() const { |
| 235 return rendering_thread_.task_runner(); | 247 return rendering_thread_.task_runner(); |
| 236 } | 248 } |
| 237 | 249 |
| 238 private: | 250 private: |
| 239 base::Thread rendering_thread_; | 251 base::Thread rendering_thread_; |
| 252 #if defined(USE_OZONE) |
| 253 ui::OzoneGpuTestHelper gpu_helper_; |
| 254 #endif |
| 240 | 255 |
| 241 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTestEnvironment); | 256 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTestEnvironment); |
| 242 }; | 257 }; |
| 243 | 258 |
| 244 // A helper class used to manage the lifetime of a Texture. | 259 // A helper class used to manage the lifetime of a Texture. |
| 245 class TextureRef : public base::RefCounted<TextureRef> { | 260 class TextureRef : public base::RefCounted<TextureRef> { |
| 246 public: | 261 public: |
| 247 TextureRef(uint32 texture_id, const base::Closure& no_longer_needed_cb) | 262 TextureRef(uint32 texture_id, const base::Closure& no_longer_needed_cb) |
| 248 : texture_id_(texture_id), no_longer_needed_cb_(no_longer_needed_cb) {} | 263 : texture_id_(texture_id), no_longer_needed_cb_(no_longer_needed_cb) {} |
| 249 | 264 |
| (...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1613 ui::OzonePlatform::InitializeForUI(); | 1628 ui::OzonePlatform::InitializeForUI(); |
| 1614 #endif | 1629 #endif |
| 1615 | 1630 |
| 1616 content::g_env = | 1631 content::g_env = |
| 1617 reinterpret_cast<content::VideoDecodeAcceleratorTestEnvironment*>( | 1632 reinterpret_cast<content::VideoDecodeAcceleratorTestEnvironment*>( |
| 1618 testing::AddGlobalTestEnvironment( | 1633 testing::AddGlobalTestEnvironment( |
| 1619 new content::VideoDecodeAcceleratorTestEnvironment())); | 1634 new content::VideoDecodeAcceleratorTestEnvironment())); |
| 1620 | 1635 |
| 1621 return RUN_ALL_TESTS(); | 1636 return RUN_ALL_TESTS(); |
| 1622 } | 1637 } |
| OLD | NEW |