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

Side by Side Diff: components/exo/display.cc

Issue 2257793002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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
« no previous file with comments | « components/exo/buffer.cc ('k') | components/exo/shared_memory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/exo/display.h" 5 #include "components/exo/display.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/shell_window_ids.h" 10 #include "ash/common/shell_window_ids.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 std::unique_ptr<SharedMemory> Display::CreateSharedMemory( 50 std::unique_ptr<SharedMemory> Display::CreateSharedMemory(
51 const base::SharedMemoryHandle& handle, 51 const base::SharedMemoryHandle& handle,
52 size_t size) { 52 size_t size) {
53 TRACE_EVENT1("exo", "Display::CreateSharedMemory", "size", size); 53 TRACE_EVENT1("exo", "Display::CreateSharedMemory", "size", size);
54 54
55 if (!base::SharedMemory::IsHandleValid(handle)) 55 if (!base::SharedMemory::IsHandleValid(handle))
56 return nullptr; 56 return nullptr;
57 57
58 return base::WrapUnique(new SharedMemory(handle)); 58 return base::MakeUnique<SharedMemory>(handle);
59 } 59 }
60 60
61 #if defined(USE_OZONE) 61 #if defined(USE_OZONE)
62 std::unique_ptr<Buffer> Display::CreateLinuxDMABufBuffer( 62 std::unique_ptr<Buffer> Display::CreateLinuxDMABufBuffer(
63 const gfx::Size& size, 63 const gfx::Size& size,
64 gfx::BufferFormat format, 64 gfx::BufferFormat format,
65 const std::vector<gfx::NativePixmapPlane>& planes, 65 const std::vector<gfx::NativePixmapPlane>& planes,
66 std::vector<base::ScopedFD>&& fds) { 66 std::vector<base::ScopedFD>&& fds) {
67 TRACE_EVENT1("exo", "Display::CreateLinuxDMABufBuffer", "size", 67 TRACE_EVENT1("exo", "Display::CreateLinuxDMABufBuffer", "size",
68 size.ToString()); 68 size.ToString());
(...skipping 20 matching lines...) Expand all
89 bool use_zero_copy = true; 89 bool use_zero_copy = true;
90 90
91 // List of overlay formats that are known to be supported. 91 // List of overlay formats that are known to be supported.
92 // TODO(reveman): Determine this at runtime. 92 // TODO(reveman): Determine this at runtime.
93 const gfx::BufferFormat kOverlayFormats[] = {gfx::BufferFormat::RGBA_8888, 93 const gfx::BufferFormat kOverlayFormats[] = {gfx::BufferFormat::RGBA_8888,
94 gfx::BufferFormat::RGBX_8888}; 94 gfx::BufferFormat::RGBX_8888};
95 bool is_overlay_candidate = 95 bool is_overlay_candidate =
96 std::find(std::begin(kOverlayFormats), std::end(kOverlayFormats), 96 std::find(std::begin(kOverlayFormats), std::end(kOverlayFormats),
97 format) != std::end(kOverlayFormats); 97 format) != std::end(kOverlayFormats);
98 98
99 return base::WrapUnique(new Buffer( 99 return base::MakeUnique<Buffer>(
100 std::move(gpu_memory_buffer), GL_TEXTURE_EXTERNAL_OES, 100 std::move(gpu_memory_buffer), GL_TEXTURE_EXTERNAL_OES,
101 // COMMANDS_COMPLETED queries are required by native pixmaps. 101 // COMMANDS_COMPLETED queries are required by native pixmaps.
102 GL_COMMANDS_COMPLETED_CHROMIUM, use_zero_copy, is_overlay_candidate)); 102 GL_COMMANDS_COMPLETED_CHROMIUM, use_zero_copy, is_overlay_candidate);
103 } 103 }
104 #endif 104 #endif
105 105
106 std::unique_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) { 106 std::unique_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) {
107 TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface", 107 TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface",
108 surface->AsTracedValue()); 108 surface->AsTracedValue());
109 109
110 if (surface->HasSurfaceDelegate()) { 110 if (surface->HasSurfaceDelegate()) {
111 DLOG(ERROR) << "Surface has already been assigned a role"; 111 DLOG(ERROR) << "Surface has already been assigned a role";
112 return nullptr; 112 return nullptr;
113 } 113 }
114 114
115 return base::WrapUnique( 115 return base::MakeUnique<ShellSurface>(surface, nullptr, gfx::Rect(),
116 new ShellSurface(surface, nullptr, gfx::Rect(), true /* activatable */, 116 true /* activatable */,
117 ash::kShellWindowId_DefaultContainer)); 117 ash::kShellWindowId_DefaultContainer);
118 } 118 }
119 119
120 std::unique_ptr<ShellSurface> Display::CreatePopupShellSurface( 120 std::unique_ptr<ShellSurface> Display::CreatePopupShellSurface(
121 Surface* surface, 121 Surface* surface,
122 ShellSurface* parent, 122 ShellSurface* parent,
123 const gfx::Point& position) { 123 const gfx::Point& position) {
124 TRACE_EVENT2("exo", "Display::CreatePopupShellSurface", "surface", 124 TRACE_EVENT2("exo", "Display::CreatePopupShellSurface", "surface",
125 surface->AsTracedValue(), "parent", parent->AsTracedValue()); 125 surface->AsTracedValue(), "parent", parent->AsTracedValue());
126 126
127 if (surface->window()->Contains(parent->GetWidget()->GetNativeWindow())) { 127 if (surface->window()->Contains(parent->GetWidget()->GetNativeWindow())) {
128 DLOG(ERROR) << "Parent is contained within surface's hierarchy"; 128 DLOG(ERROR) << "Parent is contained within surface's hierarchy";
129 return nullptr; 129 return nullptr;
130 } 130 }
131 131
132 if (surface->HasSurfaceDelegate()) { 132 if (surface->HasSurfaceDelegate()) {
133 DLOG(ERROR) << "Surface has already been assigned a role"; 133 DLOG(ERROR) << "Surface has already been assigned a role";
134 return nullptr; 134 return nullptr;
135 } 135 }
136 136
137 // Determine the initial bounds for popup. |position| is relative to the 137 // Determine the initial bounds for popup. |position| is relative to the
138 // parent's main surface origin and initial bounds are relative to the 138 // parent's main surface origin and initial bounds are relative to the
139 // container origin. 139 // container origin.
140 gfx::Rect initial_bounds(position, gfx::Size(1, 1)); 140 gfx::Rect initial_bounds(position, gfx::Size(1, 1));
141 aura::Window::ConvertRectToTarget( 141 aura::Window::ConvertRectToTarget(
142 ShellSurface::GetMainSurface(parent->GetWidget()->GetNativeWindow()) 142 ShellSurface::GetMainSurface(parent->GetWidget()->GetNativeWindow())
143 ->window(), 143 ->window(),
144 parent->GetWidget()->GetNativeWindow()->parent(), &initial_bounds); 144 parent->GetWidget()->GetNativeWindow()->parent(), &initial_bounds);
145 145
146 return base::WrapUnique( 146 return base::MakeUnique<ShellSurface>(surface, parent, initial_bounds,
147 new ShellSurface(surface, parent, initial_bounds, false /* activatable */, 147 false /* activatable */,
148 ash::kShellWindowId_DefaultContainer)); 148 ash::kShellWindowId_DefaultContainer);
149 } 149 }
150 150
151 std::unique_ptr<ShellSurface> Display::CreateRemoteShellSurface( 151 std::unique_ptr<ShellSurface> Display::CreateRemoteShellSurface(
152 Surface* surface, 152 Surface* surface,
153 int container) { 153 int container) {
154 TRACE_EVENT2("exo", "Display::CreateRemoteShellSurface", "surface", 154 TRACE_EVENT2("exo", "Display::CreateRemoteShellSurface", "surface",
155 surface->AsTracedValue(), "container", container); 155 surface->AsTracedValue(), "container", container);
156 156
157 if (surface->HasSurfaceDelegate()) { 157 if (surface->HasSurfaceDelegate()) {
158 DLOG(ERROR) << "Surface has already been assigned a role"; 158 DLOG(ERROR) << "Surface has already been assigned a role";
159 return nullptr; 159 return nullptr;
160 } 160 }
161 161
162 return base::WrapUnique(new ShellSurface(surface, nullptr, gfx::Rect(1, 1), 162 return base::MakeUnique<ShellSurface>(surface, nullptr, gfx::Rect(1, 1),
163 true /* activatable */, container)); 163 true /* activatable */, container);
164 } 164 }
165 165
166 std::unique_ptr<SubSurface> Display::CreateSubSurface(Surface* surface, 166 std::unique_ptr<SubSurface> Display::CreateSubSurface(Surface* surface,
167 Surface* parent) { 167 Surface* parent) {
168 TRACE_EVENT2("exo", "Display::CreateSubSurface", "surface", 168 TRACE_EVENT2("exo", "Display::CreateSubSurface", "surface",
169 surface->AsTracedValue(), "parent", parent->AsTracedValue()); 169 surface->AsTracedValue(), "parent", parent->AsTracedValue());
170 170
171 if (surface->window()->Contains(parent->window())) { 171 if (surface->window()->Contains(parent->window())) {
172 DLOG(ERROR) << "Parent is contained within surface's hierarchy"; 172 DLOG(ERROR) << "Parent is contained within surface's hierarchy";
173 return nullptr; 173 return nullptr;
174 } 174 }
175 175
176 if (surface->HasSurfaceDelegate()) { 176 if (surface->HasSurfaceDelegate()) {
177 DLOG(ERROR) << "Surface has already been assigned a role"; 177 DLOG(ERROR) << "Surface has already been assigned a role";
178 return nullptr; 178 return nullptr;
179 } 179 }
180 180
181 return base::WrapUnique(new SubSurface(surface, parent)); 181 return base::MakeUnique<SubSurface>(surface, parent);
182 } 182 }
183 183
184 std::unique_ptr<NotificationSurface> Display::CreateNotificationSurface( 184 std::unique_ptr<NotificationSurface> Display::CreateNotificationSurface(
185 Surface* surface, 185 Surface* surface,
186 const std::string& notification_id) { 186 const std::string& notification_id) {
187 TRACE_EVENT2("exo", "Display::CreateNotificationSurface", "surface", 187 TRACE_EVENT2("exo", "Display::CreateNotificationSurface", "surface",
188 surface->AsTracedValue(), "notification_id", notification_id); 188 surface->AsTracedValue(), "notification_id", notification_id);
189 189
190 if (!notification_surface_manager_ || 190 if (!notification_surface_manager_ ||
191 notification_surface_manager_->GetSurface(notification_id)) { 191 notification_surface_manager_->GetSurface(notification_id)) {
192 DLOG(ERROR) << "Invalid notification id, id=" << notification_id; 192 DLOG(ERROR) << "Invalid notification id, id=" << notification_id;
193 return nullptr; 193 return nullptr;
194 } 194 }
195 195
196 return base::MakeUnique<NotificationSurface>(notification_surface_manager_, 196 return base::MakeUnique<NotificationSurface>(notification_surface_manager_,
197 surface, notification_id); 197 surface, notification_id);
198 } 198 }
199 199
200 } // namespace exo 200 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/buffer.cc ('k') | components/exo/shared_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698