zcr_alpha_compositing_v1_client_protocol/
zcr_alpha_compositing_v1_client_protocol.rs

1// GENERATED FILE -- DO NOT EDIT
2//
3// Copyright 2016 The Chromium Authors.
4// 
5// Permission is hereby granted, free of charge, to any person obtaining a
6// copy of this software and associated documentation files (the "Software"),
7// to deal in the Software without restriction, including without limitation
8// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9// and/or sell copies of the Software, and to permit persons to whom the
10// Software is furnished to do so, subject to the following conditions:
11// 
12// The above copyright notice and this permission notice (including the next
13// paragraph) shall be included in all copies or substantial portions of the
14// Software.
15// 
16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22// DEALINGS IN THE SOFTWARE.
23
24#![allow(warnings)]
25#![allow(clippy::all)]
26use anyhow;
27#[allow(unused_imports)]
28use fuchsia_wayland_core::{Array, Enum, Fixed, NewId, NewObject};
29use fuchsia_wayland_core::{ArgKind, Arg, FromArgs, IntoMessage, Message,
30                            MessageGroupSpec, MessageHeader, MessageSpec, MessageType,
31                            ObjectId, EncodeError, DecodeError, Interface};
32pub mod zcr_alpha_compositing_v1 {
33use super::*;
34
35/// alpha_compositing
36///
37/// The global interface exposing compositing and blending capabilities is
38/// used to instantiate an interface extension for a wl_surface object.
39/// This extended interface will then allow the client to specify the
40/// blending equation and alpha value used for compositing the wl_surface.
41#[derive(Debug)]
42pub struct ZcrAlphaCompositingV1;
43
44impl Interface for ZcrAlphaCompositingV1 {
45    const NAME: &'static str = "zcr_alpha_compositing_v1";
46    const VERSION: u32 = 1;
47    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
48        // destroy
49        MessageSpec(&[
50        ]),
51        // get_blending
52        MessageSpec(&[
53            ArgKind::NewId,
54            ArgKind::Object,
55        ]),
56    ]);
57    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
58    ]);
59    type Incoming = Event;
60    type Outgoing = Request;
61}
62
63#[derive(Debug)]
64pub enum Request {
65
66    /// unbind from the blending interface
67    ///
68    /// Informs the server that the client will not be using this
69    /// protocol object anymore. This does not affect any other objects,
70    /// blending objects included.
71    Destroy,
72
73    /// extend surface interface for blending
74    ///
75    /// Instantiate an interface extension for the given wl_surface to
76    /// provide surface blending. If the given wl_surface already has
77    /// a blending object associated, the blending_exists protocol error
78    /// is raised.
79    GetBlending {
80        /// the new blending interface id
81        id: NewId,
82        /// the surface
83        surface: ObjectId,
84    },
85}
86
87impl MessageType for Request {
88    fn log(&self, this: ObjectId) -> String {
89        match *self {
90            Request::Destroy {
91            } => {
92                format!("zcr_alpha_compositing_v1@{:?}::destroy()", this)
93            }
94            Request::GetBlending {
95                ref id,
96                ref surface,
97            } => {
98                format!("zcr_alpha_compositing_v1@{:?}::get_blending(id: {:?}, surface: {:?})", this, id, surface)
99            }
100        }
101    }
102    fn message_name(&self) -> &'static std::ffi::CStr{
103        match *self {
104            Request::Destroy { .. } => c"zcr_alpha_compositing_v1::destroy",
105            Request::GetBlending { .. } => c"zcr_alpha_compositing_v1::get_blending",
106        }
107    }
108}
109#[derive(Debug)]
110pub enum Event {
111}
112
113impl MessageType for Event {
114    fn log(&self, this: ObjectId) -> String {
115        match *self {
116        }
117    }
118    fn message_name(&self) -> &'static std::ffi::CStr{
119        match *self {
120        }
121    }
122}
123impl IntoMessage for Request {
124    type Error = EncodeError;
125    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
126        let mut header = MessageHeader {
127            sender: id,
128            opcode: 0,
129            length: 0,
130        };
131        let mut msg = Message::new();
132        msg.write_header(&header)?;
133        match self {
134        Request::Destroy {
135        } => {
136            header.opcode = 0;
137        },
138        Request::GetBlending {
139            id,
140            surface,
141        } => {
142            msg.write_arg(Arg::NewId(id))?;
143            msg.write_arg(Arg::Object(surface))?;
144            header.opcode = 1;
145        },
146        }
147        header.length = msg.bytes().len() as u16;
148        msg.rewind();
149        msg.write_header(&header)?;
150        Ok(msg)
151    }
152}
153impl FromArgs for Event {
154    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
155        match op {
156        _ => {
157            Err(DecodeError::InvalidOpcode(op).into())
158        },
159        }
160    }
161}
162#[derive(Copy, Clone, Debug, Eq, PartialEq)]
163#[repr(u32)]
164pub enum Error {
165    /// the surface already has a blending object associated,
166    BlendingExists = 0,
167}
168
169impl Error {
170    pub fn from_bits(v: u32) -> Option<Self> {
171        match v {
172        0 => Some(Error::BlendingExists),
173        _ => None,
174        }
175    }
176
177    pub fn bits(&self) -> u32 {
178        *self as u32
179    }
180}
181impl Into<Arg> for Error {
182    fn into(self) -> Arg {
183        Arg::Uint(self.bits())
184    }
185}
186} // mod zcr_alpha_compositing_v1
187
188pub use crate::zcr_alpha_compositing_v1::ZcrAlphaCompositingV1;
189pub use crate::zcr_alpha_compositing_v1::Request as ZcrAlphaCompositingV1Request;
190pub use crate::zcr_alpha_compositing_v1::Event as ZcrAlphaCompositingV1Event;
191pub mod zcr_blending_v1 {
192use super::*;
193
194/// blending interface to a wl_surface
195///
196/// An additional interface to a wl_surface object, which allows the
197/// client to specify the blending equation used for compositing and
198/// an alpha value applied to the whole surface.
199/// 
200/// If the wl_surface associated with the bledning object is destroyed,
201/// the blending object becomes inert.
202/// 
203/// If the blending object is destroyed, the blending state is removed
204/// from the wl_surface. The change will be applied on the next
205/// wl_surface.commit.
206#[derive(Debug)]
207pub struct ZcrBlendingV1;
208
209impl Interface for ZcrBlendingV1 {
210    const NAME: &'static str = "zcr_blending_v1";
211    const VERSION: u32 = 1;
212    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
213        // destroy
214        MessageSpec(&[
215        ]),
216        // set_blending
217        MessageSpec(&[
218            ArgKind::Uint,
219        ]),
220        // set_alpha
221        MessageSpec(&[
222            ArgKind::Fixed,
223        ]),
224    ]);
225    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
226    ]);
227    type Incoming = Event;
228    type Outgoing = Request;
229}
230
231#[derive(Debug)]
232pub enum Request {
233
234    /// remove blending from the surface
235    ///
236    /// The associated wl_surface's blending state is removed.
237    /// The change is applied on the next wl_surface.commit.
238    Destroy,
239
240    /// set the blending equation
241    ///
242    /// Set the blending equation for compositing the wl_surface.
243    /// See wp_alpha_compositing for the description.
244    /// 
245    /// The blending equation state is double-buffered state,
246    /// and will be applied on the next wl_surface.commit.
247    SetBlending {
248        /// the new blending equation
249        equation: u32,
250    },
251
252    /// set the alpha value
253    ///
254    /// Set the alpha value applied to the whole surface for compositing.
255    /// See wp_alpha_compositing for the description.
256    /// 
257    /// The alpha value state is double-buffered state,
258    /// and will be applied on the next wl_surface.commit.
259    SetAlpha {
260        /// the new alpha value
261        value: Fixed,
262    },
263}
264
265impl MessageType for Request {
266    fn log(&self, this: ObjectId) -> String {
267        match *self {
268            Request::Destroy {
269            } => {
270                format!("zcr_blending_v1@{:?}::destroy()", this)
271            }
272            Request::SetBlending {
273                ref equation,
274            } => {
275                format!("zcr_blending_v1@{:?}::set_blending(equation: {:?})", this, equation)
276            }
277            Request::SetAlpha {
278                ref value,
279            } => {
280                format!("zcr_blending_v1@{:?}::set_alpha(value: {:?})", this, value)
281            }
282        }
283    }
284    fn message_name(&self) -> &'static std::ffi::CStr{
285        match *self {
286            Request::Destroy { .. } => c"zcr_blending_v1::destroy",
287            Request::SetBlending { .. } => c"zcr_blending_v1::set_blending",
288            Request::SetAlpha { .. } => c"zcr_blending_v1::set_alpha",
289        }
290    }
291}
292#[derive(Debug)]
293pub enum Event {
294}
295
296impl MessageType for Event {
297    fn log(&self, this: ObjectId) -> String {
298        match *self {
299        }
300    }
301    fn message_name(&self) -> &'static std::ffi::CStr{
302        match *self {
303        }
304    }
305}
306impl IntoMessage for Request {
307    type Error = EncodeError;
308    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
309        let mut header = MessageHeader {
310            sender: id,
311            opcode: 0,
312            length: 0,
313        };
314        let mut msg = Message::new();
315        msg.write_header(&header)?;
316        match self {
317        Request::Destroy {
318        } => {
319            header.opcode = 0;
320        },
321        Request::SetBlending {
322            equation,
323        } => {
324            msg.write_arg(Arg::Uint(equation))?;
325            header.opcode = 1;
326        },
327        Request::SetAlpha {
328            value,
329        } => {
330            msg.write_arg(Arg::Fixed(value))?;
331            header.opcode = 2;
332        },
333        }
334        header.length = msg.bytes().len() as u16;
335        msg.rewind();
336        msg.write_header(&header)?;
337        Ok(msg)
338    }
339}
340impl FromArgs for Event {
341    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
342        match op {
343        _ => {
344            Err(DecodeError::InvalidOpcode(op).into())
345        },
346        }
347    }
348}
349
350/// different blending equations for compositing
351///
352/// Blending equations that can be used when compositing a surface.
353#[derive(Copy, Clone, Debug, Eq, PartialEq)]
354#[repr(u32)]
355pub enum BlendingEquation {
356    /// no blending,
357    None = 0,
358    /// one / one_minus_src_alpha,
359    Premult = 1,
360    /// src_alpha / one_minus_src_alpha,
361    Coverage = 2,
362}
363
364impl BlendingEquation {
365    pub fn from_bits(v: u32) -> Option<Self> {
366        match v {
367        0 => Some(BlendingEquation::None),
368        1 => Some(BlendingEquation::Premult),
369        2 => Some(BlendingEquation::Coverage),
370        _ => None,
371        }
372    }
373
374    pub fn bits(&self) -> u32 {
375        *self as u32
376    }
377}
378impl Into<Arg> for BlendingEquation {
379    fn into(self) -> Arg {
380        Arg::Uint(self.bits())
381    }
382}
383} // mod zcr_blending_v1
384
385pub use crate::zcr_blending_v1::ZcrBlendingV1;
386pub use crate::zcr_blending_v1::Request as ZcrBlendingV1Request;
387pub use crate::zcr_blending_v1::Event as ZcrBlendingV1Event;