Commit 6269704f authored by spang@chromium.org's avatar spang@chromium.org

ozone: gpu: Add plumbing for platform-specific gpu messaging

ChromeOS without X11 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.

BUG=377497
TEST=content_shell --ozone-platform=egltest

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278465 0039d316-1c4b-4281-b951-d872f2087c98
parent 16dacef3
...@@ -86,6 +86,7 @@ include_rules = [ ...@@ -86,6 +86,7 @@ include_rules = [
"+ui/gfx", "+ui/gfx",
"+ui/gl", "+ui/gl",
"+ui/native_theme", "+ui/native_theme",
"+ui/ozone",
"+ui/shell_dialogs", "+ui/shell_dialogs",
"+ui/snapshot", "+ui/snapshot",
"+ui/surface", "+ui/surface",
......
...@@ -20,6 +20,11 @@ ...@@ -20,6 +20,11 @@
#include "content/common/gpu/gpu_messages.h" #include "content/common/gpu/gpu_messages.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#if defined(USE_OZONE)
#include "ui/ozone/gpu/gpu_platform_support_host.h"
#include "ui/ozone/ozone_platform.h"
#endif
namespace content { namespace content {
namespace { namespace {
...@@ -90,6 +95,11 @@ void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg) { ...@@ -90,6 +95,11 @@ void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg) {
GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id) GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id)
: host_id_(host_id) { : host_id_(host_id) {
g_hosts_by_id.Pointer()->AddWithID(this, 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 // static
...@@ -106,6 +116,12 @@ void GpuProcessHostUIShim::Destroy(int host_id, const std::string& message) { ...@@ -106,6 +116,12 @@ void GpuProcessHostUIShim::Destroy(int host_id, const std::string& message) {
logging::LOG_ERROR, "GpuProcessHostUIShim", logging::LOG_ERROR, "GpuProcessHostUIShim",
message); message);
#if defined(USE_OZONE)
ui::OzonePlatform::GetInstance()
->GetGpuPlatformSupportHost()
->OnChannelDestroyed(host_id);
#endif
delete FromID(host_id); delete FromID(host_id);
} }
...@@ -145,6 +161,13 @@ bool GpuProcessHostUIShim::Send(IPC::Message* msg) { ...@@ -145,6 +161,13 @@ bool GpuProcessHostUIShim::Send(IPC::Message* msg) {
bool GpuProcessHostUIShim::OnMessageReceived(const IPC::Message& message) { bool GpuProcessHostUIShim::OnMessageReceived(const IPC::Message& message) {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
#if defined(USE_OZONE)
if (ui::OzonePlatform::GetInstance()
->GetGpuPlatformSupportHost()
->OnMessageReceived(message))
return true;
#endif
if (message.routing_id() != MSG_ROUTING_CONTROL) if (message.routing_id() != MSG_ROUTING_CONTROL)
return false; return false;
......
...@@ -804,5 +804,10 @@ ...@@ -804,5 +804,10 @@
}, { }, {
'defines': ['USE_SECCOMP_BPF'], 'defines': ['USE_SECCOMP_BPF'],
}], }],
['use_ozone==1', {
'dependencies': [
'../ui/ozone/ozone.gyp:ozone',
],
}],
], ],
} }
...@@ -19,6 +19,11 @@ ...@@ -19,6 +19,11 @@
#include "ipc/ipc_sync_message_filter.h" #include "ipc/ipc_sync_message_filter.h"
#include "ui/gl/gl_implementation.h" #include "ui/gl/gl_implementation.h"
#if defined(USE_OZONE)
#include "ui/ozone/gpu/gpu_platform_support.h"
#include "ui/ozone/ozone_platform.h"
#endif
namespace content { namespace content {
namespace { namespace {
...@@ -113,6 +118,13 @@ bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) { ...@@ -113,6 +118,13 @@ bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) {
if (handled) if (handled)
return true; return true;
#if defined(USE_OZONE)
if (ui::OzonePlatform::GetInstance()
->GetGpuPlatformSupport()
->OnMessageReceived(msg))
return true;
#endif
return gpu_channel_manager_.get() && return gpu_channel_manager_.get() &&
gpu_channel_manager_->OnMessageReceived(msg); gpu_channel_manager_->OnMessageReceived(msg);
} }
...@@ -152,6 +164,12 @@ void GpuChildThread::OnInitialize() { ...@@ -152,6 +164,12 @@ void GpuChildThread::OnInitialize() {
watchdog_thread_.get(), watchdog_thread_.get(),
ChildProcess::current()->io_message_loop_proxy(), ChildProcess::current()->io_message_loop_proxy(),
ChildProcess::current()->GetShutDownEvent())); ChildProcess::current()->GetShutDownEvent()));
#if defined(USE_OZONE)
ui::OzonePlatform::GetInstance()
->GetGpuPlatformSupport()
->OnChannelEstablished(this);
#endif
} }
void GpuChildThread::StopWatchdog() { void GpuChildThread::StopWatchdog() {
......
// 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/gpu/gpu_platform_support.h"
#include "base/logging.h"
#include "ui/ozone/ozone_export.h"
namespace ui {
namespace {
// No-op implementation of GpuPlatformSupport.
class OZONE_EXPORT 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_GPU_GPU_PLATFORM_SUPPORT_H_
#define UI_OZONE_GPU_GPU_PLATFORM_SUPPORT_H_
#include "ipc/ipc_listener.h"
#include "ipc/ipc_sender.h"
#include "ui/ozone/ozone_export.h"
namespace ui {
// Platform-specific object to support a GPU process.
//
// See GpuPlatformSupportHost for more context.
class OZONE_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_EXPORT GpuPlatformSupport* CreateStubGpuPlatformSupport();
} // namespace ui
#endif // UI_OZONE_GPU_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/gpu/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 OZONE_EXPORT 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_GPU_GPU_PLATFORM_SUPPORT_HOST_H_
#define UI_OZONE_GPU_GPU_PLATFORM_SUPPORT_HOST_H_
#include "ipc/ipc_listener.h"
#include "ipc/ipc_sender.h"
#include "ui/ozone/ozone_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_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_EXPORT GpuPlatformSupportHost* CreateStubGpuPlatformSupportHost();
} // namespace ui
#endif // UI_OZONE_GPU_GPU_PLATFORM_SUPPORT_HOST_H_
...@@ -56,6 +56,10 @@ ...@@ -56,6 +56,10 @@
'common/chromeos/native_display_delegate_ozone.h', 'common/chromeos/native_display_delegate_ozone.h',
'common/chromeos/touchscreen_device_manager_ozone.cc', 'common/chromeos/touchscreen_device_manager_ozone.cc',
'common/chromeos/touchscreen_device_manager_ozone.h', 'common/chromeos/touchscreen_device_manager_ozone.h',
'gpu/gpu_platform_support.cc',
'gpu/gpu_platform_support.h',
'gpu/gpu_platform_support_host.cc',
'gpu/gpu_platform_support_host.h',
'ozone_platform.cc', 'ozone_platform.cc',
'ozone_platform.h', 'ozone_platform.h',
'ozone_switches.cc', 'ozone_switches.cc',
......
...@@ -18,6 +18,8 @@ class CursorFactoryOzone; ...@@ -18,6 +18,8 @@ class CursorFactoryOzone;
class EventFactoryOzone; class EventFactoryOzone;
class NativeDisplayDelegate; class NativeDisplayDelegate;
class TouchscreenDeviceManager; class TouchscreenDeviceManager;
class GpuPlatformSupport;
class GpuPlatformSupportHost;
// Base class for Ozone platform implementations. // Base class for Ozone platform implementations.
// //
...@@ -53,6 +55,8 @@ class OZONE_EXPORT OzonePlatform { ...@@ -53,6 +55,8 @@ class OZONE_EXPORT OzonePlatform {
virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() = 0; virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() = 0;
virtual ui::EventFactoryOzone* GetEventFactoryOzone() = 0; virtual ui::EventFactoryOzone* GetEventFactoryOzone() = 0;
virtual ui::CursorFactoryOzone* GetCursorFactoryOzone() = 0; virtual ui::CursorFactoryOzone* GetCursorFactoryOzone() = 0;
virtual ui::GpuPlatformSupport* GetGpuPlatformSupport() = 0;
virtual ui::GpuPlatformSupportHost* GetGpuPlatformSupportHost() = 0;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
virtual scoped_ptr<ui::NativeDisplayDelegate> virtual scoped_ptr<ui::NativeDisplayDelegate>
CreateNativeDisplayDelegate() = 0; CreateNativeDisplayDelegate() = 0;
......
...@@ -34,6 +34,12 @@ class OzonePlatformCaca : public OzonePlatform { ...@@ -34,6 +34,12 @@ class OzonePlatformCaca : public OzonePlatform {
virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE { virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE {
return cursor_factory_ozone_.get(); 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) #if defined(OS_CHROMEOS)
virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
......
...@@ -71,6 +71,12 @@ class OzonePlatformDri : public OzonePlatform { ...@@ -71,6 +71,12 @@ class OzonePlatformDri : public OzonePlatform {
virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE { virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE {
return cursor_factory_ozone_.get(); 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) #if defined(OS_CHROMEOS)
virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
OVERRIDE { OVERRIDE {
......
...@@ -78,6 +78,12 @@ class OzonePlatformGbm : public OzonePlatform { ...@@ -78,6 +78,12 @@ class OzonePlatformGbm : public OzonePlatform {
virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE { virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE {
return cursor_factory_ozone_.get(); 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) #if defined(OS_CHROMEOS)
virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
OVERRIDE { OVERRIDE {
...@@ -99,6 +105,8 @@ class OzonePlatformGbm : public OzonePlatform { ...@@ -99,6 +105,8 @@ class OzonePlatformGbm : public OzonePlatform {
cursor_factory_ozone_.reset(new CursorFactoryOzone()); cursor_factory_ozone_.reset(new CursorFactoryOzone());
event_factory_ozone_.reset(new EventFactoryEvdev( event_factory_ozone_.reset(new EventFactoryEvdev(
NULL, device_manager_.get())); NULL, device_manager_.get()));
gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost());
} }
virtual void InitializeGPU() OVERRIDE { virtual void InitializeGPU() OVERRIDE {
...@@ -110,6 +118,8 @@ class OzonePlatformGbm : public OzonePlatform { ...@@ -110,6 +118,8 @@ class OzonePlatformGbm : public OzonePlatform {
new GbmSurfaceFactory(dri_.get(), new GbmSurfaceFactory(dri_.get(),
surface_generator_->device(), surface_generator_->device(),
screen_manager_.get())); screen_manager_.get()));
gpu_platform_support_.reset(CreateStubGpuPlatformSupport());
} }
private: private:
...@@ -123,6 +133,9 @@ class OzonePlatformGbm : public OzonePlatform { ...@@ -123,6 +133,9 @@ class OzonePlatformGbm : public OzonePlatform {
scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_;
scoped_ptr<EventFactoryEvdev> event_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); DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm);
}; };
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#include "ui/gfx/ozone/impl/file_surface_factory.h" #include "ui/gfx/ozone/impl/file_surface_factory.h"
#include "ui/gfx/ozone/surface_ozone_egl.h" #include "ui/gfx/ozone/surface_ozone_egl.h"
#include "ui/gfx/vsync_provider.h" #include "ui/gfx/vsync_provider.h"
#include "ui/ozone/gpu/gpu_platform_support.h"
#include "ui/ozone/gpu/gpu_platform_support_host.h"
#include "ui/ozone/ozone_platform.h" #include "ui/ozone/ozone_platform.h"
#include "ui/ozone/ozone_switches.h" #include "ui/ozone/ozone_switches.h"
...@@ -245,6 +247,12 @@ class OzonePlatformEgltest : public OzonePlatform { ...@@ -245,6 +247,12 @@ class OzonePlatformEgltest : public OzonePlatform {
virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE { virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE {
return cursor_factory_ozone_.get(); 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) #if defined(OS_CHROMEOS)
virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
...@@ -264,10 +272,12 @@ class OzonePlatformEgltest : public OzonePlatform { ...@@ -264,10 +272,12 @@ class OzonePlatformEgltest : public OzonePlatform {
event_factory_ozone_.reset( event_factory_ozone_.reset(
new EventFactoryEvdev(NULL, device_manager_.get())); new EventFactoryEvdev(NULL, device_manager_.get()));
cursor_factory_ozone_.reset(new CursorFactoryOzone()); cursor_factory_ozone_.reset(new CursorFactoryOzone());
gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost());
} }
virtual void InitializeGPU() OVERRIDE { virtual void InitializeGPU() OVERRIDE {
surface_factory_ozone_.reset(new SurfaceFactoryEgltest(&eglplatform_shim_)); surface_factory_ozone_.reset(new SurfaceFactoryEgltest(&eglplatform_shim_));
gpu_platform_support_.reset(CreateStubGpuPlatformSupport());
} }
private: private:
...@@ -276,6 +286,8 @@ class OzonePlatformEgltest : public OzonePlatform { ...@@ -276,6 +286,8 @@ class OzonePlatformEgltest : public OzonePlatform {
scoped_ptr<SurfaceFactoryEgltest> surface_factory_ozone_; scoped_ptr<SurfaceFactoryEgltest> surface_factory_ozone_;
scoped_ptr<EventFactoryEvdev> event_factory_ozone_; scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_;
scoped_ptr<GpuPlatformSupport> gpu_platform_support_;
scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_;
bool shim_initialized_; bool shim_initialized_;
......
...@@ -40,6 +40,12 @@ class OzonePlatformTest : public OzonePlatform { ...@@ -40,6 +40,12 @@ class OzonePlatformTest : public OzonePlatform {
virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE { virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE {
return cursor_factory_ozone_.get(); 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) #if defined(OS_CHROMEOS)
virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
......
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