Skip to content

Commit

Permalink
[ozone/wayland] Use PlatformProperties to know if mojo is required
Browse files Browse the repository at this point in the history
Do not rely on the OzoneDrmMojo and avoid messing up with it as long as
it usually brings problems rather than fixes.

Thus, use PlatformProperties to know if Wayland requires mojo
communication before the gpu is started.
  • Loading branch information
msisov committed Oct 1, 2018
1 parent 30a01fc commit c226de3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
7 changes: 6 additions & 1 deletion components/viz/host/gpu_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,12 @@ void GpuHostImpl::InitOzone() {
// https://crbug.com/608839
// If the OzonePlatform is not created yet, defer the callback until
// OzonePlatform instance is created.
if (features::IsOzoneDrmMojo()) {
//
// The Ozone/Wayland requires mojo communication to be established to be
// functional with a separate gpu process. Thus, using the PlatformProperties,
// check if there is such a requirement.
if (features::IsOzoneDrmMojo() ||
ui::OzonePlatform::GetInstance()->GetPlatformProperties().requires_mojo) {
// TODO(rjkroege): Remove the legacy IPC code paths when no longer
// necessary. https://crbug.com/806092
auto interface_binder = base::BindRepeating(&GpuHostImpl::BindInterface,
Expand Down
8 changes: 6 additions & 2 deletions gpu/ipc/service/gpu_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line,
// may also have started at this point.
ui::OzonePlatform::InitParams params;
params.single_process = false;
params.using_mojo = features::IsOzoneDrmMojo();
params.using_mojo =
features::IsOzoneDrmMojo() |
ui::OzonePlatform::GetInstance()->GetPlatformProperties().requires_mojo;
ui::OzonePlatform::InitializeForGPU(params);
#endif

Expand Down Expand Up @@ -365,7 +367,9 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line,
#if defined(USE_OZONE)
ui::OzonePlatform::InitParams params;
params.single_process = true;
params.using_mojo = features::IsOzoneDrmMojo();
params.using_mojo =
features::IsOzoneDrmMojo() ||
ui::OzonePlatform::GetInstance()->GetPlatformProperties().requires_mojo;
ui::OzonePlatform::InitializeForGPU(params);
ui::OzonePlatform::GetInstance()->AfterSandboxEntry();
#endif
Expand Down
18 changes: 6 additions & 12 deletions ui/ozone/platform/wayland/ozone_platform_wayland.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class OzonePlatformWayland : public OzonePlatform {
// https://github.com/wayland-project/wayland-protocols/commit/76d1ae8c65739eff3434ef219c58a913ad34e988
properties_.custom_frame_pref_default = true;
properties_.use_system_title_bar = false;
// Ozone/Wayland relies on the mojo communication when running in
// !single_process.
// TODO(msisov, rjkroege): Remove after http://crbug.com/806092.
properties_.requires_mojo = true;
}
~OzonePlatformWayland() override {}

Expand Down Expand Up @@ -124,17 +128,8 @@ class OzonePlatformWayland : public OzonePlatform {
LOG(FATAL) << "Failed to initialize Wayland platform";

#if defined(WAYLAND_GBM)
if (!args.single_process) {
if (!features::IsOzoneDrmMojo()) {
// Override kEnableOzoneDrmMojo to the enabled state, because
// Ozone/Wayland relies on the mojo communication when running in
// !single_process.
// TODO(msisov, rjkroege): Remove after http://crbug.com/806092.
base::FeatureList::GetInstance()->InitializeFromCommandLine(
features::kEnableOzoneDrmMojo.name, std::string());
}
if (!args.single_process)
connector_.reset(new WaylandConnectionConnector(connection_.get()));
}
#endif

cursor_factory_.reset(new BitmapCursorFactoryOzone);
Expand Down Expand Up @@ -169,8 +164,7 @@ class OzonePlatformWayland : public OzonePlatform {
}

const PlatformProperties& GetPlatformProperties() override {
DCHECK(connection_.get());
if (properties_.supported_buffer_formats.empty()) {
if (connection_ && properties_.supported_buffer_formats.empty()) {
properties_.supported_buffer_formats =
connection_->GetSupportedBufferFormats();
}
Expand Down
2 changes: 2 additions & 0 deletions ui/ozone/public/ozone_platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ OzonePlatform::PlatformProperties::PlatformProperties(
bool needs_request,
bool custom_frame_default,
bool can_use_system_title_bar,
bool requires_mojo_for_ipc,
std::vector<gfx::BufferFormat> buffer_formats)
: needs_view_owner_request(needs_request),
custom_frame_pref_default(custom_frame_default),
use_system_title_bar(can_use_system_title_bar),
requires_mojo(requires_mojo_for_ipc),
supported_buffer_formats(buffer_formats) {}

OzonePlatform::PlatformProperties::~PlatformProperties() = default;
Expand Down
5 changes: 5 additions & 0 deletions ui/ozone/public/ozone_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class OZONE_EXPORT OzonePlatform {
PlatformProperties(bool needs_request,
bool custom_frame_default,
bool can_use_system_title_bar,
bool requires_mojo_for_ipc,
std::vector<gfx::BufferFormat> buffer_formats);
~PlatformProperties();
PlatformProperties(const PlatformProperties& other);
Expand All @@ -108,6 +109,10 @@ class OZONE_EXPORT OzonePlatform {
// supported.
bool use_system_title_bar = false;

// Determines if the platform requires mojo communication for the IPC.
// Currently used only by the Ozone/Wayland platform.
bool requires_mojo = false;

// Wayland only: carries buffer formats supported by a Wayland server.
std::vector<gfx::BufferFormat> supported_buffer_formats;
};
Expand Down

0 comments on commit c226de3

Please sign in to comment.