Commit 60ee6c04 authored by dnicoara's avatar dnicoara Committed by Commit bot

[Ozone-DRI] Assume window IPC arrives before surface IPC

Creating a DriWindow happens before the Compositor associated with
it. On DriWindow creation an IPC is sent to the GPU process to
initialize the window on the GPU side. The Compositor also sends
an IPC to create a surface for the window. Since the same channel
is used when IPC-ing both messages, the order of IPCs should be
maintained. Thus, assume that, on the GPU side, the window (delegate)
is already present when trying to create a surface.

Note the previous implementation was working around an issue during
initialization where the channel wasn't established. The issue was
that the channel in the platform was established late, so the IPCs
in Chrome would be serviced before the IPCs in the Ozone platform.

For clarity, these are the major steps taken at startup when creating
a window:

1) PostTaskOnUI(create GpuProcessHostShim)
2) Create WindowTreeHost
3) Create DriWindow
  a) If channel established PostTaskOnIO(create window on GPU)
4) WindowTreeHost::OnAcceleratedWidget()
5) Create Compositor
6) PostTaskOnUI(create output surface)
7) MessageLoop::Run()
8) Execute task in (1)
  a) Create GpuProcessHostShim
  b) OnChannelEstablished
    i) DriWindow::OnChannelEstablished -> PostTaskOnIO(create window
       on GPU)
9) Execute task in (6) -> PostTaskOnIO(create surface on GPU)

Note, even if the channel isn't up and running in step (8), messages
will be queued internally in GpuProcessHost. Thus the messages in
(8) and (9) will be queued in the correct order.

BUG=none
NOTRY=true

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

Cr-Commit-Position: refs/heads/master@{#313521}
parent 47a823b5
...@@ -229,16 +229,10 @@ bool DriGpuPlatformSupport::OnMessageReceived(const IPC::Message& message) { ...@@ -229,16 +229,10 @@ bool DriGpuPlatformSupport::OnMessageReceived(const IPC::Message& message) {
void DriGpuPlatformSupport::OnCreateWindowDelegate( void DriGpuPlatformSupport::OnCreateWindowDelegate(
gfx::AcceleratedWidget widget) { gfx::AcceleratedWidget widget) {
// Due to how the GPU process starts up this IPC call may happen after the IPC scoped_ptr<DriWindowDelegate> delegate(new DriWindowDelegateImpl(
// to create a surface. Since a surface wants to know the window associated widget, drm_, window_manager_, screen_manager_));
// with it, we create it ahead of time. So when this call happens we do not delegate->Initialize();
// create a delegate if it already exists. window_manager_->AddWindowDelegate(widget, delegate.Pass());
if (!window_manager_->HasWindowDelegate(widget)) {
scoped_ptr<DriWindowDelegate> delegate(new DriWindowDelegateImpl(
widget, drm_, window_manager_, screen_manager_));
delegate->Initialize();
window_manager_->AddWindowDelegate(widget, delegate.Pass());
}
} }
void DriGpuPlatformSupport::OnDestroyWindowDelegate( void DriGpuPlatformSupport::OnDestroyWindowDelegate(
......
...@@ -22,6 +22,16 @@ class DriWindowManager; ...@@ -22,6 +22,16 @@ class DriWindowManager;
class EventFactoryEvdev; class EventFactoryEvdev;
class DriGpuPlatformSupportHost; class DriGpuPlatformSupportHost;
// Implementation of the platform window. This object and its handle |widget_|
// uniquely identify a window. Since the DRI/GBM platform is split into 2
// pieces (Browser process and GPU process), internally we need to make sure the
// state is synchronized between the 2 processes.
//
// |widget_| is used in both processes to uniquely identify the window. This
// means that any state on the browser side needs to be propagated to the GPU.
// State propagation needs to happen before the state change is acknowledged to
// |delegate_| as |delegate_| is responsible for initializing the surface
// associated with the window (the surface is created on the GPU process).
class DriWindow : public PlatformWindow, class DriWindow : public PlatformWindow,
public PlatformEventDispatcher, public PlatformEventDispatcher,
public ChannelObserver { public ChannelObserver {
......
...@@ -41,9 +41,4 @@ DriWindowDelegate* DriWindowDelegateManager::GetWindowDelegate( ...@@ -41,9 +41,4 @@ DriWindowDelegate* DriWindowDelegateManager::GetWindowDelegate(
return NULL; return NULL;
} }
bool DriWindowDelegateManager::HasWindowDelegate(
gfx::AcceleratedWidget widget) {
return delegate_map_.find(widget) != delegate_map_.end();
}
} // namespace ui } // namespace ui
...@@ -31,9 +31,6 @@ class DriWindowDelegateManager { ...@@ -31,9 +31,6 @@ class DriWindowDelegateManager {
// be called only if a valid delegate has been associated with |widget|. // be called only if a valid delegate has been associated with |widget|.
DriWindowDelegate* GetWindowDelegate(gfx::AcceleratedWidget widget); DriWindowDelegate* GetWindowDelegate(gfx::AcceleratedWidget widget);
// Check if |widget| has a valid delegate associated with it.
bool HasWindowDelegate(gfx::AcceleratedWidget widget);
private: private:
typedef base::ScopedPtrHashMap<gfx::AcceleratedWidget, DriWindowDelegate> typedef base::ScopedPtrHashMap<gfx::AcceleratedWidget, DriWindowDelegate>
WidgetToDelegateMap; WidgetToDelegateMap;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "ui/ozone/platform/dri/gbm_surface.h" #include "ui/ozone/platform/dri/gbm_surface.h"
#include "ui/ozone/platform/dri/gbm_surfaceless.h" #include "ui/ozone/platform/dri/gbm_surfaceless.h"
#include "ui/ozone/platform/dri/gbm_wrapper.h" #include "ui/ozone/platform/dri/gbm_wrapper.h"
#include "ui/ozone/platform/dri/screen_manager.h" #include "ui/ozone/platform/dri/hardware_display_controller.h"
#include "ui/ozone/public/native_pixmap.h" #include "ui/ozone/public/native_pixmap.h"
#include "ui/ozone/public/overlay_candidates_ozone.h" #include "ui/ozone/public/overlay_candidates_ozone.h"
#include "ui/ozone/public/ozone_switches.h" #include "ui/ozone/public/ozone_switches.h"
...@@ -76,10 +76,8 @@ GbmSurfaceFactory::~GbmSurfaceFactory() {} ...@@ -76,10 +76,8 @@ GbmSurfaceFactory::~GbmSurfaceFactory() {}
void GbmSurfaceFactory::InitializeGpu( void GbmSurfaceFactory::InitializeGpu(
GbmWrapper* gbm, GbmWrapper* gbm,
ScreenManager* screen_manager,
DriWindowDelegateManager* window_manager) { DriWindowDelegateManager* window_manager) {
gbm_ = gbm; gbm_ = gbm;
screen_manager_ = screen_manager;
window_manager_ = window_manager; window_manager_ = window_manager;
} }
...@@ -121,9 +119,8 @@ bool GbmSurfaceFactory::LoadEGLGLES2Bindings( ...@@ -121,9 +119,8 @@ bool GbmSurfaceFactory::LoadEGLGLES2Bindings(
scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget(
gfx::AcceleratedWidget widget) { gfx::AcceleratedWidget widget) {
DriWindowDelegate* delegate = GetOrCreateWindowDelegate(widget); scoped_ptr<GbmSurface> surface(
new GbmSurface(window_manager_->GetWindowDelegate(widget), gbm_));
scoped_ptr<GbmSurface> surface(new GbmSurface(delegate, gbm_));
if (!surface->Initialize()) if (!surface->Initialize())
return nullptr; return nullptr;
...@@ -136,8 +133,8 @@ GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( ...@@ -136,8 +133,8 @@ GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget(
if (!allow_surfaceless_) if (!allow_surfaceless_)
return nullptr; return nullptr;
DriWindowDelegate* delegate = GetOrCreateWindowDelegate(widget); return scoped_ptr<SurfaceOzoneEGL>(
return scoped_ptr<SurfaceOzoneEGL>(new GbmSurfaceless(delegate)); new GbmSurfaceless(window_manager_->GetWindowDelegate(widget)));
} }
scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap(
...@@ -208,16 +205,4 @@ bool GbmSurfaceFactory::CanCreateNativePixmap(BufferUsage usage) { ...@@ -208,16 +205,4 @@ bool GbmSurfaceFactory::CanCreateNativePixmap(BufferUsage usage) {
return false; return false;
} }
DriWindowDelegate* GbmSurfaceFactory::GetOrCreateWindowDelegate(
gfx::AcceleratedWidget widget) {
if (!window_manager_->HasWindowDelegate(widget)) {
scoped_ptr<DriWindowDelegate> delegate(new DriWindowDelegateImpl(
widget, gbm_, window_manager_, screen_manager_));
delegate->Initialize();
window_manager_->AddWindowDelegate(widget, delegate.Pass());
}
return window_manager_->GetWindowDelegate(widget);
}
} // namespace ui } // namespace ui
...@@ -12,7 +12,6 @@ namespace ui { ...@@ -12,7 +12,6 @@ namespace ui {
class DriWindowDelegate; class DriWindowDelegate;
class DriWindowDelegateManager; class DriWindowDelegateManager;
class GbmWrapper; class GbmWrapper;
class ScreenManager;
class GbmSurfaceFactory : public DriSurfaceFactory { class GbmSurfaceFactory : public DriSurfaceFactory {
public: public:
...@@ -20,7 +19,6 @@ class GbmSurfaceFactory : public DriSurfaceFactory { ...@@ -20,7 +19,6 @@ class GbmSurfaceFactory : public DriSurfaceFactory {
~GbmSurfaceFactory() override; ~GbmSurfaceFactory() override;
void InitializeGpu(GbmWrapper* gbm, void InitializeGpu(GbmWrapper* gbm,
ScreenManager* screen_manager,
DriWindowDelegateManager* window_manager); DriWindowDelegateManager* window_manager);
// DriSurfaceFactory: // DriSurfaceFactory:
...@@ -51,10 +49,7 @@ class GbmSurfaceFactory : public DriSurfaceFactory { ...@@ -51,10 +49,7 @@ class GbmSurfaceFactory : public DriSurfaceFactory {
bool CanCreateNativePixmap(BufferUsage usage) override; bool CanCreateNativePixmap(BufferUsage usage) override;
private: private:
DriWindowDelegate* GetOrCreateWindowDelegate(gfx::AcceleratedWidget widget);
GbmWrapper* gbm_; // Not owned. GbmWrapper* gbm_; // Not owned.
ScreenManager* screen_manager_; // Not owned.
bool allow_surfaceless_; bool allow_surfaceless_;
DISALLOW_COPY_AND_ASSIGN(GbmSurfaceFactory); DISALLOW_COPY_AND_ASSIGN(GbmSurfaceFactory);
......
...@@ -161,7 +161,7 @@ class OzonePlatformGbm : public OzonePlatform { ...@@ -161,7 +161,7 @@ class OzonePlatformGbm : public OzonePlatform {
if (!surface_factory_ozone_) if (!surface_factory_ozone_)
surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_));
surface_factory_ozone_->InitializeGpu(gbm_.get(), screen_manager_.get(), surface_factory_ozone_->InitializeGpu(gbm_.get(),
window_delegate_manager_.get()); window_delegate_manager_.get());
scoped_ptr<NativeDisplayDelegateDri> ndd( scoped_ptr<NativeDisplayDelegateDri> ndd(
new NativeDisplayDelegateDri(gbm_.get(), screen_manager_.get())); new NativeDisplayDelegateDri(gbm_.get(), screen_manager_.get()));
......
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