// Code generated by wlbgen. DO NOT EDIT. // Protocol: zwp_linux_explicit_synchronization_unstable_v1 // Source: linux-explicit-synchronization-unstable-v1.xml // Upstream protocol copyright and license: // Copyright 2016 The Chromium Authors. // Copyright 2017 Intel Corporation // Copyright 2018 Collabora, Ltd // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice (including the next // paragraph) shall be included in all copies or substantial portions of the // Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. package linuxexplicitsynchronization import ( "sync" cross_wl_surface "github.com/bnema/go-wayland-bindings/client/wayland" "github.com/bnema/wlturbo/wl" ) // ERROR_SYNCHRONIZATION_EXISTS is the error synchronization_exists value. const ERROR_SYNCHRONIZATION_EXISTS = 0 // ERROR_INVALID_FENCE is the error invalid_fence value. const ERROR_INVALID_FENCE = 0 // ERROR_DUPLICATE_FENCE is the error duplicate_fence value. const ERROR_DUPLICATE_FENCE = 1 // ERROR_DUPLICATE_RELEASE is the error duplicate_release value. const ERROR_DUPLICATE_RELEASE = 2 // ERROR_NO_SURFACE is the error no_surface value. const ERROR_NO_SURFACE = 3 // ERROR_UNSUPPORTED_BUFFER is the error unsupported_buffer value. const ERROR_UNSUPPORTED_BUFFER = 4 // ERROR_NO_BUFFER is the error no_buffer value. const ERROR_NO_BUFFER = 5 // LinuxExplicitSynchronizationInterface is the protocol interface name. const LinuxExplicitSynchronizationInterface = "zwp_linux_explicit_synchronization_v1" // LinuxExplicitSynchronization is the generated binding for zwp_linux_explicit_synchronization_v1 version 2. type LinuxExplicitSynchronization struct { wl.BaseProxy } // NewLinuxExplicitSynchronization returns an unbound LinuxExplicitSynchronization. func NewLinuxExplicitSynchronization(ctx *wl.Context) *LinuxExplicitSynchronization { obj := &LinuxExplicitSynchronization{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Destroy this explicit synchronization factory object. Other objects, including zwp_linux_surface_synchronization_v1 objects created by this factory, shall not be affected by this request. func (o *LinuxExplicitSynchronization) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_linux_explicit_synchronization_v1.destroy", Destructor: true}); err != nil { return err } return nil } // Instantiate an interface extension for the given wl_surface to provide explicit synchronization. If the given wl_surface already has an explicit synchronization object associated, the synchronization_exists protocol error is raised. Graphics APIs, like EGL or Vulkan, that manage the buffer queue and commits of a wl_surface themselves, are likely to be using this extension internally. If a client is using such an API for a wl_surface, it should not directly use this extension on that surface, to avoid raising a synchronization_exists protocol error. func (o *LinuxExplicitSynchronization) GetSynchronization(surface *cross_wl_surface.Surface) (*LinuxSurfaceSynchronization, error) { var arg1 wl.Object if surface != nil { arg1 = surface } child := &LinuxSurfaceSynchronization{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_linux_explicit_synchronization_v1.get_synchronization", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil { return nil, err } return child, nil } // EventSignature returns the declared event argument types in wire order. func (o *LinuxExplicitSynchronization) EventSignature(opcode uint16) (string, bool) { switch opcode { default: return "", false } } // Dispatch decodes one event on zwp_linux_explicit_synchronization_v1 and calls the registered handlers. func (o *LinuxExplicitSynchronization) Dispatch(event *wl.Event) { switch event.Opcode { default: } } // LinuxSurfaceSynchronizationInterface is the protocol interface name. const LinuxSurfaceSynchronizationInterface = "zwp_linux_surface_synchronization_v1" // LinuxSurfaceSynchronization is the generated binding for zwp_linux_surface_synchronization_v1 version 2. type LinuxSurfaceSynchronization struct { wl.BaseProxy } // NewLinuxSurfaceSynchronization returns an unbound LinuxSurfaceSynchronization. func NewLinuxSurfaceSynchronization(ctx *wl.Context) *LinuxSurfaceSynchronization { obj := &LinuxSurfaceSynchronization{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Destroy this explicit synchronization object. Any fence set by this object with set_acquire_fence since the last commit will be discarded by the server. Any fences set by this object before the last commit are not affected. zwp_linux_buffer_release_v1 objects created by this object are not affected by this request. func (o *LinuxSurfaceSynchronization) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_linux_surface_synchronization_v1.destroy", Destructor: true}); err != nil { return err } return nil } // Set the acquire fence that must be signaled before the compositor may sample from the buffer attached with wl_surface.attach. The fence is a dma_fence kernel object. The acquire fence is double-buffered state, and will be applied on the next wl_surface.commit request for the associated surface. Thus, it applies only to the buffer that is attached to the surface at commit time. If the provided fd is not a valid dma_fence fd, then an INVALID_FENCE error is raised. If a fence has already been attached during the same commit cycle, a DUPLICATE_FENCE error is raised. If the associated wl_surface was destroyed, a NO_SURFACE error is raised. If at surface commit time the attached buffer does not support explicit synchronization, an UNSUPPORTED_BUFFER error is raised. If at surface commit time there is no buffer attached, a NO_BUFFER error is raised. func (o *LinuxSurfaceSynchronization) SetAcquireFence(fd int) error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_linux_surface_synchronization_v1.set_acquire_fence", FDs: []int{fd}}, wl.ArgFD()); err != nil { return err } return nil } // Create a listener for the release of the buffer attached by the client with wl_surface.attach. See zwp_linux_buffer_release_v1 documentation for more information. The release object is double-buffered state, and will be associated with the buffer that is attached to the surface at wl_surface.commit time. If a zwp_linux_buffer_release_v1 object has already been requested for the surface in the same commit cycle, a DUPLICATE_RELEASE error is raised. If the associated wl_surface was destroyed, a NO_SURFACE error is raised. If at surface commit time there is no buffer attached, a NO_BUFFER error is raised. func (o *LinuxSurfaceSynchronization) GetRelease() (*LinuxBufferRelease, error) { child := &LinuxBufferRelease{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "zwp_linux_surface_synchronization_v1.get_release", Child: child}, wl.ArgObject(child)); err != nil { return nil, err } return child, nil } // EventSignature returns the declared event argument types in wire order. func (o *LinuxSurfaceSynchronization) EventSignature(opcode uint16) (string, bool) { switch opcode { default: return "", false } } // Dispatch decodes one event on zwp_linux_surface_synchronization_v1 and calls the registered handlers. func (o *LinuxSurfaceSynchronization) Dispatch(event *wl.Event) { switch event.Opcode { default: } } // LinuxBufferReleaseInterface is the protocol interface name. const LinuxBufferReleaseInterface = "zwp_linux_buffer_release_v1" // LinuxBufferRelease is the generated binding for zwp_linux_buffer_release_v1 version 1. type LinuxBufferRelease struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onFencedRelease []func(fence *wl.OwnedFD) onImmediateRelease []func() } // NewLinuxBufferRelease returns an unbound LinuxBufferRelease. func NewLinuxBufferRelease(ctx *wl.Context) *LinuxBufferRelease { obj := &LinuxBufferRelease{} obj.SetContext(ctx) ctx.Register(obj) return obj } // OnFencedRelease registers a handler for the fenced_release event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *LinuxBufferRelease) OnFencedRelease(handler func(fence *wl.OwnedFD)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onFencedRelease = append(o.onFencedRelease, handler) } // handlersForFencedRelease returns the handlers registered for fenced_release, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *LinuxBufferRelease) handlersForFencedRelease() []func(fence *wl.OwnedFD) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onFencedRelease } // OnImmediateRelease registers a handler for the immediate_release event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *LinuxBufferRelease) OnImmediateRelease(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onImmediateRelease = append(o.onImmediateRelease, handler) } // handlersForImmediateRelease returns the handlers registered for immediate_release, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *LinuxBufferRelease) handlersForImmediateRelease() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onImmediateRelease } // EventSignature returns the declared event argument types in wire order. func (o *LinuxBufferRelease) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "fd,", true case 1: return "", true default: return "", false } } // Dispatch decodes one event on zwp_linux_buffer_release_v1 and calls the registered handlers. func (o *LinuxBufferRelease) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // fenced_release fence := event.FD() ownedfence := fence defer ownedfence.Close() for i, handler := range o.handlersForFencedRelease() { if i > 0 { fence = nil } handler(fence) } o.Context().Unregister(o) case 1: // immediate_release for i, handler := range o.handlersForImmediateRelease() { _ = i handler() } o.Context().Unregister(o) default: } }