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

Side by Side Diff: ui/ozone/platform/dri/ozone_platform_dri.cc

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « ui/ozone/platform/dri/ozone_platform_dri.h ('k') | ui/ozone/platform/dri/ozone_platform_gbm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "ui/ozone/platform/dri/ozone_platform_dri.h"
6
7 #include "base/at_exit.h"
8 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
9 #include "ui/events/ozone/device/device_manager.h"
10 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
11 #include "ui/events/ozone/evdev/event_factory_evdev.h"
12 #include "ui/ozone/platform/dri/dri_buffer.h"
13 #include "ui/ozone/platform/dri/dri_cursor.h"
14 #include "ui/ozone/platform/dri/dri_gpu_platform_support.h"
15 #include "ui/ozone/platform/dri/dri_gpu_platform_support_host.h"
16 #include "ui/ozone/platform/dri/dri_surface_factory.h"
17 #include "ui/ozone/platform/dri/dri_window.h"
18 #include "ui/ozone/platform/dri/dri_window_delegate_impl.h"
19 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h"
20 #include "ui/ozone/platform/dri/dri_window_manager.h"
21 #include "ui/ozone/platform/dri/dri_wrapper.h"
22 #include "ui/ozone/platform/dri/native_display_delegate_dri.h"
23 #include "ui/ozone/platform/dri/screen_manager.h"
24 #include "ui/ozone/platform/dri/virtual_terminal_manager.h"
25 #include "ui/ozone/public/ozone_platform.h"
26 #include "ui/ozone/public/ui_thread_gpu.h"
27
28 namespace ui {
29
30 namespace {
31
32 const char kDefaultGraphicsCardPath[] = "/dev/dri/card0";
33
34 // OzonePlatform for Linux DRI (Direct Rendering Infrastructure)
35 //
36 // This platform is Linux without any display server (no X, wayland, or
37 // anything). This means chrome alone owns the display and input devices.
38 class OzonePlatformDri : public OzonePlatform {
39 public:
40 OzonePlatformDri()
41 : vt_manager_(new VirtualTerminalManager()),
42 dri_(new DriWrapper(kDefaultGraphicsCardPath)),
43 buffer_generator_(new DriBufferGenerator(dri_.get())),
44 screen_manager_(new ScreenManager(dri_.get(),
45 buffer_generator_.get())),
46 device_manager_(CreateDeviceManager()) {
47 base::AtExitManager::RegisterTask(
48 base::Bind(&base::DeletePointer<OzonePlatformDri>, this));
49 }
50 virtual ~OzonePlatformDri() {}
51
52 // OzonePlatform:
53 virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override {
54 return surface_factory_ozone_.get();
55 }
56 virtual CursorFactoryOzone* GetCursorFactoryOzone() override {
57 return cursor_factory_ozone_.get();
58 }
59 virtual GpuPlatformSupport* GetGpuPlatformSupport() override {
60 return gpu_platform_support_.get();
61 }
62 virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() override {
63 return gpu_platform_support_host_.get();
64 }
65 virtual scoped_ptr<PlatformWindow> CreatePlatformWindow(
66 PlatformWindowDelegate* delegate,
67 const gfx::Rect& bounds) override {
68 scoped_ptr<DriWindow> platform_window(
69 new DriWindow(delegate,
70 bounds,
71 gpu_platform_support_host_.get(),
72 event_factory_ozone_.get(),
73 window_manager_.get()));
74 platform_window->Initialize();
75 return platform_window.Pass();
76 }
77 virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
78 override {
79 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateDri(
80 dri_.get(), screen_manager_.get(), device_manager_.get()));
81 }
82 virtual void InitializeUI() override {
83 dri_->Initialize();
84 surface_factory_ozone_.reset(new DriSurfaceFactory(
85 dri_.get(), screen_manager_.get(), &window_delegate_manager_));
86 gpu_platform_support_.reset(
87 new DriGpuPlatformSupport(surface_factory_ozone_.get(),
88 &window_delegate_manager_,
89 screen_manager_.get(),
90 scoped_ptr<NativeDisplayDelegateDri>()));
91 gpu_platform_support_host_.reset(new DriGpuPlatformSupportHost());
92 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone);
93 window_manager_.reset(new DriWindowManager(surface_factory_ozone_.get()));
94 event_factory_ozone_.reset(new EventFactoryEvdev(window_manager_->cursor(),
95 device_manager_.get()));
96 if (surface_factory_ozone_->InitializeHardware() !=
97 DriSurfaceFactory::INITIALIZED)
98 LOG(FATAL) << "Failed to initialize display hardware.";
99
100 if (!ui_thread_gpu_.Initialize())
101 LOG(FATAL) << "Failed to initialize dummy channel.";
102 }
103
104 virtual void InitializeGPU() override {}
105
106 private:
107 scoped_ptr<VirtualTerminalManager> vt_manager_;
108 scoped_ptr<DriWrapper> dri_;
109 scoped_ptr<DriBufferGenerator> buffer_generator_;
110 scoped_ptr<ScreenManager> screen_manager_;
111 scoped_ptr<DeviceManager> device_manager_;
112
113 scoped_ptr<DriSurfaceFactory> surface_factory_ozone_;
114 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_;
115 scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
116
117 scoped_ptr<DriWindowManager> window_manager_;
118
119 scoped_ptr<DriGpuPlatformSupport> gpu_platform_support_;
120 scoped_ptr<DriGpuPlatformSupportHost> gpu_platform_support_host_;
121
122 DriWindowDelegateManager window_delegate_manager_;
123
124 UiThreadGpu ui_thread_gpu_;
125
126 DISALLOW_COPY_AND_ASSIGN(OzonePlatformDri);
127 };
128
129 } // namespace
130
131 OzonePlatform* CreateOzonePlatformDri() { return new OzonePlatformDri; }
132
133 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/ozone_platform_dri.h ('k') | ui/ozone/platform/dri/ozone_platform_gbm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698