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

Side by Side Diff: components/exo/wayland/server.cc

Issue 1558513002: Global conversion of Pass()→std::move() on OS=linux (GYP edition) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: formatted Created 4 years, 11 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/surface.cc ('k') | no next file » | 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/wayland/server.h" 5 #include "components/exo/wayland/server.h"
6 6
7 #include <linux/input.h> 7 #include <linux/input.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <wayland-server-core.h> 10 #include <wayland-server-core.h>
11 #include <wayland-server-protocol-core.h> 11 #include <wayland-server-protocol-core.h>
12 #include <xdg-shell-unstable-v5-server-protocol.h> 12 #include <xdg-shell-unstable-v5-server-protocol.h>
13
14 #include <algorithm> 13 #include <algorithm>
14 #include <utility>
15 15
16 #include "base/bind.h" 16 #include "base/bind.h"
17 #include "base/cancelable_callback.h" 17 #include "base/cancelable_callback.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "components/exo/buffer.h" 20 #include "components/exo/buffer.h"
21 #include "components/exo/display.h" 21 #include "components/exo/display.h"
22 #include "components/exo/keyboard.h" 22 #include "components/exo/keyboard.h"
23 #include "components/exo/keyboard_delegate.h" 23 #include "components/exo/keyboard_delegate.h"
24 #include "components/exo/pointer.h" 24 #include "components/exo/pointer.h"
(...skipping 25 matching lines...) Expand all
50 50
51 template <class T> 51 template <class T>
52 T* GetUserDataAs(wl_resource* resource) { 52 T* GetUserDataAs(wl_resource* resource) {
53 return static_cast<T*>(wl_resource_get_user_data(resource)); 53 return static_cast<T*>(wl_resource_get_user_data(resource));
54 } 54 }
55 55
56 template <class T> 56 template <class T>
57 scoped_ptr<T> TakeUserDataAs(wl_resource* resource) { 57 scoped_ptr<T> TakeUserDataAs(wl_resource* resource) {
58 scoped_ptr<T> user_data = make_scoped_ptr(GetUserDataAs<T>(resource)); 58 scoped_ptr<T> user_data = make_scoped_ptr(GetUserDataAs<T>(resource));
59 wl_resource_set_user_data(resource, nullptr); 59 wl_resource_set_user_data(resource, nullptr);
60 return user_data.Pass(); 60 return user_data;
61 } 61 }
62 62
63 template <class T> 63 template <class T>
64 void DestroyUserData(wl_resource* resource) { 64 void DestroyUserData(wl_resource* resource) {
65 TakeUserDataAs<T>(resource); 65 TakeUserDataAs<T>(resource);
66 } 66 }
67 67
68 template <class T> 68 template <class T>
69 void SetImplementation(wl_resource* resource, 69 void SetImplementation(wl_resource* resource,
70 const void* implementation, 70 const void* implementation,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 // base::Unretained is safe as the resource owns the callback. 142 // base::Unretained is safe as the resource owns the callback.
143 scoped_ptr<base::CancelableCallback<void(base::TimeTicks)>> 143 scoped_ptr<base::CancelableCallback<void(base::TimeTicks)>>
144 cancelable_callback(new base::CancelableCallback<void(base::TimeTicks)>( 144 cancelable_callback(new base::CancelableCallback<void(base::TimeTicks)>(
145 base::Bind(&handle_surface_frame_callback, 145 base::Bind(&handle_surface_frame_callback,
146 base::Unretained(callback_resource)))); 146 base::Unretained(callback_resource))));
147 147
148 GetUserDataAs<Surface>(resource) 148 GetUserDataAs<Surface>(resource)
149 ->RequestFrameCallback(cancelable_callback->callback()); 149 ->RequestFrameCallback(cancelable_callback->callback());
150 150
151 SetImplementation(callback_resource, nullptr, cancelable_callback.Pass()); 151 SetImplementation(callback_resource, nullptr, std::move(cancelable_callback));
152 } 152 }
153 153
154 void surface_set_opaque_region(wl_client* client, 154 void surface_set_opaque_region(wl_client* client,
155 wl_resource* resource, 155 wl_resource* resource,
156 wl_resource* region_resource) { 156 wl_resource* region_resource) {
157 GetUserDataAs<Surface>(resource)->SetOpaqueRegion( 157 GetUserDataAs<Surface>(resource)->SetOpaqueRegion(
158 region_resource ? *GetUserDataAs<SkRegion>(region_resource) 158 region_resource ? *GetUserDataAs<SkRegion>(region_resource)
159 : SkRegion(SkIRect::MakeEmpty())); 159 : SkRegion(SkIRect::MakeEmpty()));
160 } 160 }
161 161
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 wl_resource* surface_resource = wl_resource_create( 235 wl_resource* surface_resource = wl_resource_create(
236 client, &wl_surface_interface, wl_resource_get_version(resource), id); 236 client, &wl_surface_interface, wl_resource_get_version(resource), id);
237 if (!surface_resource) { 237 if (!surface_resource) {
238 wl_resource_post_no_memory(resource); 238 wl_resource_post_no_memory(resource);
239 return; 239 return;
240 } 240 }
241 241
242 // Set the surface resource property for type-checking downcast support. 242 // Set the surface resource property for type-checking downcast support.
243 surface->SetProperty(kSurfaceResourceKey, surface_resource); 243 surface->SetProperty(kSurfaceResourceKey, surface_resource);
244 244
245 SetImplementation(surface_resource, &surface_implementation, surface.Pass()); 245 SetImplementation(surface_resource, &surface_implementation,
246 std::move(surface));
246 } 247 }
247 248
248 void compositor_create_region(wl_client* client, 249 void compositor_create_region(wl_client* client,
249 wl_resource* resource, 250 wl_resource* resource,
250 uint32_t id) { 251 uint32_t id) {
251 scoped_ptr<SkRegion> region(new SkRegion); 252 scoped_ptr<SkRegion> region(new SkRegion);
252 253
253 wl_resource* region_resource = 254 wl_resource* region_resource =
254 wl_resource_create(client, &wl_region_interface, 1, id); 255 wl_resource_create(client, &wl_region_interface, 1, id);
255 if (!region_resource) { 256 if (!region_resource) {
256 wl_resource_post_no_memory(resource); 257 wl_resource_post_no_memory(resource);
257 return; 258 return;
258 } 259 }
259 260
260 SetImplementation(region_resource, &region_implementation, region.Pass()); 261 SetImplementation(region_resource, &region_implementation, std::move(region));
261 } 262 }
262 263
263 const struct wl_compositor_interface compositor_implementation = { 264 const struct wl_compositor_interface compositor_implementation = {
264 compositor_create_surface, compositor_create_region}; 265 compositor_create_surface, compositor_create_region};
265 266
266 const uint32_t compositor_version = 3; 267 const uint32_t compositor_version = 3;
267 268
268 void bind_compositor(wl_client* client, 269 void bind_compositor(wl_client* client,
269 void* data, 270 void* data,
270 uint32_t version, 271 uint32_t version,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 wl_resource* buffer_resource = 333 wl_resource* buffer_resource =
333 wl_resource_create(client, &wl_buffer_interface, 1, id); 334 wl_resource_create(client, &wl_buffer_interface, 1, id);
334 if (!buffer_resource) { 335 if (!buffer_resource) {
335 wl_resource_post_no_memory(resource); 336 wl_resource_post_no_memory(resource);
336 return; 337 return;
337 } 338 }
338 339
339 buffer->set_release_callback( 340 buffer->set_release_callback(
340 base::Bind(&wl_buffer_send_release, base::Unretained(buffer_resource))); 341 base::Bind(&wl_buffer_send_release, base::Unretained(buffer_resource)));
341 342
342 SetImplementation(buffer_resource, &buffer_implementation, buffer.Pass()); 343 SetImplementation(buffer_resource, &buffer_implementation, std::move(buffer));
343 } 344 }
344 345
345 void shm_pool_destroy(wl_client* client, wl_resource* resource) { 346 void shm_pool_destroy(wl_client* client, wl_resource* resource) {
346 wl_resource_destroy(resource); 347 wl_resource_destroy(resource);
347 } 348 }
348 349
349 void shm_pool_resize(wl_client* client, wl_resource* resource, int32_t size) { 350 void shm_pool_resize(wl_client* client, wl_resource* resource, int32_t size) {
350 // Nothing to do here. 351 // Nothing to do here.
351 } 352 }
352 353
(...skipping 17 matching lines...) Expand all
370 } 371 }
371 372
372 wl_resource* shm_pool_resource = 373 wl_resource* shm_pool_resource =
373 wl_resource_create(client, &wl_shm_pool_interface, 1, id); 374 wl_resource_create(client, &wl_shm_pool_interface, 1, id);
374 if (!shm_pool_resource) { 375 if (!shm_pool_resource) {
375 wl_resource_post_no_memory(resource); 376 wl_resource_post_no_memory(resource);
376 return; 377 return;
377 } 378 }
378 379
379 SetImplementation(shm_pool_resource, &shm_pool_implementation, 380 SetImplementation(shm_pool_resource, &shm_pool_implementation,
380 shared_memory.Pass()); 381 std::move(shared_memory));
381 } 382 }
382 383
383 const struct wl_shm_interface shm_implementation = {shm_create_pool}; 384 const struct wl_shm_interface shm_implementation = {shm_create_pool};
384 385
385 void bind_shm(wl_client* client, void* data, uint32_t version, uint32_t id) { 386 void bind_shm(wl_client* client, void* data, uint32_t version, uint32_t id) {
386 wl_resource* resource = wl_resource_create(client, &wl_shm_interface, 1, id); 387 wl_resource* resource = wl_resource_create(client, &wl_shm_interface, 1, id);
387 if (!resource) { 388 if (!resource) {
388 wl_client_post_no_memory(client); 389 wl_client_post_no_memory(client);
389 return; 390 return;
390 } 391 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 } 575 }
575 576
576 wl_resource* subsurface_resource = 577 wl_resource* subsurface_resource =
577 wl_resource_create(client, &wl_subsurface_interface, 1, id); 578 wl_resource_create(client, &wl_subsurface_interface, 1, id);
578 if (!subsurface_resource) { 579 if (!subsurface_resource) {
579 wl_resource_post_no_memory(resource); 580 wl_resource_post_no_memory(resource);
580 return; 581 return;
581 } 582 }
582 583
583 SetImplementation(subsurface_resource, &subsurface_implementation, 584 SetImplementation(subsurface_resource, &subsurface_implementation,
584 subsurface.Pass()); 585 std::move(subsurface));
585 } 586 }
586 587
587 const struct wl_subcompositor_interface subcompositor_implementation = { 588 const struct wl_subcompositor_interface subcompositor_implementation = {
588 subcompositor_destroy, subcompositor_get_subsurface}; 589 subcompositor_destroy, subcompositor_get_subsurface};
589 590
590 void bind_subcompositor(wl_client* client, 591 void bind_subcompositor(wl_client* client,
591 void* data, 592 void* data,
592 uint32_t version, 593 uint32_t version,
593 uint32_t id) { 594 uint32_t id) {
594 wl_resource* resource = 595 wl_resource* resource =
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 } 700 }
700 701
701 wl_resource* shell_surface_resource = 702 wl_resource* shell_surface_resource =
702 wl_resource_create(client, &wl_shell_surface_interface, 1, id); 703 wl_resource_create(client, &wl_shell_surface_interface, 1, id);
703 if (!shell_surface_resource) { 704 if (!shell_surface_resource) {
704 wl_resource_post_no_memory(resource); 705 wl_resource_post_no_memory(resource);
705 return; 706 return;
706 } 707 }
707 708
708 SetImplementation(shell_surface_resource, &shell_surface_implementation, 709 SetImplementation(shell_surface_resource, &shell_surface_implementation,
709 shell_surface.Pass()); 710 std::move(shell_surface));
710 } 711 }
711 712
712 const struct wl_shell_interface shell_implementation = { 713 const struct wl_shell_interface shell_implementation = {
713 shell_get_shell_surface}; 714 shell_get_shell_surface};
714 715
715 void bind_shell(wl_client* client, void* data, uint32_t version, uint32_t id) { 716 void bind_shell(wl_client* client, void* data, uint32_t version, uint32_t id) {
716 wl_resource* resource = 717 wl_resource* resource =
717 wl_resource_create(client, &wl_shell_interface, 1, id); 718 wl_resource_create(client, &wl_shell_interface, 1, id);
718 if (!resource) { 719 if (!resource) {
719 wl_client_post_no_memory(client); 720 wl_client_post_no_memory(client);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 wl_resource_create(client, &xdg_surface_interface, 1, id); 865 wl_resource_create(client, &xdg_surface_interface, 1, id);
865 if (!xdg_surface_resource) { 866 if (!xdg_surface_resource) {
866 wl_resource_post_no_memory(resource); 867 wl_resource_post_no_memory(resource);
867 return; 868 return;
868 } 869 }
869 870
870 // An XdgSurface is a toplevel shell surface. 871 // An XdgSurface is a toplevel shell surface.
871 shell_surface->SetToplevel(); 872 shell_surface->SetToplevel();
872 873
873 SetImplementation(xdg_surface_resource, &xdg_surface_implementation, 874 SetImplementation(xdg_surface_resource, &xdg_surface_implementation,
874 shell_surface.Pass()); 875 std::move(shell_surface));
875 } 876 }
876 877
877 void xdg_shell_get_xdg_popup(wl_client* client, 878 void xdg_shell_get_xdg_popup(wl_client* client,
878 wl_resource* resource, 879 wl_resource* resource,
879 uint32_t id, 880 uint32_t id,
880 wl_resource* surface, 881 wl_resource* surface,
881 wl_resource* parent, 882 wl_resource* parent,
882 wl_resource* seat, 883 wl_resource* seat,
883 uint32_t serial, 884 uint32_t serial,
884 int32_t x, 885 int32_t x,
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 DCHECK(event_loop); 1446 DCHECK(event_loop);
1446 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); 1447 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds());
1447 } 1448 }
1448 1449
1449 void Server::Flush() { 1450 void Server::Flush() {
1450 wl_display_flush_clients(wl_display_.get()); 1451 wl_display_flush_clients(wl_display_.get());
1451 } 1452 }
1452 1453
1453 } // namespace wayland 1454 } // namespace wayland
1454 } // namespace exo 1455 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/surface.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698