Chromium Code Reviews| Index: components/exo/wayland/server.cc |
| diff --git a/components/exo/wayland/server.cc b/components/exo/wayland/server.cc |
| index 53b20f9432e12933ea581195d6beb1b66a0a4470..52ea82fda4b9f4dcca13508a36aff95bbc390b24 100644 |
| --- a/components/exo/wayland/server.cc |
| +++ b/components/exo/wayland/server.cc |
| @@ -14,6 +14,7 @@ |
| // Note: core wayland headers need to be included before protocol headers. |
| #include <alpha-compositing-unstable-v1-server-protocol.h> // NOLINT |
| +#include <linux-explicit-synchronization-unstable-v1-server-protocol.h> // NOLINT |
| #include <gaming-input-unstable-v1-server-protocol.h> // NOLINT |
| #include <remote-shell-unstable-v1-server-protocol.h> // NOLINT |
| #include <secure-output-unstable-v1-server-protocol.h> // NOLINT |
| @@ -60,8 +61,10 @@ |
| #include "components/exo/touch.h" |
| #include "components/exo/touch_delegate.h" |
| #include "components/exo/wm_helper.h" |
| +#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
| #include "ipc/unix_domain_socket_util.h" |
| #include "third_party/skia/include/core/SkRegion.h" |
| +#include "ui/aura/env.h" |
| #include "ui/aura/window_property.h" |
| #include "ui/base/hit_test.h" |
| #include "ui/compositor/compositor_vsync_manager.h" |
| @@ -97,7 +100,7 @@ namespace { |
| const int kConfigureDelayAfterLayoutSwitchMs = 300; |
| // Default wayland socket name. |
| -const base::FilePath::CharType kSocketName[] = FILE_PATH_LITERAL("wayland-0"); |
| +const base::FilePath::CharType kSocketName[] = FILE_PATH_LITERAL("exosphere-0"); |
|
fooishbar
2016/10/12 15:50:51
Sorry, this still crept in from git-cl having squa
reveman
2016/10/12 19:20:20
No problem. If you can remove it when you have a c
|
| // Group used for wayland socket. |
| const char kWaylandSocketGroup[] = "wayland"; |
| @@ -154,6 +157,12 @@ DEFINE_SURFACE_PROPERTY_KEY(bool, kSurfaceHasSecurityKey, false); |
| // associated with window. |
| DEFINE_SURFACE_PROPERTY_KEY(bool, kSurfaceHasBlendingKey, false); |
| +#if defined(USE_OZONE) |
| +// A property key containing a boolean set to true if a blending object is |
| +// associated with window. |
| +DEFINE_SURFACE_PROPERTY_KEY(bool, kSurfaceHasSynchronizationKey, false); |
| +#endif |
| + |
| wl_resource* GetSurfaceResource(Surface* surface) { |
| return surface->GetProperty(kSurfaceResourceKey); |
| } |
| @@ -762,6 +771,115 @@ void bind_linux_dmabuf(wl_client* client, |
| zwp_linux_dmabuf_v1_send_format(resource, supported_format.dmabuf_format); |
| } |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// synchronization interface: |
| + |
| +class Synchronization : public SurfaceObserver { |
|
reveman
2016/10/12 19:20:20
nit: add the following comment above this class:
|
| + public: |
| + explicit Synchronization(Display* display, Surface* surface) : |
| + surface_(surface), |
| + display_(display) { |
| + surface_->AddSurfaceObserver(this); |
| + surface_->SetProperty(kSurfaceHasSynchronizationKey, true); |
| + } |
| + ~Synchronization() override { |
| + if (surface_) { |
| + surface_->RemoveSurfaceObserver(this); |
| + surface_->SetProperty(kSurfaceHasSynchronizationKey, true); |
|
reveman
2016/10/12 19:20:20
s/true/false/ here
|
| + } |
| + } |
| + |
| + bool SetAcquireFence(int fd_raw) { |
|
reveman
2016/10/12 19:20:20
nit: s/int fd_raw/base::ScopedFD fd/ as it's best
|
| + std::unique_ptr<gfx::GpuFence> fence; |
|
reveman
2016/10/12 19:20:20
nit: move down where it's first used
|
| + base::ScopedFD fd(fd_raw); |
| + |
| + fence = display_->CreateLinuxFence(fd); |
| + if (!fence) |
| + return false; |
| + |
| + surface_->SetAcquireFence(std::move(fence)); |
| + return true; |
| + } |
| + |
| + void OnSurfaceDestroying(Surface* surface) override { |
| + surface->RemoveSurfaceObserver(this); |
| + surface_ = nullptr; |
| + } |
| + |
| + private: |
| + Surface* surface_; |
| + Display* display_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(Synchronization); |
| +}; |
| + |
| +void synchronization_destroy(wl_client* client, wl_resource* resource) { |
| + wl_resource_destroy(resource); |
| +} |
| + |
| +void synchronization_set_acquire_fence(wl_client* client, wl_resource* resource, |
| + int fd_raw) { |
|
reveman
2016/10/12 19:20:20
nit: s/int fd_raw/int32_t fd/
|
| + Synchronization* synchronization = GetUserDataAs<Synchronization>(resource); |
| + |
| + if (!synchronization->SetAcquireFence(fd_raw)) { |
|
reveman
2016/10/12 19:20:20
s/fd_raw/base::ScopedFD(fd)/
|
| + wl_resource_post_error(resource, |
| + ZCR_SYNCHRONIZATION_V1_ERROR_INVALID_FENCE, |
| + "fence creation failed"); |
| + } |
| +} |
| + |
| +const struct zcr_synchronization_v1_interface |
| + synchronization_implementation = { |
| + synchronization_destroy, |
| + synchronization_set_acquire_fence}; |
| + |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// linux_explicit_synchronization interface: |
| + |
| +void linux_explicit_synchronization_destroy(wl_client* client, |
| + wl_resource* resource) { |
| + wl_resource_destroy(resource); |
| +} |
| + |
| +void linux_explicit_synchronization_get_surface(wl_client* client, |
| + wl_resource* resource, |
| + uint32_t id, |
| + wl_resource* surface_resource) { |
| + Display* display = GetUserDataAs<Display>(resource); |
| + Surface* surface = GetUserDataAs<Surface>(surface_resource); |
| + |
| + if (surface->GetProperty(kSurfaceHasSynchronizationKey)) { |
| + wl_resource_post_error(resource, |
| + ZCR_LINUX_EXPLICIT_SYNCHRONIZATION_V1_ERROR_SYNCHRONIZATION_EXISTS, |
| + "a synchronization object for that surface already exists"); |
| + return; |
| + } |
| + |
| + wl_resource* synchronization_resource = |
| + wl_resource_create(client, &zcr_synchronization_v1_interface, 1, id); |
| + |
| + SetImplementation(synchronization_resource, &synchronization_implementation, |
| + base::MakeUnique<Synchronization>(display, surface)); |
| +} |
| + |
| +const struct zcr_linux_explicit_synchronization_v1_interface |
| + linux_explicit_synchronization_implementation = { |
| + linux_explicit_synchronization_destroy, |
| + linux_explicit_synchronization_get_surface}; |
| + |
| +void bind_linux_explicit_synchronization(wl_client* client, void* data, |
| + uint32_t version, uint32_t id) { |
| + wl_resource* resource = |
| + wl_resource_create(client, |
| + &zcr_linux_explicit_synchronization_v1_interface, |
| + 1, |
| + id); |
| + wl_resource_set_implementation(resource, |
| + &linux_explicit_synchronization_implementation, |
| + data, |
| + nullptr); |
| +} |
| #endif |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -2966,6 +3084,7 @@ void bind_stylus(wl_client* client, void* data, uint32_t version, uint32_t id) { |
| nullptr); |
| } |
| + |
|
reveman
2016/10/12 19:20:20
nit: no need for this blank line
|
| } // namespace |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -2981,6 +3100,9 @@ Server::Server(Display* display) |
| bind_drm); |
| wl_global_create(wl_display_.get(), &zwp_linux_dmabuf_v1_interface, 1, |
| display_, bind_linux_dmabuf); |
| + wl_global_create(wl_display_.get(), |
| + &zcr_linux_explicit_synchronization_v1_interface, 1, display_, |
| + bind_linux_explicit_synchronization); |
| #endif |
| wl_global_create(wl_display_.get(), &wl_subcompositor_interface, 1, display_, |
| bind_subcompositor); |