use super::connection::{Connection, NativeConnectionWrapper};
use crate::{Error, GLApi};
use std::sync::Arc;
pub use crate::platform::unix::generic::device::Adapter;
pub struct Device {
pub(crate) native_connection: Arc<NativeConnectionWrapper>,
pub(crate) adapter: Adapter,
}
#[derive(Clone)]
pub struct NativeDevice {
pub adapter: Adapter,
}
impl Device {
#[inline]
pub(crate) fn new(connection: &Connection, adapter: &Adapter) -> Result<Device, Error> {
Ok(Device {
native_connection: connection.native_connection.clone(),
adapter: (*adapter).clone(),
})
}
#[inline]
pub fn native_device(&self) -> NativeDevice {
NativeDevice {
adapter: self.adapter(),
}
}
#[inline]
pub fn connection(&self) -> Connection {
Connection {
native_connection: self.native_connection.clone(),
}
}
#[inline]
pub fn adapter(&self) -> Adapter {
self.adapter.clone()
}
#[inline]
pub fn gl_api(&self) -> GLApi {
if std::env::var("SURFMAN_FORCE_GLES").is_ok() {
GLApi::GLES
} else {
GLApi::GL
}
}
}