gfx-api: add GfxApi
This commit is contained in:
parent
b604192bf0
commit
ca6e3891af
15 changed files with 72 additions and 61 deletions
|
|
@ -18,7 +18,8 @@ use {
|
|||
},
|
||||
ahash::AHashMap,
|
||||
indexmap::{IndexMap, IndexSet},
|
||||
jay_config::video::{GfxApi, Transform},
|
||||
jay_config::video::{GfxApi as ConfigGfxApi, Transform},
|
||||
linearize::Linearize,
|
||||
std::{
|
||||
any::Any,
|
||||
cell::Cell,
|
||||
|
|
@ -33,6 +34,51 @@ use {
|
|||
uapi::OwnedFd,
|
||||
};
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Linearize)]
|
||||
pub enum GfxApi {
|
||||
OpenGl,
|
||||
Vulkan,
|
||||
}
|
||||
|
||||
impl TryFrom<ConfigGfxApi> for GfxApi {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(value: ConfigGfxApi) -> Result<Self, Self::Error> {
|
||||
let v = match value {
|
||||
ConfigGfxApi::OpenGl => GfxApi::OpenGl,
|
||||
ConfigGfxApi::Vulkan => GfxApi::Vulkan,
|
||||
_ => return Err(()),
|
||||
};
|
||||
Ok(v)
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<ConfigGfxApi> for GfxApi {
|
||||
fn into(self) -> ConfigGfxApi {
|
||||
match self {
|
||||
GfxApi::OpenGl => ConfigGfxApi::OpenGl,
|
||||
GfxApi::Vulkan => ConfigGfxApi::Vulkan,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GfxApi {
|
||||
pub fn to_str(&self) -> &'static str {
|
||||
match self {
|
||||
GfxApi::OpenGl => "OpenGl",
|
||||
GfxApi::Vulkan => "Vulkan",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_str_lossy(s: &str) -> Option<Self> {
|
||||
match &*s.to_ascii_lowercase() {
|
||||
"opengl" => Some(Self::OpenGl),
|
||||
"vulkan" => Some(Self::Vulkan),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum GfxApiOpt {
|
||||
Sync,
|
||||
FillRect(FillRect),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue