surfman/platform/unix/x11/
device.rs1use super::connection::{Connection, NativeConnectionWrapper};
6use crate::{Error, GLApi};
7
8use std::sync::Arc;
9
10pub use crate::platform::unix::generic::device::Adapter;
11
12pub struct Device {
16 pub(crate) native_connection: Arc<NativeConnectionWrapper>,
17 pub(crate) adapter: Adapter,
18}
19
20#[derive(Clone)]
24pub struct NativeDevice {
25 pub adapter: Adapter,
27}
28
29impl Device {
30 #[inline]
31 pub(crate) fn new(connection: &Connection, adapter: &Adapter) -> Result<Device, Error> {
32 Ok(Device {
33 native_connection: connection.native_connection.clone(),
34 adapter: (*adapter).clone(),
35 })
36 }
37
38 #[inline]
43 pub fn native_device(&self) -> NativeDevice {
44 NativeDevice {
45 adapter: self.adapter(),
46 }
47 }
48
49 #[inline]
51 pub fn connection(&self) -> Connection {
52 Connection {
53 native_connection: self.native_connection.clone(),
54 }
55 }
56
57 #[inline]
59 pub fn adapter(&self) -> Adapter {
60 self.adapter.clone()
61 }
62
63 #[inline]
65 pub fn gl_api(&self) -> GLApi {
66 GLApi::GL
67 }
68}