| Index: components/exo/wayland/server.cc
|
| diff --git a/components/exo/wayland/server.cc b/components/exo/wayland/server.cc
|
| index 7b3d47ed80040647c1ddc52cbfadf1d94d6f513a..2e1401dff6acc5e14e867a616d8f41332ed678b1 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
|
| @@ -71,6 +72,7 @@
|
| #include "ui/events/keycodes/dom/keycode_converter.h"
|
| #include "ui/gfx/buffer_format_util.h"
|
| #include "ui/gfx/buffer_types.h"
|
| +#include "ui/gfx/gpu_fence.h"
|
| #include "ui/views/widget/widget.h"
|
| #include "ui/views/widget/widget_observer.h"
|
|
|
| @@ -154,6 +156,10 @@ DEFINE_SURFACE_PROPERTY_KEY(bool, kSurfaceHasSecurityKey, false);
|
| // associated with window.
|
| DEFINE_SURFACE_PROPERTY_KEY(bool, kSurfaceHasBlendingKey, false);
|
|
|
| +// A property key containing a boolean set to true if a synchronization object
|
| +// is associated with window.
|
| +DEFINE_SURFACE_PROPERTY_KEY(bool, kSurfaceHasSynchronizationKey, false);
|
| +
|
| wl_resource* GetSurfaceResource(Surface* surface) {
|
| return surface->GetProperty(kSurfaceResourceKey);
|
| }
|
| @@ -761,8 +767,112 @@ void bind_linux_dmabuf(wl_client* client,
|
| for (const auto& supported_format : dmabuf_supported_formats)
|
| zwp_linux_dmabuf_v1_send_format(resource, supported_format.dmabuf_format);
|
| }
|
| +#endif // defined(USE_OZONE)
|
|
|
| -#endif
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// 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 =
|
| + display_->CreateLinuxFence(std::move(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,
|
| + int32_t fd) {
|
| + 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);
|
| +}
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // wl_subsurface_interface:
|
| @@ -2981,7 +3091,10 @@ Server::Server(Display* display)
|
| bind_drm);
|
| wl_global_create(wl_display_.get(), &zwp_linux_dmabuf_v1_interface, 1,
|
| display_, bind_linux_dmabuf);
|
| -#endif
|
| +#endif // defined(USE_OZONE)
|
| + wl_global_create(wl_display_.get(),
|
| + &zcr_linux_explicit_synchronization_v1_interface, 1,
|
| + display_, bind_linux_explicit_synchronization);
|
| wl_global_create(wl_display_.get(), &wl_subcompositor_interface, 1, display_,
|
| bind_subcompositor);
|
| wl_global_create(wl_display_.get(), &wl_shell_interface, 1, display_,
|
|
|