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

Side by Side Diff: ui/ozone/platform/cast/ozone_platform_cast.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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
OLDNEW
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 "chromecast/public/cast_egl_platform.h" 13 #include "chromecast/public/cast_egl_platform.h"
13 #include "chromecast/public/cast_egl_platform_shlib.h" 14 #include "chromecast/public/cast_egl_platform_shlib.h"
14 #include "ui/ozone/common/native_display_delegate_ozone.h" 15 #include "ui/ozone/common/native_display_delegate_ozone.h"
15 #include "ui/ozone/platform/cast/gpu_platform_support_cast.h" 16 #include "ui/ozone/platform/cast/gpu_platform_support_cast.h"
16 #include "ui/ozone/platform/cast/overlay_manager_cast.h" 17 #include "ui/ozone/platform/cast/overlay_manager_cast.h"
17 #include "ui/ozone/platform/cast/platform_window_cast.h" 18 #include "ui/ozone/platform/cast/platform_window_cast.h"
18 #include "ui/ozone/platform/cast/surface_factory_cast.h" 19 #include "ui/ozone/platform/cast/surface_factory_cast.h"
19 #include "ui/ozone/public/cursor_factory_ozone.h" 20 #include "ui/ozone/public/cursor_factory_ozone.h"
20 #include "ui/ozone/public/gpu_platform_support_host.h" 21 #include "ui/ozone/public/gpu_platform_support_host.h"
21 #include "ui/ozone/public/input_controller.h" 22 #include "ui/ozone/public/input_controller.h"
22 #include "ui/ozone/public/ozone_platform.h" 23 #include "ui/ozone/public/ozone_platform.h"
23 #include "ui/ozone/public/system_input_injector.h" 24 #include "ui/ozone/public/system_input_injector.h"
24 25
25 using chromecast::CastEglPlatform; 26 using chromecast::CastEglPlatform;
26 27
27 namespace ui { 28 namespace ui {
28 namespace { 29 namespace {
29 30
30 base::LazyInstance<scoped_ptr<GpuPlatformSupport>> g_gpu_platform_support = 31 base::LazyInstance<std::unique_ptr<GpuPlatformSupport>> g_gpu_platform_support =
31 LAZY_INSTANCE_INITIALIZER; 32 LAZY_INSTANCE_INITIALIZER;
32 33
33 // Ozone platform implementation for Cast. Implements functionality 34 // Ozone platform implementation for Cast. Implements functionality
34 // common to all Cast implementations: 35 // common to all Cast implementations:
35 // - Always one window with window size equal to display size 36 // - Always one window with window size equal to display size
36 // - No input, cursor support 37 // - No input, cursor support
37 // - Relinquish GPU resources flow for switching to external applications 38 // - Relinquish GPU resources flow for switching to external applications
38 // Meanwhile, platform-specific implementation details are abstracted out 39 // Meanwhile, platform-specific implementation details are abstracted out
39 // to the CastEglPlatform interface. 40 // to the CastEglPlatform interface.
40 class OzonePlatformCast : public OzonePlatform { 41 class OzonePlatformCast : public OzonePlatform {
41 public: 42 public:
42 explicit OzonePlatformCast(scoped_ptr<CastEglPlatform> egl_platform) 43 explicit OzonePlatformCast(std::unique_ptr<CastEglPlatform> egl_platform)
43 : egl_platform_(std::move(egl_platform)) {} 44 : egl_platform_(std::move(egl_platform)) {}
44 ~OzonePlatformCast() override {} 45 ~OzonePlatformCast() override {}
45 46
46 // OzonePlatform implementation: 47 // OzonePlatform implementation:
47 SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { 48 SurfaceFactoryOzone* GetSurfaceFactoryOzone() override {
48 return surface_factory_.get(); 49 return surface_factory_.get();
49 } 50 }
50 OverlayManagerOzone* GetOverlayManager() override { 51 OverlayManagerOzone* GetOverlayManager() override {
51 return overlay_manager_.get(); 52 return overlay_manager_.get();
52 } 53 }
53 CursorFactoryOzone* GetCursorFactoryOzone() override { 54 CursorFactoryOzone* GetCursorFactoryOzone() override {
54 return cursor_factory_.get(); 55 return cursor_factory_.get();
55 } 56 }
56 InputController* GetInputController() override { 57 InputController* GetInputController() override {
57 return input_controller_.get(); 58 return input_controller_.get();
58 } 59 }
59 GpuPlatformSupport* GetGpuPlatformSupport() override { 60 GpuPlatformSupport* GetGpuPlatformSupport() override {
60 return g_gpu_platform_support.Get().get(); 61 return g_gpu_platform_support.Get().get();
61 } 62 }
62 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { 63 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override {
63 return gpu_platform_support_host_.get(); 64 return gpu_platform_support_host_.get();
64 } 65 }
65 scoped_ptr<SystemInputInjector> CreateSystemInputInjector() override { 66 std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() override {
66 return nullptr; // no input injection support 67 return nullptr; // no input injection support
67 } 68 }
68 scoped_ptr<PlatformWindow> CreatePlatformWindow( 69 std::unique_ptr<PlatformWindow> CreatePlatformWindow(
69 PlatformWindowDelegate* delegate, 70 PlatformWindowDelegate* delegate,
70 const gfx::Rect& bounds) override { 71 const gfx::Rect& bounds) override {
71 return make_scoped_ptr<PlatformWindow>( 72 return base::WrapUnique<PlatformWindow>(
72 new PlatformWindowCast(delegate, bounds)); 73 new PlatformWindowCast(delegate, bounds));
73 } 74 }
74 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { 75 std::unique_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
75 return make_scoped_ptr(new NativeDisplayDelegateOzone()); 76 override {
77 return base::WrapUnique(new NativeDisplayDelegateOzone());
76 } 78 }
77 79
78 void InitializeUI() override { 80 void InitializeUI() override {
79 overlay_manager_.reset(new OverlayManagerCast()); 81 overlay_manager_.reset(new OverlayManagerCast());
80 cursor_factory_.reset(new CursorFactoryOzone()); 82 cursor_factory_.reset(new CursorFactoryOzone());
81 input_controller_ = CreateStubInputController(); 83 input_controller_ = CreateStubInputController();
82 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); 84 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost());
83 85
84 // Enable dummy software rendering support if GPU process disabled 86 // Enable dummy software rendering support if GPU process disabled
85 // or if we're an audio-only build. 87 // or if we're an audio-only build.
86 // Note: switch is kDisableGpu from content/public/common/content_switches.h 88 // Note: switch is kDisableGpu from content/public/common/content_switches.h
87 bool enable_dummy_software_rendering = true; 89 bool enable_dummy_software_rendering = true;
88 #if !defined(DISABLE_DISPLAY) 90 #if !defined(DISABLE_DISPLAY)
89 enable_dummy_software_rendering = 91 enable_dummy_software_rendering =
90 base::CommandLine::ForCurrentProcess()->HasSwitch("disable-gpu"); 92 base::CommandLine::ForCurrentProcess()->HasSwitch("disable-gpu");
91 #endif 93 #endif
92 94
93 if (enable_dummy_software_rendering) 95 if (enable_dummy_software_rendering)
94 surface_factory_.reset(new SurfaceFactoryCast()); 96 surface_factory_.reset(new SurfaceFactoryCast());
95 } 97 }
96 void InitializeGPU() override { 98 void InitializeGPU() override {
97 surface_factory_.reset(new SurfaceFactoryCast(std::move(egl_platform_))); 99 surface_factory_.reset(new SurfaceFactoryCast(std::move(egl_platform_)));
98 g_gpu_platform_support.Get() = 100 g_gpu_platform_support.Get() =
99 make_scoped_ptr(new GpuPlatformSupportCast(surface_factory_.get())); 101 base::WrapUnique(new GpuPlatformSupportCast(surface_factory_.get()));
100 } 102 }
101 103
102 private: 104 private:
103 scoped_ptr<CastEglPlatform> egl_platform_; 105 std::unique_ptr<CastEglPlatform> egl_platform_;
104 scoped_ptr<SurfaceFactoryCast> surface_factory_; 106 std::unique_ptr<SurfaceFactoryCast> surface_factory_;
105 scoped_ptr<CursorFactoryOzone> cursor_factory_; 107 std::unique_ptr<CursorFactoryOzone> cursor_factory_;
106 scoped_ptr<InputController> input_controller_; 108 std::unique_ptr<InputController> input_controller_;
107 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; 109 std::unique_ptr<GpuPlatformSupportHost> gpu_platform_support_host_;
108 scoped_ptr<OverlayManagerOzone> overlay_manager_; 110 std::unique_ptr<OverlayManagerOzone> overlay_manager_;
109 111
110 DISALLOW_COPY_AND_ASSIGN(OzonePlatformCast); 112 DISALLOW_COPY_AND_ASSIGN(OzonePlatformCast);
111 }; 113 };
112 114
113 } // namespace 115 } // namespace
114 116
115 OzonePlatform* CreateOzonePlatformCast() { 117 OzonePlatform* CreateOzonePlatformCast() {
116 const std::vector<std::string>& argv = 118 const std::vector<std::string>& argv =
117 base::CommandLine::ForCurrentProcess()->argv(); 119 base::CommandLine::ForCurrentProcess()->argv();
118 scoped_ptr<chromecast::CastEglPlatform> platform( 120 std::unique_ptr<chromecast::CastEglPlatform> platform(
119 chromecast::CastEglPlatformShlib::Create(argv)); 121 chromecast::CastEglPlatformShlib::Create(argv));
120 return new OzonePlatformCast(std::move(platform)); 122 return new OzonePlatformCast(std::move(platform));
121 } 123 }
122 124
123 } // namespace ui 125 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/cast/overlay_manager_cast.cc ('k') | ui/ozone/platform/cast/surface_factory_cast.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698