OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_dri.h" | 5 #include "ui/ozone/platform/dri/ozone_platform_dri.h" |
6 | 6 |
7 #include "ui/events/ozone/device/device_manager.h" | 7 #include "ui/events/ozone/device/device_manager.h" |
8 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" | 8 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" |
9 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 9 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
10 #include "ui/ozone/ozone_platform.h" | 10 #include "ui/ozone/ozone_platform.h" |
11 #include "ui/ozone/platform/dri/cursor_factory_evdev_dri.h" | 11 #include "ui/ozone/platform/dri/cursor_factory_evdev_dri.h" |
| 12 #include "ui/ozone/platform/dri/dri_surface.h" |
12 #include "ui/ozone/platform/dri/dri_surface_factory.h" | 13 #include "ui/ozone/platform/dri/dri_surface_factory.h" |
13 #include "ui/ozone/platform/dri/dri_wrapper.h" | 14 #include "ui/ozone/platform/dri/dri_wrapper.h" |
| 15 #include "ui/ozone/platform/dri/scanout_surface.h" |
14 #include "ui/ozone/platform/dri/screen_manager.h" | 16 #include "ui/ozone/platform/dri/screen_manager.h" |
15 | 17 |
16 #if defined(OS_CHROMEOS) | 18 #if defined(OS_CHROMEOS) |
17 #include "ui/ozone/platform/dri/chromeos/native_display_delegate_dri.h" | 19 #include "ui/ozone/platform/dri/chromeos/native_display_delegate_dri.h" |
18 #endif | 20 #endif |
19 | 21 |
20 namespace ui { | 22 namespace ui { |
21 | 23 |
22 namespace { | 24 namespace { |
23 | 25 |
24 const char kDefaultGraphicsCardPath[] = "/dev/dri/card0"; | 26 const char kDefaultGraphicsCardPath[] = "/dev/dri/card0"; |
25 | 27 |
| 28 class DriSurfaceGenerator : public ScanoutSurfaceGenerator { |
| 29 public: |
| 30 DriSurfaceGenerator(DriWrapper* dri) : dri_(dri) {} |
| 31 virtual ~DriSurfaceGenerator() {} |
| 32 |
| 33 virtual ScanoutSurface* Create(const gfx::Size& size) OVERRIDE { |
| 34 return new DriSurface(dri_, size); |
| 35 } |
| 36 |
| 37 private: |
| 38 DriWrapper* dri_; // Not owned. |
| 39 |
| 40 DISALLOW_COPY_AND_ASSIGN(DriSurfaceGenerator); |
| 41 }; |
| 42 |
26 // OzonePlatform for Linux DRI (Direct Rendering Infrastructure) | 43 // OzonePlatform for Linux DRI (Direct Rendering Infrastructure) |
27 // | 44 // |
28 // This platform is Linux without any display server (no X, wayland, or | 45 // This platform is Linux without any display server (no X, wayland, or |
29 // anything). This means chrome alone owns the display and input devices. | 46 // anything). This means chrome alone owns the display and input devices. |
30 class OzonePlatformDri : public OzonePlatform { | 47 class OzonePlatformDri : public OzonePlatform { |
31 public: | 48 public: |
32 OzonePlatformDri() | 49 OzonePlatformDri() |
33 : dri_(new DriWrapper(kDefaultGraphicsCardPath)), | 50 : dri_(new DriWrapper(kDefaultGraphicsCardPath)), |
34 screen_manager_(new ScreenManager(dri_.get())), | 51 surface_generator_(new DriSurfaceGenerator(dri_.get())), |
| 52 screen_manager_(new ScreenManager(dri_.get(), |
| 53 surface_generator_.get())), |
35 device_manager_(CreateDeviceManager()) {} | 54 device_manager_(CreateDeviceManager()) {} |
36 virtual ~OzonePlatformDri() {} | 55 virtual ~OzonePlatformDri() {} |
37 | 56 |
38 // OzonePlatform: | 57 // OzonePlatform: |
39 virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE { | 58 virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE { |
40 return surface_factory_ozone_.get(); | 59 return surface_factory_ozone_.get(); |
41 } | 60 } |
42 virtual EventFactoryOzone* GetEventFactoryOzone() OVERRIDE { | 61 virtual EventFactoryOzone* GetEventFactoryOzone() OVERRIDE { |
43 return event_factory_ozone_.get(); | 62 return event_factory_ozone_.get(); |
44 } | 63 } |
(...skipping 13 matching lines...) Expand all Loading... |
58 cursor_factory_ozone_.reset( | 77 cursor_factory_ozone_.reset( |
59 new CursorFactoryEvdevDri(surface_factory_ozone_.get())); | 78 new CursorFactoryEvdevDri(surface_factory_ozone_.get())); |
60 event_factory_ozone_.reset(new EventFactoryEvdev( | 79 event_factory_ozone_.reset(new EventFactoryEvdev( |
61 cursor_factory_ozone_.get(), device_manager_.get())); | 80 cursor_factory_ozone_.get(), device_manager_.get())); |
62 } | 81 } |
63 | 82 |
64 virtual void InitializeGPU() OVERRIDE {} | 83 virtual void InitializeGPU() OVERRIDE {} |
65 | 84 |
66 private: | 85 private: |
67 scoped_ptr<DriWrapper> dri_; | 86 scoped_ptr<DriWrapper> dri_; |
| 87 scoped_ptr<DriSurfaceGenerator> surface_generator_; |
68 // TODO(dnicoara) Move ownership of |screen_manager_| to NDD. | 88 // TODO(dnicoara) Move ownership of |screen_manager_| to NDD. |
69 scoped_ptr<ScreenManager> screen_manager_; | 89 scoped_ptr<ScreenManager> screen_manager_; |
70 scoped_ptr<DeviceManager> device_manager_; | 90 scoped_ptr<DeviceManager> device_manager_; |
71 | 91 |
72 scoped_ptr<DriSurfaceFactory> surface_factory_ozone_; | 92 scoped_ptr<DriSurfaceFactory> surface_factory_ozone_; |
73 scoped_ptr<CursorFactoryEvdevDri> cursor_factory_ozone_; | 93 scoped_ptr<CursorFactoryEvdevDri> cursor_factory_ozone_; |
74 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; | 94 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; |
75 | 95 |
76 DISALLOW_COPY_AND_ASSIGN(OzonePlatformDri); | 96 DISALLOW_COPY_AND_ASSIGN(OzonePlatformDri); |
77 }; | 97 }; |
78 | 98 |
79 } // namespace | 99 } // namespace |
80 | 100 |
81 OzonePlatform* CreateOzonePlatformDri() { return new OzonePlatformDri; } | 101 OzonePlatform* CreateOzonePlatformDri() { return new OzonePlatformDri; } |
82 | 102 |
83 } // namespace ui | 103 } // namespace ui |
OLD | NEW |