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 "components/exo/wayland/server.h" | 5 #include "components/exo/wayland/server.h" |
| 6 | 6 |
| 7 #include <grp.h> | 7 #include <grp.h> |
| 8 #include <linux/input.h> | 8 #include <linux/input.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| 11 #include <viewporter-server-protocol.h> | 11 #include <viewporter-server-protocol.h> |
| 12 #include <wayland-server-core.h> | 12 #include <wayland-server-core.h> |
| 13 #include <wayland-server-protocol-core.h> | 13 #include <wayland-server-protocol-core.h> |
| 14 | 14 |
| 15 // Note: core wayland headers need to be included before protocol headers. | 15 // Note: core wayland headers need to be included before protocol headers. |
| 16 #include <alpha-compositing-unstable-v1-server-protocol.h> // NOLINT | 16 #include <alpha-compositing-unstable-v1-server-protocol.h> // NOLINT |
| 17 #include <linux-explicit-synchronization-unstable-v1-server-protocol.h> // NOLI NT | |
| 17 #include <gaming-input-unstable-v1-server-protocol.h> // NOLINT | 18 #include <gaming-input-unstable-v1-server-protocol.h> // NOLINT |
| 18 #include <remote-shell-unstable-v1-server-protocol.h> // NOLINT | 19 #include <remote-shell-unstable-v1-server-protocol.h> // NOLINT |
| 19 #include <secure-output-unstable-v1-server-protocol.h> // NOLINT | 20 #include <secure-output-unstable-v1-server-protocol.h> // NOLINT |
| 20 #include <stylus-unstable-v1-server-protocol.h> // NOLINT | 21 #include <stylus-unstable-v1-server-protocol.h> // NOLINT |
| 21 #include <xdg-shell-unstable-v5-server-protocol.h> // NOLINT | 22 #include <xdg-shell-unstable-v5-server-protocol.h> // NOLINT |
| 22 #include <vsync-feedback-unstable-v1-server-protocol.h> // NOLINT | 23 #include <vsync-feedback-unstable-v1-server-protocol.h> // NOLINT |
| 23 | 24 |
| 24 #include <algorithm> | 25 #include <algorithm> |
| 25 #include <cstdlib> | 26 #include <cstdlib> |
| 26 #include <iterator> | 27 #include <iterator> |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 53 #include "components/exo/pointer_delegate.h" | 54 #include "components/exo/pointer_delegate.h" |
| 54 #include "components/exo/pointer_stylus_delegate.h" | 55 #include "components/exo/pointer_stylus_delegate.h" |
| 55 #include "components/exo/shared_memory.h" | 56 #include "components/exo/shared_memory.h" |
| 56 #include "components/exo/shell_surface.h" | 57 #include "components/exo/shell_surface.h" |
| 57 #include "components/exo/sub_surface.h" | 58 #include "components/exo/sub_surface.h" |
| 58 #include "components/exo/surface.h" | 59 #include "components/exo/surface.h" |
| 59 #include "components/exo/surface_property.h" | 60 #include "components/exo/surface_property.h" |
| 60 #include "components/exo/touch.h" | 61 #include "components/exo/touch.h" |
| 61 #include "components/exo/touch_delegate.h" | 62 #include "components/exo/touch_delegate.h" |
| 62 #include "components/exo/wm_helper.h" | 63 #include "components/exo/wm_helper.h" |
| 64 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | |
|
fooishbar
2016/10/13 16:55:34
oops - this needs to go too.
| |
| 63 #include "ipc/unix_domain_socket_util.h" | 65 #include "ipc/unix_domain_socket_util.h" |
| 64 #include "third_party/skia/include/core/SkRegion.h" | 66 #include "third_party/skia/include/core/SkRegion.h" |
| 65 #include "ui/aura/window_property.h" | 67 #include "ui/aura/window_property.h" |
| 66 #include "ui/base/hit_test.h" | 68 #include "ui/base/hit_test.h" |
| 67 #include "ui/compositor/compositor_vsync_manager.h" | 69 #include "ui/compositor/compositor_vsync_manager.h" |
| 68 #include "ui/display/display_observer.h" | 70 #include "ui/display/display_observer.h" |
| 69 #include "ui/display/manager/managed_display_info.h" | 71 #include "ui/display/manager/managed_display_info.h" |
| 70 #include "ui/display/screen.h" | 72 #include "ui/display/screen.h" |
| 71 #include "ui/events/keycodes/dom/keycode_converter.h" | 73 #include "ui/events/keycodes/dom/keycode_converter.h" |
| 72 #include "ui/gfx/buffer_format_util.h" | 74 #include "ui/gfx/buffer_format_util.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 DEFINE_SURFACE_PROPERTY_KEY(bool, kSurfaceHasViewportKey, false); | 149 DEFINE_SURFACE_PROPERTY_KEY(bool, kSurfaceHasViewportKey, false); |
| 148 | 150 |
| 149 // A property key containing a boolean set to true if a security object is | 151 // A property key containing a boolean set to true if a security object is |
| 150 // associated with window. | 152 // associated with window. |
| 151 DEFINE_SURFACE_PROPERTY_KEY(bool, kSurfaceHasSecurityKey, false); | 153 DEFINE_SURFACE_PROPERTY_KEY(bool, kSurfaceHasSecurityKey, false); |
| 152 | 154 |
| 153 // A property key containing a boolean set to true if a blending object is | 155 // A property key containing a boolean set to true if a blending object is |
| 154 // associated with window. | 156 // associated with window. |
| 155 DEFINE_SURFACE_PROPERTY_KEY(bool, kSurfaceHasBlendingKey, false); | 157 DEFINE_SURFACE_PROPERTY_KEY(bool, kSurfaceHasBlendingKey, false); |
| 156 | 158 |
| 159 #if defined(USE_OZONE) | |
| 160 // A property key containing a boolean set to true if a blending object is | |
| 161 // associated with window. | |
| 162 DEFINE_SURFACE_PROPERTY_KEY(bool, kSurfaceHasSynchronizationKey, false); | |
| 163 #endif | |
| 164 | |
| 157 wl_resource* GetSurfaceResource(Surface* surface) { | 165 wl_resource* GetSurfaceResource(Surface* surface) { |
| 158 return surface->GetProperty(kSurfaceResourceKey); | 166 return surface->GetProperty(kSurfaceResourceKey); |
| 159 } | 167 } |
| 160 | 168 |
| 161 //////////////////////////////////////////////////////////////////////////////// | 169 //////////////////////////////////////////////////////////////////////////////// |
| 162 // wl_buffer_interface: | 170 // wl_buffer_interface: |
| 163 | 171 |
| 164 void buffer_destroy(wl_client* client, wl_resource* resource) { | 172 void buffer_destroy(wl_client* client, wl_resource* resource) { |
| 165 wl_resource_destroy(resource); | 173 wl_resource_destroy(resource); |
| 166 } | 174 } |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 755 wl_resource* resource = | 763 wl_resource* resource = |
| 756 wl_resource_create(client, &zwp_linux_dmabuf_v1_interface, 1, id); | 764 wl_resource_create(client, &zwp_linux_dmabuf_v1_interface, 1, id); |
| 757 | 765 |
| 758 wl_resource_set_implementation(resource, &linux_dmabuf_implementation, data, | 766 wl_resource_set_implementation(resource, &linux_dmabuf_implementation, data, |
| 759 nullptr); | 767 nullptr); |
| 760 | 768 |
| 761 for (const auto& supported_format : dmabuf_supported_formats) | 769 for (const auto& supported_format : dmabuf_supported_formats) |
| 762 zwp_linux_dmabuf_v1_send_format(resource, supported_format.dmabuf_format); | 770 zwp_linux_dmabuf_v1_send_format(resource, supported_format.dmabuf_format); |
| 763 } | 771 } |
| 764 | 772 |
| 773 //////////////////////////////////////////////////////////////////////////////// | |
| 774 // synchronization interface: | |
| 775 | |
| 776 // Implements the synchronization interface to a Surface. A window property | |
| 777 // will be set during the lifetime of this class to prevent multiple instances | |
| 778 // from being created for the same Surface. | |
| 779 class Synchronization : public SurfaceObserver { | |
| 780 public: | |
| 781 explicit Synchronization(Display* display, Surface* surface) | |
| 782 : surface_(surface), display_(display) { | |
| 783 surface_->AddSurfaceObserver(this); | |
| 784 surface_->SetProperty(kSurfaceHasSynchronizationKey, true); | |
| 785 } | |
| 786 ~Synchronization() override { | |
| 787 if (surface_) { | |
| 788 surface_->RemoveSurfaceObserver(this); | |
| 789 surface_->SetProperty(kSurfaceHasSynchronizationKey, false); | |
| 790 } | |
| 791 } | |
| 792 | |
| 793 bool SetAcquireFence(base::ScopedFD fd) { | |
| 794 std::unique_ptr<gfx::GpuFence> fence; | |
| 795 | |
| 796 fence = display_->CreateLinuxFence(fd); | |
|
reveman
2016/10/13 17:13:51
nit: std::unique_ptr<gfx::GpuFence> fence = displa
reveman
2016/10/13 17:26:01
also, you need to use std::move(fd) here
| |
| 797 if (!fence) | |
| 798 return false; | |
| 799 | |
| 800 surface_->SetAcquireFence(std::move(fence)); | |
| 801 return true; | |
| 802 } | |
| 803 | |
| 804 void OnSurfaceDestroying(Surface* surface) override { | |
| 805 surface->RemoveSurfaceObserver(this); | |
| 806 surface_ = nullptr; | |
| 807 } | |
| 808 | |
| 809 private: | |
| 810 Surface* surface_; | |
| 811 Display* display_; | |
| 812 | |
| 813 DISALLOW_COPY_AND_ASSIGN(Synchronization); | |
| 814 }; | |
| 815 | |
| 816 void synchronization_destroy(wl_client* client, wl_resource* resource) { | |
| 817 wl_resource_destroy(resource); | |
| 818 } | |
| 819 | |
| 820 void synchronization_set_acquire_fence(wl_client* client, | |
| 821 wl_resource* resource, | |
| 822 in32_t fd) { | |
|
reveman
2016/10/13 17:26:01
s/in32_t/int32_t/
| |
| 823 Synchronization* synchronization = GetUserDataAs<Synchronization>(resource); | |
| 824 | |
| 825 if (!synchronization->SetAcquireFence(base::ScopedFD(fd))) { | |
| 826 wl_resource_post_error(resource, ZCR_SYNCHRONIZATION_V1_ERROR_INVALID_FENCE, | |
| 827 "fence creation failed"); | |
| 828 } | |
| 829 } | |
| 830 | |
| 831 const struct zcr_synchronization_v1_interface synchronization_implementation = { | |
| 832 synchronization_destroy, synchronization_set_acquire_fence}; | |
| 833 | |
| 834 //////////////////////////////////////////////////////////////////////////////// | |
| 835 // linux_explicit_synchronization interface: | |
| 836 | |
| 837 void linux_explicit_synchronization_destroy(wl_client* client, | |
| 838 wl_resource* resource) { | |
| 839 wl_resource_destroy(resource); | |
| 840 } | |
| 841 | |
| 842 void linux_explicit_synchronization_get_surface(wl_client* client, | |
| 843 wl_resource* resource, | |
| 844 uint32_t id, | |
| 845 wl_resource* surface_resource) { | |
| 846 Display* display = GetUserDataAs<Display>(resource); | |
| 847 Surface* surface = GetUserDataAs<Surface>(surface_resource); | |
| 848 | |
| 849 if (surface->GetProperty(kSurfaceHasSynchronizationKey)) { | |
| 850 wl_resource_post_error( | |
| 851 resource, | |
| 852 ZCR_LINUX_EXPLICIT_SYNCHRONIZATION_V1_ERROR_SYNCHRONIZATION_EXISTS, | |
| 853 "a synchronization object for that surface already exists"); | |
| 854 return; | |
| 855 } | |
| 856 | |
| 857 wl_resource* synchronization_resource = | |
| 858 wl_resource_create(client, &zcr_synchronization_v1_interface, 1, id); | |
| 859 | |
| 860 SetImplementation(synchronization_resource, &synchronization_implementation, | |
| 861 base::MakeUnique<Synchronization>(display, surface)); | |
| 862 } | |
| 863 | |
| 864 const struct zcr_linux_explicit_synchronization_v1_interface | |
| 865 linux_explicit_synchronization_implementation = { | |
| 866 linux_explicit_synchronization_destroy, | |
| 867 linux_explicit_synchronization_get_surface}; | |
| 868 | |
| 869 void bind_linux_explicit_synchronization(wl_client* client, | |
| 870 void* data, | |
| 871 uint32_t version, | |
| 872 uint32_t id) { | |
| 873 wl_resource* resource = wl_resource_create( | |
| 874 client, &zcr_linux_explicit_synchronization_v1_interface, 1, id); | |
| 875 wl_resource_set_implementation( | |
| 876 resource, &linux_explicit_synchronization_implementation, data, nullptr); | |
| 877 } | |
| 765 #endif | 878 #endif |
| 766 | 879 |
| 767 //////////////////////////////////////////////////////////////////////////////// | 880 //////////////////////////////////////////////////////////////////////////////// |
| 768 // wl_subsurface_interface: | 881 // wl_subsurface_interface: |
| 769 | 882 |
| 770 void subsurface_destroy(wl_client* client, wl_resource* resource) { | 883 void subsurface_destroy(wl_client* client, wl_resource* resource) { |
| 771 wl_resource_destroy(resource); | 884 wl_resource_destroy(resource); |
| 772 } | 885 } |
| 773 | 886 |
| 774 void subsurface_set_position(wl_client* client, | 887 void subsurface_set_position(wl_client* client, |
| (...skipping 2199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2974 Server::Server(Display* display) | 3087 Server::Server(Display* display) |
| 2975 : display_(display), wl_display_(wl_display_create()) { | 3088 : display_(display), wl_display_(wl_display_create()) { |
| 2976 wl_global_create(wl_display_.get(), &wl_compositor_interface, | 3089 wl_global_create(wl_display_.get(), &wl_compositor_interface, |
| 2977 compositor_version, display_, bind_compositor); | 3090 compositor_version, display_, bind_compositor); |
| 2978 wl_global_create(wl_display_.get(), &wl_shm_interface, 1, display_, bind_shm); | 3091 wl_global_create(wl_display_.get(), &wl_shm_interface, 1, display_, bind_shm); |
| 2979 #if defined(USE_OZONE) | 3092 #if defined(USE_OZONE) |
| 2980 wl_global_create(wl_display_.get(), &wl_drm_interface, drm_version, display_, | 3093 wl_global_create(wl_display_.get(), &wl_drm_interface, drm_version, display_, |
| 2981 bind_drm); | 3094 bind_drm); |
| 2982 wl_global_create(wl_display_.get(), &zwp_linux_dmabuf_v1_interface, 1, | 3095 wl_global_create(wl_display_.get(), &zwp_linux_dmabuf_v1_interface, 1, |
| 2983 display_, bind_linux_dmabuf); | 3096 display_, bind_linux_dmabuf); |
| 3097 wl_global_create(wl_display_.get(), | |
| 3098 &zcr_linux_explicit_synchronization_v1_interface, 1, | |
| 3099 display_, bind_linux_explicit_synchronization); | |
| 2984 #endif | 3100 #endif |
| 2985 wl_global_create(wl_display_.get(), &wl_subcompositor_interface, 1, display_, | 3101 wl_global_create(wl_display_.get(), &wl_subcompositor_interface, 1, display_, |
| 2986 bind_subcompositor); | 3102 bind_subcompositor); |
| 2987 wl_global_create(wl_display_.get(), &wl_shell_interface, 1, display_, | 3103 wl_global_create(wl_display_.get(), &wl_shell_interface, 1, display_, |
| 2988 bind_shell); | 3104 bind_shell); |
| 2989 wl_global_create(wl_display_.get(), &wl_output_interface, output_version, | 3105 wl_global_create(wl_display_.get(), &wl_output_interface, output_version, |
| 2990 display_, bind_output); | 3106 display_, bind_output); |
| 2991 wl_global_create(wl_display_.get(), &xdg_shell_interface, 1, display_, | 3107 wl_global_create(wl_display_.get(), &xdg_shell_interface, 1, display_, |
| 2992 bind_xdg_shell); | 3108 bind_xdg_shell); |
| 2993 wl_global_create(wl_display_.get(), &zcr_vsync_feedback_v1_interface, 1, | 3109 wl_global_create(wl_display_.get(), &zcr_vsync_feedback_v1_interface, 1, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3072 DCHECK(event_loop); | 3188 DCHECK(event_loop); |
| 3073 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 3189 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
| 3074 } | 3190 } |
| 3075 | 3191 |
| 3076 void Server::Flush() { | 3192 void Server::Flush() { |
| 3077 wl_display_flush_clients(wl_display_.get()); | 3193 wl_display_flush_clients(wl_display_.get()); |
| 3078 } | 3194 } |
| 3079 | 3195 |
| 3080 } // namespace wayland | 3196 } // namespace wayland |
| 3081 } // namespace exo | 3197 } // namespace exo |
| OLD | NEW |