zcr_alpha_compositing_v1_server_protocol/
zcr_alpha_compositing_v1_server_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 = Request;
60    type Outgoing = Event;
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: NewObject<ZcrBlendingV1>,
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 Event {
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        }
135        header.length = msg.bytes().len() as u16;
136        msg.rewind();
137        msg.write_header(&header)?;
138        Ok(msg)
139    }
140}
141impl FromArgs for Request {
142    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
143        match op {
144        0 /* destroy */ => {
145            let mut iter = args.into_iter();
146            Ok(Request::Destroy {
147
148            })
149        },
150        1 /* get_blending */ => {
151            let mut iter = args.into_iter();
152            Ok(Request::GetBlending {
153                id: iter.next()
154                                             .ok_or(DecodeError::InsufficientArgs)?
155                                             .as_new_id()?.into(),
156                surface: iter.next()
157                                             .ok_or(DecodeError::InsufficientArgs)?
158                                             .as_object()?,
159
160            })
161        },
162        _ => {
163            Err(DecodeError::InvalidOpcode(op).into())
164        },
165        }
166    }
167}
168#[derive(Copy, Clone, Debug, Eq, PartialEq)]
169#[repr(u32)]
170pub enum Error {
171    /// the surface already has a blending object associated,
172    BlendingExists = 0,
173}
174
175impl Error {
176    pub fn from_bits(v: u32) -> Option<Self> {
177        match v {
178        0 => Some(Error::BlendingExists),
179        _ => None,
180        }
181    }
182
183    pub fn bits(&self) -> u32 {
184        *self as u32
185    }
186}
187impl Into<Arg> for Error {
188    fn into(self) -> Arg {
189        Arg::Uint(self.bits())
190    }
191}
192} // mod zcr_alpha_compositing_v1
193
194pub use crate::zcr_alpha_compositing_v1::ZcrAlphaCompositingV1;
195pub use crate::zcr_alpha_compositing_v1::Request as ZcrAlphaCompositingV1Request;
196pub use crate::zcr_alpha_compositing_v1::Event as ZcrAlphaCompositingV1Event;
197pub mod zcr_blending_v1 {
198use super::*;
199
200/// blending interface to a wl_surface
201///
202/// An additional interface to a wl_surface object, which allows the
203/// client to specify the blending equation used for compositing and
204/// an alpha value applied to the whole surface.
205/// 
206/// If the wl_surface associated with the bledning object is destroyed,
207/// the blending object becomes inert.
208/// 
209/// If the blending object is destroyed, the blending state is removed
210/// from the wl_surface. The change will be applied on the next
211/// wl_surface.commit.
212#[derive(Debug)]
213pub struct ZcrBlendingV1;
214
215impl Interface for ZcrBlendingV1 {
216    const NAME: &'static str = "zcr_blending_v1";
217    const VERSION: u32 = 1;
218    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
219        // destroy
220        MessageSpec(&[
221        ]),
222        // set_blending
223        MessageSpec(&[
224            ArgKind::Uint,
225        ]),
226        // set_alpha
227        MessageSpec(&[
228            ArgKind::Fixed,
229        ]),
230    ]);
231    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
232    ]);
233    type Incoming = Request;
234    type Outgoing = Event;
235}
236
237#[derive(Debug)]
238pub enum Request {
239
240    /// remove blending from the surface
241    ///
242    /// The associated wl_surface's blending state is removed.
243    /// The change is applied on the next wl_surface.commit.
244    Destroy,
245
246    /// set the blending equation
247    ///
248    /// Set the blending equation for compositing the wl_surface.
249    /// See wp_alpha_compositing for the description.
250    /// 
251    /// The blending equation state is double-buffered state,
252    /// and will be applied on the next wl_surface.commit.
253    SetBlending {
254        /// the new blending equation
255        equation: u32,
256    },
257
258    /// set the alpha value
259    ///
260    /// Set the alpha value applied to the whole surface for compositing.
261    /// See wp_alpha_compositing for the description.
262    /// 
263    /// The alpha value state is double-buffered state,
264    /// and will be applied on the next wl_surface.commit.
265    SetAlpha {
266        /// the new alpha value
267        value: Fixed,
268    },
269}
270
271impl MessageType for Request {
272    fn log(&self, this: ObjectId) -> String {
273        match *self {
274            Request::Destroy {
275            } => {
276                format!("zcr_blending_v1@{:?}::destroy()", this)
277            }
278            Request::SetBlending {
279                ref equation,
280            } => {
281                format!("zcr_blending_v1@{:?}::set_blending(equation: {:?})", this, equation)
282            }
283            Request::SetAlpha {
284                ref value,
285            } => {
286                format!("zcr_blending_v1@{:?}::set_alpha(value: {:?})", this, value)
287            }
288        }
289    }
290    fn message_name(&self) -> &'static std::ffi::CStr{
291        match *self {
292            Request::Destroy { .. } => c"zcr_blending_v1::destroy",
293            Request::SetBlending { .. } => c"zcr_blending_v1::set_blending",
294            Request::SetAlpha { .. } => c"zcr_blending_v1::set_alpha",
295        }
296    }
297}
298#[derive(Debug)]
299pub enum Event {
300}
301
302impl MessageType for Event {
303    fn log(&self, this: ObjectId) -> String {
304        match *self {
305        }
306    }
307    fn message_name(&self) -> &'static std::ffi::CStr{
308        match *self {
309        }
310    }
311}
312impl IntoMessage for Event {
313    type Error = EncodeError;
314    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
315        let mut header = MessageHeader {
316            sender: id,
317            opcode: 0,
318            length: 0,
319        };
320        let mut msg = Message::new();
321        msg.write_header(&header)?;
322        match self {
323        }
324        header.length = msg.bytes().len() as u16;
325        msg.rewind();
326        msg.write_header(&header)?;
327        Ok(msg)
328    }
329}
330impl FromArgs for Request {
331    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
332        match op {
333        0 /* destroy */ => {
334            let mut iter = args.into_iter();
335            Ok(Request::Destroy {
336
337            })
338        },
339        1 /* set_blending */ => {
340            let mut iter = args.into_iter();
341            Ok(Request::SetBlending {
342                equation: iter.next()
343                                             .ok_or(DecodeError::InsufficientArgs)?
344                                             .as_uint()?,
345
346            })
347        },
348        2 /* set_alpha */ => {
349            let mut iter = args.into_iter();
350            Ok(Request::SetAlpha {
351                value: iter.next()
352                                             .ok_or(DecodeError::InsufficientArgs)?
353                                             .as_fixed()?.into(),
354
355            })
356        },
357        _ => {
358            Err(DecodeError::InvalidOpcode(op).into())
359        },
360        }
361    }
362}
363
364/// different blending equations for compositing
365///
366/// Blending equations that can be used when compositing a surface.
367#[derive(Copy, Clone, Debug, Eq, PartialEq)]
368#[repr(u32)]
369pub enum BlendingEquation {
370    /// no blending,
371    None = 0,
372    /// one / one_minus_src_alpha,
373    Premult = 1,
374    /// src_alpha / one_minus_src_alpha,
375    Coverage = 2,
376}
377
378impl BlendingEquation {
379    pub fn from_bits(v: u32) -> Option<Self> {
380        match v {
381        0 => Some(BlendingEquation::None),
382        1 => Some(BlendingEquation::Premult),
383        2 => Some(BlendingEquation::Coverage),
384        _ => None,
385        }
386    }
387
388    pub fn bits(&self) -> u32 {
389        *self as u32
390    }
391}
392impl Into<Arg> for BlendingEquation {
393    fn into(self) -> Arg {
394        Arg::Uint(self.bits())
395    }
396}
397} // mod zcr_blending_v1
398
399pub use crate::zcr_blending_v1::ZcrBlendingV1;
400pub use crate::zcr_blending_v1::Request as ZcrBlendingV1Request;
401pub use crate::zcr_blending_v1::Event as ZcrBlendingV1Event;