// Code generated by wlturbo-scanner. DO NOT EDIT. // Protocol: color_representation_v1 // Source: color-representation-v1.xml // Upstream protocol copyright and license: // Copyright 2022 Simon Ser // Copyright 2022 Red Hat, Inc. // Copyright 2022 Collabora, Ltd. // Copyright 2022-2025 Red Hat, Inc. // // 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 colorrepresentation import ( "sync" cross_wl_surface "github.com/bnema/wlturbo/protocol/core" "github.com/bnema/wlturbo/wl" ) // ERROR_SURFACE_EXISTS is the error surface_exists value. const ERROR_SURFACE_EXISTS = 1 // ERROR_ALPHA_MODE is the error alpha_mode value. const ERROR_ALPHA_MODE = 1 // ERROR_COEFFICIENTS is the error coefficients value. const ERROR_COEFFICIENTS = 2 // ERROR_PIXEL_FORMAT is the error pixel_format value. const ERROR_PIXEL_FORMAT = 3 // ERROR_INERT is the error inert value. const ERROR_INERT = 4 // ERROR_CHROMA_LOCATION is the error chroma_location value. const ERROR_CHROMA_LOCATION = 5 // ALPHA_MODE_PREMULTIPLIED_ELECTRICAL is the alpha_mode premultiplied_electrical value. const ALPHA_MODE_PREMULTIPLIED_ELECTRICAL = 0 // ALPHA_MODE_PREMULTIPLIED_OPTICAL is the alpha_mode premultiplied_optical value. const ALPHA_MODE_PREMULTIPLIED_OPTICAL = 1 // ALPHA_MODE_STRAIGHT is the alpha_mode straight value. const ALPHA_MODE_STRAIGHT = 2 // COEFFICIENTS_IDENTITY is the coefficients identity value. const COEFFICIENTS_IDENTITY = 1 // COEFFICIENTS_BT709 is the coefficients bt709 value. const COEFFICIENTS_BT709 = 2 // COEFFICIENTS_FCC is the coefficients fcc value. const COEFFICIENTS_FCC = 3 // COEFFICIENTS_BT601 is the coefficients bt601 value. const COEFFICIENTS_BT601 = 4 // COEFFICIENTS_SMPTE240 is the coefficients smpte240 value. const COEFFICIENTS_SMPTE240 = 5 // COEFFICIENTS_BT2020 is the coefficients bt2020 value. const COEFFICIENTS_BT2020 = 6 // COEFFICIENTS_BT2020_CL is the coefficients bt2020_cl value. const COEFFICIENTS_BT2020_CL = 7 // COEFFICIENTS_ICTCP is the coefficients ictcp value. const COEFFICIENTS_ICTCP = 8 // RANGE_FULL is the range full value. const RANGE_FULL = 1 // RANGE_LIMITED is the range limited value. const RANGE_LIMITED = 2 // CHROMA_LOCATION_TYPE_0 is the chroma_location type_0 value. const CHROMA_LOCATION_TYPE_0 = 1 // CHROMA_LOCATION_TYPE_1 is the chroma_location type_1 value. const CHROMA_LOCATION_TYPE_1 = 2 // CHROMA_LOCATION_TYPE_2 is the chroma_location type_2 value. const CHROMA_LOCATION_TYPE_2 = 3 // CHROMA_LOCATION_TYPE_3 is the chroma_location type_3 value. const CHROMA_LOCATION_TYPE_3 = 4 // CHROMA_LOCATION_TYPE_4 is the chroma_location type_4 value. const CHROMA_LOCATION_TYPE_4 = 5 // CHROMA_LOCATION_TYPE_5 is the chroma_location type_5 value. const CHROMA_LOCATION_TYPE_5 = 6 // WpColorRepresentationManagerInterface is the protocol interface name. const WpColorRepresentationManagerInterface = "wp_color_representation_manager_v1" // WpColorRepresentationManager is the generated binding for wp_color_representation_manager_v1 version 1. type WpColorRepresentationManager struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onSupportedAlphaMode []func(alphaMode uint32) onSupportedCoefficientsAndRanges []func(coefficients uint32, rangeArg uint32) onDone []func() } // NewWpColorRepresentationManager returns an unbound WpColorRepresentationManager. func NewWpColorRepresentationManager(ctx *wl.Context) *WpColorRepresentationManager { obj := &WpColorRepresentationManager{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Destroy the wp_color_representation_manager_v1 object. This does not affect any other objects in any way. func (o *WpColorRepresentationManager) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wp_color_representation_manager_v1.destroy", Destructor: true}); err != nil { return err } return nil } // If a wp_color_representation_surface_v1 object already exists for the given wl_surface, the protocol error surface_exists is raised. This creates a new color wp_color_representation_surface_v1 object for the given wl_surface. See the wp_color_representation_surface_v1 interface for more details. func (o *WpColorRepresentationManager) GetSurface(surface *cross_wl_surface.Surface) (*WpColorRepresentationSurface, error) { var arg1 wl.Object if surface != nil { arg1 = surface } child := &WpColorRepresentationSurface{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wp_color_representation_manager_v1.get_surface", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil { return nil, err } return child, nil } // OnSupportedAlphaMode registers a handler for the supported_alpha_mode 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 *WpColorRepresentationManager) OnSupportedAlphaMode(handler func(alphaMode uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onSupportedAlphaMode = append(o.onSupportedAlphaMode, handler) } // handlersForSupportedAlphaMode returns the handlers registered for supported_alpha_mode, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *WpColorRepresentationManager) handlersForSupportedAlphaMode() []func(alphaMode uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onSupportedAlphaMode } // OnSupportedCoefficientsAndRanges registers a handler for the supported_coefficients_and_ranges 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 *WpColorRepresentationManager) OnSupportedCoefficientsAndRanges(handler func(coefficients uint32, rangeArg uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onSupportedCoefficientsAndRanges = append(o.onSupportedCoefficientsAndRanges, handler) } // handlersForSupportedCoefficientsAndRanges returns the handlers registered for supported_coefficients_and_ranges, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *WpColorRepresentationManager) handlersForSupportedCoefficientsAndRanges() []func(coefficients uint32, rangeArg uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onSupportedCoefficientsAndRanges } // OnDone registers a handler for the done 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 *WpColorRepresentationManager) OnDone(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onDone = append(o.onDone, handler) } // handlersForDone returns the handlers registered for done, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *WpColorRepresentationManager) handlersForDone() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onDone } // EventSignature returns the declared event argument types in wire order. func (o *WpColorRepresentationManager) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "uint,", true case 1: return "uint,uint,", true case 2: return "", true default: return "", false } } // Dispatch decodes one event on wp_color_representation_manager_v1 and calls the registered handlers. func (o *WpColorRepresentationManager) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // supported_alpha_mode alphaMode := event.Uint32() for i, handler := range o.handlersForSupportedAlphaMode() { _ = i handler(alphaMode) } case 1: // supported_coefficients_and_ranges coefficients := event.Uint32() rangeArg := event.Uint32() for i, handler := range o.handlersForSupportedCoefficientsAndRanges() { _ = i handler(coefficients, rangeArg) } case 2: // done for i, handler := range o.handlersForDone() { _ = i handler() } default: } } // WpColorRepresentationSurfaceInterface is the protocol interface name. const WpColorRepresentationSurfaceInterface = "wp_color_representation_surface_v1" // WpColorRepresentationSurface is the generated binding for wp_color_representation_surface_v1 version 1. type WpColorRepresentationSurface struct { wl.BaseProxy } // NewWpColorRepresentationSurface returns an unbound WpColorRepresentationSurface. func NewWpColorRepresentationSurface(ctx *wl.Context) *WpColorRepresentationSurface { obj := &WpColorRepresentationSurface{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Destroy the wp_color_representation_surface_v1 object. Destroying this object unsets all the color representation metadata from the surface. See the wp_color_representation_surface_v1 interface description for how a compositor handles a surface without color representation metadata. Unsetting is double-buffered state, see wl_surface.commit. func (o *WpColorRepresentationSurface) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wp_color_representation_surface_v1.destroy", Destructor: true}); err != nil { return err } return nil } // If this protocol object is inert, the protocol error inert is raised. Assuming an alpha channel exists, it is always linear. The alpha mode determines whether and how the color channels include pre-multiplied alpha. Using straight alpha might have performance benefits. Only alpha modes advertised by the compositor are allowed to be used as argument for this request. The "alpha_mode" protocol error is raised otherwise. Alpha mode is double buffered, see wl_surface.commit. func (o *WpColorRepresentationSurface) SetAlphaMode(alphaMode uint32) error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wp_color_representation_surface_v1.set_alpha_mode"}, wl.ArgUint(alphaMode)); err != nil { return err } return nil } // If this protocol object is inert, the protocol error inert is raised. Set the matrix coefficients and video range which defines the formula and the related constants used to derive red, green and blue signals. Usually coefficients correspond to MatrixCoefficients code points in H.273. Only combinations advertised by the compositor are allowed to be used as argument for this request. The "coefficients" protocol error is raised otherwise. A call to wl_surface.commit verifies that the pixel format and the coefficients-range combination in the committed surface contents are compatible, if contents exist. The "pixel_format" protocol error is raised otherwise. A pixel format is compatible with the coefficients-range combination if the related equations and conventions as defined in H.273 can produce the color channels (RGB or YCbCr) of the pixel format. For the definition of the supported combination, see the wp_color_representation_surface_v1::coefficients and wp_color_representation_surface_v1::range enums. The coefficients-range combination is double-buffered, see wl_surface.commit. func (o *WpColorRepresentationSurface) SetCoefficientsAndRange(coefficients uint32, rangeArg uint32) error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "wp_color_representation_surface_v1.set_coefficients_and_range"}, wl.ArgUint(coefficients), wl.ArgUint(rangeArg)); err != nil { return err } return nil } // If this protocol object is inert, the protocol error inert is raised. Set the chroma location type which defines the position of downsampled chroma samples, corresponding to Chroma420SampleLocType code points in H.273. An invalid chroma location enum value raises the "chroma_location" protocol error. A call to wl_surface.commit verifies that the pixel format and chroma location type in the committed surface contents are compatible, if contents exist. The "pixel_format" protocol error is raised otherwise. For the definition of the supported chroma location types, see the wp_color_representation_surface_v1::chroma_location enum. The chroma location type is double-buffered, see wl_surface.commit. func (o *WpColorRepresentationSurface) SetChromaLocation(chromaLocation uint32) error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "wp_color_representation_surface_v1.set_chroma_location"}, wl.ArgUint(chromaLocation)); err != nil { return err } return nil } // EventSignature returns the declared event argument types in wire order. func (o *WpColorRepresentationSurface) EventSignature(opcode uint16) (string, bool) { switch opcode { default: return "", false } } // Dispatch decodes one event on wp_color_representation_surface_v1 and calls the registered handlers. func (o *WpColorRepresentationSurface) Dispatch(event *wl.Event) { switch event.Opcode { default: } }