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

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

Issue 106633002: GBM Ozone implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/ozone/platform/dri/ozone_platform_gbm.h ('k') | ui/ozone/platform/dri/scanout_surface.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 2014 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_gbm.h"
6
7 #include <stdlib.h>
8 #include <gbm.h>
9
10 #include "ui/base/cursor/ozone/cursor_factory_ozone.h"
11 #include "ui/events/ozone/device/device_manager.h"
12 #include "ui/events/ozone/evdev/event_factory_evdev.h"
13 #include "ui/ozone/ozone_platform.h"
14 #include "ui/ozone/platform/dri/dri_wrapper.h"
15 #include "ui/ozone/platform/dri/gbm_surface.h"
16 #include "ui/ozone/platform/dri/gbm_surface_factory.h"
17 #include "ui/ozone/platform/dri/scanout_surface.h"
18 #include "ui/ozone/platform/dri/screen_manager.h"
19
20 #if defined(OS_CHROMEOS)
21 #include "ui/ozone/common/chromeos/native_display_delegate_ozone.h"
22 #endif
23
24 namespace ui {
25
26 namespace {
27
28 const char kDefaultGraphicsCardPath[] = "/dev/dri/card0";
29
30 class GbmSurfaceGenerator : public ScanoutSurfaceGenerator {
31 public:
32 GbmSurfaceGenerator(DriWrapper* dri)
33 : dri_(dri),
34 device_(gbm_create_device(dri_->get_fd())) {}
35 virtual ~GbmSurfaceGenerator() {
36 gbm_device_destroy(device_);
37 }
38
39 gbm_device* device() const { return device_; }
40
41 virtual ScanoutSurface* Create(const gfx::Size& size) OVERRIDE {
42 return new GbmSurface(device_, dri_, size);
43 }
44
45 private:
46 DriWrapper* dri_; // Not owned.
47
48 gbm_device* device_;
49
50 DISALLOW_COPY_AND_ASSIGN(GbmSurfaceGenerator);
51 };
52
53 class OzonePlatformGbm : public OzonePlatform {
54 public:
55 OzonePlatformGbm() {}
56 virtual ~OzonePlatformGbm() {}
57
58 // OzonePlatform:
59 virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE {
60 return surface_factory_ozone_.get();
61 }
62 virtual EventFactoryOzone* GetEventFactoryOzone() OVERRIDE {
63 return event_factory_ozone_.get();
64 }
65 virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE {
66 return cursor_factory_ozone_.get();
67 }
68 #if defined(OS_CHROMEOS)
69 virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
70 OVERRIDE {
71 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone());
72 }
73 #endif
74 virtual void InitializeUI() OVERRIDE {
75 // Needed since the browser process creates the accelerated widgets and that
76 // happens through SFO.
77 surface_factory_ozone_.reset(new GbmSurfaceFactory(NULL, NULL, NULL));
78
79 device_manager_ = CreateDeviceManager();
80 cursor_factory_ozone_.reset(new CursorFactoryOzone());
81 event_factory_ozone_.reset(new EventFactoryEvdev(
82 NULL, device_manager_.get()));
83 }
84
85 virtual void InitializeGPU() OVERRIDE {
86 dri_.reset(new DriWrapper(kDefaultGraphicsCardPath));
87 surface_generator_.reset(new GbmSurfaceGenerator(dri_.get()));
88 screen_manager_.reset(new ScreenManager(dri_.get(),
89 surface_generator_.get()));
90 surface_factory_ozone_.reset(
91 new GbmSurfaceFactory(dri_.get(),
92 surface_generator_->device(),
93 screen_manager_.get()));
94 }
95
96 private:
97 scoped_ptr<DriWrapper> dri_;
98 scoped_ptr<GbmSurfaceGenerator> surface_generator_;
99 // TODO(dnicoara) Move ownership of |screen_manager_| to NDD.
100 scoped_ptr<ScreenManager> screen_manager_;
101 scoped_ptr<DeviceManager> device_manager_;
102
103 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_;
104 scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_;
105 scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
106
107 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm);
108 };
109
110 } // namespace
111
112 OzonePlatform* CreateOzonePlatformGbm() { return new OzonePlatformGbm; }
113
114 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/ozone_platform_gbm.h ('k') | ui/ozone/platform/dri/scanout_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698