| 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/egltest/ozone_platform_egltest.h" | 5 #include "ui/ozone/platform/egltest/ozone_platform_egltest.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/environment.h" | 8 #include "base/environment.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 198 } |
| 199 | 199 |
| 200 // Test platform for EGL. | 200 // Test platform for EGL. |
| 201 // | 201 // |
| 202 // This is a tiny EGL-based platform. Creation of the native window is | 202 // This is a tiny EGL-based platform. Creation of the native window is |
| 203 // handled by a separate library called eglplatform_shim.so.1 because | 203 // handled by a separate library called eglplatform_shim.so.1 because |
| 204 // this itself is platform specific and we want to test out multiple | 204 // this itself is platform specific and we want to test out multiple |
| 205 // hardware platforms. | 205 // hardware platforms. |
| 206 class OzonePlatformEgltest : public OzonePlatform { | 206 class OzonePlatformEgltest : public OzonePlatform { |
| 207 public: | 207 public: |
| 208 OzonePlatformEgltest() | 208 OzonePlatformEgltest() : shim_initialized_(false) {} |
| 209 : device_manager_(CreateDeviceManager()), | |
| 210 surface_factory_ozone_(&eglplatform_shim_), | |
| 211 event_factory_ozone_(NULL, device_manager_.get()), | |
| 212 shim_initialized_(false) {} | |
| 213 virtual ~OzonePlatformEgltest() { | 209 virtual ~OzonePlatformEgltest() { |
| 214 if (shim_initialized_) | 210 if (shim_initialized_) |
| 215 eglplatform_shim_.ShimTerminate(); | 211 eglplatform_shim_.ShimTerminate(); |
| 216 } | 212 } |
| 217 | 213 |
| 218 void LoadShim() { | 214 void LoadShim() { |
| 219 std::string library = GetShimLibraryName(); | 215 std::string library = GetShimLibraryName(); |
| 220 | 216 |
| 221 if (eglplatform_shim_.Load(library)) | 217 if (eglplatform_shim_.Load(library)) |
| 222 return; | 218 return; |
| 223 | 219 |
| 224 base::FilePath module_path; | 220 base::FilePath module_path; |
| 225 if (!PathService::Get(base::DIR_MODULE, &module_path)) | 221 if (!PathService::Get(base::DIR_MODULE, &module_path)) |
| 226 LOG(ERROR) << "failed to get DIR_MODULE from PathService"; | 222 LOG(ERROR) << "failed to get DIR_MODULE from PathService"; |
| 227 base::FilePath library_path = module_path.Append(library); | 223 base::FilePath library_path = module_path.Append(library); |
| 228 | 224 |
| 229 if (eglplatform_shim_.Load(library_path.value())) | 225 if (eglplatform_shim_.Load(library_path.value())) |
| 230 return; | 226 return; |
| 231 | 227 |
| 232 LOG(FATAL) << "failed to load " << library; | 228 LOG(FATAL) << "failed to load " << library; |
| 233 } | 229 } |
| 234 | 230 |
| 235 void Initialize() { | 231 void Initialize() { |
| 236 LoadShim(); | 232 LoadShim(); |
| 237 shim_initialized_ = eglplatform_shim_.ShimInitialize(); | 233 shim_initialized_ = eglplatform_shim_.ShimInitialize(); |
| 238 } | 234 } |
| 239 | 235 |
| 240 // OzonePlatform: | 236 // OzonePlatform: |
| 241 virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE { | 237 virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE { |
| 242 return &surface_factory_ozone_; | 238 return surface_factory_ozone_.get(); |
| 243 } | 239 } |
| 244 virtual EventFactoryOzone* GetEventFactoryOzone() OVERRIDE { | 240 virtual EventFactoryOzone* GetEventFactoryOzone() OVERRIDE { |
| 245 return &event_factory_ozone_; | 241 return event_factory_ozone_.get(); |
| 246 } | 242 } |
| 247 virtual InputMethodContextFactoryOzone* GetInputMethodContextFactoryOzone() | 243 virtual InputMethodContextFactoryOzone* GetInputMethodContextFactoryOzone() |
| 248 OVERRIDE { | 244 OVERRIDE { |
| 249 return &input_method_context_factory_ozone_; | 245 return input_method_context_factory_ozone_.get(); |
| 250 } | 246 } |
| 251 virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE { | 247 virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE { |
| 252 return &cursor_factory_ozone_; | 248 return cursor_factory_ozone_.get(); |
| 253 } | 249 } |
| 254 | 250 |
| 255 #if defined(OS_CHROMEOS) | 251 #if defined(OS_CHROMEOS) |
| 256 virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() | 252 virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() |
| 257 OVERRIDE { | 253 OVERRIDE { |
| 258 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); | 254 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); |
| 259 } | 255 } |
| 260 #endif | 256 #endif |
| 261 | 257 |
| 258 virtual void InitializeUI() OVERRIDE { |
| 259 device_manager_ = CreateDeviceManager(); |
| 260 surface_factory_ozone_.reset(new SurfaceFactoryEgltest(&eglplatform_shim_)); |
| 261 event_factory_ozone_.reset( |
| 262 new EventFactoryEvdev(NULL, device_manager_.get())); |
| 263 input_method_context_factory_ozone_.reset( |
| 264 new InputMethodContextFactoryOzone()); |
| 265 cursor_factory_ozone_.reset(new CursorFactoryOzone()); |
| 266 } |
| 267 |
| 268 virtual void InitializeGPU() OVERRIDE {} |
| 269 |
| 262 private: | 270 private: |
| 263 LibeglplatformShimLoader eglplatform_shim_; | 271 LibeglplatformShimLoader eglplatform_shim_; |
| 264 scoped_ptr<DeviceManager> device_manager_; | 272 scoped_ptr<DeviceManager> device_manager_; |
| 265 SurfaceFactoryEgltest surface_factory_ozone_; | 273 scoped_ptr<SurfaceFactoryEgltest> surface_factory_ozone_; |
| 266 EventFactoryEvdev event_factory_ozone_; | 274 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; |
| 267 InputMethodContextFactoryOzone input_method_context_factory_ozone_; | 275 scoped_ptr<InputMethodContextFactoryOzone> |
| 268 CursorFactoryOzone cursor_factory_ozone_; | 276 input_method_context_factory_ozone_; |
| 277 scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; |
| 269 | 278 |
| 270 bool shim_initialized_; | 279 bool shim_initialized_; |
| 271 | 280 |
| 272 DISALLOW_COPY_AND_ASSIGN(OzonePlatformEgltest); | 281 DISALLOW_COPY_AND_ASSIGN(OzonePlatformEgltest); |
| 273 }; | 282 }; |
| 274 | 283 |
| 275 } // namespace | 284 } // namespace |
| 276 | 285 |
| 277 OzonePlatform* CreateOzonePlatformEgltest() { | 286 OzonePlatform* CreateOzonePlatformEgltest() { |
| 278 OzonePlatformEgltest* platform = new OzonePlatformEgltest; | 287 OzonePlatformEgltest* platform = new OzonePlatformEgltest; |
| 279 platform->Initialize(); | 288 platform->Initialize(); |
| 280 return platform; | 289 return platform; |
| 281 } | 290 } |
| 282 | 291 |
| 283 } // namespace ui | 292 } // namespace ui |
| OLD | NEW |