diff options
author | rockot <rockot@chromium.org> | 2016-03-13 16:40:53 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-13 23:41:58 +0000 |
commit | f749fe6715f1f3c81bda3576fd60f260ac47282a (patch) | |
tree | ef65540d2d3295c28b511cc59d0fc8bde771d6b5 /content/common/gpu | |
parent | 0c0405dd113d2184996666f43be37abb373606e8 (diff) | |
download | chromium_src-f749fe6715f1f3c81bda3576fd60f260ac47282a.zip chromium_src-f749fe6715f1f3c81bda3576fd60f260ac47282a.tar.gz chromium_src-f749fe6715f1f3c81bda3576fd60f260ac47282a.tar.bz2 |
Revert of content gpu refactor: get rid of gpu related content switches. (patchset #8 id:100002 of https://codereview.chromium.org/1784193003/ )
Reason for revert:
Closed the tree: https://build.chromium.org/p/chromium/builders/Win/builds/41257/steps/compile/logs/stdio
Original issue's description:
> content gpu refactor: get rid of gpu related content switches.
>
> BUG=590825
> CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:win_optional_gpu_tests_rel;tryserver.chromium.mac:mac_optional_gpu_tests_rel
> CQ_EXTRA_TRYBOTS=tryserver.chromium.perf:winx64_10_perf_cq;tryserver.chromium.perf:mac_retina_perf_cq;tryserver.chromium.perf:linux_perf_cq
>
> Committed: https://crrev.com/9288ad04012900a9656959f441f4519f4239dccb
> Cr-Commit-Position: refs/heads/master@{#380906}
TBR=dcheng@chromium.org,mcasas@chromium.org,piman@chromium.org,penghuang@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=590825
Review URL: https://codereview.chromium.org/1796633002
Cr-Commit-Position: refs/heads/master@{#380908}
Diffstat (limited to 'content/common/gpu')
14 files changed, 122 insertions, 159 deletions
diff --git a/content/common/gpu/gpu_host_messages.h b/content/common/gpu/gpu_host_messages.h index 2aa1490..9a18a822 100644 --- a/content/common/gpu/gpu_host_messages.h +++ b/content/common/gpu/gpu_host_messages.h @@ -104,16 +104,6 @@ IPC_STRUCT_TRAITS_BEGIN(gpu::GpuPreferences) IPC_STRUCT_TRAITS_MEMBER(single_process) IPC_STRUCT_TRAITS_MEMBER(in_process_gpu) IPC_STRUCT_TRAITS_MEMBER(ui_prioritize_in_gpu_process) - IPC_STRUCT_TRAITS_MEMBER(disable_accelerated_video_decode) -#if defined(OS_CHROMEOS) - IPC_STRUCT_TRAITS_MEMBER(disable_vaapi_accelerated_video_encode) -#endif -#if defined(ENABLE_WEBRTC) - IPC_STRUCT_TRAITS_MEMBER(disable_web_rtc_hw_encoding) -#endif -#if defined(OS_WIN) - IPC_STRUCT_TRAITS_MEMBER(enable_accelerated_vpx_decode) -#endif IPC_STRUCT_TRAITS_MEMBER(compile_shader_always_succeeds) IPC_STRUCT_TRAITS_MEMBER(disable_gl_error_limit) IPC_STRUCT_TRAITS_MEMBER(disable_glsl_translator) diff --git a/content/common/gpu/image_transport_surface_android.cc b/content/common/gpu/image_transport_surface_android.cc index df50dbc..9362b67 100644 --- a/content/common/gpu/image_transport_surface_android.cc +++ b/content/common/gpu/image_transport_surface_android.cc @@ -4,9 +4,14 @@ #include "content/common/gpu/image_transport_surface.h" +#include "base/command_line.h" #include "base/logging.h" +#include "content/common/gpu/gpu_channel.h" +#include "content/common/gpu/gpu_channel_manager.h" +#include "content/common/gpu/gpu_command_buffer_stub.h" #include "content/common/gpu/gpu_surface_lookup.h" #include "content/common/gpu/pass_through_image_transport_surface.h" +#include "content/public/common/content_switches.h" #include "ui/gl/gl_surface_egl.h" namespace content { diff --git a/content/common/gpu/image_transport_surface_win.cc b/content/common/gpu/image_transport_surface_win.cc index 7e98f11..b23a494 100644 --- a/content/common/gpu/image_transport_surface_win.cc +++ b/content/common/gpu/image_transport_surface_win.cc @@ -4,10 +4,19 @@ #include "content/common/gpu/image_transport_surface.h" +#include "base/bind.h" +#include "base/command_line.h" +#include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" +#include "base/win/windows_version.h" #include "content/common/gpu/child_window_surface_win.h" +#include "content/common/gpu/gpu_messages.h" #include "content/common/gpu/pass_through_image_transport_surface.h" +#include "content/public/common/content_switches.h" #include "ui/gfx/native_widget_types.h" #include "ui/gl/gl_bindings.h" +#include "ui/gl/gl_context.h" #include "ui/gl/gl_implementation.h" #include "ui/gl/gl_surface_egl.h" #include "ui/gl/vsync_provider_win.h" diff --git a/content/common/gpu/media/android_video_decode_accelerator.cc b/content/common/gpu/media/android_video_decode_accelerator.cc index 9eccdc6..05952cb 100644 --- a/content/common/gpu/media/android_video_decode_accelerator.cc +++ b/content/common/gpu/media/android_video_decode_accelerator.cc @@ -21,6 +21,7 @@ #include "content/common/gpu/media/android_deferred_rendering_backing_strategy.h" #include "content/common/gpu/media/avda_return_on_failure.h" #include "content/common/gpu/media/shared_memory_region.h" +#include "content/public/common/content_switches.h" #include "gpu/command_buffer/service/gles2_cmd_decoder.h" #include "gpu/command_buffer/service/gpu_switches.h" #include "gpu/command_buffer/service/mailbox_manager.h" @@ -30,6 +31,7 @@ #include "media/base/bitstream_buffer.h" #include "media/base/limits.h" #include "media/base/media.h" +#include "media/base/media_switches.h" #include "media/base/timestamp_constants.h" #include "media/base/video_decoder_config.h" #include "media/video/picture.h" diff --git a/content/common/gpu/media/android_video_encode_accelerator.cc b/content/common/gpu/media/android_video_encode_accelerator.cc index c170716..406c1bc 100644 --- a/content/common/gpu/media/android_video_encode_accelerator.cc +++ b/content/common/gpu/media/android_video_encode_accelerator.cc @@ -7,11 +7,13 @@ #include <set> #include "base/bind.h" +#include "base/command_line.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" #include "base/metrics/histogram.h" #include "content/common/gpu/gpu_channel.h" #include "content/common/gpu/media/shared_memory_region.h" +#include "content/public/common/content_switches.h" #include "gpu/command_buffer/service/gles2_cmd_decoder.h" #include "media/base/android/media_codec_util.h" #include "media/base/bitstream_buffer.h" @@ -104,6 +106,12 @@ media::VideoEncodeAccelerator::SupportedProfiles AndroidVideoEncodeAccelerator::GetSupportedProfiles() { SupportedProfiles profiles; +#if defined(ENABLE_WEBRTC) + const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); + if (cmd_line->HasSwitch(switches::kDisableWebRtcHWEncoding)) + return profiles; +#endif + const struct { const media::VideoCodec codec; const media::VideoCodecProfile profile; diff --git a/content/common/gpu/media/dxva_video_decode_accelerator_win.cc b/content/common/gpu/media/dxva_video_decode_accelerator_win.cc index f127bb1..695f06b 100644 --- a/content/common/gpu/media/dxva_video_decode_accelerator_win.cc +++ b/content/common/gpu/media/dxva_video_decode_accelerator_win.cc @@ -21,6 +21,7 @@ #include "base/base_paths_win.h" #include "base/bind.h" #include "base/callback.h" +#include "base/command_line.h" #include "base/debug/alias.h" #include "base/file_version_info.h" #include "base/files/file_path.h" @@ -33,6 +34,7 @@ #include "base/trace_event/trace_event.h" #include "base/win/windows_version.h" #include "build/build_config.h" +#include "content/public/common/content_switches.h" #include "media/base/win/mf_initializer.h" #include "media/video/video_decode_accelerator.h" #include "third_party/angle/include/EGL/egl.h" @@ -41,6 +43,7 @@ #include "ui/gl/gl_context.h" #include "ui/gl/gl_fence.h" #include "ui/gl/gl_surface_egl.h" +#include "ui/gl/gl_switches.h" namespace { @@ -673,8 +676,7 @@ DXVAVideoDecodeAccelerator::PendingSampleInfo::~PendingSampleInfo() {} DXVAVideoDecodeAccelerator::DXVAVideoDecodeAccelerator( const base::Callback<bool(void)>& make_context_current, - gfx::GLContext* gl_context, - bool enable_accelerated_vpx_decode) + gfx::GLContext* gl_context) : client_(NULL), dev_manager_reset_token_(0), dx11_dev_manager_reset_token_(0), @@ -692,7 +694,6 @@ DXVAVideoDecodeAccelerator::DXVAVideoDecodeAccelerator( dx11_video_format_converter_media_type_needs_init_(true), gl_context_(gl_context), using_angle_device_(false), - enable_accelerated_vpx_decode_(enable_accelerated_vpx_decode), weak_this_factory_(this) { weak_ptr_ = weak_this_factory_.GetWeakPtr(); memset(&input_stream_info_, 0, sizeof(input_stream_info_)); @@ -1254,9 +1255,10 @@ bool DXVAVideoDecodeAccelerator::InitDecoder(media::VideoCodecProfile profile) { false); codec_ = media::kCodecH264; clsid = __uuidof(CMSH264DecoderMFT); - } else if (enable_accelerated_vpx_decode_ && - (profile == media::VP8PROFILE_ANY || - profile == media::VP9PROFILE_ANY)) { + } else if ((profile == media::VP8PROFILE_ANY || + profile == media::VP9PROFILE_ANY) && + base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableAcceleratedVpxDecode)) { int program_files_key = base::DIR_PROGRAM_FILES; if (base::win::OSInfo::GetInstance()->wow64_status() == base::win::OSInfo::WOW64_ENABLED) { diff --git a/content/common/gpu/media/dxva_video_decode_accelerator_win.h b/content/common/gpu/media/dxva_video_decode_accelerator_win.h index aa60638..7624202 100644 --- a/content/common/gpu/media/dxva_video_decode_accelerator_win.h +++ b/content/common/gpu/media/dxva_video_decode_accelerator_win.h @@ -60,10 +60,9 @@ class CONTENT_EXPORT DXVAVideoDecodeAccelerator }; // Does not take ownership of |client| which must outlive |*this|. - DXVAVideoDecodeAccelerator( + explicit DXVAVideoDecodeAccelerator( const base::Callback<bool(void)>& make_context_current, - gfx::GLContext* gl_context, - bool enable_accelerated_vpx_decode); + gfx::GLContext* gl_context); ~DXVAVideoDecodeAccelerator() override; // media::VideoDecodeAccelerator implementation. @@ -394,9 +393,6 @@ class CONTENT_EXPORT DXVAVideoDecodeAccelerator // Set to true if we are sharing ANGLE's device. bool using_angle_device_; - // Enables experimental hardware acceleration for VP8/VP9 video decoding. - const bool enable_accelerated_vpx_decode_; - // WeakPtrFactory for posting tasks back to |this|. base::WeakPtrFactory<DXVAVideoDecodeAccelerator> weak_this_factory_; diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.cc b/content/common/gpu/media/gpu_video_decode_accelerator.cc index 2bab173..0d57d4a 100644 --- a/content/common/gpu/media/gpu_video_decode_accelerator.cc +++ b/content/common/gpu/media/gpu_video_decode_accelerator.cc @@ -7,6 +7,7 @@ #include <vector> #include "base/bind.h" +#include "base/command_line.h" #include "base/location.h" #include "base/logging.h" #include "base/memory/ref_counted.h" @@ -16,11 +17,10 @@ #include "build/build_config.h" #include "content/common/gpu/gpu_channel.h" -#include "content/common/gpu/gpu_channel_manager.h" #include "content/common/gpu/media/gpu_video_accelerator_util.h" #include "content/common/gpu/media/media_messages.h" +#include "content/public/common/content_switches.h" #include "gpu/command_buffer/common/command_buffer.h" -#include "gpu/command_buffer/service/gpu_preferences.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_utils.h" #include "ipc/message_filter.h" @@ -152,10 +152,10 @@ GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { // static gpu::VideoDecodeAcceleratorCapabilities -GpuVideoDecodeAccelerator::GetCapabilities( - const gpu::GpuPreferences& gpu_preferences) { +GpuVideoDecodeAccelerator::GetCapabilities() { media::VideoDecodeAccelerator::Capabilities capabilities; - if (gpu_preferences.disable_accelerated_video_decode) + const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); + if (cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) return gpu::VideoDecodeAcceleratorCapabilities(); // Query supported profiles for each VDA. The order of querying VDAs should @@ -329,11 +329,6 @@ bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { bool GpuVideoDecodeAccelerator::Initialize( const media::VideoDecodeAccelerator::Config& config) { - const gpu::GpuPreferences& gpu_preferences = - stub_->channel()->gpu_channel_manager()->gpu_preferences(); - if (gpu_preferences.disable_accelerated_video_decode) - return false; - DCHECK(!video_decode_accelerator_); if (!stub_->channel()->AddRoute(host_route_id_, stub_->stream_id(), this)) { @@ -353,26 +348,13 @@ bool GpuVideoDecodeAccelerator::Initialize( // platform. This list is ordered by priority of use and it should be the // same as the order of querying supported profiles of VDAs. const GpuVideoDecodeAccelerator::CreateVDAFp create_vda_fps[] = { -#if defined(OS_WIN) - &GpuVideoDecodeAccelerator::CreateDXVAVDA, -#endif -#if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) - &GpuVideoDecodeAccelerator::CreateV4L2VDA, - &GpuVideoDecodeAccelerator::CreateV4L2SliceVDA, -#endif -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) - &GpuVideoDecodeAccelerator::CreateVaapiVDA, -#endif -#if defined(OS_MACOSX) - &GpuVideoDecodeAccelerator::CreateVTVDA, -#endif -#if !defined(OS_CHROMEOS) && defined(USE_OZONE) - &GpuVideoDecodeAccelerator::CreateOzoneVDA, -#endif -#if defined(OS_ANDROID) - &GpuVideoDecodeAccelerator::CreateAndroidVDA, -#endif - }; + &GpuVideoDecodeAccelerator::CreateDXVAVDA, + &GpuVideoDecodeAccelerator::CreateV4L2VDA, + &GpuVideoDecodeAccelerator::CreateV4L2SliceVDA, + &GpuVideoDecodeAccelerator::CreateVaapiVDA, + &GpuVideoDecodeAccelerator::CreateVTVDA, + &GpuVideoDecodeAccelerator::CreateOzoneVDA, + &GpuVideoDecodeAccelerator::CreateAndroidVDA}; for (const auto& create_vda_function : create_vda_fps) { video_decode_accelerator_ = (this->*create_vda_function)(); @@ -392,28 +374,25 @@ bool GpuVideoDecodeAccelerator::Initialize( return false; } -#if defined(OS_WIN) scoped_ptr<media::VideoDecodeAccelerator> GpuVideoDecodeAccelerator::CreateDXVAVDA() { scoped_ptr<media::VideoDecodeAccelerator> decoder; - const gpu::GpuPreferences& gpu_preferences = - stub_->channel()->gpu_channel_manager()->gpu_preferences(); +#if defined(OS_WIN) if (base::win::GetVersion() >= base::win::VERSION_WIN7) { DVLOG(0) << "Initializing DXVA HW decoder for windows."; - decoder.reset(new DXVAVideoDecodeAccelerator( - make_context_current_, stub_->decoder()->GetGLContext(), - gpu_preferences.enable_accelerated_vpx_decode)); + decoder.reset(new DXVAVideoDecodeAccelerator(make_context_current_, + stub_->decoder()->GetGLContext())); } else { NOTIMPLEMENTED() << "HW video decode acceleration not available."; } +#endif return decoder; } -#endif -#if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) scoped_ptr<media::VideoDecodeAccelerator> GpuVideoDecodeAccelerator::CreateV4L2VDA() { scoped_ptr<media::VideoDecodeAccelerator> decoder; +#if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); if (device.get()) { decoder.reset(new V4L2VideoDecodeAccelerator( @@ -424,12 +403,14 @@ GpuVideoDecodeAccelerator::CreateV4L2VDA() { device, io_task_runner_)); } +#endif return decoder; } scoped_ptr<media::VideoDecodeAccelerator> GpuVideoDecodeAccelerator::CreateV4L2SliceVDA() { scoped_ptr<media::VideoDecodeAccelerator> decoder; +#if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); if (device.get()) { decoder.reset(new V4L2SliceVideoDecodeAccelerator( @@ -440,11 +421,10 @@ GpuVideoDecodeAccelerator::CreateV4L2SliceVDA() { make_context_current_, io_task_runner_)); } +#endif return decoder; } -#endif -#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) void GpuVideoDecodeAccelerator::BindImage(uint32_t client_texture_id, uint32_t texture_target, scoped_refptr<gl::GLImage> image) { @@ -457,48 +437,49 @@ void GpuVideoDecodeAccelerator::BindImage(uint32_t client_texture_id, gpu::gles2::Texture::BOUND); } } -#endif -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) scoped_ptr<media::VideoDecodeAccelerator> GpuVideoDecodeAccelerator::CreateVaapiVDA() { - return make_scoped_ptr<media::VideoDecodeAccelerator>( - new VaapiVideoDecodeAccelerator( - make_context_current_, - base::Bind(&GpuVideoDecodeAccelerator::BindImage, - base::Unretained(this)))); -} + scoped_ptr<media::VideoDecodeAccelerator> decoder; +#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) + decoder.reset(new VaapiVideoDecodeAccelerator( + make_context_current_, base::Bind(&GpuVideoDecodeAccelerator::BindImage, + base::Unretained(this)))); #endif + return decoder; +} -#if defined(OS_MACOSX) scoped_ptr<media::VideoDecodeAccelerator> GpuVideoDecodeAccelerator::CreateVTVDA() { - return make_scoped_ptr<media::VideoDecodeAccelerator>( - new VTVideoDecodeAccelerator( - make_context_current_, - base::Bind(&GpuVideoDecodeAccelerator::BindImage, - base::Unretained(this)))); -} + scoped_ptr<media::VideoDecodeAccelerator> decoder; +#if defined(OS_MACOSX) + decoder.reset(new VTVideoDecodeAccelerator( + make_context_current_, base::Bind(&GpuVideoDecodeAccelerator::BindImage, + base::Unretained(this)))); #endif + return decoder; +} -#if !defined(OS_CHROMEOS) && defined(USE_OZONE) scoped_ptr<media::VideoDecodeAccelerator> GpuVideoDecodeAccelerator::CreateOzoneVDA() { + scoped_ptr<media::VideoDecodeAccelerator> decoder; +#if !defined(OS_CHROMEOS) && defined(USE_OZONE) media::MediaOzonePlatform* platform = media::MediaOzonePlatform::GetInstance(); - return make_scoped_ptr<media::VideoDecodeAccelerator>( - platform->CreateVideoDecodeAccelerator(make_context_current_)); -} + decoder.reset(platform->CreateVideoDecodeAccelerator(make_context_current_)); #endif + return decoder; +} -#if defined(OS_ANDROID) scoped_ptr<media::VideoDecodeAccelerator> GpuVideoDecodeAccelerator::CreateAndroidVDA() { - return make_scoped_ptr<media::VideoDecodeAccelerator>( - new AndroidVideoDecodeAccelerator(stub_->decoder()->AsWeakPtr(), - make_context_current_)); -} + scoped_ptr<media::VideoDecodeAccelerator> decoder; +#if defined(OS_ANDROID) + decoder.reset(new AndroidVideoDecodeAccelerator(stub_->decoder()->AsWeakPtr(), + make_context_current_)); #endif + return decoder; +} void GpuVideoDecodeAccelerator::OnSetCdm(int cdm_id) { DCHECK(video_decode_accelerator_); diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.h b/content/common/gpu/media/gpu_video_decode_accelerator.h index 541271f..ac9b118 100644 --- a/content/common/gpu/media/gpu_video_decode_accelerator.h +++ b/content/common/gpu/media/gpu_video_decode_accelerator.h @@ -23,10 +23,6 @@ #include "media/video/video_decode_accelerator.h" #include "ui/gfx/geometry/size.h" -namespace gpu { -struct GpuPreferences; -} // namespace gpu - namespace content { class GpuVideoDecodeAccelerator @@ -46,8 +42,7 @@ class GpuVideoDecodeAccelerator // Static query for the capabilities, which includes the supported profiles. // This query calls the appropriate platform-specific version. The returned // capabilities will not contain duplicate supported profile entries. - static gpu::VideoDecodeAcceleratorCapabilities GetCapabilities( - const gpu::GpuPreferences& gpu_preferences); + static gpu::VideoDecodeAcceleratorCapabilities GetCapabilities(); // IPC::Listener implementation. bool OnMessageReceived(const IPC::Message& message) override; @@ -77,30 +72,18 @@ class GpuVideoDecodeAccelerator bool Initialize(const media::VideoDecodeAccelerator::Config& config); private: - typedef scoped_ptr<media::VideoDecodeAccelerator> ( + typedef scoped_ptr<media::VideoDecodeAccelerator>( GpuVideoDecodeAccelerator::*CreateVDAFp)(); class MessageFilter; -#if defined(OS_WIN) scoped_ptr<media::VideoDecodeAccelerator> CreateDXVAVDA(); -#endif -#if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2VDA(); scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2SliceVDA(); -#endif -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) scoped_ptr<media::VideoDecodeAccelerator> CreateVaapiVDA(); -#endif -#if defined(OS_MACOSX) scoped_ptr<media::VideoDecodeAccelerator> CreateVTVDA(); -#endif -#if !defined(OS_CHROMEOS) && defined(USE_OZONE) scoped_ptr<media::VideoDecodeAccelerator> CreateOzoneVDA(); -#endif -#if defined(OS_ANDROID) scoped_ptr<media::VideoDecodeAccelerator> CreateAndroidVDA(); -#endif // We only allow self-delete, from OnWillDestroyStub(), after cleanup there. ~GpuVideoDecodeAccelerator() override; @@ -121,12 +104,10 @@ class GpuVideoDecodeAccelerator // Sets the texture to cleared. void SetTextureCleared(const media::Picture& picture); -#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) // Helper to bind |image| to the texture specified by |client_texture_id|. void BindImage(uint32_t client_texture_id, uint32_t texture_target, scoped_refptr<gl::GLImage> image); -#endif // Helper function to call NotifyError in the |child_task_runner_| thread. void CallOrPostNotifyError(media::VideoDecodeAccelerator::Error error); diff --git a/content/common/gpu/media/gpu_video_encode_accelerator.cc b/content/common/gpu/media/gpu_video_encode_accelerator.cc index 21b1bc5..c12c424 100644 --- a/content/common/gpu/media/gpu_video_encode_accelerator.cc +++ b/content/common/gpu/media/gpu_video_encode_accelerator.cc @@ -13,7 +13,6 @@ #include "build/build_config.h" #include "content/common/gpu/client/gpu_memory_buffer_impl.h" #include "content/common/gpu/gpu_channel.h" -#include "content/common/gpu/gpu_channel_manager.h" #include "content/common/gpu/media/gpu_video_accelerator_util.h" #include "content/common/gpu/media/media_messages.h" #include "content/public/common/content_switches.h" @@ -103,11 +102,8 @@ bool GpuVideoEncodeAccelerator::Initialize( return false; } - const gpu::GpuPreferences& gpu_preferences = - stub_->channel()->gpu_channel_manager()->gpu_preferences(); - - std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> create_vea_fps = - CreateVEAFps(gpu_preferences); + std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> + create_vea_fps = CreateVEAFps(); // Try all possible encoders and use the first successful encoder. for (size_t i = 0; i < create_vea_fps.size(); ++i) { encoder_ = (*create_vea_fps[i])(); @@ -176,11 +172,10 @@ void GpuVideoEncodeAccelerator::OnWillDestroyStub() { // static gpu::VideoEncodeAcceleratorSupportedProfiles -GpuVideoEncodeAccelerator::GetSupportedProfiles( - const gpu::GpuPreferences& gpu_preferences) { +GpuVideoEncodeAccelerator::GetSupportedProfiles() { media::VideoEncodeAccelerator::SupportedProfiles profiles; - std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> create_vea_fps = - CreateVEAFps(gpu_preferences); + std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> + create_vea_fps = CreateVEAFps(); for (size_t i = 0; i < create_vea_fps.size(); ++i) { scoped_ptr<media::VideoEncodeAccelerator> @@ -197,52 +192,47 @@ GpuVideoEncodeAccelerator::GetSupportedProfiles( // static std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> -GpuVideoEncodeAccelerator::CreateVEAFps( - const gpu::GpuPreferences& gpu_preferences) { +GpuVideoEncodeAccelerator::CreateVEAFps() { std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> create_vea_fps; -#if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateV4L2VEA); -#endif -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) - if (!gpu_preferences.disable_vaapi_accelerated_video_encode) - create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVaapiVEA); -#endif -#if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) - if (!gpu_preferences.disable_web_rtc_hw_encoding) - create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateAndroidVEA); -#endif + create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVaapiVEA); + create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateAndroidVEA); return create_vea_fps; } -#if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) // static scoped_ptr<media::VideoEncodeAccelerator> GpuVideoEncodeAccelerator::CreateV4L2VEA() { scoped_ptr<media::VideoEncodeAccelerator> encoder; +#if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); if (device) encoder.reset(new V4L2VideoEncodeAccelerator(device)); +#endif return encoder; } -#endif -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) // static scoped_ptr<media::VideoEncodeAccelerator> GpuVideoEncodeAccelerator::CreateVaapiVEA() { - return make_scoped_ptr<media::VideoEncodeAccelerator>( - new VaapiVideoEncodeAccelerator()); -} + scoped_ptr<media::VideoEncodeAccelerator> encoder; +#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) + const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); + if (!cmd_line->HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode)) + encoder.reset(new VaapiVideoEncodeAccelerator()); #endif + return encoder; +} -#if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) // static scoped_ptr<media::VideoEncodeAccelerator> GpuVideoEncodeAccelerator::CreateAndroidVEA() { - return make_scoped_ptr<media::VideoEncodeAccelerator>( - new AndroidVideoEncodeAccelerator()); -} + scoped_ptr<media::VideoEncodeAccelerator> encoder; +#if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) + encoder.reset(new AndroidVideoEncodeAccelerator()); #endif + return encoder; +} void GpuVideoEncodeAccelerator::OnEncode( const AcceleratedVideoEncoderMsg_Encode_Params& params) { diff --git a/content/common/gpu/media/gpu_video_encode_accelerator.h b/content/common/gpu/media/gpu_video_encode_accelerator.h index 27081b6..f299861 100644 --- a/content/common/gpu/media/gpu_video_encode_accelerator.h +++ b/content/common/gpu/media/gpu_video_encode_accelerator.h @@ -26,10 +26,6 @@ namespace base { class SharedMemory; } // namespace base -namespace gpu { -struct GpuPreferences; -} // namespace gpu - namespace content { // This class encapsulates the GPU process view of a VideoEncodeAccelerator, @@ -68,25 +64,17 @@ class GpuVideoEncodeAccelerator // Static query for supported profiles. This query calls the appropriate // platform-specific version. The returned supported profiles vector will // not contain duplicates. - static gpu::VideoEncodeAcceleratorSupportedProfiles GetSupportedProfiles( - const gpu::GpuPreferences& gpu_preferences); + static gpu::VideoEncodeAcceleratorSupportedProfiles GetSupportedProfiles(); private: typedef scoped_ptr<media::VideoEncodeAccelerator>(*CreateVEAFp)(); // Return a set of VEA Create function pointers applicable to the current // platform. - static std::vector<CreateVEAFp> CreateVEAFps( - const gpu::GpuPreferences& gpu_preferences); -#if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) + static std::vector<CreateVEAFp> CreateVEAFps(); static scoped_ptr<media::VideoEncodeAccelerator> CreateV4L2VEA(); -#endif -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) static scoped_ptr<media::VideoEncodeAccelerator> CreateVaapiVEA(); -#endif -#if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) static scoped_ptr<media::VideoEncodeAccelerator> CreateAndroidVEA(); -#endif // IPC handlers, proxying media::VideoEncodeAccelerator for the renderer // process. diff --git a/content/common/gpu/media/vaapi_wrapper.cc b/content/common/gpu/media/vaapi_wrapper.cc index f5e90da..2a18b3f 100644 --- a/content/common/gpu/media/vaapi_wrapper.cc +++ b/content/common/gpu/media/vaapi_wrapper.cc @@ -9,6 +9,7 @@ #include "base/bind.h" #include "base/callback_helpers.h" +#include "base/command_line.h" #include "base/logging.h" #include "base/macros.h" #include "base/numerics/safe_conversions.h" @@ -17,6 +18,7 @@ // Auto-generated for dlopen libva libraries #include "content/common/gpu/media/va_stubs.h" #include "content/common/gpu/media/vaapi_picture.h" +#include "content/public/common/content_switches.h" #include "third_party/libyuv/include/libyuv.h" #include "ui/gl/gl_bindings.h" #if defined(USE_X11) @@ -212,6 +214,10 @@ scoped_refptr<VaapiWrapper> VaapiWrapper::CreateForVideoCodec( media::VideoEncodeAccelerator::SupportedProfiles VaapiWrapper::GetSupportedEncodeProfiles() { media::VideoEncodeAccelerator::SupportedProfiles profiles; + const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); + if (cmd_line->HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode)) + return profiles; + std::vector<ProfileInfo> encode_profile_infos = profile_infos_.Get().GetSupportedProfileInfosForCodecMode(kEncode); diff --git a/content/common/gpu/media/video_decode_accelerator_unittest.cc b/content/common/gpu/media/video_decode_accelerator_unittest.cc index ff799a1..eeb89d1 100644 --- a/content/common/gpu/media/video_decode_accelerator_unittest.cc +++ b/content/common/gpu/media/video_decode_accelerator_unittest.cc @@ -521,12 +521,10 @@ GLRenderingVDAClient::CreateDXVAVDA() { scoped_ptr<media::VideoDecodeAccelerator> decoder; #if defined(OS_WIN) if (base::win::GetVersion() >= base::win::VERSION_WIN7) - const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); - const bool enable_accelerated_vpx_decode = - cmd_line->HasSwitch(switches::kEnableAcceleratedVpxDecode); - decoder.reset(new DXVAVideoDecodeAccelerator( - base::Bind(&DoNothingReturnTrue), rendering_helper_->GetGLContext().get(), - enable_accelerated_vpx_decode)); + decoder.reset( + new DXVAVideoDecodeAccelerator( + base::Bind(&DoNothingReturnTrue), + rendering_helper_->GetGLContext().get())); #endif return decoder; } diff --git a/content/common/gpu/media/vt_video_decode_accelerator_mac.cc b/content/common/gpu/media/vt_video_decode_accelerator_mac.cc index e4ea5cd..8804a69 100644 --- a/content/common/gpu/media/vt_video_decode_accelerator_mac.cc +++ b/content/common/gpu/media/vt_video_decode_accelerator_mac.cc @@ -10,6 +10,7 @@ #include <stddef.h> #include "base/bind.h" +#include "base/command_line.h" #include "base/logging.h" #include "base/mac/mac_logging.h" #include "base/macros.h" @@ -19,6 +20,7 @@ #include "base/thread_task_runner_handle.h" #include "base/version.h" #include "content/common/gpu/media/vt_video_decode_accelerator_mac.h" +#include "content/public/common/content_switches.h" #include "media/base/limits.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_image_io_surface.h" @@ -177,6 +179,11 @@ static bool CreateVideoToolboxSession(const uint8_t* sps, size_t sps_size, // session fails, hardware decoding will be disabled (Initialize() will always // return false). static bool InitializeVideoToolboxInternal() { + if (base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableAcceleratedVideoDecode)) { + return false; + } + if (!IsVtInitialized()) { // CoreVideo is also required, but the loader stops after the first path is // loaded. Instead we rely on the transitive dependency from VideoToolbox to |