OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/ozone/platform/dri/ozone_platform_gbm.h" | 5 #include "ui/ozone/platform/dri/ozone_platform_gbm.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <gbm.h> | 9 #include <gbm.h> |
10 | 10 |
| 11 #include "base/at_exit.h" |
11 #include "ui/base/cursor/ozone/cursor_factory_ozone.h" | 12 #include "ui/base/cursor/ozone/cursor_factory_ozone.h" |
12 #include "ui/events/ozone/device/device_manager.h" | 13 #include "ui/events/ozone/device/device_manager.h" |
13 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 14 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
14 #include "ui/ozone/ozone_platform.h" | 15 #include "ui/ozone/ozone_platform.h" |
15 #include "ui/ozone/platform/dri/dri_wrapper.h" | 16 #include "ui/ozone/platform/dri/dri_wrapper.h" |
16 #include "ui/ozone/platform/dri/gbm_surface.h" | 17 #include "ui/ozone/platform/dri/gbm_surface.h" |
17 #include "ui/ozone/platform/dri/gbm_surface_factory.h" | 18 #include "ui/ozone/platform/dri/gbm_surface_factory.h" |
18 #include "ui/ozone/platform/dri/scanout_surface.h" | 19 #include "ui/ozone/platform/dri/scanout_surface.h" |
19 #include "ui/ozone/platform/dri/screen_manager.h" | 20 #include "ui/ozone/platform/dri/screen_manager.h" |
| 21 #include "ui/ozone/platform/dri/virtual_terminal_manager.h" |
20 | 22 |
21 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
22 #include "ui/ozone/common/chromeos/native_display_delegate_ozone.h" | 24 #include "ui/ozone/common/chromeos/native_display_delegate_ozone.h" |
23 #include "ui/ozone/common/chromeos/touchscreen_device_manager_ozone.h" | 25 #include "ui/ozone/common/chromeos/touchscreen_device_manager_ozone.h" |
24 #endif | 26 #endif |
25 | 27 |
26 namespace ui { | 28 namespace ui { |
27 | 29 |
28 namespace { | 30 namespace { |
29 | 31 |
(...skipping 23 matching lines...) Expand all Loading... |
53 // HACK: gbm drivers have broken linkage | 55 // HACK: gbm drivers have broken linkage |
54 void *glapi_lib_; | 56 void *glapi_lib_; |
55 | 57 |
56 gbm_device* device_; | 58 gbm_device* device_; |
57 | 59 |
58 DISALLOW_COPY_AND_ASSIGN(GbmSurfaceGenerator); | 60 DISALLOW_COPY_AND_ASSIGN(GbmSurfaceGenerator); |
59 }; | 61 }; |
60 | 62 |
61 class OzonePlatformGbm : public OzonePlatform { | 63 class OzonePlatformGbm : public OzonePlatform { |
62 public: | 64 public: |
63 OzonePlatformGbm() {} | 65 OzonePlatformGbm() { |
| 66 base::AtExitManager::RegisterTask( |
| 67 base::Bind(&base::DeletePointer<OzonePlatformGbm>, this)); |
| 68 } |
64 virtual ~OzonePlatformGbm() {} | 69 virtual ~OzonePlatformGbm() {} |
65 | 70 |
66 // OzonePlatform: | 71 // OzonePlatform: |
67 virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE { | 72 virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE { |
68 return surface_factory_ozone_.get(); | 73 return surface_factory_ozone_.get(); |
69 } | 74 } |
70 virtual EventFactoryOzone* GetEventFactoryOzone() OVERRIDE { | 75 virtual EventFactoryOzone* GetEventFactoryOzone() OVERRIDE { |
71 return event_factory_ozone_.get(); | 76 return event_factory_ozone_.get(); |
72 } | 77 } |
73 virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE { | 78 virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE { |
74 return cursor_factory_ozone_.get(); | 79 return cursor_factory_ozone_.get(); |
75 } | 80 } |
76 #if defined(OS_CHROMEOS) | 81 #if defined(OS_CHROMEOS) |
77 virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() | 82 virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() |
78 OVERRIDE { | 83 OVERRIDE { |
79 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); | 84 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); |
80 } | 85 } |
81 virtual scoped_ptr<TouchscreenDeviceManager> | 86 virtual scoped_ptr<TouchscreenDeviceManager> |
82 CreateTouchscreenDeviceManager() OVERRIDE { | 87 CreateTouchscreenDeviceManager() OVERRIDE { |
83 return scoped_ptr<TouchscreenDeviceManager>( | 88 return scoped_ptr<TouchscreenDeviceManager>( |
84 new TouchscreenDeviceManagerOzone()); | 89 new TouchscreenDeviceManagerOzone()); |
85 } | 90 } |
86 #endif | 91 #endif |
87 virtual void InitializeUI() OVERRIDE { | 92 virtual void InitializeUI() OVERRIDE { |
| 93 vt_manager_.reset(new VirtualTerminalManager()); |
88 // Needed since the browser process creates the accelerated widgets and that | 94 // Needed since the browser process creates the accelerated widgets and that |
89 // happens through SFO. | 95 // happens through SFO. |
90 surface_factory_ozone_.reset(new GbmSurfaceFactory(NULL, NULL, NULL)); | 96 surface_factory_ozone_.reset(new GbmSurfaceFactory(NULL, NULL, NULL)); |
91 | 97 |
92 device_manager_ = CreateDeviceManager(); | 98 device_manager_ = CreateDeviceManager(); |
93 cursor_factory_ozone_.reset(new CursorFactoryOzone()); | 99 cursor_factory_ozone_.reset(new CursorFactoryOzone()); |
94 event_factory_ozone_.reset(new EventFactoryEvdev( | 100 event_factory_ozone_.reset(new EventFactoryEvdev( |
95 NULL, device_manager_.get())); | 101 NULL, device_manager_.get())); |
96 } | 102 } |
97 | 103 |
98 virtual void InitializeGPU() OVERRIDE { | 104 virtual void InitializeGPU() OVERRIDE { |
99 dri_.reset(new DriWrapper(kDefaultGraphicsCardPath)); | 105 dri_.reset(new DriWrapper(kDefaultGraphicsCardPath)); |
100 surface_generator_.reset(new GbmSurfaceGenerator(dri_.get())); | 106 surface_generator_.reset(new GbmSurfaceGenerator(dri_.get())); |
101 screen_manager_.reset(new ScreenManager(dri_.get(), | 107 screen_manager_.reset(new ScreenManager(dri_.get(), |
102 surface_generator_.get())); | 108 surface_generator_.get())); |
103 surface_factory_ozone_.reset( | 109 surface_factory_ozone_.reset( |
104 new GbmSurfaceFactory(dri_.get(), | 110 new GbmSurfaceFactory(dri_.get(), |
105 surface_generator_->device(), | 111 surface_generator_->device(), |
106 screen_manager_.get())); | 112 screen_manager_.get())); |
107 } | 113 } |
108 | 114 |
109 private: | 115 private: |
| 116 scoped_ptr<VirtualTerminalManager> vt_manager_; |
110 scoped_ptr<DriWrapper> dri_; | 117 scoped_ptr<DriWrapper> dri_; |
111 scoped_ptr<GbmSurfaceGenerator> surface_generator_; | 118 scoped_ptr<GbmSurfaceGenerator> surface_generator_; |
112 // TODO(dnicoara) Move ownership of |screen_manager_| to NDD. | |
113 scoped_ptr<ScreenManager> screen_manager_; | 119 scoped_ptr<ScreenManager> screen_manager_; |
114 scoped_ptr<DeviceManager> device_manager_; | 120 scoped_ptr<DeviceManager> device_manager_; |
115 | 121 |
116 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_; | 122 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_; |
117 scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; | 123 scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; |
118 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; | 124 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; |
119 | 125 |
120 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); | 126 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); |
121 }; | 127 }; |
122 | 128 |
123 } // namespace | 129 } // namespace |
124 | 130 |
125 OzonePlatform* CreateOzonePlatformGbm() { return new OzonePlatformGbm; } | 131 OzonePlatform* CreateOzonePlatformGbm() { return new OzonePlatformGbm; } |
126 | 132 |
127 } // namespace ui | 133 } // namespace ui |
OLD | NEW |