Skip to content

Commit

Permalink
Remove content::GpuVideoDecodeAcceleratorFactory
Browse files Browse the repository at this point in the history
This can be replaced by media::GpuVideoDecodeAcceleratorFactoryImpl, modulo
properly wiring GpuPreferences.

This in turns allows us to remove GpuChildThread::current() for great justice.

BUG=597150

Review-Url: https://codereview.chromium.org/2171473003
Cr-Commit-Position: refs/heads/master@{#407741}
  • Loading branch information
pimanttr authored and Commit bot committed Jul 26, 2016
1 parent 2d4220a commit e785d25
Show file tree
Hide file tree
Showing 21 changed files with 49 additions and 244 deletions.
3 changes: 0 additions & 3 deletions android_webview/gpu/aw_content_gpu_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ AwContentGpuClient::AwContentGpuClient(

AwContentGpuClient::~AwContentGpuClient() {}

void AwContentGpuClient::ExposeInterfacesToBrowser(
shell::InterfaceRegistry* registry) {}

gpu::SyncPointManager* AwContentGpuClient::GetSyncPointManager() {
return sync_point_manager_callback_.Run();
}
Expand Down
1 change: 0 additions & 1 deletion android_webview/gpu/aw_content_gpu_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class AwContentGpuClient : public content::ContentGpuClient {
~AwContentGpuClient() override;

// content::ContentGpuClient implementation.
void ExposeInterfacesToBrowser(shell::InterfaceRegistry* registry) override;
gpu::SyncPointManager* GetSyncPointManager() override;

private:
Expand Down
1 change: 1 addition & 0 deletions chrome/chrome_gpu.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'dependencies': [
'../content/content.gyp:content_common',
'../content/content.gyp:content_gpu',
'../media/media.gyp:media_gpu',
],
'conditions': [
['chromeos==1', {
Expand Down
3 changes: 3 additions & 0 deletions chrome/gpu/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ static_library("gpu") {
deps = [
"//content/public/common",
"//content/public/gpu",
"//gpu/command_buffer/service",
"//media",
"//media/gpu",
]

sources = [
Expand Down
1 change: 1 addition & 0 deletions chrome/gpu/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include_rules = [
"+content/public/gpu",
"+media/video",
"+media/base/video_frame.h",
"+media/gpu",
"+mojo/edk/embedder",
"+services/shell/public/cpp",
]
15 changes: 9 additions & 6 deletions chrome/gpu/arc_gpu_video_decode_accelerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "base/logging.h"
#include "base/numerics/safe_math.h"
#include "base/run_loop.h"
#include "content/public/gpu/gpu_video_decode_accelerator_factory.h"
#include "media/base/video_frame.h"
#include "media/gpu/gpu_video_decode_accelerator_factory_impl.h"

namespace chromeos {
namespace arc {
Expand Down Expand Up @@ -51,11 +51,13 @@ ArcGpuVideoDecodeAccelerator::OutputBufferInfo::OutputBufferInfo(

ArcGpuVideoDecodeAccelerator::OutputBufferInfo::~OutputBufferInfo() = default;

ArcGpuVideoDecodeAccelerator::ArcGpuVideoDecodeAccelerator()
ArcGpuVideoDecodeAccelerator::ArcGpuVideoDecodeAccelerator(
const gpu::GpuPreferences& gpu_preferences)
: arc_client_(nullptr),
next_bitstream_buffer_id_(0),
output_pixel_format_(media::PIXEL_FORMAT_UNKNOWN),
output_buffer_size_(0) {}
output_buffer_size_(0),
gpu_preferences_(gpu_preferences) {}

ArcGpuVideoDecodeAccelerator::~ArcGpuVideoDecodeAccelerator() {
DCHECK(thread_checker_.CalledOnValidThread());
Expand Down Expand Up @@ -109,9 +111,10 @@ ArcVideoAccelerator::Result ArcGpuVideoDecodeAccelerator::Initialize(
vda_config.output_mode =
media::VideoDecodeAccelerator::Config::OutputMode::IMPORT;

std::unique_ptr<content::GpuVideoDecodeAcceleratorFactory> vda_factory =
content::GpuVideoDecodeAcceleratorFactory::CreateWithNoGL();
vda_ = vda_factory->CreateVDA(this, vda_config);
auto vda_factory =
media::GpuVideoDecodeAcceleratorFactoryImpl::CreateWithNoGL();
vda_ = vda_factory->CreateVDA(
this, vda_config, gpu::GpuDriverBugWorkarounds(), gpu_preferences_);
if (!vda_) {
DLOG(ERROR) << "Failed to create VDA.";
return PLATFORM_FAILURE;
Expand Down
3 changes: 2 additions & 1 deletion chrome/gpu/arc_gpu_video_decode_accelerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class ArcGpuVideoDecodeAccelerator
public media::VideoDecodeAccelerator::Client,
public base::SupportsWeakPtr<ArcGpuVideoDecodeAccelerator> {
public:
ArcGpuVideoDecodeAccelerator();
explicit ArcGpuVideoDecodeAccelerator(
const gpu::GpuPreferences& gpu_preferences);
~ArcGpuVideoDecodeAccelerator() override;

// Implementation of the ArcVideoAccelerator interface.
Expand Down
15 changes: 10 additions & 5 deletions chrome/gpu/chrome_content_gpu_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,24 @@
namespace {

void DeprecatedCreateGpuArcVideoService(
const gpu::GpuPreferences& gpu_preferences,
::arc::mojom::VideoAcceleratorServiceClientRequest request) {
// GpuArcVideoService is strongly bound to the Mojo message pipe it
// is connected to. When that message pipe is closed, either explicitly on the
// other end (in the browser process), or by a connection error, this object
// will be destroyed.
auto* service = new chromeos::arc::GpuArcVideoService();
auto* service = new chromeos::arc::GpuArcVideoService(gpu_preferences);
service->Connect(std::move(request));
}

void CreateGpuArcVideoService(
const gpu::GpuPreferences& gpu_preferences,
::arc::mojom::VideoAcceleratorServiceRequest request) {
// GpuArcVideoService is strongly bound to the Mojo message pipe it
// is connected to. When that message pipe is closed, either explicitly on the
// other end (in the browser process), or by a connection error, this object
// will be destroyed.
new chromeos::arc::GpuArcVideoService(std::move(request));
new chromeos::arc::GpuArcVideoService(std::move(request), gpu_preferences);
}

} // namespace
Expand All @@ -41,10 +43,13 @@ ChromeContentGpuClient::ChromeContentGpuClient() {}
ChromeContentGpuClient::~ChromeContentGpuClient() {}

void ChromeContentGpuClient::ExposeInterfacesToBrowser(
shell::InterfaceRegistry* registry) {
shell::InterfaceRegistry* registry,
const gpu::GpuPreferences& gpu_preferences) {
#if defined(OS_CHROMEOS)
registry->AddInterface(base::Bind(&CreateGpuArcVideoService));
registry->AddInterface(base::Bind(&DeprecatedCreateGpuArcVideoService));
registry->AddInterface(
base::Bind(&CreateGpuArcVideoService, gpu_preferences));
registry->AddInterface(
base::Bind(&DeprecatedCreateGpuArcVideoService, gpu_preferences));
#endif
}

Expand Down
4 changes: 3 additions & 1 deletion chrome/gpu/chrome_content_gpu_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class ChromeContentGpuClient : public content::ContentGpuClient {

// content::ContentGpuClient:
void Initialize(base::FieldTrialList::Observer* observer) override;
void ExposeInterfacesToBrowser(shell::InterfaceRegistry* registry) override;
void ExposeInterfacesToBrowser(
shell::InterfaceRegistry* registry,
const gpu::GpuPreferences& gpu_preferences) override;

private:
std::unique_ptr<chrome_variations::ChildProcessFieldTrialSyncer>
Expand Down
12 changes: 8 additions & 4 deletions chrome/gpu/gpu_arc_video_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,15 @@ struct TypeConverter<chromeos::arc::ArcVideoAccelerator::DmabufPlane,
namespace chromeos {
namespace arc {

GpuArcVideoService::GpuArcVideoService() : binding_(this) {}
GpuArcVideoService::GpuArcVideoService(
const gpu::GpuPreferences& gpu_preferences)
: gpu_preferences_(gpu_preferences), binding_(this) {}

GpuArcVideoService::GpuArcVideoService(
::arc::mojom::VideoAcceleratorServiceRequest request)
: accelerator_(new ArcGpuVideoDecodeAccelerator()),
::arc::mojom::VideoAcceleratorServiceRequest request,
const gpu::GpuPreferences& gpu_preferences)
: gpu_preferences_(gpu_preferences),
accelerator_(new ArcGpuVideoDecodeAccelerator(gpu_preferences_)),
binding_(this, std::move(request)) {
DVLOG(2) << "GpuArcVideoService connected";
binding_.set_connection_error_handler(base::Bind(&OnConnectionError));
Expand All @@ -154,7 +158,7 @@ void GpuArcVideoService::Connect(
request.PassMessagePipe(), 0u));
client_.set_connection_error_handler(base::Bind(&OnConnectionError));

accelerator_.reset(new ArcGpuVideoDecodeAccelerator());
accelerator_.reset(new ArcGpuVideoDecodeAccelerator(gpu_preferences_));

::arc::mojom::VideoAcceleratorServicePtr service;
binding_.Bind(GetProxy(&service));
Expand Down
9 changes: 6 additions & 3 deletions chrome/gpu/gpu_arc_video_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/macros.h"
#include "chrome/gpu/arc_video_accelerator.h"
#include "components/arc/common/video_accelerator.mojom.h"
#include "gpu/command_buffer/service/gpu_preferences.h"
#include "mojo/public/cpp/bindings/strong_binding.h"

namespace chromeos {
Expand All @@ -24,9 +25,10 @@ namespace arc {
class GpuArcVideoService : public ::arc::mojom::VideoAcceleratorService,
public ArcVideoAccelerator::Client {
public:
explicit GpuArcVideoService(
::arc::mojom::VideoAcceleratorServiceRequest request);
GpuArcVideoService();
GpuArcVideoService(
::arc::mojom::VideoAcceleratorServiceRequest request,
const gpu::GpuPreferences& gpu_preferences);
explicit GpuArcVideoService(const gpu::GpuPreferences& gpu_preferences);
~GpuArcVideoService() override;

// Connects to VideoAcceleratorServiceClient.
Expand Down Expand Up @@ -75,6 +77,7 @@ class GpuArcVideoService : public ::arc::mojom::VideoAcceleratorService,

base::ThreadChecker thread_checker_;

gpu::GpuPreferences gpu_preferences_;
std::unique_ptr<ArcVideoAccelerator> accelerator_;
::arc::mojom::VideoAcceleratorServiceClientPtr client_;

Expand Down
2 changes: 0 additions & 2 deletions content/content_gpu.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
'gpu/in_process_gpu_thread.h',
'public/gpu/content_gpu_client.cc',
'public/gpu/content_gpu_client.h',
'public/gpu/gpu_video_decode_accelerator_factory.cc',
'public/gpu/gpu_video_decode_accelerator_factory.h',
],
'include_dirs': [
'..',
Expand Down
13 changes: 1 addition & 12 deletions content/gpu/gpu_child_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@
namespace content {
namespace {

base::LazyInstance<base::ThreadLocalPointer<GpuChildThread>> g_lazy_tls =
LAZY_INSTANCE_INITIALIZER;

static base::LazyInstance<scoped_refptr<ThreadSafeSender> >
g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER;

Expand Down Expand Up @@ -144,11 +141,6 @@ ChildThreadImpl::Options GetOptions(

} // namespace

// static
GpuChildThread* GpuChildThread::current() {
return g_lazy_tls.Pointer()->Get();
}

GpuChildThread::GpuChildThread(
GpuWatchdogThread* watchdog_thread,
bool dead_on_arrival,
Expand All @@ -166,7 +158,6 @@ GpuChildThread::GpuChildThread(
target_services_ = NULL;
#endif
g_thread_safe_sender.Get() = thread_safe_sender();
g_lazy_tls.Pointer()->Set(this);
}

GpuChildThread::GpuChildThread(
Expand Down Expand Up @@ -195,15 +186,13 @@ GpuChildThread::GpuChildThread(
VLOG(1) << "gl::init::InitializeGLOneOff failed";

g_thread_safe_sender.Get() = thread_safe_sender();
g_lazy_tls.Pointer()->Set(this);
}

GpuChildThread::~GpuChildThread() {
while (!deferred_messages_.empty()) {
delete deferred_messages_.front();
deferred_messages_.pop();
}
g_lazy_tls.Pointer()->Set(nullptr);
}

void GpuChildThread::Shutdown() {
Expand Down Expand Up @@ -403,7 +392,7 @@ void GpuChildThread::OnInitialize(const gpu::GpuPreferences& gpu_preferences) {

if (GetContentClient()->gpu()) { // NULL in tests.
GetContentClient()->gpu()->ExposeInterfacesToBrowser(
GetInterfaceRegistry());
GetInterfaceRegistry(), gpu_preferences_);
}

GetInterfaceRegistry()->ResumeBinding();
Expand Down
4 changes: 0 additions & 4 deletions content/gpu/gpu_child_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ class GpuChildThread : public ChildThreadImpl,
public:
typedef std::queue<IPC::Message*> DeferredMessages;

// Returns the one gpu thread for this process. Note that this can only
// be accessed when running on the gpu thread itself.
static GpuChildThread* current();

GpuChildThread(GpuWatchdogThread* gpu_watchdog_thread,
bool dead_on_arrival,
const gpu::GPUInfo& gpu_info,
Expand Down
4 changes: 0 additions & 4 deletions content/public/gpu/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ target(link_target_type, "gpu_sources") {
sources = [
"content_gpu_client.cc",
"content_gpu_client.h",
"gpu_video_decode_accelerator_factory.cc",
"gpu_video_decode_accelerator_factory.h",
]

deps = [
Expand All @@ -41,8 +39,6 @@ target(link_target_type, "gpu_sources") {
"//content/public/common:common_sources",
"//gpu/command_buffer/service",
"//gpu/config",
"//media",
"//media/gpu",
]

allow_circular_includes_from = [ "//content/gpu:gpu_sources" ]
Expand Down
3 changes: 0 additions & 3 deletions content/public/gpu/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@ specific_include_rules = {
"+content/common",
"+content/gpu",
],
"gpu_video_decode_accelerator_factory.h": [
"+gpu",
],
}
5 changes: 4 additions & 1 deletion content/public/gpu/content_gpu_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace gpu {
class SyncPointManager;
struct GpuPreferences;
}

namespace shell {
Expand All @@ -30,7 +31,9 @@ class CONTENT_EXPORT ContentGpuClient {

// Allows the client to expose interfaces from the GPU process to the browser
// process via |registry|.
virtual void ExposeInterfacesToBrowser(shell::InterfaceRegistry* registry) {}
virtual void ExposeInterfacesToBrowser(
shell::InterfaceRegistry* registry,
const gpu::GpuPreferences& gpu_preferences) {}

// Allows client to supply a SyncPointManager instance instead of having
// content internally create one.
Expand Down
Loading

0 comments on commit e785d25

Please sign in to comment.