Fix search results being clipped in app list.
[chromium-blink-merge.git] / ui / ozone / platform / drm / ozone_platform_drm.cc
blob5b6e32c1344db529059e8ba9c678812387c199e1
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/ozone/platform/drm/ozone_platform_drm.h"
7 #include "base/at_exit.h"
8 #include "base/thread_task_runner_handle.h"
9 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
10 #include "ui/events/ozone/device/device_manager.h"
11 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
12 #include "ui/events/ozone/evdev/event_factory_evdev.h"
13 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
14 #include "ui/ozone/platform/drm/drm_surface_factory.h"
15 #include "ui/ozone/platform/drm/gpu/drm_buffer.h"
16 #include "ui/ozone/platform/drm/gpu/drm_device.h"
17 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h"
18 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
19 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h"
20 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h"
21 #include "ui/ozone/platform/drm/gpu/drm_util.h"
22 #include "ui/ozone/platform/drm/gpu/drm_window.h"
23 #include "ui/ozone/platform/drm/gpu/gpu_lock.h"
24 #include "ui/ozone/platform/drm/gpu/screen_manager.h"
25 #include "ui/ozone/platform/drm/host/display_manager.h"
26 #include "ui/ozone/platform/drm/host/drm_cursor.h"
27 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h"
28 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h"
29 #include "ui/ozone/platform/drm/host/drm_window_host.h"
30 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h"
31 #include "ui/ozone/public/ozone_gpu_test_helper.h"
32 #include "ui/ozone/public/ozone_platform.h"
34 #if defined(USE_XKBCOMMON)
35 #include "ui/events/ozone/layout/xkb/xkb_evdev_codes.h"
36 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h"
37 #else
38 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h"
39 #endif
41 namespace ui {
43 namespace {
45 // OzonePlatform for Linux DRM (Direct Rendering Manager)
47 // This platform is Linux without any display server (no X, wayland, or
48 // anything). This means chrome alone owns the display and input devices.
49 class OzonePlatformDrm : public OzonePlatform {
50 public:
51 OzonePlatformDrm()
52 : drm_(new DrmDevice(GetPrimaryDisplayCardPath())),
53 buffer_generator_(new DrmBufferGenerator()),
54 screen_manager_(new ScreenManager(buffer_generator_.get())),
55 device_manager_(CreateDeviceManager()) {}
56 ~OzonePlatformDrm() override {}
58 // OzonePlatform:
59 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override {
60 return surface_factory_ozone_.get();
62 CursorFactoryOzone* GetCursorFactoryOzone() override {
63 return cursor_factory_ozone_.get();
65 InputController* GetInputController() override {
66 return event_factory_ozone_->input_controller();
68 GpuPlatformSupport* GetGpuPlatformSupport() override {
69 return gpu_platform_support_.get();
71 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override {
72 return gpu_platform_support_host_.get();
74 scoped_ptr<SystemInputInjector> CreateSystemInputInjector() override {
75 return event_factory_ozone_->CreateSystemInputInjector();
77 scoped_ptr<PlatformWindow> CreatePlatformWindow(
78 PlatformWindowDelegate* delegate,
79 const gfx::Rect& bounds) override {
80 scoped_ptr<DrmWindowHost> platform_window(
81 new DrmWindowHost(delegate, bounds, gpu_platform_support_host_.get(),
82 event_factory_ozone_.get(), cursor_.get(),
83 window_manager_.get(), display_manager_.get()));
84 platform_window->Initialize();
85 return platform_window.Pass();
87 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override {
88 return make_scoped_ptr(new DrmNativeDisplayDelegate(
89 gpu_platform_support_host_.get(), device_manager_.get(),
90 display_manager_.get(), drm_->device_path()));
92 void InitializeUI() override {
93 #if defined(OS_CHROMEOS)
94 gpu_lock_.reset(new GpuLock());
95 #endif
96 if (!drm_->Initialize())
97 LOG(FATAL) << "Failed to initialize primary DRM device";
99 // This makes sure that simple targets that do not handle display
100 // configuration can still use the primary display.
101 ForceInitializationOfPrimaryDisplay(drm_, screen_manager_.get());
102 drm_device_manager_.reset(new DrmDeviceManager(drm_));
103 display_manager_.reset(new DisplayManager());
104 window_manager_.reset(new DrmWindowHostManager());
105 cursor_.reset(new DrmCursor(window_manager_.get()));
106 surface_factory_ozone_.reset(new DrmSurfaceFactory(screen_manager_.get()));
107 scoped_ptr<DrmGpuDisplayManager> ndd(new DrmGpuDisplayManager(
108 screen_manager_.get(), drm_,
109 scoped_ptr<DrmDeviceGenerator>(new DrmDeviceGenerator())));
110 gpu_platform_support_.reset(new DrmGpuPlatformSupport(
111 drm_device_manager_.get(), screen_manager_.get(), ndd.Pass()));
112 gpu_platform_support_host_.reset(
113 new DrmGpuPlatformSupportHost(cursor_.get()));
114 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone);
115 #if defined(USE_XKBCOMMON)
116 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(make_scoped_ptr(
117 new XkbKeyboardLayoutEngine(xkb_evdev_code_converter_)));
118 #else
119 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(
120 make_scoped_ptr(new StubKeyboardLayoutEngine()));
121 #endif
122 event_factory_ozone_.reset(new EventFactoryEvdev(
123 cursor_.get(), device_manager_.get(),
124 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine()));
126 if (!gpu_helper_.Initialize(base::ThreadTaskRunnerHandle::Get(),
127 base::ThreadTaskRunnerHandle::Get()))
128 LOG(FATAL) << "Failed to initialize dummy channel.";
131 void InitializeGPU() override {}
133 private:
134 // Objects in the "GPU" process.
135 scoped_ptr<GpuLock> gpu_lock_;
136 scoped_refptr<DrmDevice> drm_;
137 scoped_ptr<DrmDeviceManager> drm_device_manager_;
138 scoped_ptr<DrmBufferGenerator> buffer_generator_;
139 scoped_ptr<ScreenManager> screen_manager_;
140 scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_;
142 // Objects in the "Browser" process.
143 scoped_ptr<DeviceManager> device_manager_;
144 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_;
145 scoped_ptr<DrmWindowHostManager> window_manager_;
146 scoped_ptr<DrmCursor> cursor_;
147 scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
148 scoped_ptr<DisplayManager> display_manager_;
149 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_;
151 #if defined(USE_XKBCOMMON)
152 XkbEvdevCodes xkb_evdev_code_converter_;
153 #endif
155 // Objects on both processes.
156 scoped_ptr<DrmSurfaceFactory> surface_factory_ozone_;
158 OzoneGpuTestHelper gpu_helper_;
160 DISALLOW_COPY_AND_ASSIGN(OzonePlatformDrm);
163 } // namespace
165 OzonePlatform* CreateOzonePlatformDri() {
166 return new OzonePlatformDrm;
169 OzonePlatform* CreateOzonePlatformDrm() {
170 return new OzonePlatformDrm;
173 } // namespace ui