Commit 929881f7 authored by spang@chromium.org's avatar spang@chromium.org

ozone: gpu: Add plumbing for platform-specific gpu messaging (reland)

    
ChromeOS on bare hardware will do display configuration and cursor
movement from the GPU process. This is the conduit for the messages
needed to make this work.
    
This plumbing also supports other platforms with similar requirements
(e.g. wayland's port). X11 does not need any specific messaging here,
since we just call the X server from the browser.
    
TBR=piman@chromium.org,rjkroege@chromium.org,alexst@chromium.org,chrishtr@chromium.org
NOTRY=true
BUG=377497

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278817 0039d316-1c4b-4281-b951-d872f2087c98
parent 824237ba
......@@ -86,7 +86,7 @@ include_rules = [
"+ui/gfx",
"+ui/gl",
"+ui/native_theme",
"+ui/ozone/public",
"+ui/ozone",
"+ui/shell_dialogs",
"+ui/snapshot",
"+ui/surface",
......
......@@ -20,6 +20,11 @@
#include "content/common/gpu/gpu_messages.h"
#include "content/public/browser/browser_thread.h"
#if defined(USE_OZONE)
#include "ui/ozone/ozone_platform.h"
#include "ui/ozone/public/gpu_platform_support_host.h"
#endif
namespace content {
namespace {
......@@ -90,6 +95,11 @@ void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg) {
GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id)
: host_id_(host_id) {
g_hosts_by_id.Pointer()->AddWithID(this, host_id_);
#if defined(USE_OZONE)
ui::OzonePlatform::GetInstance()
->GetGpuPlatformSupportHost()
->OnChannelEstablished(host_id, this);
#endif
}
// static
......@@ -106,6 +116,12 @@ void GpuProcessHostUIShim::Destroy(int host_id, const std::string& message) {
logging::LOG_ERROR, "GpuProcessHostUIShim",
message);
#if defined(USE_OZONE)
ui::OzonePlatform::GetInstance()
->GetGpuPlatformSupportHost()
->OnChannelDestroyed(host_id);
#endif
delete FromID(host_id);
}
......@@ -145,6 +161,13 @@ bool GpuProcessHostUIShim::Send(IPC::Message* msg) {
bool GpuProcessHostUIShim::OnMessageReceived(const IPC::Message& message) {
DCHECK(CalledOnValidThread());
#if defined(USE_OZONE)
if (ui::OzonePlatform::GetInstance()
->GetGpuPlatformSupportHost()
->OnMessageReceived(message))
return true;
#endif
if (message.routing_id() != MSG_ROUTING_CONTROL)
return false;
......
......@@ -798,5 +798,10 @@
}, {
'defines': ['USE_SECCOMP_BPF'],
}],
['use_ozone==1', {
'dependencies': [
'../ui/ozone/ozone.gyp:ozone',
],
}],
],
}
......@@ -19,6 +19,11 @@
#include "ipc/ipc_sync_message_filter.h"
#include "ui/gl/gl_implementation.h"
#if defined(USE_OZONE)
#include "ui/ozone/ozone_platform.h"
#include "ui/ozone/public/gpu_platform_support.h"
#endif
namespace content {
namespace {
......@@ -113,6 +118,13 @@ bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) {
if (handled)
return true;
#if defined(USE_OZONE)
if (ui::OzonePlatform::GetInstance()
->GetGpuPlatformSupport()
->OnMessageReceived(msg))
return true;
#endif
return gpu_channel_manager_.get() &&
gpu_channel_manager_->OnMessageReceived(msg);
}
......@@ -152,6 +164,12 @@ void GpuChildThread::OnInitialize() {
watchdog_thread_.get(),
ChildProcess::current()->io_message_loop_proxy(),
ChildProcess::current()->GetShutDownEvent()));
#if defined(USE_OZONE)
ui::OzonePlatform::GetInstance()
->GetGpuPlatformSupport()
->OnChannelEstablished(this);
#endif
}
void GpuChildThread::StopWatchdog() {
......
......@@ -30,6 +30,10 @@
'public/cursor_factory_ozone.h',
'public/event_factory_ozone.cc',
'public/event_factory_ozone.h',
'public/gpu_platform_support.cc',
'public/gpu_platform_support.h',
'public/gpu_platform_support_host.cc',
'public/gpu_platform_support_host.h',
'public/overlay_candidates_ozone.cc',
'public/overlay_candidates_ozone.h',
'public/surface_factory_ozone.cc',
......
......@@ -15,6 +15,8 @@ class EventFactoryOzone;
class NativeDisplayDelegate;
class SurfaceFactoryOzone;
class TouchscreenDeviceManager;
class GpuPlatformSupport;
class GpuPlatformSupportHost;
// Base class for Ozone platform implementations.
//
......@@ -50,6 +52,8 @@ class OZONE_EXPORT OzonePlatform {
virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() = 0;
virtual ui::EventFactoryOzone* GetEventFactoryOzone() = 0;
virtual ui::CursorFactoryOzone* GetCursorFactoryOzone() = 0;
virtual ui::GpuPlatformSupport* GetGpuPlatformSupport() = 0;
virtual ui::GpuPlatformSupportHost* GetGpuPlatformSupportHost() = 0;
#if defined(OS_CHROMEOS)
virtual scoped_ptr<ui::NativeDisplayDelegate>
CreateNativeDisplayDelegate() = 0;
......
......@@ -34,6 +34,12 @@ class OzonePlatformCaca : public OzonePlatform {
virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE {
return cursor_factory_ozone_.get();
}
virtual GpuPlatformSupport* GetGpuPlatformSupport() OVERRIDE {
return NULL; // no GPU support
}
virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() OVERRIDE {
return NULL; // no GPU support
}
#if defined(OS_CHROMEOS)
virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
......
......@@ -71,6 +71,12 @@ class OzonePlatformDri : public OzonePlatform {
virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE {
return cursor_factory_ozone_.get();
}
virtual GpuPlatformSupport* GetGpuPlatformSupport() OVERRIDE {
return NULL; // no GPU support
}
virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() OVERRIDE {
return NULL; // no GPU support
}
#if defined(OS_CHROMEOS)
virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
OVERRIDE {
......
......@@ -78,6 +78,12 @@ class OzonePlatformGbm : public OzonePlatform {
virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE {
return cursor_factory_ozone_.get();
}
virtual GpuPlatformSupport* GetGpuPlatformSupport() OVERRIDE {
return gpu_platform_support_.get()
}
virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() OVERRIDE {
return gpu_platform_support_host_.get();
}
#if defined(OS_CHROMEOS)
virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
OVERRIDE {
......@@ -99,6 +105,8 @@ class OzonePlatformGbm : public OzonePlatform {
cursor_factory_ozone_.reset(new CursorFactoryOzone());
event_factory_ozone_.reset(new EventFactoryEvdev(
NULL, device_manager_.get()));
gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost());
}
virtual void InitializeGPU() OVERRIDE {
......@@ -110,6 +118,8 @@ class OzonePlatformGbm : public OzonePlatform {
new GbmSurfaceFactory(dri_.get(),
surface_generator_->device(),
screen_manager_.get()));
gpu_platform_support_.reset(CreateStubGpuPlatformSupport());
}
private:
......@@ -123,6 +133,9 @@ class OzonePlatformGbm : public OzonePlatform {
scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_;
scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
scoped_ptr<GpuPlatformSupport> gpu_platform_support_;
scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_;
DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm);
};
......
......@@ -16,6 +16,8 @@
#include "ui/ozone/ozone_switches.h"
#include "ui/ozone/platform/test/file_surface_factory.h"
#include "ui/ozone/public/cursor_factory_ozone.h"
#include "ui/ozone/public/gpu_platform_support.h"
#include "ui/ozone/public/gpu_platform_support_host.h"
#include "ui/ozone/public/surface_ozone_egl.h"
#if defined(OS_CHROMEOS)
......@@ -244,6 +246,12 @@ class OzonePlatformEgltest : public OzonePlatform {
virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE {
return cursor_factory_ozone_.get();
}
virtual GpuPlatformSupport* GetGpuPlatformSupport() OVERRIDE {
return gpu_platform_support_.get();
}
virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() OVERRIDE {
return gpu_platform_support_host_.get();
}
#if defined(OS_CHROMEOS)
virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
......@@ -263,10 +271,12 @@ class OzonePlatformEgltest : public OzonePlatform {
event_factory_ozone_.reset(
new EventFactoryEvdev(NULL, device_manager_.get()));
cursor_factory_ozone_.reset(new CursorFactoryOzone());
gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost());
}
virtual void InitializeGPU() OVERRIDE {
surface_factory_ozone_.reset(new SurfaceFactoryEgltest(&eglplatform_shim_));
gpu_platform_support_.reset(CreateStubGpuPlatformSupport());
}
private:
......@@ -275,6 +285,8 @@ class OzonePlatformEgltest : public OzonePlatform {
scoped_ptr<SurfaceFactoryEgltest> surface_factory_ozone_;
scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_;
scoped_ptr<GpuPlatformSupport> gpu_platform_support_;
scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_;
bool shim_initialized_;
......
......@@ -40,6 +40,12 @@ class OzonePlatformTest : public OzonePlatform {
virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE {
return cursor_factory_ozone_.get();
}
virtual GpuPlatformSupport* GetGpuPlatformSupport() OVERRIDE {
return NULL; // no GPU support
}
virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() OVERRIDE {
return NULL; // no GPU support
}
#if defined(OS_CHROMEOS)
virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
......
// 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.
#include "ui/ozone/public/gpu_platform_support.h"
#include "base/logging.h"
#include "ui/ozone/ozone_export.h"
namespace ui {
namespace {
// No-op implementation of GpuPlatformSupport.
class StubGpuPlatformSupport : public GpuPlatformSupport {
public:
// GpuPlatformSupport:
virtual void OnChannelEstablished(IPC::Sender* sender) {}
bool OnMessageReceived(const IPC::Message&) OVERRIDE { return false; }
};
} // namespace
GpuPlatformSupport::GpuPlatformSupport() {
}
GpuPlatformSupport::~GpuPlatformSupport() {
}
GpuPlatformSupport* CreateStubGpuPlatformSupport() {
return new StubGpuPlatformSupport;
}
} // namespace ui
// 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 UI_OZONE_PUBLIC_GPU_PLATFORM_SUPPORT_H_
#define UI_OZONE_PUBLIC_GPU_PLATFORM_SUPPORT_H_
#include "ipc/ipc_listener.h"
#include "ipc/ipc_sender.h"
#include "ui/ozone/ozone_base_export.h"
namespace ui {
// Platform-specific object to support a GPU process.
//
// See GpuPlatformSupportHost for more context.
class OZONE_BASE_EXPORT GpuPlatformSupport : public IPC::Listener {
public:
GpuPlatformSupport();
virtual ~GpuPlatformSupport();
// Called when the GPU process is spun up & channel established.
virtual void OnChannelEstablished(IPC::Sender* sender) = 0;
};
// Create a stub implementation.
OZONE_BASE_EXPORT GpuPlatformSupport* CreateStubGpuPlatformSupport();
} // namespace ui
#endif // UI_OZONE_PUBLIC_GPU_PLATFORM_SUPPORT_H_
// 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.
#include "ui/ozone/public/gpu_platform_support_host.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "ui/ozone/ozone_export.h"
namespace ui {
namespace {
// No-op implementations of GpuPlatformSupportHost.
class StubGpuPlatformSupportHost : public GpuPlatformSupportHost {
public:
// GpuPlatformSupportHost:
virtual void OnChannelEstablished(int host_id, IPC::Sender* sender) OVERRIDE {
}
virtual void OnChannelDestroyed(int host_id) OVERRIDE {}
virtual bool OnMessageReceived(const IPC::Message&) OVERRIDE { return false; }
};
} // namespace
GpuPlatformSupportHost::GpuPlatformSupportHost() {
}
GpuPlatformSupportHost::~GpuPlatformSupportHost() {
}
GpuPlatformSupportHost* CreateStubGpuPlatformSupportHost() {
return new StubGpuPlatformSupportHost;
}
} // namespace ui
// 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 UI_OZONE_PUBLIC_GPU_PLATFORM_SUPPORT_HOST_H_
#define UI_OZONE_PUBLIC_GPU_PLATFORM_SUPPORT_HOST_H_
#include "ipc/ipc_listener.h"
#include "ipc/ipc_sender.h"
#include "ui/ozone/ozone_base_export.h"
namespace ui {
// Platform-specific object to support a GPU process host.
//
// ChromeOS on bare hardware will do display configuration and cursor
// movement from the GPU process. This provides a conduit for the
// messages needed to make this work.
//
// Under X11, we don't need any GPU messages for display configuration.
// That's why there's no real functionality here: it's purely mechanism
// to support additional messages needed by specific platforms.
class OZONE_BASE_EXPORT GpuPlatformSupportHost : public IPC::Listener {
public:
GpuPlatformSupportHost();
virtual ~GpuPlatformSupportHost();
// Called when the GPU process is spun up & channel established.
virtual void OnChannelEstablished(int host_id, IPC::Sender* sender) = 0;
// Called when the GPU process is destroyed.
virtual void OnChannelDestroyed(int host_id) = 0;
};
// create a stub implementation.
OZONE_BASE_EXPORT GpuPlatformSupportHost* CreateStubGpuPlatformSupportHost();
} // namespace ui
#endif // UI_OZONE_PUBLIC_GPU_PLATFORM_SUPPORT_HOST_H_
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