Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Unified Diff: ui/ozone/platform/x11/ozone_platform_x11.cc

Issue 2741033002: Call XInitThreads() for single-process mode. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/ozone/platform/x11/DEPS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/x11/ozone_platform_x11.cc
diff --git a/ui/ozone/platform/x11/ozone_platform_x11.cc b/ui/ozone/platform/x11/ozone_platform_x11.cc
index ae74f0e97bced311ce6aada3c20ec32a6abe6f3c..03ac7cc92662e59bd09d6440cc84658e83e0ba6d 100644
--- a/ui/ozone/platform/x11/ozone_platform_x11.cc
+++ b/ui/ozone/platform/x11/ozone_platform_x11.cc
@@ -12,6 +12,7 @@
#include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "ui/base/x/x11_util.h"
#include "ui/display/fake_display_delegate.h"
#include "ui/events/platform/x11/x11_event_source_libevent.h"
#include "ui/ozone/common/stub_overlay_manager.h"
@@ -29,22 +30,17 @@ namespace ui {
namespace {
-// Returns true if we should operate in Mus mode.
+// Returns true if Ozone is running inside the mus process.
bool RunningInsideMus() {
bool has_channel_handle = base::CommandLine::ForCurrentProcess()->HasSwitch(
"mojo-platform-channel-handle");
return has_channel_handle;
}
-// Singleton OzonePlatform implementation for Linux X11 platform.
+// Singleton OzonePlatform implementation for X11 platform.
class OzonePlatformX11 : public OzonePlatform {
public:
- OzonePlatformX11() {
- // If we're running in Mus mode both the UI and GPU components of Ozone will
- // be running in the same process. Enable X11 concurrent thread support.
- if (RunningInsideMus())
- XInitThreads();
- }
+ OzonePlatformX11() {}
~OzonePlatformX11() override {}
@@ -88,22 +84,24 @@ class OzonePlatformX11 : public OzonePlatform {
return base::MakeUnique<display::FakeDisplayDelegate>();
}
- void InitializeUI() override {
+ void InitializeUI(const InitParams& params) override {
+ InitializeCommon(params);
window_manager_.reset(new X11WindowManagerOzone);
- if (!event_source_)
- event_source_.reset(new X11EventSourceLibevent(gfx::GetXDisplay()));
overlay_manager_.reset(new StubOverlayManager());
input_controller_ = CreateStubInputController();
cursor_factory_ozone_.reset(new X11CursorFactoryOzone());
gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost());
}
- void InitializeGPU() override {
- if (!event_source_)
- event_source_.reset(new X11EventSourceLibevent(gfx::GetXDisplay()));
+ void InitializeUI() override { NOTREACHED(); }
+
+ void InitializeGPU(const InitParams& params) override {
+ InitializeCommon(params);
surface_factory_ozone_.reset(new X11SurfaceFactory());
}
+ void InitializeGPU() override { NOTREACHED(); }
+
base::MessageLoop::Type GetMessageLoopTypeForGpu() override {
// When Ozone X11 backend is running use an UI loop to grab Expose events.
// See GLSurfaceGLX and https://crbug.com/326995.
@@ -111,7 +109,27 @@ class OzonePlatformX11 : public OzonePlatform {
}
private:
- // Objects in the browser process.
+ // Performs initialization steps need by both UI and GPU.
+ void InitializeCommon(const InitParams& params) {
+ // TODO(kylechar): Add DCHECK we only enter InitializeCommon() twice for
+ // single process mode.
+ if (common_initialized_)
+ return;
+
+ // If both UI and GPU are running in the same process then XInitThreads()
+ // must be the first Xlib call.
+ if (params.single_process || RunningInsideMus())
+ XInitThreads();
+
+ ui::SetDefaultX11ErrorHandlers();
+ event_source_.reset(new X11EventSourceLibevent(gfx::GetXDisplay()));
+
+ common_initialized_ = true;
+ }
+
+ bool common_initialized_ = false;
+
+ // Objects in the UI process.
std::unique_ptr<X11WindowManagerOzone> window_manager_;
std::unique_ptr<OverlayManagerOzone> overlay_manager_;
std::unique_ptr<InputController> input_controller_;
@@ -121,7 +139,7 @@ class OzonePlatformX11 : public OzonePlatform {
// Objects in the GPU process.
std::unique_ptr<X11SurfaceFactory> surface_factory_ozone_;
- // Objects in both browser and GPU process.
+ // Objects in both UI and GPU process.
std::unique_ptr<X11EventSourceLibevent> event_source_;
DISALLOW_COPY_AND_ASSIGN(OzonePlatformX11);
« no previous file with comments | « ui/ozone/platform/x11/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698