Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/cast/ozone_platform_cast.h" | 5 #include "ui/ozone/platform/cast/ozone_platform_cast.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "chromecast/chromecast_features.h" | 13 #include "chromecast/chromecast_features.h" |
| 14 #include "chromecast/public/cast_egl_platform.h" | 14 #include "chromecast/public/cast_egl_platform.h" |
| 15 #include "chromecast/public/cast_egl_platform_shlib.h" | 15 #include "chromecast/public/cast_egl_platform_shlib.h" |
| 16 #include "ui/display/types/native_display_delegate.h" | 16 #include "ui/display/types/native_display_delegate.h" |
| 17 #include "ui/events/ozone/device/device_manager.h" | |
| 18 #include "ui/events/ozone/evdev/event_factory_evdev.h" | |
| 19 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | |
| 20 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" | |
| 17 #include "ui/ozone/platform/cast/overlay_manager_cast.h" | 21 #include "ui/ozone/platform/cast/overlay_manager_cast.h" |
| 18 #include "ui/ozone/platform/cast/platform_window_cast.h" | 22 #include "ui/ozone/platform/cast/platform_window_cast.h" |
| 19 #include "ui/ozone/platform/cast/surface_factory_cast.h" | 23 #include "ui/ozone/platform/cast/surface_factory_cast.h" |
| 20 #include "ui/ozone/public/cursor_factory_ozone.h" | 24 #include "ui/ozone/public/cursor_factory_ozone.h" |
| 21 #include "ui/ozone/public/gpu_platform_support_host.h" | 25 #include "ui/ozone/public/gpu_platform_support_host.h" |
| 22 #include "ui/ozone/public/input_controller.h" | 26 #include "ui/ozone/public/input_controller.h" |
| 23 #include "ui/ozone/public/ozone_platform.h" | 27 #include "ui/ozone/public/ozone_platform.h" |
| 24 #include "ui/ozone/public/system_input_injector.h" | 28 #include "ui/ozone/public/system_input_injector.h" |
| 25 | 29 |
| 26 using chromecast::CastEglPlatform; | 30 using chromecast::CastEglPlatform; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 54 } | 58 } |
| 55 return surface_factory_.get(); | 59 return surface_factory_.get(); |
| 56 } | 60 } |
| 57 OverlayManagerOzone* GetOverlayManager() override { | 61 OverlayManagerOzone* GetOverlayManager() override { |
| 58 return overlay_manager_.get(); | 62 return overlay_manager_.get(); |
| 59 } | 63 } |
| 60 CursorFactoryOzone* GetCursorFactoryOzone() override { | 64 CursorFactoryOzone* GetCursorFactoryOzone() override { |
| 61 return cursor_factory_.get(); | 65 return cursor_factory_.get(); |
| 62 } | 66 } |
| 63 InputController* GetInputController() override { | 67 InputController* GetInputController() override { |
| 64 return input_controller_.get(); | 68 return event_factory_ozone_->input_controller(); |
| 65 } | 69 } |
| 66 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { | 70 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { |
| 67 return gpu_platform_support_host_.get(); | 71 return gpu_platform_support_host_.get(); |
| 68 } | 72 } |
| 69 std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() override { | 73 std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() override { |
| 70 return nullptr; // no input injection support | 74 return event_factory_ozone_->CreateSystemInputInjector(); |
| 71 } | 75 } |
| 72 std::unique_ptr<PlatformWindow> CreatePlatformWindow( | 76 std::unique_ptr<PlatformWindow> CreatePlatformWindow( |
| 73 PlatformWindowDelegate* delegate, | 77 PlatformWindowDelegate* delegate, |
| 74 const gfx::Rect& bounds) override { | 78 const gfx::Rect& bounds) override { |
| 75 return base::WrapUnique<PlatformWindow>( | 79 return base::WrapUnique<PlatformWindow>( |
| 76 new PlatformWindowCast(delegate, bounds)); | 80 new PlatformWindowCast(delegate, bounds)); |
| 77 } | 81 } |
| 78 std::unique_ptr<display::NativeDisplayDelegate> CreateNativeDisplayDelegate() | 82 std::unique_ptr<display::NativeDisplayDelegate> CreateNativeDisplayDelegate() |
| 79 override { | 83 override { |
| 80 NOTREACHED(); | 84 NOTREACHED(); |
| 81 return nullptr; | 85 return nullptr; |
| 82 } | 86 } |
| 83 | 87 |
| 84 void InitializeUI() override { | 88 void InitializeUI() override { |
| 89 device_manager_ = CreateDeviceManager(); | |
| 85 overlay_manager_.reset(new OverlayManagerCast()); | 90 overlay_manager_.reset(new OverlayManagerCast()); |
| 86 cursor_factory_.reset(new CursorFactoryOzone()); | 91 cursor_factory_.reset(new CursorFactoryOzone()); |
| 87 input_controller_ = CreateStubInputController(); | |
| 88 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); | 92 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); |
| 89 | 93 |
| 90 // Enable dummy software rendering support if GPU process disabled | 94 // Enable dummy software rendering support if GPU process disabled |
| 91 // or if we're an audio-only build. | 95 // or if we're an audio-only build. |
| 92 // Note: switch is kDisableGpu from content/public/common/content_switches.h | 96 // Note: switch is kDisableGpu from content/public/common/content_switches.h |
| 93 bool enable_dummy_software_rendering = true; | 97 bool enable_dummy_software_rendering = true; |
| 94 #if !BUILDFLAG(IS_CAST_AUDIO_ONLY) | 98 #if !BUILDFLAG(IS_CAST_AUDIO_ONLY) |
| 95 enable_dummy_software_rendering = | 99 enable_dummy_software_rendering = |
| 96 base::CommandLine::ForCurrentProcess()->HasSwitch("disable-gpu"); | 100 base::CommandLine::ForCurrentProcess()->HasSwitch("disable-gpu"); |
| 97 #endif // BUILDFLAG(IS_CAST_AUDIO_ONLY) | 101 #endif // BUILDFLAG(IS_CAST_AUDIO_ONLY) |
| 98 | 102 |
| 103 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( | |
| 104 base::WrapUnique(new StubKeyboardLayoutEngine())); | |
|
derekjchow1
2017/01/13 18:12:28
MakeUnique would be more concise
Joshua LeVasseur
2017/01/13 23:38:13
Done.
| |
| 105 ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine() | |
| 106 ->SetCurrentLayoutByName("us"); | |
| 107 event_factory_ozone_.reset(new EventFactoryEvdev( | |
| 108 nullptr, device_manager_.get(), | |
| 109 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); | |
| 110 | |
| 99 if (enable_dummy_software_rendering) | 111 if (enable_dummy_software_rendering) |
| 100 surface_factory_.reset(new SurfaceFactoryCast()); | 112 surface_factory_.reset(new SurfaceFactoryCast()); |
| 101 } | 113 } |
| 102 void InitializeGPU() override { | 114 void InitializeGPU() override { |
| 103 surface_factory_.reset(new SurfaceFactoryCast(std::move(egl_platform_))); | 115 surface_factory_.reset(new SurfaceFactoryCast(std::move(egl_platform_))); |
| 104 } | 116 } |
| 105 | 117 |
| 106 private: | 118 private: |
| 119 std::unique_ptr<DeviceManager> device_manager_; | |
| 107 std::unique_ptr<CastEglPlatform> egl_platform_; | 120 std::unique_ptr<CastEglPlatform> egl_platform_; |
| 108 std::unique_ptr<SurfaceFactoryCast> surface_factory_; | 121 std::unique_ptr<SurfaceFactoryCast> surface_factory_; |
| 109 std::unique_ptr<CursorFactoryOzone> cursor_factory_; | 122 std::unique_ptr<CursorFactoryOzone> cursor_factory_; |
| 110 std::unique_ptr<InputController> input_controller_; | |
| 111 std::unique_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; | 123 std::unique_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; |
| 112 std::unique_ptr<OverlayManagerOzone> overlay_manager_; | 124 std::unique_ptr<OverlayManagerOzone> overlay_manager_; |
| 125 std::unique_ptr<EventFactoryEvdev> event_factory_ozone_; | |
| 113 | 126 |
| 114 DISALLOW_COPY_AND_ASSIGN(OzonePlatformCast); | 127 DISALLOW_COPY_AND_ASSIGN(OzonePlatformCast); |
| 115 }; | 128 }; |
| 116 | 129 |
| 117 } // namespace | 130 } // namespace |
| 118 | 131 |
| 119 OzonePlatform* CreateOzonePlatformCast() { | 132 OzonePlatform* CreateOzonePlatformCast() { |
| 120 const std::vector<std::string>& argv = | 133 const std::vector<std::string>& argv = |
| 121 base::CommandLine::ForCurrentProcess()->argv(); | 134 base::CommandLine::ForCurrentProcess()->argv(); |
| 122 std::unique_ptr<chromecast::CastEglPlatform> platform( | 135 std::unique_ptr<chromecast::CastEglPlatform> platform( |
| 123 chromecast::CastEglPlatformShlib::Create(argv)); | 136 chromecast::CastEglPlatformShlib::Create(argv)); |
| 124 return new OzonePlatformCast(std::move(platform)); | 137 return new OzonePlatformCast(std::move(platform)); |
| 125 } | 138 } |
| 126 | 139 |
| 127 } // namespace ui | 140 } // namespace ui |
| OLD | NEW |