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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/environment.h" | 11 #include "base/environment.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" |
14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
15 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
16 #include "library_loaders/libeglplatform_shim.h" | 17 #include "library_loaders/libeglplatform_shim.h" |
17 #include "third_party/khronos/EGL/egl.h" | 18 #include "third_party/khronos/EGL/egl.h" |
18 #include "ui/events/devices/device_data_manager.h" | 19 #include "ui/events/devices/device_data_manager.h" |
19 #include "ui/events/event.h" | 20 #include "ui/events/event.h" |
20 #include "ui/events/ozone/device/device_manager.h" | 21 #include "ui/events/ozone/device/device_manager.h" |
21 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 22 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
22 #include "ui/events/ozone/events_ozone.h" | 23 #include "ui/events/ozone/events_ozone.h" |
23 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 24 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
(...skipping 19 matching lines...) Expand all Loading... |
43 namespace { | 44 namespace { |
44 | 45 |
45 const char kEglplatformShim[] = "EGLPLATFORM_SHIM"; | 46 const char kEglplatformShim[] = "EGLPLATFORM_SHIM"; |
46 const char kEglplatformShimDefault[] = "libeglplatform_shim.so.1"; | 47 const char kEglplatformShimDefault[] = "libeglplatform_shim.so.1"; |
47 const char kDefaultEglSoname[] = "libEGL.so.1"; | 48 const char kDefaultEglSoname[] = "libEGL.so.1"; |
48 const char kDefaultGlesSoname[] = "libGLESv2.so.2"; | 49 const char kDefaultGlesSoname[] = "libGLESv2.so.2"; |
49 | 50 |
50 // Get the library soname to load. | 51 // Get the library soname to load. |
51 std::string GetShimLibraryName() { | 52 std::string GetShimLibraryName() { |
52 std::string library; | 53 std::string library; |
53 scoped_ptr<base::Environment> env(base::Environment::Create()); | 54 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
54 if (env->GetVar(kEglplatformShim, &library)) | 55 if (env->GetVar(kEglplatformShim, &library)) |
55 return library; | 56 return library; |
56 return kEglplatformShimDefault; | 57 return kEglplatformShimDefault; |
57 } | 58 } |
58 | 59 |
59 // Touch events are reported in device coordinates. This scales the event to the | 60 // Touch events are reported in device coordinates. This scales the event to the |
60 // window's coordinate space. | 61 // window's coordinate space. |
61 void ScaleTouchEvent(TouchEvent* event, const gfx::SizeF& size) { | 62 void ScaleTouchEvent(TouchEvent* event, const gfx::SizeF& size) { |
62 for (const auto& device : | 63 for (const auto& device : |
63 DeviceDataManager::GetInstance()->touchscreen_devices()) { | 64 DeviceDataManager::GetInstance()->touchscreen_devices()) { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 bool OnSwapBuffers() override { return true; } | 226 bool OnSwapBuffers() override { return true; } |
226 | 227 |
227 void OnSwapBuffersAsync(const SwapCompletionCallback& callback) override { | 228 void OnSwapBuffersAsync(const SwapCompletionCallback& callback) override { |
228 callback.Run(gfx::SwapResult::SWAP_ACK); | 229 callback.Run(gfx::SwapResult::SWAP_ACK); |
229 } | 230 } |
230 | 231 |
231 bool ResizeNativeWindow(const gfx::Size& viewport_size) override { | 232 bool ResizeNativeWindow(const gfx::Size& viewport_size) override { |
232 return true; | 233 return true; |
233 } | 234 } |
234 | 235 |
235 scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() override { | 236 std::unique_ptr<gfx::VSyncProvider> CreateVSyncProvider() override { |
236 return nullptr; | 237 return nullptr; |
237 } | 238 } |
238 | 239 |
239 void* /* EGLConfig */ GetEGLSurfaceConfig( | 240 void* /* EGLConfig */ GetEGLSurfaceConfig( |
240 const EglConfigCallbacks& egl) override { | 241 const EglConfigCallbacks& egl) override { |
241 EGLint broken_props[] = { | 242 EGLint broken_props[] = { |
242 EGL_RENDERABLE_TYPE, | 243 EGL_RENDERABLE_TYPE, |
243 EGL_OPENGL_ES2_BIT, | 244 EGL_OPENGL_ES2_BIT, |
244 EGL_SURFACE_TYPE, | 245 EGL_SURFACE_TYPE, |
245 EGL_WINDOW_BIT | EGL_PBUFFER_BIT, | 246 EGL_WINDOW_BIT | EGL_PBUFFER_BIT, |
(...skipping 15 matching lines...) Expand all Loading... |
261 class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone { | 262 class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone { |
262 public: | 263 public: |
263 SurfaceFactoryEgltest(LibeglplatformShimLoader* eglplatform_shim) | 264 SurfaceFactoryEgltest(LibeglplatformShimLoader* eglplatform_shim) |
264 : eglplatform_shim_(eglplatform_shim) {} | 265 : eglplatform_shim_(eglplatform_shim) {} |
265 ~SurfaceFactoryEgltest() override { | 266 ~SurfaceFactoryEgltest() override { |
266 DCHECK(thread_checker_.CalledOnValidThread()); | 267 DCHECK(thread_checker_.CalledOnValidThread()); |
267 } | 268 } |
268 | 269 |
269 // SurfaceFactoryOzone: | 270 // SurfaceFactoryOzone: |
270 intptr_t GetNativeDisplay() override; | 271 intptr_t GetNativeDisplay() override; |
271 scoped_ptr<SurfaceOzoneEGL> CreateEGLSurfaceForWidget( | 272 std::unique_ptr<SurfaceOzoneEGL> CreateEGLSurfaceForWidget( |
272 gfx::AcceleratedWidget widget) override; | 273 gfx::AcceleratedWidget widget) override; |
273 bool LoadEGLGLES2Bindings( | 274 bool LoadEGLGLES2Bindings( |
274 AddGLLibraryCallback add_gl_library, | 275 AddGLLibraryCallback add_gl_library, |
275 SetGLGetProcAddressProcCallback set_gl_get_proc_address) override; | 276 SetGLGetProcAddressProcCallback set_gl_get_proc_address) override; |
276 | 277 |
277 private: | 278 private: |
278 LibeglplatformShimLoader* eglplatform_shim_; | 279 LibeglplatformShimLoader* eglplatform_shim_; |
279 base::ThreadChecker thread_checker_; | 280 base::ThreadChecker thread_checker_; |
280 }; | 281 }; |
281 | 282 |
282 intptr_t SurfaceFactoryEgltest::GetNativeDisplay() { | 283 intptr_t SurfaceFactoryEgltest::GetNativeDisplay() { |
283 DCHECK(thread_checker_.CalledOnValidThread()); | 284 DCHECK(thread_checker_.CalledOnValidThread()); |
284 return eglplatform_shim_->ShimGetNativeDisplay(); | 285 return eglplatform_shim_->ShimGetNativeDisplay(); |
285 } | 286 } |
286 | 287 |
287 scoped_ptr<SurfaceOzoneEGL> SurfaceFactoryEgltest::CreateEGLSurfaceForWidget( | 288 std::unique_ptr<SurfaceOzoneEGL> |
| 289 SurfaceFactoryEgltest::CreateEGLSurfaceForWidget( |
288 gfx::AcceleratedWidget widget) { | 290 gfx::AcceleratedWidget widget) { |
289 DCHECK(thread_checker_.CalledOnValidThread()); | 291 DCHECK(thread_checker_.CalledOnValidThread()); |
290 return make_scoped_ptr<SurfaceOzoneEGL>( | 292 return base::WrapUnique<SurfaceOzoneEGL>( |
291 new SurfaceOzoneEgltest(widget, eglplatform_shim_)); | 293 new SurfaceOzoneEgltest(widget, eglplatform_shim_)); |
292 } | 294 } |
293 | 295 |
294 bool SurfaceFactoryEgltest::LoadEGLGLES2Bindings( | 296 bool SurfaceFactoryEgltest::LoadEGLGLES2Bindings( |
295 AddGLLibraryCallback add_gl_library, | 297 AddGLLibraryCallback add_gl_library, |
296 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { | 298 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { |
297 DCHECK(thread_checker_.CalledOnValidThread()); | 299 DCHECK(thread_checker_.CalledOnValidThread()); |
298 const char* egl_soname = eglplatform_shim_->ShimQueryString(SHIM_EGL_LIBRARY); | 300 const char* egl_soname = eglplatform_shim_->ShimQueryString(SHIM_EGL_LIBRARY); |
299 const char* gles_soname = | 301 const char* gles_soname = |
300 eglplatform_shim_->ShimQueryString(SHIM_GLES_LIBRARY); | 302 eglplatform_shim_->ShimQueryString(SHIM_GLES_LIBRARY); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 } | 357 } |
356 InputController* GetInputController() override { | 358 InputController* GetInputController() override { |
357 return event_factory_ozone_->input_controller(); | 359 return event_factory_ozone_->input_controller(); |
358 } | 360 } |
359 GpuPlatformSupport* GetGpuPlatformSupport() override { | 361 GpuPlatformSupport* GetGpuPlatformSupport() override { |
360 return gpu_platform_support_.get(); | 362 return gpu_platform_support_.get(); |
361 } | 363 } |
362 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { | 364 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { |
363 return gpu_platform_support_host_.get(); | 365 return gpu_platform_support_host_.get(); |
364 } | 366 } |
365 scoped_ptr<SystemInputInjector> CreateSystemInputInjector() override { | 367 std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() override { |
366 return nullptr; // no input injection support. | 368 return nullptr; // no input injection support. |
367 } | 369 } |
368 scoped_ptr<PlatformWindow> CreatePlatformWindow( | 370 std::unique_ptr<PlatformWindow> CreatePlatformWindow( |
369 PlatformWindowDelegate* delegate, | 371 PlatformWindowDelegate* delegate, |
370 const gfx::Rect& bounds) override { | 372 const gfx::Rect& bounds) override { |
371 return make_scoped_ptr<PlatformWindow>(new EgltestWindow( | 373 return base::WrapUnique<PlatformWindow>(new EgltestWindow( |
372 delegate, &eglplatform_shim_, event_factory_ozone_.get(), bounds)); | 374 delegate, &eglplatform_shim_, event_factory_ozone_.get(), bounds)); |
373 } | 375 } |
374 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { | 376 std::unique_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() |
375 return make_scoped_ptr(new NativeDisplayDelegateOzone()); | 377 override { |
| 378 return base::WrapUnique(new NativeDisplayDelegateOzone()); |
376 } | 379 } |
377 | 380 |
378 void InitializeUI() override { | 381 void InitializeUI() override { |
379 device_manager_ = CreateDeviceManager(); | 382 device_manager_ = CreateDeviceManager(); |
380 overlay_manager_.reset(new StubOverlayManager()); | 383 overlay_manager_.reset(new StubOverlayManager()); |
381 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( | 384 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( |
382 make_scoped_ptr(new StubKeyboardLayoutEngine())); | 385 base::WrapUnique(new StubKeyboardLayoutEngine())); |
383 event_factory_ozone_.reset(new EventFactoryEvdev( | 386 event_factory_ozone_.reset(new EventFactoryEvdev( |
384 NULL, device_manager_.get(), | 387 NULL, device_manager_.get(), |
385 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); | 388 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); |
386 cursor_factory_ozone_.reset(new CursorFactoryOzone()); | 389 cursor_factory_ozone_.reset(new CursorFactoryOzone()); |
387 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); | 390 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); |
388 } | 391 } |
389 | 392 |
390 void InitializeGPU() override { | 393 void InitializeGPU() override { |
391 surface_factory_ozone_.reset(new SurfaceFactoryEgltest(&eglplatform_shim_)); | 394 surface_factory_ozone_.reset(new SurfaceFactoryEgltest(&eglplatform_shim_)); |
392 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); | 395 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); |
393 } | 396 } |
394 | 397 |
395 private: | 398 private: |
396 LibeglplatformShimLoader eglplatform_shim_; | 399 LibeglplatformShimLoader eglplatform_shim_; |
397 scoped_ptr<DeviceManager> device_manager_; | 400 std::unique_ptr<DeviceManager> device_manager_; |
398 scoped_ptr<SurfaceFactoryEgltest> surface_factory_ozone_; | 401 std::unique_ptr<SurfaceFactoryEgltest> surface_factory_ozone_; |
399 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; | 402 std::unique_ptr<EventFactoryEvdev> event_factory_ozone_; |
400 scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; | 403 std::unique_ptr<CursorFactoryOzone> cursor_factory_ozone_; |
401 scoped_ptr<GpuPlatformSupport> gpu_platform_support_; | 404 std::unique_ptr<GpuPlatformSupport> gpu_platform_support_; |
402 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; | 405 std::unique_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; |
403 scoped_ptr<OverlayManagerOzone> overlay_manager_; | 406 std::unique_ptr<OverlayManagerOzone> overlay_manager_; |
404 | 407 |
405 bool shim_initialized_; | 408 bool shim_initialized_; |
406 | 409 |
407 DISALLOW_COPY_AND_ASSIGN(OzonePlatformEgltest); | 410 DISALLOW_COPY_AND_ASSIGN(OzonePlatformEgltest); |
408 }; | 411 }; |
409 | 412 |
410 } // namespace | 413 } // namespace |
411 | 414 |
412 OzonePlatform* CreateOzonePlatformEgltest() { | 415 OzonePlatform* CreateOzonePlatformEgltest() { |
413 OzonePlatformEgltest* platform = new OzonePlatformEgltest; | 416 OzonePlatformEgltest* platform = new OzonePlatformEgltest; |
414 platform->Initialize(); | 417 platform->Initialize(); |
415 return platform; | 418 return platform; |
416 } | 419 } |
417 | 420 |
418 } // namespace ui | 421 } // namespace ui |
OLD | NEW |