Skip to content

Commit

Permalink
Enable accelerated video decode for in process gpu and single process.
Browse files Browse the repository at this point in the history
Essentially just removes a bunch of "no hardware decode" restrictions
on single process and in process gpu as well as populates the VDA
capabilities during in-process-gpu startup (normally done during GpuMain).

BUG=574935, 578296, 582170
TEST=android_webview_shell plays video with --enable-unified-media-pipeline,
webgl_conformance tests pass on N4. Content plays with on Android One device
using the unified pipeline.

Review URL: https://codereview.chromium.org/1641013002

Cr-Commit-Position: refs/heads/master@{#372507}
  • Loading branch information
dalecurtis authored and Commit bot committed Jan 30, 2016
1 parent 1a8b9d7 commit 49485b3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 31 deletions.
1 change: 0 additions & 1 deletion android_webview/lib/main/aw_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ bool AwMainDelegate::BasicStartupComplete(int* exit_code) {
#if defined(ENABLE_WEBRTC)
cl->AppendSwitch(switches::kDisableWebRtcHWDecoding);
#endif
cl->AppendSwitch(switches::kDisableAcceleratedVideoDecode);

// This is needed for sharing textures across the different GL threads.
cl->AppendSwitch(switches::kEnableThreadedTextureMailboxes);
Expand Down
18 changes: 2 additions & 16 deletions content/browser/gpu/gpu_data_manager_impl_private.cc
Original file line number Diff line number Diff line change
Expand Up @@ -932,22 +932,8 @@ bool GpuDataManagerImplPrivate::ShouldDisableAcceleratedVideoDecode(
if (group_name == "Disabled")
return true;

// Accelerated decode is never available with --disable-gpu. It is also
// currently non-functional with --single-process and --in-process-gpu, but
// these should be fixable. We set the --disable-accelerated-video-decode flag
// in these cases so that the renderer can be aware. (Which is important on
// Android where there is no fallback once WMPI is selected.)
//
// TODO(sandersd): Enable support for accelerated decode with
// --in-process-gpu, at least on Android (necessary to support WebView).
// http://crbug.com/574935.
if (command_line->HasSwitch(switches::kDisableGpu) ||
command_line->HasSwitch(switches::kSingleProcess) ||
command_line->HasSwitch(switches::kInProcessGPU)) {
return true;
}

return false;
// Accelerated decode is never available with --disable-gpu.
return command_line->HasSwitch(switches::kDisableGpu);
}

void GpuDataManagerImplPrivate::GetDisabledExtensions(
Expand Down
20 changes: 16 additions & 4 deletions content/common/gpu/media/android_video_decode_accelerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
#include "content/common/gpu/gpu_channel.h"
#include "content/common/gpu/media/android_copying_backing_strategy.h"
#include "content/common/gpu/media/android_deferred_rendering_backing_strategy.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"
#include "media/base/bind_to_current_loop.h"
#include "media/base/bitstream_buffer.h"
#include "media/base/limits.h"
Expand Down Expand Up @@ -167,10 +170,16 @@ AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator(
error_sequence_token_(0),
defer_errors_(false),
weak_this_factory_(this) {
if (UseDeferredRenderingStrategy())
if (UseDeferredRenderingStrategy()) {
// TODO(liberato, watk): Figure out what we want to do about zero copy for
// fullscreen external SurfaceView in WebView. http://crbug.com/582170.
DCHECK(!gl_decoder_->GetContextGroup()->mailbox_manager()->UsesSync());
DVLOG(1) << __FUNCTION__ << ", using deferred rendering strategy.";
strategy_.reset(new AndroidDeferredRenderingBackingStrategy());
else
} else {
DVLOG(1) << __FUNCTION__ << ", using copy back strategy.";
strategy_.reset(new AndroidCopyingBackingStrategy());
}
}

AndroidVideoDecodeAccelerator::~AndroidVideoDecodeAccelerator() {
Expand Down Expand Up @@ -960,8 +969,11 @@ void AndroidVideoDecodeAccelerator::ManageTimer(bool did_work) {

// static
bool AndroidVideoDecodeAccelerator::UseDeferredRenderingStrategy() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableUnifiedMediaPipeline);
const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
// TODO(liberato, watk): Figure out what we want to do about zero copy for
// fullscreen external SurfaceView in WebView. http://crbug.com/582170.
return cmd_line->HasSwitch(switches::kEnableUnifiedMediaPipeline) &&
!cmd_line->HasSwitch(switches::kEnableThreadedTextureMailboxes);
}

// static
Expand Down
6 changes: 6 additions & 0 deletions content/gpu/gpu_child_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "content/child/thread_safe_sender.h"
#include "content/common/gpu/gpu_memory_buffer_factory.h"
#include "content/common/gpu/gpu_messages.h"
#include "content/common/gpu/media/gpu_video_decode_accelerator.h"
#include "content/gpu/gpu_process_control_impl.h"
#include "content/gpu/gpu_watchdog_thread.h"
#include "content/public/common/content_client.h"
Expand Down Expand Up @@ -173,6 +174,11 @@ GpuChildThread::GpuChildThread(
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kInProcessGPU));

// Populate accelerator capabilities (normally done during GpuMain, which is
// not called for single process or in process gpu).
gpu_info_.video_decode_accelerator_capabilities =
content::GpuVideoDecodeAccelerator::GetCapabilities();

if (!gfx::GLSurface::InitializeOneOff())
VLOG(1) << "gfx::GLSurface::InitializeOneOff failed";

Expand Down
10 changes: 0 additions & 10 deletions content/renderer/render_thread_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1461,16 +1461,6 @@ media::GpuVideoAcceleratorFactories* RenderThreadImpl::GetGpuFactories() {

const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();

#if defined(OS_ANDROID)
if (SynchronousCompositorFactory::GetInstance()) {
if (!cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) {
DLOG(WARNING) << "Accelerated video decoding is not explicitly disabled, "
"but is not supported by in-process rendering";
}
return NULL;
}
#endif

scoped_refptr<base::SingleThreadTaskRunner> media_task_runner =
GetMediaThreadTaskRunner();
scoped_refptr<ContextProviderCommandBuffer> shared_context_provider =
Expand Down

0 comments on commit 49485b3

Please sign in to comment.