Commit 8b9d29e9 authored by Mohsen Izadi's avatar Mohsen Izadi Committed by Commit Bot

Use HostGpuMemoryBufferManager in content

This change replaces usage of content::BrowserGpuMemoryBufferManager
with viz::HostGpuMemoryBufferManager.

With this change BrowserGpuMemoryBufferManager is not needed anymore and
code to handle buffer allocation in GpuProcessHost is also removed.

BUG=733482

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I6a9387e2e33a5d98d4ed7559618f4995256bafa4
Reviewed-on: https://chromium-review.googlesource.com/1095815
Commit-Queue: Mohsen Izadi <mohsen@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584455}
parent 5f2d6d0e
...@@ -38,7 +38,6 @@ class Predictor; ...@@ -38,7 +38,6 @@ class Predictor;
} }
namespace content { namespace content {
class BrowserGpuChannelHostFactory; class BrowserGpuChannelHostFactory;
class BrowserGpuMemoryBufferManager;
class BrowserMainLoop; class BrowserMainLoop;
class BrowserProcessSubThread; class BrowserProcessSubThread;
class BrowserShutdownProfileDumper; class BrowserShutdownProfileDumper;
...@@ -331,7 +330,6 @@ class BASE_EXPORT ScopedAllowBaseSyncPrimitives { ...@@ -331,7 +330,6 @@ class BASE_EXPORT ScopedAllowBaseSyncPrimitives {
LaunchXdgUtilityScopedAllowBaseSyncPrimitives; LaunchXdgUtilityScopedAllowBaseSyncPrimitives;
friend class webrtc::DesktopConfigurationMonitor; friend class webrtc::DesktopConfigurationMonitor;
friend class content::ServiceWorkerSubresourceLoader; friend class content::ServiceWorkerSubresourceLoader;
friend class viz::HostGpuMemoryBufferManager;
ScopedAllowBaseSyncPrimitives() EMPTY_BODY_IF_DCHECK_IS_OFF; ScopedAllowBaseSyncPrimitives() EMPTY_BODY_IF_DCHECK_IS_OFF;
~ScopedAllowBaseSyncPrimitives() EMPTY_BODY_IF_DCHECK_IS_OFF; ~ScopedAllowBaseSyncPrimitives() EMPTY_BODY_IF_DCHECK_IS_OFF;
...@@ -361,6 +359,7 @@ class BASE_EXPORT ScopedAllowBaseSyncPrimitivesOutsideBlockingScope { ...@@ -361,6 +359,7 @@ class BASE_EXPORT ScopedAllowBaseSyncPrimitivesOutsideBlockingScope {
friend class midi::TaskService; // https://crbug.com/796830 friend class midi::TaskService; // https://crbug.com/796830
// Not used in production yet, https://crbug.com/844078. // Not used in production yet, https://crbug.com/844078.
friend class service_manager::ServiceProcessLauncher; friend class service_manager::ServiceProcessLauncher;
friend class viz::HostGpuMemoryBufferManager;
ScopedAllowBaseSyncPrimitivesOutsideBlockingScope() ScopedAllowBaseSyncPrimitivesOutsideBlockingScope()
EMPTY_BODY_IF_DCHECK_IS_OFF; EMPTY_BODY_IF_DCHECK_IS_OFF;
...@@ -488,8 +487,6 @@ class BASE_EXPORT ThreadRestrictions { ...@@ -488,8 +487,6 @@ class BASE_EXPORT ThreadRestrictions {
friend class chrome_browser_net::Predictor; // http://crbug.com/78451 friend class chrome_browser_net::Predictor; // http://crbug.com/78451
friend class friend class
content::BrowserGpuChannelHostFactory; // http://crbug.com/125248 content::BrowserGpuChannelHostFactory; // http://crbug.com/125248
friend class
content::BrowserGpuMemoryBufferManager; // http://crbug.com/420368
friend class content::TextInputClientMac; // http://crbug.com/121917 friend class content::TextInputClientMac; // http://crbug.com/121917
friend class dbus::Bus; // http://crbug.com/125222 friend class dbus::Bus; // http://crbug.com/125222
friend class disk_cache::BackendImpl; // http://crbug.com/74623 friend class disk_cache::BackendImpl; // http://crbug.com/74623
......
...@@ -50,10 +50,15 @@ HostGpuMemoryBufferManager::HostGpuMemoryBufferManager( ...@@ -50,10 +50,15 @@ HostGpuMemoryBufferManager::HostGpuMemoryBufferManager(
native_configurations_(gpu::GetNativeGpuMemoryBufferConfigurations( native_configurations_(gpu::GetNativeGpuMemoryBufferConfigurations(
gpu_memory_buffer_support_.get())), gpu_memory_buffer_support_.get())),
task_runner_(std::move(task_runner)), task_runner_(std::move(task_runner)),
weak_factory_(this) {} weak_factory_(this) {
base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
this, "HostGpuMemoryBufferManager", task_runner_);
}
HostGpuMemoryBufferManager::~HostGpuMemoryBufferManager() { HostGpuMemoryBufferManager::~HostGpuMemoryBufferManager() {
DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(task_runner_->BelongsToCurrentThread());
base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
this);
} }
void HostGpuMemoryBufferManager::DestroyGpuMemoryBuffer( void HostGpuMemoryBufferManager::DestroyGpuMemoryBuffer(
...@@ -115,30 +120,27 @@ void HostGpuMemoryBufferManager::AllocateGpuMemoryBuffer( ...@@ -115,30 +120,27 @@ void HostGpuMemoryBufferManager::AllocateGpuMemoryBuffer(
if (!weak_ptr_) if (!weak_ptr_)
weak_ptr_ = weak_factory_.GetWeakPtr(); weak_ptr_ = weak_factory_.GetWeakPtr();
if (gpu_memory_buffer_support_->GetNativeGpuMemoryBufferType() != if (gpu_memory_buffer_support_->GetNativeGpuMemoryBufferType() !=
gfx::EMPTY_BUFFER) { gfx::EMPTY_BUFFER &&
const bool is_native = native_configurations_.find(std::make_pair( IsNativeGpuMemoryBufferConfiguration(format, usage)) {
format, usage)) != native_configurations_.end(); if (auto* gpu_service = GetGpuService()) {
if (is_native) { PendingBufferInfo buffer_info;
if (auto* gpu_service = GetGpuService()) { buffer_info.size = size;
PendingBufferInfo buffer_info; buffer_info.format = format;
buffer_info.size = size; buffer_info.usage = usage;
buffer_info.format = format; buffer_info.surface_handle = surface_handle;
buffer_info.usage = usage; buffer_info.callback = std::move(callback);
buffer_info.surface_handle = surface_handle; pending_buffers_[client_id].insert(
buffer_info.callback = std::move(callback); std::make_pair(id, std::move(buffer_info)));
pending_buffers_[client_id].insert( gpu_service->CreateGpuMemoryBuffer(
std::make_pair(id, std::move(buffer_info))); id, size, format, usage, client_id, surface_handle,
gpu_service->CreateGpuMemoryBuffer( base::BindOnce(
id, size, format, usage, client_id, surface_handle, &HostGpuMemoryBufferManager::OnGpuMemoryBufferAllocated,
base::BindOnce( weak_ptr_, gpu_service_version_, client_id, id));
&HostGpuMemoryBufferManager::OnGpuMemoryBufferAllocated, } else {
weak_ptr_, gpu_service_version_, client_id, id)); // GPU service failed to start. Run the callback with null handle.
} else { std::move(callback).Run(gfx::GpuMemoryBufferHandle());
// GPU service failed to start. Run the callback with null handle.
std::move(callback).Run(gfx::GpuMemoryBufferHandle());
}
return;
} }
return;
} }
gfx::GpuMemoryBufferHandle buffer_handle; gfx::GpuMemoryBufferHandle buffer_handle;
...@@ -163,6 +165,14 @@ void HostGpuMemoryBufferManager::AllocateGpuMemoryBuffer( ...@@ -163,6 +165,14 @@ void HostGpuMemoryBufferManager::AllocateGpuMemoryBuffer(
FROM_HERE, base::BindOnce(std::move(callback), std::move(buffer_handle))); FROM_HERE, base::BindOnce(std::move(callback), std::move(buffer_handle)));
} }
bool HostGpuMemoryBufferManager::IsNativeGpuMemoryBufferConfiguration(
gfx::BufferFormat format,
gfx::BufferUsage usage) const {
DCHECK(task_runner_->BelongsToCurrentThread());
return native_configurations_.find(std::make_pair(format, usage)) !=
native_configurations_.end();
}
std::unique_ptr<gfx::GpuMemoryBuffer> std::unique_ptr<gfx::GpuMemoryBuffer>
HostGpuMemoryBufferManager::CreateGpuMemoryBuffer( HostGpuMemoryBufferManager::CreateGpuMemoryBuffer(
const gfx::Size& size, const gfx::Size& size,
...@@ -189,7 +199,8 @@ HostGpuMemoryBufferManager::CreateGpuMemoryBuffer( ...@@ -189,7 +199,8 @@ HostGpuMemoryBufferManager::CreateGpuMemoryBuffer(
base::Unretained(this), id, client_id_, size, format, base::Unretained(this), id, client_id_, size, format,
usage, surface_handle, std::move(reply_callback)); usage, surface_handle, std::move(reply_callback));
task_runner_->PostTask(FROM_HERE, std::move(allocate_callback)); task_runner_->PostTask(FROM_HERE, std::move(allocate_callback));
base::ScopedAllowBaseSyncPrimitives allow_base_sync_primitives; base::ScopedAllowBaseSyncPrimitivesOutsideBlockingScope
allow_base_sync_primitives;
wait_event.Wait(); wait_event.Wait();
if (handle.is_null()) if (handle.is_null())
return nullptr; return nullptr;
......
...@@ -67,6 +67,9 @@ class VIZ_HOST_EXPORT HostGpuMemoryBufferManager ...@@ -67,6 +67,9 @@ class VIZ_HOST_EXPORT HostGpuMemoryBufferManager
gpu::SurfaceHandle surface_handle, gpu::SurfaceHandle surface_handle,
base::OnceCallback<void(gfx::GpuMemoryBufferHandle)> callback); base::OnceCallback<void(gfx::GpuMemoryBufferHandle)> callback);
bool IsNativeGpuMemoryBufferConfiguration(gfx::BufferFormat format,
gfx::BufferUsage usage) const;
// Overridden from gpu::GpuMemoryBufferManager: // Overridden from gpu::GpuMemoryBufferManager:
std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBuffer( std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBuffer(
const gfx::Size& size, const gfx::Size& size,
......
...@@ -876,8 +876,6 @@ jumbo_source_set("browser") { ...@@ -876,8 +876,6 @@ jumbo_source_set("browser") {
"gpu/browser_gpu_channel_host_factory.h", "gpu/browser_gpu_channel_host_factory.h",
"gpu/browser_gpu_client_delegate.cc", "gpu/browser_gpu_client_delegate.cc",
"gpu/browser_gpu_client_delegate.h", "gpu/browser_gpu_client_delegate.h",
"gpu/browser_gpu_memory_buffer_manager.cc",
"gpu/browser_gpu_memory_buffer_manager.h",
"gpu/compositor_util.cc", "gpu/compositor_util.cc",
"gpu/compositor_util.h", "gpu/compositor_util.h",
"gpu/gpu_client_delegate.h", "gpu/gpu_client_delegate.h",
...@@ -893,6 +891,8 @@ jumbo_source_set("browser") { ...@@ -893,6 +891,8 @@ jumbo_source_set("browser") {
"gpu/gpu_internals_ui.h", "gpu/gpu_internals_ui.h",
"gpu/gpu_main_thread_factory.cc", "gpu/gpu_main_thread_factory.cc",
"gpu/gpu_main_thread_factory.h", "gpu/gpu_main_thread_factory.h",
"gpu/gpu_memory_buffer_manager_singleton.cc",
"gpu/gpu_memory_buffer_manager_singleton.h",
"gpu/gpu_process_host.cc", "gpu/gpu_process_host.cc",
"gpu/gpu_process_host.h", "gpu/gpu_process_host.h",
"gpu/shader_cache_factory.cc", "gpu/shader_cache_factory.cc",
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
#include "content/browser/download/download_resource_handler.h" #include "content/browser/download/download_resource_handler.h"
#include "content/browser/download/save_file_manager.h" #include "content/browser/download/save_file_manager.h"
#include "content/browser/gpu/browser_gpu_channel_host_factory.h" #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" #include "content/browser/gpu/browser_gpu_client_delegate.h"
#include "content/browser/gpu/compositor_util.h" #include "content/browser/gpu/compositor_util.h"
#include "content/browser/gpu/gpu_data_manager_impl.h" #include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_process_host.h" #include "content/browser/gpu/gpu_process_host.h"
...@@ -1124,9 +1124,8 @@ void BrowserMainLoop::ShutdownThreadsAndCleanUp() { ...@@ -1124,9 +1124,8 @@ void BrowserMainLoop::ShutdownThreadsAndCleanUp() {
device_monitor_mac_.reset(); device_monitor_mac_.reset();
#endif #endif
if (BrowserGpuChannelHostFactory::instance()) { if (BrowserGpuChannelHostFactory::instance())
BrowserGpuChannelHostFactory::instance()->CloseChannel(); BrowserGpuChannelHostFactory::instance()->CloseChannel();
}
// Shutdown the Service Manager and IPC. // Shutdown the Service Manager and IPC.
service_manager_context_.reset(); service_manager_context_.reset();
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "base/trace_event/memory_dump_manager.h" #include "base/trace_event/memory_dump_manager.h"
#include "content/browser/browser_child_process_host_impl.h" #include "content/browser/browser_child_process_host_impl.h"
#include "content/browser/browser_thread_impl.h" #include "content/browser/browser_thread_impl.h"
#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
#include "content/browser/notification_service_impl.h" #include "content/browser/notification_service_impl.h"
#include "content/browser/utility_process_host.h" #include "content/browser/utility_process_host.h"
#include "content/common/child_process_host_impl.h" #include "content/common/child_process_host_impl.h"
...@@ -222,10 +221,6 @@ void BrowserProcessSubThread::IOThreadCleanUp() { ...@@ -222,10 +221,6 @@ void BrowserProcessSubThread::IOThreadCleanUp() {
// and delete the BrowserChildProcessHost instances to release whatever // and delete the BrowserChildProcessHost instances to release whatever
// IO thread only resources they are referencing. // IO thread only resources they are referencing.
BrowserChildProcessHostImpl::TerminateAll(); BrowserChildProcessHostImpl::TerminateAll();
// Unregister GpuMemoryBuffer dump provider before IO thread is shut down.
base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
BrowserGpuMemoryBufferManager::current());
} }
} // namespace content } // namespace content
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/viz/common/features.h" #include "components/viz/common/features.h"
#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
#include "content/browser/gpu/gpu_data_manager_impl.h" #include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_memory_buffer_manager_singleton.h"
#include "content/browser/gpu/gpu_process_host.h" #include "content/browser/gpu/gpu_process_host.h"
#include "content/browser/gpu/shader_cache_factory.h" #include "content/browser/gpu/shader_cache_factory.h"
#include "content/common/child_process_host_impl.h" #include "content/common/child_process_host_impl.h"
...@@ -228,14 +228,6 @@ void BrowserGpuChannelHostFactory::EstablishRequest::Cancel() { ...@@ -228,14 +228,6 @@ void BrowserGpuChannelHostFactory::EstablishRequest::Cancel() {
established_callbacks_.clear(); established_callbacks_.clear();
} }
void BrowserGpuChannelHostFactory::CloseChannel() {
DCHECK(instance_);
if (instance_->gpu_channel_) {
instance_->gpu_channel_->DestroyChannel();
instance_->gpu_channel_ = nullptr;
}
}
void BrowserGpuChannelHostFactory::Initialize(bool establish_gpu_channel) { void BrowserGpuChannelHostFactory::Initialize(bool establish_gpu_channel) {
DCHECK(!instance_); DCHECK(!instance_);
instance_ = new BrowserGpuChannelHostFactory(); instance_ = new BrowserGpuChannelHostFactory();
...@@ -250,13 +242,20 @@ void BrowserGpuChannelHostFactory::Terminate() { ...@@ -250,13 +242,20 @@ void BrowserGpuChannelHostFactory::Terminate() {
instance_ = nullptr; instance_ = nullptr;
} }
void BrowserGpuChannelHostFactory::CloseChannel() {
if (gpu_channel_) {
gpu_channel_->DestroyChannel();
gpu_channel_ = nullptr;
}
gpu_memory_buffer_manager_ = nullptr;
}
BrowserGpuChannelHostFactory::BrowserGpuChannelHostFactory() BrowserGpuChannelHostFactory::BrowserGpuChannelHostFactory()
: gpu_client_id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), : gpu_client_id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()),
gpu_client_tracing_id_( gpu_client_tracing_id_(
memory_instrumentation::mojom::kServiceTracingProcessId), memory_instrumentation::mojom::kServiceTracingProcessId),
gpu_memory_buffer_manager_( gpu_memory_buffer_manager_(
new BrowserGpuMemoryBufferManager(gpu_client_id_, new GpuMemoryBufferManagerSingleton(gpu_client_id_)) {
gpu_client_tracing_id_)) {
if (!base::CommandLine::ForCurrentProcess()->HasSwitch( if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableGpuShaderDiskCache)) { switches::kDisableGpuShaderDiskCache)) {
DCHECK(GetContentClient()); DCHECK(GetContentClient());
......
...@@ -17,11 +17,15 @@ ...@@ -17,11 +17,15 @@
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/public/browser/browser_thread.h"
#include "gpu/ipc/client/gpu_channel_host.h" #include "gpu/ipc/client/gpu_channel_host.h"
#include "ipc/message_filter.h" #include "ipc/message_filter.h"
namespace gpu {
class GpuMemoryBufferManager;
}
namespace content { namespace content {
class BrowserGpuMemoryBufferManager;
class CONTENT_EXPORT BrowserGpuChannelHostFactory class CONTENT_EXPORT BrowserGpuChannelHostFactory
: public gpu::GpuChannelEstablishFactory { : public gpu::GpuChannelEstablishFactory {
...@@ -62,7 +66,8 @@ class CONTENT_EXPORT BrowserGpuChannelHostFactory ...@@ -62,7 +66,8 @@ class CONTENT_EXPORT BrowserGpuChannelHostFactory
const int gpu_client_id_; const int gpu_client_id_;
const uint64_t gpu_client_tracing_id_; const uint64_t gpu_client_tracing_id_;
scoped_refptr<gpu::GpuChannelHost> gpu_channel_; scoped_refptr<gpu::GpuChannelHost> gpu_channel_;
std::unique_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_; std::unique_ptr<gpu::GpuMemoryBufferManager, BrowserThread::DeleteOnIOThread>
gpu_memory_buffer_manager_;
scoped_refptr<EstablishRequest> pending_request_; scoped_refptr<EstablishRequest> pending_request_;
base::OneShotTimer timeout_; base::OneShotTimer timeout_;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "content/browser/gpu/browser_gpu_client_delegate.h" #include "content/browser/gpu/browser_gpu_client_delegate.h"
#include "content/browser/gpu/gpu_memory_buffer_manager_singleton.h"
#include "content/browser/gpu/gpu_process_host.h" #include "content/browser/gpu/gpu_process_host.h"
#include "gpu/config/gpu_feature_info.h" #include "gpu/config/gpu_feature_info.h"
#include "gpu/config/gpu_info.h" #include "gpu/config/gpu_info.h"
...@@ -69,4 +70,9 @@ void BrowserGpuClientDelegate::EstablishGpuChannel( ...@@ -69,4 +70,9 @@ void BrowserGpuClientDelegate::EstablishGpuChannel(
base::BindOnce(&OnEstablishGpuChannel, std::move(callback))); base::BindOnce(&OnEstablishGpuChannel, std::move(callback)));
} }
viz::HostGpuMemoryBufferManager*
BrowserGpuClientDelegate::GetGpuMemoryBufferManager() {
return GpuMemoryBufferManagerSingleton::GetInstance();
}
} // namespace content } // namespace content
...@@ -19,6 +19,7 @@ class BrowserGpuClientDelegate : public GpuClientDelegate { ...@@ -19,6 +19,7 @@ class BrowserGpuClientDelegate : public GpuClientDelegate {
void EstablishGpuChannel(int client_id, void EstablishGpuChannel(int client_id,
uint64_t client_tracing_id, uint64_t client_tracing_id,
EstablishGpuChannelCallback callback) override; EstablishGpuChannelCallback callback) override;
viz::HostGpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
private: private:
DISALLOW_COPY_AND_ASSIGN(BrowserGpuClientDelegate); DISALLOW_COPY_AND_ASSIGN(BrowserGpuClientDelegate);
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_
#define CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <utility>
#include "base/callback.h"
#include "base/containers/hash_tables.h"
#include "base/hash.h"
#include "base/macros.h"
#include "base/trace_event/memory_dump_provider.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/common/content_export.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
#include "gpu/ipc/common/surface_handle.h"
#include "gpu/ipc/host/gpu_memory_buffer_support.h"
namespace gpu {
class GpuMemoryBufferSupport;
}
namespace content {
class CONTENT_EXPORT BrowserGpuMemoryBufferManager
: public gpu::GpuMemoryBufferManager,
public base::trace_event::MemoryDumpProvider {
public:
using CreateCallback =
base::OnceCallback<void(gfx::GpuMemoryBufferHandle handle)>;
using AllocationCallback = CreateCallback;
BrowserGpuMemoryBufferManager(int gpu_client_id,
uint64_t gpu_client_tracing_id);
~BrowserGpuMemoryBufferManager() override;
static BrowserGpuMemoryBufferManager* current();
// Overridden from gpu::GpuMemoryBufferManager:
std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBuffer(
const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
gpu::SurfaceHandle surface_handle) override;
void SetDestructionSyncToken(gfx::GpuMemoryBuffer* buffer,
const gpu::SyncToken& sync_token) override;
// Overridden from base::trace_event::MemoryDumpProvider:
bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) override;
void AllocateGpuMemoryBufferForChildProcess(gfx::GpuMemoryBufferId id,
const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
int child_client_id,
AllocationCallback callback);
void ChildProcessDeletedGpuMemoryBuffer(
gfx::GpuMemoryBufferId id,
int child_client_id,
const gpu::SyncToken& sync_token);
void ProcessRemoved(int client_id);
bool IsNativeGpuMemoryBufferConfiguration(gfx::BufferFormat format,
gfx::BufferUsage usage) const;
private:
struct BufferInfo {
BufferInfo(const gfx::Size& size,
gfx::GpuMemoryBufferType type,
gfx::BufferFormat format,
gfx::BufferUsage usage,
int gpu_host_id);
BufferInfo(const BufferInfo& other);
~BufferInfo();
gfx::Size size;
gfx::GpuMemoryBufferType type = gfx::EMPTY_BUFFER;
gfx::BufferFormat format = gfx::BufferFormat::RGBA_8888;
gfx::BufferUsage usage = gfx::BufferUsage::GPU_READ;
int gpu_host_id = 0;
base::UnguessableToken shared_memory_guid;
};
struct CreateGpuMemoryBufferRequest;
std::unique_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForSurface(
const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
gpu::SurfaceHandle surface_handle);
// Functions that handle synchronous buffer creation requests.
void HandleCreateGpuMemoryBufferOnIO(CreateGpuMemoryBufferRequest* request);
void HandleGpuMemoryBufferCreatedOnIO(CreateGpuMemoryBufferRequest* request,
gfx::GpuMemoryBufferHandle handle);
// Functions that implement asynchronous buffer creation.
void CreateGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id,
const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
gpu::SurfaceHandle surface_handle,
int client_id,
CreateCallback callback);
void GpuMemoryBufferCreatedOnIO(gfx::GpuMemoryBufferId id,
gpu::SurfaceHandle surface_handle,
int client_id,
int gpu_host_id,
CreateCallback callback,
gfx::GpuMemoryBufferHandle handle,
GpuProcessHost::BufferCreationStatus status);
void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id,
int client_id,
const gpu::SyncToken& sync_token);
uint64_t ClientIdToTracingProcessId(int client_id) const;
std::unique_ptr<gpu::GpuMemoryBufferSupport> gpu_memory_buffer_support_;
const gpu::GpuMemoryBufferConfigurationSet native_configurations_;
const int gpu_client_id_;
const uint64_t gpu_client_tracing_id_;
int next_gpu_memory_id_ = 1;
// Stores info about buffers for all clients. This should only be accessed
// on the IO thread.
using BufferMap = base::hash_map<gfx::GpuMemoryBufferId, BufferInfo>;
using ClientMap = base::hash_map<int, BufferMap>;
ClientMap clients_;
DISALLOW_COPY_AND_ASSIGN(BrowserGpuMemoryBufferManager);
};
} // namespace content
#endif // CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_
...@@ -17,6 +17,8 @@ namespace viz { ...@@ -17,6 +17,8 @@ namespace viz {
namespace mojom { namespace mojom {
class GpuService; class GpuService;
} }
class HostGpuMemoryBufferManager;
} // namespace viz } // namespace viz
namespace content { namespace content {
...@@ -53,6 +55,9 @@ class GpuClientDelegate { ...@@ -53,6 +55,9 @@ class GpuClientDelegate {
virtual void EstablishGpuChannel(int client_id, virtual void EstablishGpuChannel(int client_id,
uint64_t client_tracing_id, uint64_t client_tracing_id,
EstablishGpuChannelCallback callback) = 0; EstablishGpuChannelCallback callback) = 0;
// Returns the current viz::HostGpuMemoryBufferManager instance.
virtual viz::HostGpuMemoryBufferManager* GetGpuMemoryBufferManager() = 0;
}; };
} // namespace content } // namespace content
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
#include "content/browser/gpu/gpu_client_impl.h" #include "content/browser/gpu/gpu_client_impl.h"
#include "components/viz/host/host_gpu_memory_buffer_manager.h"
#include "content/browser/gpu/browser_gpu_client_delegate.h" #include "content/browser/gpu/browser_gpu_client_delegate.h"
#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
#include "content/common/child_process_host_impl.h" #include "content/common/child_process_host_impl.h"
#include "gpu/ipc/client/gpu_channel_host.h" #include "gpu/ipc/client/gpu_channel_host.h"
#include "gpu/ipc/common/gpu_memory_buffer_impl.h" #include "gpu/ipc/common/gpu_memory_buffer_impl.h"
...@@ -61,11 +61,11 @@ void GpuClientImpl::Add(ui::mojom::GpuRequest request) { ...@@ -61,11 +61,11 @@ void GpuClientImpl::Add(ui::mojom::GpuRequest request) {
void GpuClientImpl::OnError(ErrorReason reason) { void GpuClientImpl::OnError(ErrorReason reason) {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
ClearCallback(); ClearCallback();
if (gpu_bindings_.empty()) { if (gpu_bindings_.empty() && delegate_) {
BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager = if (auto* gpu_memory_buffer_manager =
BrowserGpuMemoryBufferManager::current(); delegate_->GetGpuMemoryBufferManager()) {
if (gpu_memory_buffer_manager) gpu_memory_buffer_manager->DestroyAllGpuMemoryBufferForClient(client_id_);
gpu_memory_buffer_manager->ProcessRemoved(client_id_); }
} }
if (reason == ErrorReason::kConnectionLost && connection_error_handler_) if (reason == ErrorReason::kConnectionLost && connection_error_handler_)
std::move(connection_error_handler_).Run(this); std::move(connection_error_handler_).Run(this);
...@@ -179,7 +179,8 @@ void GpuClientImpl::CreateGpuMemoryBuffer( ...@@ -179,7 +179,8 @@ void GpuClientImpl::CreateGpuMemoryBuffer(
gfx::BufferFormat format, gfx::BufferFormat format,
gfx::BufferUsage usage, gfx::BufferUsage usage,
ui::mojom::GpuMemoryBufferFactory::CreateGpuMemoryBufferCallback callback) { ui::mojom::GpuMemoryBufferFactory::CreateGpuMemoryBufferCallback callback) {
DCHECK(BrowserGpuMemoryBufferManager::current()); auto* gpu_memory_buffer_manager = delegate_->GetGpuMemoryBufferManager();
DCHECK(gpu_memory_buffer_manager);
base::CheckedNumeric<int> bytes = size.width(); base::CheckedNumeric<int> bytes = size.width();
bytes *= size.height(); bytes *= size.height();
...@@ -188,19 +189,19 @@ void GpuClientImpl::CreateGpuMemoryBuffer( ...@@ -188,19 +189,19 @@ void GpuClientImpl::CreateGpuMemoryBuffer(
return; return;
} }
BrowserGpuMemoryBufferManager::current() gpu_memory_buffer_manager->AllocateGpuMemoryBuffer(
->AllocateGpuMemoryBufferForChildProcess( id, client_id_, size, format, usage, gpu::kNullSurfaceHandle,
id, size, format, usage, client_id_, base::BindOnce(&GpuClientImpl::OnCreateGpuMemoryBuffer,
base::BindOnce(&GpuClientImpl::OnCreateGpuMemoryBuffer, weak_factory_.GetWeakPtr(), std::move(callback)));
weak_factory_.GetWeakPtr(), std::move(callback)));
} }
void GpuClientImpl::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, void GpuClientImpl::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
const gpu::SyncToken& sync_token) { const gpu::SyncToken& sync_token) {
DCHECK(BrowserGpuMemoryBufferManager::current()); if (auto* gpu_memory_buffer_manager =
delegate_->GetGpuMemoryBufferManager()) {
BrowserGpuMemoryBufferManager::current()->ChildProcessDeletedGpuMemoryBuffer( gpu_memory_buffer_manager->DestroyGpuMemoryBuffer(id, client_id_,
id, client_id_, sync_token); sync_token);
}
} }
void GpuClientImpl::CreateGpuMemoryBufferFactory( void GpuClientImpl::CreateGpuMemoryBufferFactory(
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "cc/base/switches.h" #include "cc/base/switches.h"
#include "components/viz/common/features.h" #include "components/viz/common/features.h"
#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" #include "content/browser/gpu/gpu_memory_buffer_manager_singleton.h"
#include "content/browser/gpu/gpu_process_host.h" #include "content/browser/gpu/gpu_process_host.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/gpu_data_manager_observer.h" #include "content/public/browser/gpu_data_manager_observer.h"
...@@ -584,11 +584,10 @@ void GpuDataManagerImplPrivate::UpdateGpuPreferences( ...@@ -584,11 +584,10 @@ void GpuDataManagerImplPrivate::UpdateGpuPreferences(
gpu::GpuPreferences* gpu_preferences) const { gpu::GpuPreferences* gpu_preferences) const {
DCHECK(gpu_preferences); DCHECK(gpu_preferences);
BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager =
BrowserGpuMemoryBufferManager::current();
// For performance reasons, discourage storing VideoFrames in a biplanar // For performance reasons, discourage storing VideoFrames in a biplanar
// GpuMemoryBuffer if this is not native, see https://crbug.com/791676. // GpuMemoryBuffer if this is not native, see https://crbug.com/791676.
if (gpu_memory_buffer_manager) { if (auto* gpu_memory_buffer_manager =
GpuMemoryBufferManagerSingleton::GetInstance()) {
gpu_preferences->disable_biplanar_gpu_memory_buffers_for_video_frames = gpu_preferences->disable_biplanar_gpu_memory_buffers_for_video_frames =
!gpu_memory_buffer_manager->IsNativeGpuMemoryBufferConfiguration( !gpu_memory_buffer_manager->IsNativeGpuMemoryBufferConfiguration(
gfx::BufferFormat::YUV_420_BIPLANAR, gfx::BufferFormat::YUV_420_BIPLANAR,
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/gpu/gpu_memory_buffer_manager_singleton.h"
#include "base/bind.h"
#include "base/logging.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/public/browser/browser_thread.h"
#include "gpu/ipc/common/gpu_memory_buffer_support.h"
namespace content {
namespace {
GpuMemoryBufferManagerSingleton* g_gpu_memory_buffer_manager;
viz::mojom::GpuService* GetGpuService(
base::OnceClosure connection_error_handler) {
if (auto* host = GpuProcessHost::Get()) {
host->AddConnectionErrorHandler(std::move(connection_error_handler));
return host->gpu_service();
}
return nullptr;
}
} // namespace
GpuMemoryBufferManagerSingleton::GpuMemoryBufferManagerSingleton(int client_id)
: HostGpuMemoryBufferManager(
base::BindRepeating(&content::GetGpuService),
client_id,
std::make_unique<gpu::GpuMemoryBufferSupport>(),
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)) {
DCHECK(!g_gpu_memory_buffer_manager);
g_gpu_memory_buffer_manager = this;
}
GpuMemoryBufferManagerSingleton::~GpuMemoryBufferManagerSingleton() {
DCHECK_EQ(this, g_gpu_memory_buffer_manager);
g_gpu_memory_buffer_manager = nullptr;
}
// static
GpuMemoryBufferManagerSingleton*
GpuMemoryBufferManagerSingleton::GetInstance() {
return g_gpu_memory_buffer_manager;
}
} // namespace content
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_GPU_GPU_MEMORY_BUFFER_MANAGER_SINGLETON_H_
#define CONTENT_BROWSER_GPU_GPU_MEMORY_BUFFER_MANAGER_SINGLETON_H_
#include "components/viz/host/host_gpu_memory_buffer_manager.h"
namespace content {
// This class ensures that there is at most one instance of
// |viz::HostGpuMemoryBufferManager| in content at any given time. Code in
// content must use this class to access the instance.
class GpuMemoryBufferManagerSingleton : public viz::HostGpuMemoryBufferManager {
public:
explicit GpuMemoryBufferManagerSingleton(int client_id);
~GpuMemoryBufferManagerSingleton() override;
static GpuMemoryBufferManagerSingleton* GetInstance();
private:
DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferManagerSingleton);
};
} // namespace content
#endif // CONTENT_BROWSER_GPU_GPU_MEMORY_BUFFER_MANAGER_SINGLETON_H_
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "content/browser/gpu/compositor_util.h" #include "content/browser/gpu/compositor_util.h"
#include "content/browser/gpu/gpu_data_manager_impl.h" #include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_main_thread_factory.h" #include "content/browser/gpu/gpu_main_thread_factory.h"
#include "content/browser/gpu/gpu_memory_buffer_manager_singleton.h"
#include "content/browser/gpu/shader_cache_factory.h" #include "content/browser/gpu/shader_cache_factory.h"
#include "content/browser/memory/memory_coordinator_impl.h" #include "content/browser/memory/memory_coordinator_impl.h"
#include "content/browser/service_manager/service_manager_context.h" #include "content/browser/service_manager/service_manager_context.h"
...@@ -734,7 +735,7 @@ GpuProcessHost::~GpuProcessHost() { ...@@ -734,7 +735,7 @@ GpuProcessHost::~GpuProcessHost() {
if (in_process_gpu_thread_) if (in_process_gpu_thread_)
DCHECK(process_); DCHECK(process_);
SendOutstandingReplies(); OnConnectionError();
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
if (ca_transaction_gpu_coordinator_) { if (ca_transaction_gpu_coordinator_) {
...@@ -940,6 +941,8 @@ bool GpuProcessHost::Init() { ...@@ -940,6 +941,8 @@ bool GpuProcessHost::Init() {
mojo::MakeRequest(&gpu_service_ptr_), std::move(host_proxy), mojo::MakeRequest(&gpu_service_ptr_), std::move(host_proxy),
std::move(discardable_manager_ptr), activity_flags_.CloneHandle(), std::move(discardable_manager_ptr), activity_flags_.CloneHandle(),
GetFontRenderParamsOnIO().params.subpixel_rendering); GetFontRenderParamsOnIO().params.subpixel_rendering);
gpu_service_ptr_.set_connection_error_handler(base::BindOnce(
&GpuProcessHost::OnConnectionError, weak_ptr_factory_.GetWeakPtr()));
#if defined(USE_OZONE) #if defined(USE_OZONE)
InitOzone(); InitOzone();
...@@ -959,14 +962,14 @@ bool GpuProcessHost::Send(IPC::Message* msg) { ...@@ -959,14 +962,14 @@ bool GpuProcessHost::Send(IPC::Message* msg) {
return true; return true;
} }
bool result = process_->Send(msg); return process_->Send(msg);
if (!result) { }
// Channel is hosed, but we may not get destroyed for a while. Send
// outstanding channel creation failures now so that the caller can restart void GpuProcessHost::OnConnectionError() {
// with a new process/channel without waiting. SendOutstandingReplies();
SendOutstandingReplies(); for (auto& handler : connection_error_handlers_)
} std::move(handler).Run();
return result; connection_error_handlers_.clear();
} }
bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) {
...@@ -988,6 +991,10 @@ void GpuProcessHost::OnChannelConnected(int32_t peer_pid) { ...@@ -988,6 +991,10 @@ void GpuProcessHost::OnChannelConnected(int32_t peer_pid) {
} }
} }
void GpuProcessHost::AddConnectionErrorHandler(base::OnceClosure handler) {
connection_error_handlers_.push_back(std::move(handler));
}
void GpuProcessHost::EstablishGpuChannel(int client_id, void GpuProcessHost::EstablishGpuChannel(int client_id,
uint64_t client_tracing_id, uint64_t client_tracing_id,
bool is_gpu_host, bool is_gpu_host,
...@@ -1038,31 +1045,6 @@ void GpuProcessHost::EstablishGpuChannel(int client_id, ...@@ -1038,31 +1045,6 @@ void GpuProcessHost::EstablishGpuChannel(int client_id,
} }
} }
void GpuProcessHost::CreateGpuMemoryBuffer(
gfx::GpuMemoryBufferId id,
const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
int client_id,
gpu::SurfaceHandle surface_handle,
CreateGpuMemoryBufferCallback callback) {
TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer");
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
create_gpu_memory_buffer_requests_.push(std::move(callback));
gpu_service_ptr_->CreateGpuMemoryBuffer(
id, size, format, usage, client_id, surface_handle,
base::BindOnce(&GpuProcessHost::OnGpuMemoryBufferCreated,
weak_ptr_factory_.GetWeakPtr()));
}
void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
int client_id,
const gpu::SyncToken& sync_token) {
TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer");
gpu_service_ptr_->DestroyGpuMemoryBuffer(id, client_id, sync_token);
}
void GpuProcessHost::ConnectFrameSinkManager( void GpuProcessHost::ConnectFrameSinkManager(
viz::mojom::FrameSinkManagerRequest request, viz::mojom::FrameSinkManagerRequest request,
viz::mojom::FrameSinkManagerClientPtrInfo client) { viz::mojom::FrameSinkManagerClientPtrInfo client) {
...@@ -1111,16 +1093,6 @@ void GpuProcessHost::OnChannelEstablished( ...@@ -1111,16 +1093,6 @@ void GpuProcessHost::OnChannelEstablished(
gpu_data_manager->GetGpuFeatureInfo(), EstablishChannelStatus::SUCCESS); gpu_data_manager->GetGpuFeatureInfo(), EstablishChannelStatus::SUCCESS);
} }
void GpuProcessHost::OnGpuMemoryBufferCreated(
gfx::GpuMemoryBufferHandle handle) {
TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated");
DCHECK(!create_gpu_memory_buffer_requests_.empty());
auto callback = std::move(create_gpu_memory_buffer_requests_.front());
create_gpu_memory_buffer_requests_.pop();
std::move(callback).Run(std::move(handle), BufferCreationStatus::SUCCESS);
}
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
void GpuProcessHost::OnDestroyingVideoSurfaceAck() { void GpuProcessHost::OnDestroyingVideoSurfaceAck() {
TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceAck"); TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceAck");
...@@ -1174,7 +1146,6 @@ void GpuProcessHost::OnProcessCrashed(int exit_code) { ...@@ -1174,7 +1146,6 @@ void GpuProcessHost::OnProcessCrashed(int exit_code) {
cache_key.first, base::Time(), base::Time::Max(), base::Bind([] {})); cache_key.first, base::Time(), base::Time::Max(), base::Bind([] {}));
} }
} }
SendOutstandingReplies();
ChildProcessTerminationInfo info = ChildProcessTerminationInfo info =
process_->GetTerminationInfo(true /* known_dead */); process_->GetTerminationInfo(true /* known_dead */);
...@@ -1472,13 +1443,6 @@ void GpuProcessHost::SendOutstandingReplies() { ...@@ -1472,13 +1443,6 @@ void GpuProcessHost::SendOutstandingReplies() {
EstablishChannelStatus::GPU_HOST_INVALID); EstablishChannelStatus::GPU_HOST_INVALID);
} }
while (!create_gpu_memory_buffer_requests_.empty()) {
auto callback = std::move(create_gpu_memory_buffer_requests_.front());
create_gpu_memory_buffer_requests_.pop();
std::move(callback).Run(gfx::GpuMemoryBufferHandle(),
BufferCreationStatus::GPU_HOST_INVALID);
}
if (!send_destroying_video_surface_done_cb_.is_null()) if (!send_destroying_video_surface_done_cb_.is_null())
base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run();
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <memory> #include <memory>
#include <set> #include <set>
#include <string> #include <string>
#include <vector>
#include "base/atomicops.h" #include "base/atomicops.h"
#include "base/callback.h" #include "base/callback.h"
...@@ -36,8 +37,6 @@ ...@@ -36,8 +37,6 @@
#include "services/viz/privileged/interfaces/gl/gpu_host.mojom.h" #include "services/viz/privileged/interfaces/gl/gpu_host.mojom.h"
#include "services/viz/privileged/interfaces/gl/gpu_service.mojom.h" #include "services/viz/privileged/interfaces/gl/gpu_service.mojom.h"
#include "services/viz/privileged/interfaces/viz_main.mojom.h" #include "services/viz/privileged/interfaces/viz_main.mojom.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gpu_memory_buffer.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace base { namespace base {
...@@ -50,7 +49,6 @@ struct FontRenderParams; ...@@ -50,7 +49,6 @@ struct FontRenderParams;
namespace gpu { namespace gpu {
class ShaderDiskCache; class ShaderDiskCache;
struct SyncToken;
} }
namespace content { namespace content {
...@@ -84,14 +82,6 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, ...@@ -84,14 +82,6 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
const gpu::GpuFeatureInfo&, const gpu::GpuFeatureInfo&,
EstablishChannelStatus status)>; EstablishChannelStatus status)>;
enum class BufferCreationStatus {
GPU_HOST_INVALID,
SUCCESS,
};
using CreateGpuMemoryBufferCallback =
base::OnceCallback<void(gfx::GpuMemoryBufferHandle handle,
BufferCreationStatus status)>;
using RequestHDRStatusCallback = base::RepeatingCallback<void(bool)>; using RequestHDRStatusCallback = base::RepeatingCallback<void(bool)>;
static int GetGpuCrashCount(); static int GetGpuCrashCount();
...@@ -132,6 +122,9 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, ...@@ -132,6 +122,9 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
// IPC::Sender implementation. // IPC::Sender implementation.
bool Send(IPC::Message* msg) override; bool Send(IPC::Message* msg) override;
// Adds a connection error handler for the GpuService.
void AddConnectionErrorHandler(base::OnceClosure handler);
// Tells the GPU process to create a new channel for communication with a // Tells the GPU process to create a new channel for communication with a
// client. Once the GPU process responds asynchronously with the IPC handle // client. Once the GPU process responds asynchronously with the IPC handle
// and GPUInfo, we call the callback. // and GPUInfo, we call the callback.
...@@ -140,20 +133,6 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, ...@@ -140,20 +133,6 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
bool is_gpu_host, bool is_gpu_host,
EstablishChannelCallback callback); EstablishChannelCallback callback);
// Tells the GPU process to create a new GPU memory buffer.
void CreateGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
int client_id,
gpu::SurfaceHandle surface_handle,
CreateGpuMemoryBufferCallback callback);
// Tells the GPU process to destroy GPU memory buffer.
void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
int client_id,
const gpu::SyncToken& sync_token);
// Connects to FrameSinkManager running in the viz process. In this // Connects to FrameSinkManager running in the viz process. In this
// configuration the display compositor runs in the viz process and the // configuration the display compositor runs in the viz process and the
// browser must submit CompositorFrames over IPC. // browser must submit CompositorFrames over IPC.
...@@ -206,6 +185,9 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, ...@@ -206,6 +185,9 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
void InitOzone(); void InitOzone();
#endif // defined(USE_OZONE) #endif // defined(USE_OZONE)
// Called when GpuService connection is lost.
void OnConnectionError();
// BrowserChildProcessHostDelegate implementation. // BrowserChildProcessHostDelegate implementation.
bool OnMessageReceived(const IPC::Message& message) override; bool OnMessageReceived(const IPC::Message& message) override;
void OnChannelConnected(int32_t peer_pid) override; void OnChannelConnected(int32_t peer_pid) override;
...@@ -240,7 +222,6 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, ...@@ -240,7 +222,6 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
void OnChannelEstablished(int client_id, void OnChannelEstablished(int client_id,
mojo::ScopedMessagePipeHandle channel_handle); mojo::ScopedMessagePipeHandle channel_handle);
void OnGpuMemoryBufferCreated(gfx::GpuMemoryBufferHandle handle);
// Message handlers. // Message handlers.
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
...@@ -264,13 +245,13 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, ...@@ -264,13 +245,13 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
// The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair.
int host_id_; int host_id_;
// List of connection error handlers for the GpuService.
std::vector<base::OnceClosure> connection_error_handlers_;
// These are the channel requests that we have already sent to // These are the channel requests that we have already sent to
// the GPU process, but haven't heard back about yet. // the GPU process, but haven't heard back about yet.
base::queue<EstablishChannelCallback> channel_requests_; base::queue<EstablishChannelCallback> channel_requests_;
// The pending create gpu memory buffer requests we need to reply to.
base::queue<CreateGpuMemoryBufferCallback> create_gpu_memory_buffer_requests_;
// A callback to signal the completion of a SendDestroyingVideoSurface call. // A callback to signal the completion of a SendDestroyingVideoSurface call.
base::Closure send_destroying_video_surface_done_cb_; base::Closure send_destroying_video_surface_done_cb_;
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "base/threading/thread_local.h" #include "base/threading/thread_local.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "content/browser/child_process_security_policy_impl.h" #include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
#include "content/browser/gpu/gpu_process_host.h" #include "content/browser/gpu/gpu_process_host.h"
#include "content/browser/renderer_host/media/audio_input_device_manager.h" #include "content/browser/renderer_host/media/audio_input_device_manager.h"
#include "content/browser/renderer_host/media/audio_service_listener.h" #include "content/browser/renderer_host/media/audio_service_listener.h"
...@@ -71,6 +70,7 @@ ...@@ -71,6 +70,7 @@
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chromeos/audio/cras_audio_handler.h" #include "chromeos/audio/cras_audio_handler.h"
#include "content/browser/gpu/gpu_memory_buffer_manager_singleton.h"
#include "media/capture/video/chromeos/camera_hal_dispatcher_impl.h" #include "media/capture/video/chromeos/camera_hal_dispatcher_impl.h"
#include "media/capture/video/chromeos/public/cros_features.h" #include "media/capture/video/chromeos/public/cros_features.h"
#include "media/capture/video/chromeos/video_capture_device_factory_chromeos.h" #include "media/capture/video/chromeos/video_capture_device_factory_chromeos.h"
...@@ -482,7 +482,7 @@ MediaStreamManager::MediaStreamManager( ...@@ -482,7 +482,7 @@ MediaStreamManager::MediaStreamManager(
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
if (media::ShouldUseCrosCameraService()) { if (media::ShouldUseCrosCameraService()) {
media::VideoCaptureDeviceFactoryChromeOS::SetGpuBufferManager( media::VideoCaptureDeviceFactoryChromeOS::SetGpuBufferManager(
BrowserGpuMemoryBufferManager::current()); GpuMemoryBufferManagerSingleton::GetInstance());
media::CameraHalDispatcherImpl::GetInstance()->Start( media::CameraHalDispatcherImpl::GetInstance()->Start(
base::BindRepeating( base::BindRepeating(
&VideoCaptureDependencies::CreateJpegDecodeAccelerator), &VideoCaptureDependencies::CreateJpegDecodeAccelerator),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment