blob: f82aba378ce498ac25309e14232c51f644516f9e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Copyright 2019 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use std::process::exit;
#[cfg(any(target_os = "android", target_os = "linux"))]
mod platform {
use anyhow::Context;
use anyhow::Result;
use gpu_display::*;
pub fn run() -> Result<()> {
let mut disp = GpuDisplay::open_wayland(None::<&str>).context("open_wayland")?;
let surface_id = disp
.create_surface(None, 1280, 1024, SurfaceType::Scanout)
.context("create_surface")?;
disp.flip(surface_id);
disp.commit(surface_id).context("commit")?;
while !disp.close_requested(surface_id) {
disp.dispatch_events().context("dispatch_events")?;
}
Ok(())
}
}
#[cfg(not(unix))]
mod platform {
use anyhow::anyhow;
use anyhow::Result;
pub fn run() -> Result<()> {
Err(anyhow!("Only supported on unix targets"))
}
}
fn main() {
if let Err(e) = platform::run() {
eprintln!("error: {:#}", e);
exit(1);
}
}
|