0

Remove content/gpu from content/browser/android/DEPS

Synchronous compositor used this include to insert its own
SyncPointManager instance to be used by the in-process GPU thread.

Remove that DEPS and add ContentGpuClient::GetSyncPointManager so that
GPU code can directly get a SyncPointManager from content embedder. This
works for out of process GPU as well.

This also removes the InProcessCommandBuffer dependency from Android.

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

Cr-Commit-Position: refs/heads/master@{#389046}
This commit is contained in:
boliu
2016-04-21 23:38:50 -07:00
committed by Commit bot
parent 17f325f176
commit 1384d6d1c0
21 changed files with 130 additions and 81 deletions

@ -516,6 +516,8 @@ source_set("common") {
"common/url_constants.h",
"crash_reporter/aw_microdump_crash_reporter.cc",
"crash_reporter/aw_microdump_crash_reporter.h",
"gpu/aw_content_gpu_client.cc",
"gpu/aw_content_gpu_client.h",
"lib/aw_browser_dependency_factory_impl.cc",
"lib/aw_browser_dependency_factory_impl.h",
"lib/main/aw_main_delegate.cc",

@ -406,6 +406,8 @@
'common/url_constants.h',
'crash_reporter/aw_microdump_crash_reporter.cc',
'crash_reporter/aw_microdump_crash_reporter.h',
'gpu/aw_content_gpu_client.cc',
'gpu/aw_content_gpu_client.h',
'lib/aw_browser_dependency_factory_impl.cc',
'lib/aw_browser_dependency_factory_impl.h',
'lib/main/aw_main_delegate.cc',

@ -11,7 +11,6 @@
#include "base/strings/string_number_conversions.h"
#include "base/synchronization/lock.h"
#include "base/trace_event/trace_event.h"
#include "content/public/browser/android/synchronous_compositor.h"
#include "content/public/browser/gpu_utils.h"
#include "content/public/common/content_switches.h"
#include "gpu/command_buffer/service/framebuffer_completeness_cache.h"
@ -59,10 +58,8 @@ ScopedAllowGL::~ScopedAllowGL() {
// static
void DeferredGpuCommandService::SetInstance() {
if (!g_service.Get().get()) {
if (!g_service.Get().get())
g_service.Get() = new DeferredGpuCommandService;
content::SynchronousCompositor::SetGpuService(g_service.Get());
}
}
// static

3
android_webview/gpu/DEPS Normal file

@ -0,0 +1,3 @@
include_rules = [
"+content/public/gpu",
]

@ -0,0 +1,22 @@
// Copyright 2016 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 "android_webview/gpu/aw_content_gpu_client.h"
namespace android_webview {
AwContentGpuClient::AwContentGpuClient(
const GetSyncPointManagerCallback& callback)
: sync_point_manager_callback_(callback) {}
AwContentGpuClient::~AwContentGpuClient() {}
void AwContentGpuClient::RegisterMojoServices(
content::ServiceRegistry* registry) {}
gpu::SyncPointManager* AwContentGpuClient::GetSyncPointManager() {
return sync_point_manager_callback_.Run();
}
} // namespace android_webview

@ -0,0 +1,32 @@
// Copyright 2016 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 ANDROID_WEBVIEW_GPU_AW_CONTENT_GPU_CLIENT_H_
#define ANDROID_WEBVIEW_GPU_AW_CONTENT_GPU_CLIENT_H_
#include "base/callback.h"
#include "base/macros.h"
#include "content/public/gpu/content_gpu_client.h"
namespace android_webview {
class AwContentGpuClient : public content::ContentGpuClient {
public:
using GetSyncPointManagerCallback = base::Callback<gpu::SyncPointManager*()>;
explicit AwContentGpuClient(const GetSyncPointManagerCallback& callback);
~AwContentGpuClient() override;
// content::ContentGpuClient implementation.
void RegisterMojoServices(content::ServiceRegistry* registry) override;
gpu::SyncPointManager* GetSyncPointManager() override;
private:
GetSyncPointManagerCallback sync_point_manager_callback_;
DISALLOW_COPY_AND_ASSIGN(AwContentGpuClient);
};
} // namespace android_webview
#endif // ANDROID_WEBVIEW_GPU_AW_CONTENT_GPU_CLIENT_H_

@ -8,10 +8,12 @@
#include "android_webview/browser/aw_content_browser_client.h"
#include "android_webview/browser/browser_view_renderer.h"
#include "android_webview/browser/deferred_gpu_command_service.h"
#include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h"
#include "android_webview/common/aw_descriptors.h"
#include "android_webview/common/aw_switches.h"
#include "android_webview/crash_reporter/aw_microdump_crash_reporter.h"
#include "android_webview/gpu/aw_content_gpu_client.h"
#include "android_webview/lib/aw_browser_dependency_factory_impl.h"
#include "android_webview/native/aw_locale_manager_impl.h"
#include "android_webview/native/aw_media_url_interceptor.h"
@ -221,6 +223,19 @@ content::ContentBrowserClient*
return content_browser_client_.get();
}
namespace {
gpu::SyncPointManager* GetSyncPointManager() {
DCHECK(DeferredGpuCommandService::GetInstance());
return DeferredGpuCommandService::GetInstance()->sync_point_manager();
}
} // namespace
content::ContentGpuClient* AwMainDelegate::CreateContentGpuClient() {
content_gpu_client_.reset(
new AwContentGpuClient(base::Bind(&GetSyncPointManager)));
return content_gpu_client_.get();
}
content::ContentRendererClient*
AwMainDelegate::CreateContentRendererClient() {
content_renderer_client_.reset(new AwContentRendererClient());

@ -20,6 +20,7 @@ class BrowserMainRunner;
namespace android_webview {
class AwContentBrowserClient;
class AwContentGpuClient;
class AwContentRendererClient;
// Android WebView implementation of ContentMainDelegate.
@ -38,6 +39,7 @@ class AwMainDelegate : public content::ContentMainDelegate,
const content::MainFunctionParams& main_function_params) override;
void ProcessExiting(const std::string& process_type) override;
content::ContentBrowserClient* CreateContentBrowserClient() override;
content::ContentGpuClient* CreateContentGpuClient() override;
content::ContentRendererClient* CreateContentRendererClient() override;
// JniDependencyFactory implementation.
@ -56,6 +58,7 @@ class AwMainDelegate : public content::ContentMainDelegate,
std::unique_ptr<content::BrowserMainRunner> browser_runner_;
AwContentClient content_client_;
std::unique_ptr<AwContentBrowserClient> content_browser_client_;
std::unique_ptr<AwContentGpuClient> content_gpu_client_;
std::unique_ptr<AwContentRendererClient> content_renderer_client_;
DISALLOW_COPY_AND_ASSIGN(AwMainDelegate);

@ -25,6 +25,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/common/ssl_status.h"
#include "jni/AwAutofillClient_jni.h"
#include "ui/gfx/geometry/rect_f.h"
using base::android::AttachCurrentThread;
using base::android::ConvertUTF16ToJavaString;

@ -1,3 +0,0 @@
include_rules = [
"+content/gpu/in_process_gpu_thread.h",
]

@ -13,12 +13,10 @@
#include "base/trace_event/trace_event_argument.h"
#include "cc/output/compositor_frame_ack.h"
#include "content/browser/android/in_process/synchronous_compositor_renderer_statics.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/browser/renderer_host/render_widget_host_view_android.h"
#include "content/browser/web_contents/web_contents_android.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/android/sync_compositor_messages.h"
#include "content/gpu/in_process_gpu_thread.h"
#include "content/public/browser/android/synchronous_compositor_client.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
@ -32,29 +30,6 @@
namespace content {
namespace {
base::LazyInstance<scoped_refptr<gpu::InProcessCommandBuffer::Service>>
g_gpu_service = LAZY_INSTANCE_INITIALIZER;
base::Thread* CreateInProcessGpuThreadForSynchronousCompositor(
const InProcessChildThreadParams& params,
const gpu::GpuPreferences& gpu_preferences) {
DCHECK(g_gpu_service.Get());
return new InProcessGpuThread(params, gpu_preferences,
g_gpu_service.Get()->sync_point_manager());
}
} // namespace
void SynchronousCompositor::SetGpuService(
scoped_refptr<gpu::InProcessCommandBuffer::Service> service) {
DCHECK(!g_gpu_service.Get());
g_gpu_service.Get() = service;
GpuProcessHost::RegisterGpuMainThreadFactory(
CreateInProcessGpuThreadForSynchronousCompositor);
}
// static
void SynchronousCompositor::SetClientForWebContents(
WebContents* contents,

@ -24,6 +24,7 @@
'gpu/gpu_watchdog_thread.h',
'gpu/in_process_gpu_thread.cc',
'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',

@ -27,6 +27,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/gpu/content_gpu_client.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
#include "gpu/config/gpu_info_collector.h"
#include "gpu/config/gpu_switches.h"
#include "gpu/config/gpu_util.h"
@ -158,11 +159,9 @@ GpuChildThread::GpuChildThread(
bool dead_on_arrival,
const gpu::GPUInfo& gpu_info,
const DeferredMessages& deferred_messages,
gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory,
gpu::SyncPointManager* sync_point_manager)
gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory)
: ChildThreadImpl(GetOptions(gpu_memory_buffer_factory)),
dead_on_arrival_(dead_on_arrival),
sync_point_manager_(sync_point_manager),
gpu_info_(gpu_info),
deferred_messages_(deferred_messages),
in_browser_process_(false),
@ -178,8 +177,7 @@ GpuChildThread::GpuChildThread(
GpuChildThread::GpuChildThread(
const gpu::GpuPreferences& gpu_preferences,
const InProcessChildThreadParams& params,
gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory,
gpu::SyncPointManager* sync_point_manager)
gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory)
: ChildThreadImpl(ChildThreadImpl::Options::Builder()
.InBrowserProcess(params)
.AddStartupFilter(new GpuMemoryBufferMessageFilter(
@ -187,7 +185,6 @@ GpuChildThread::GpuChildThread(
.Build()),
gpu_preferences_(gpu_preferences),
dead_on_arrival_(false),
sync_point_manager_(sync_point_manager),
in_browser_process_(true),
gpu_memory_buffer_factory_(gpu_memory_buffer_factory) {
#if defined(OS_WIN)
@ -385,6 +382,17 @@ void GpuChildThread::OnInitialize(const gpu::GpuPreferences& gpu_preferences) {
if (!in_browser_process_)
logging::SetLogMessageHandler(GpuProcessLogMessageHandler);
gpu::SyncPointManager* sync_point_manager = nullptr;
// Note SyncPointManager from ContentGpuClient cannot be owned by this.
if (GetContentClient()->gpu())
sync_point_manager = GetContentClient()->gpu()->GetSyncPointManager();
if (!sync_point_manager) {
if (!owned_sync_point_manager_) {
owned_sync_point_manager_.reset(new gpu::SyncPointManager(false));
}
sync_point_manager = owned_sync_point_manager_.get();
}
// Defer creation of the render thread. This is to prevent it from handling
// IPC messages before the sandbox has been enabled and all other necessary
// initialization has succeeded.
@ -393,7 +401,7 @@ void GpuChildThread::OnInitialize(const gpu::GpuPreferences& gpu_preferences) {
base::ThreadTaskRunnerHandle::Get().get(),
ChildProcess::current()->io_task_runner(),
ChildProcess::current()->GetShutDownEvent(),
sync_point_manager_, gpu_memory_buffer_factory_));
sync_point_manager, gpu_memory_buffer_factory_));
media_service_.reset(new MediaService(gpu_channel_manager_.get()));

@ -64,13 +64,11 @@ class GpuChildThread : public ChildThreadImpl,
bool dead_on_arrival,
const gpu::GPUInfo& gpu_info,
const DeferredMessages& deferred_messages,
gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory,
gpu::SyncPointManager* sync_point_manager);
gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory);
GpuChildThread(const gpu::GpuPreferences& gpu_preferences,
const InProcessChildThreadParams& params,
gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory,
gpu::SyncPointManager* sync_point_manager);
gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory);
~GpuChildThread() override;
@ -157,8 +155,8 @@ class GpuChildThread : public ChildThreadImpl,
sandbox::TargetServices* target_services_;
#endif
// Non-owning.
gpu::SyncPointManager* sync_point_manager_;
// Can be null if overridden by ContentGpuClient.
std::unique_ptr<gpu::SyncPointManager> owned_sync_point_manager_;
std::unique_ptr<gpu::GpuChannelManager> gpu_channel_manager_;

@ -30,7 +30,6 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
#include "gpu/config/gpu_info_collector.h"
#include "gpu/config/gpu_switches.h"
#include "gpu/config/gpu_util.h"
@ -384,8 +383,6 @@ int GpuMain(const MainFunctionParams& parameters) {
if (gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER)
gpu_memory_buffer_factory = gpu::GpuMemoryBufferFactory::CreateNativeType();
gpu::SyncPointManager sync_point_manager(false);
base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL;
#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
io_thread_priority = base::ThreadPriority::DISPLAY;
@ -395,8 +392,7 @@ int GpuMain(const MainFunctionParams& parameters) {
GpuChildThread* child_thread = new GpuChildThread(
watchdog_thread.get(), dead_on_arrival, gpu_info, deferred_messages.Get(),
gpu_memory_buffer_factory.get(),
&sync_point_manager);
gpu_memory_buffer_factory.get());
while (!deferred_messages.Get().empty())
deferred_messages.Get().pop();

@ -8,7 +8,6 @@
#include "build/build_config.h"
#include "content/gpu/gpu_child_thread.h"
#include "content/gpu/gpu_process.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
#include "gpu/ipc/common/gpu_memory_buffer_support.h"
#include "gpu/ipc/service/gpu_memory_buffer_factory.h"
@ -20,22 +19,15 @@ namespace content {
InProcessGpuThread::InProcessGpuThread(
const InProcessChildThreadParams& params,
const gpu::GpuPreferences& gpu_preferences,
gpu::SyncPointManager* sync_point_manager_override)
const gpu::GpuPreferences& gpu_preferences)
: base::Thread("Chrome_InProcGpuThread"),
params_(params),
gpu_process_(NULL),
gpu_preferences_(gpu_preferences),
sync_point_manager_override_(sync_point_manager_override),
gpu_memory_buffer_factory_(
gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER
? gpu::GpuMemoryBufferFactory::CreateNativeType()
: nullptr) {
if (!sync_point_manager_override_) {
sync_point_manager_.reset(new gpu::SyncPointManager(false));
sync_point_manager_override_ = sync_point_manager_.get();
}
}
: nullptr) {}
InProcessGpuThread::~InProcessGpuThread() {
Stop();
@ -59,8 +51,7 @@ void InProcessGpuThread::Init() {
// The process object takes ownership of the thread object, so do not
// save and delete the pointer.
GpuChildThread* child_thread = new GpuChildThread(
gpu_preferences_, params_, gpu_memory_buffer_factory_.get(),
sync_point_manager_override_);
gpu_preferences_, params_, gpu_memory_buffer_factory_.get());
// Since we are in the browser process, use the thread start time as the
// process start time.
@ -77,8 +68,7 @@ void InProcessGpuThread::CleanUp() {
base::Thread* CreateInProcessGpuThread(
const InProcessChildThreadParams& params,
const gpu::GpuPreferences& gpu_preferences) {
return new InProcessGpuThread(
params, gpu_preferences, nullptr);
return new InProcessGpuThread(params, gpu_preferences);
}
} // namespace content

@ -15,7 +15,6 @@
namespace gpu {
class GpuMemoryBufferFactory;
class SyncPointManager;
struct GpuPreferences;
}
@ -28,8 +27,7 @@ class GpuProcess;
class InProcessGpuThread : public base::Thread {
public:
InProcessGpuThread(const InProcessChildThreadParams& params,
const gpu::GpuPreferences& gpu_preferences,
gpu::SyncPointManager* sync_point_manager_override);
const gpu::GpuPreferences& gpu_preferences);
~InProcessGpuThread() override;
protected:
@ -44,12 +42,6 @@ class InProcessGpuThread : public base::Thread {
const gpu::GpuPreferences gpu_preferences_;
// Can be null if overridden.
std::unique_ptr<gpu::SyncPointManager> sync_point_manager_;
// Non-owning.
gpu::SyncPointManager* sync_point_manager_override_;
std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory_;
DISALLOW_COPY_AND_ASSIGN(InProcessGpuThread);

@ -10,8 +10,8 @@
#include <memory>
#include "base/memory/ref_counted.h"
#include "base/time/time.h"
#include "content/common/content_export.h"
#include "gpu/command_buffer/service/in_process_command_buffer.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
@ -28,10 +28,6 @@ class ScrollOffset;
class Transform;
};
namespace gpu {
class GLInProcessContext;
}
namespace content {
class SynchronousCompositorClient;
@ -47,9 +43,6 @@ class CONTENT_EXPORT SynchronousCompositor {
static void SetClientForWebContents(WebContents* contents,
SynchronousCompositorClient* client);
static void SetGpuService(
scoped_refptr<gpu::InProcessCommandBuffer::Service> service);
struct Frame {
Frame();
~Frame();

@ -23,6 +23,7 @@ source_set("gpu_sources") {
configs += [ "//content:content_implementation" ]
sources = [
"content_gpu_client.cc",
"content_gpu_client.h",
"gpu_video_decode_accelerator_factory.cc",
"gpu_video_decode_accelerator_factory.h",

@ -0,0 +1,13 @@
// Copyright 2016 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/public/gpu/content_gpu_client.h"
namespace content {
gpu::SyncPointManager* ContentGpuClient::GetSyncPointManager() {
return nullptr;
}
} // namespace content

@ -7,6 +7,10 @@
#include "content/public/common/content_client.h"
namespace gpu {
class SyncPointManager;
}
namespace content {
class ServiceRegistry;
@ -20,6 +24,10 @@ class CONTENT_EXPORT ContentGpuClient {
// The registered services will be exposed to the browser process through
// GpuProcessHost.
virtual void RegisterMojoServices(ServiceRegistry* registry) {}
// Allows client to supply a SyncPointManager instance instead of having
// content internally create one.
virtual gpu::SyncPointManager* GetSyncPointManager();
};
} // namespace content