use crate::client::Client;
use crate::object::{ObjectRef, RequestReceiver};
use anyhow::{format_err, Error};
use wayland_server_protocol::*;
use {fuchsia_trace as ftrace, fuchsia_wayland_core as wl};
const SUPPORTED_PIXEL_FORMATS: &[wl_shm::Format] =
&[wl_shm::Format::Argb8888, wl_shm::Format::Xrgb8888];
pub struct Shm;
impl Shm {
pub fn new() -> Self {
Self
}
pub fn post_formats(&self, this: wl::ObjectId, client: &Client) -> Result<(), Error> {
ftrace::duration!(c"wayland", c"Shm::post_formats");
for format in SUPPORTED_PIXEL_FORMATS.iter() {
client.event_queue().post(this, WlShmEvent::Format { format: *format })?;
}
Ok(())
}
}
impl RequestReceiver<WlShm> for Shm {
fn receive(
_this: ObjectRef<Self>,
_request: WlShmRequest,
_client: &mut Client,
) -> Result<(), Error> {
Err(format_err!("Shm::receive not supported"))
}
}