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

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

Issue 742103002: Ozone keyboard layout (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lite-code
Patch Set: address review comments (Wez) + cleanup Created 6 years 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
OLDNEW
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 <gbm.h> 8 #include <gbm.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" 14 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
15 #include "ui/events/ozone/device/device_manager.h" 15 #include "ui/events/ozone/device/device_manager.h"
16 #include "ui/events/ozone/evdev/event_factory_evdev.h" 16 #include "ui/events/ozone/evdev/event_factory_evdev.h"
17 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
18 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h"
17 #include "ui/ozone/platform/dri/display_manager.h" 19 #include "ui/ozone/platform/dri/display_manager.h"
18 #include "ui/ozone/platform/dri/dri_cursor.h" 20 #include "ui/ozone/platform/dri/dri_cursor.h"
19 #include "ui/ozone/platform/dri/dri_gpu_platform_support.h" 21 #include "ui/ozone/platform/dri/dri_gpu_platform_support.h"
20 #include "ui/ozone/platform/dri/dri_gpu_platform_support_host.h" 22 #include "ui/ozone/platform/dri/dri_gpu_platform_support_host.h"
21 #include "ui/ozone/platform/dri/dri_window.h" 23 #include "ui/ozone/platform/dri/dri_window.h"
22 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" 24 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h"
23 #include "ui/ozone/platform/dri/dri_window_manager.h" 25 #include "ui/ozone/platform/dri/dri_window_manager.h"
24 #include "ui/ozone/platform/dri/dri_wrapper.h" 26 #include "ui/ozone/platform/dri/dri_wrapper.h"
25 #include "ui/ozone/platform/dri/gbm_buffer.h" 27 #include "ui/ozone/platform/dri/gbm_buffer.h"
26 #include "ui/ozone/platform/dri/gbm_surface.h" 28 #include "ui/ozone/platform/dri/gbm_surface.h"
(...skipping 25 matching lines...) Expand all
52 } 54 }
53 virtual ~GbmBufferGenerator() { 55 virtual ~GbmBufferGenerator() {
54 gbm_device_destroy(device_); 56 gbm_device_destroy(device_);
55 if (glapi_lib_) 57 if (glapi_lib_)
56 dlclose(glapi_lib_); 58 dlclose(glapi_lib_);
57 } 59 }
58 60
59 gbm_device* device() const { return device_; } 61 gbm_device* device() const { return device_; }
60 62
61 scoped_refptr<ScanoutBuffer> Create(const gfx::Size& size) override { 63 scoped_refptr<ScanoutBuffer> Create(const gfx::Size& size) override {
62 return GbmBuffer::CreateBuffer( 64 return GbmBuffer::CreateBuffer(dri_, device_,
63 dri_, device_, SurfaceFactoryOzone::RGBA_8888, size, true); 65 SurfaceFactoryOzone::RGBA_8888, size, true);
64 } 66 }
65 67
66 protected: 68 protected:
67 DriWrapper* dri_; // Not owned. 69 DriWrapper* dri_; // Not owned.
68 70
69 // HACK: gbm drivers have broken linkage 71 // HACK: gbm drivers have broken linkage
70 void *glapi_lib_; 72 void* glapi_lib_;
71 73
72 gbm_device* device_; 74 gbm_device* device_;
73 75
74 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator); 76 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator);
75 }; 77 };
76 78
77 class OzonePlatformGbm : public OzonePlatform { 79 class OzonePlatformGbm : public OzonePlatform {
78 public: 80 public:
79 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) { 81 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) {
80 base::AtExitManager::RegisterTask( 82 base::AtExitManager::RegisterTask(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Needed since the browser process creates the accelerated widgets and that 120 // Needed since the browser process creates the accelerated widgets and that
119 // happens through SFO. 121 // happens through SFO.
120 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); 122 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_));
121 device_manager_ = CreateDeviceManager(); 123 device_manager_ = CreateDeviceManager();
122 gpu_platform_support_host_.reset(new DriGpuPlatformSupportHost()); 124 gpu_platform_support_host_.reset(new DriGpuPlatformSupportHost());
123 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); 125 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone);
124 window_manager_.reset( 126 window_manager_.reset(
125 new DriWindowManager(gpu_platform_support_host_.get())); 127 new DriWindowManager(gpu_platform_support_host_.get()));
126 event_factory_ozone_.reset(new EventFactoryEvdev(window_manager_->cursor(), 128 event_factory_ozone_.reset(new EventFactoryEvdev(window_manager_->cursor(),
127 device_manager_.get())); 129 device_manager_.get()));
130 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(
131 make_scoped_ptr(new StubKeyboardLayoutEngine()));
128 } 132 }
129 133
130 void InitializeGPU() override { 134 void InitializeGPU() override {
131 dri_.reset(new DriWrapper(kDefaultGraphicsCardPath)); 135 dri_.reset(new DriWrapper(kDefaultGraphicsCardPath));
132 dri_->Initialize(); 136 dri_->Initialize();
133 buffer_generator_.reset(new GbmBufferGenerator(dri_.get())); 137 buffer_generator_.reset(new GbmBufferGenerator(dri_.get()));
134 screen_manager_.reset(new ScreenManager(dri_.get(), 138 screen_manager_.reset(
135 buffer_generator_.get())); 139 new ScreenManager(dri_.get(), buffer_generator_.get()));
136 window_delegate_manager_.reset(new DriWindowDelegateManager()); 140 window_delegate_manager_.reset(new DriWindowDelegateManager());
137 if (!surface_factory_ozone_) 141 if (!surface_factory_ozone_)
138 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); 142 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_));
139 143
140 surface_factory_ozone_->InitializeGpu( 144 surface_factory_ozone_->InitializeGpu(
141 dri_.get(), buffer_generator_->device(), screen_manager_.get(), 145 dri_.get(), buffer_generator_->device(), screen_manager_.get(),
142 window_delegate_manager_.get()); 146 window_delegate_manager_.get());
143 gpu_platform_support_.reset(new DriGpuPlatformSupport( 147 gpu_platform_support_.reset(new DriGpuPlatformSupport(
144 dri_.get(), window_delegate_manager_.get(), screen_manager_.get(), 148 dri_.get(), window_delegate_manager_.get(), screen_manager_.get(),
145 scoped_ptr<NativeDisplayDelegateDri>(new NativeDisplayDelegateDri( 149 scoped_ptr<NativeDisplayDelegateDri>(new NativeDisplayDelegateDri(
(...skipping 26 matching lines...) Expand all
172 }; 176 };
173 177
174 } // namespace 178 } // namespace
175 179
176 OzonePlatform* CreateOzonePlatformGbm() { 180 OzonePlatform* CreateOzonePlatformGbm() {
177 CommandLine* cmd = CommandLine::ForCurrentProcess(); 181 CommandLine* cmd = CommandLine::ForCurrentProcess();
178 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); 182 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless));
179 } 183 }
180 184
181 } // namespace ui 185 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698