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..870fc7093a49770399f087c862d1df34e97bf37a 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,6 +61,7 @@ |
| #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" |
|
fooishbar
2016/10/13 16:55:34
oops - this needs to go too.
|
| #include "ipc/unix_domain_socket_util.h" |
| #include "third_party/skia/include/core/SkRegion.h" |
| #include "ui/aura/window_property.h" |
| @@ -154,6 +156,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 +770,111 @@ void bind_linux_dmabuf(wl_client* client, |
| zwp_linux_dmabuf_v1_send_format(resource, supported_format.dmabuf_format); |
| } |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// synchronization interface: |
| + |
| +// Implements the synchronization interface to a Surface. A window property |
| +// will be set during the lifetime of this class to prevent multiple instances |
| +// from being created for the same Surface. |
| +class Synchronization : public SurfaceObserver { |
| + 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, false); |
| + } |
| + } |
| + |
| + bool SetAcquireFence(base::ScopedFD fd) { |
| + std::unique_ptr<gfx::GpuFence> fence; |
| + |
| + 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
|
| + 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, |
| + in32_t fd) { |
|
reveman
2016/10/13 17:26:01
s/in32_t/int32_t/
|
| + Synchronization* synchronization = GetUserDataAs<Synchronization>(resource); |
| + |
| + if (!synchronization->SetAcquireFence(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 |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -2981,6 +3094,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); |