use super::*;
impl BlendMode {
pub fn to_css(&self) -> &str {
match self {
BlendMode::Normal => BLEND_MODE_NORMAL,
BlendMode::Multiply => BLEND_MODE_MULTIPLY,
BlendMode::Screen => BLEND_MODE_SCREEN,
BlendMode::Lighter => BLEND_MODE_LIGHTER,
BlendMode::Overlay => BLEND_MODE_OVERLAY,
BlendMode::Darken => BLEND_MODE_DARKEN,
BlendMode::Lighten => BLEND_MODE_LIGHTEN,
BlendMode::ColorDodge => BLEND_MODE_COLOR_DODGE,
BlendMode::ColorBurn => BLEND_MODE_COLOR_BURN,
BlendMode::HardLight => BLEND_MODE_HARD_LIGHT,
BlendMode::SoftLight => BLEND_MODE_SOFT_LIGHT,
BlendMode::Difference => BLEND_MODE_DIFFERENCE,
BlendMode::Exclusion => BLEND_MODE_EXCLUSION,
BlendMode::Hue => BLEND_MODE_HUE,
BlendMode::Saturation => BLEND_MODE_SATURATION,
BlendMode::Color => BLEND_MODE_COLOR,
BlendMode::Luminosity => BLEND_MODE_LUMINOSITY,
}
}
}
impl VertexStepMode {
pub fn as_str(&self) -> &'static str {
match self {
Self::Vertex => WEBGPU_VERTEX_STEP_MODE_VERTEX,
Self::Instance => WEBGPU_VERTEX_STEP_MODE_INSTANCE,
}
}
}
impl BitOr for BufferUsage {
type Output = u32;
fn bitor(self, rhs: Self) -> Self::Output {
buffer_usage_bit(self) | buffer_usage_bit(rhs)
}
}
impl BitOr for TextureUsage {
type Output = u32;
fn bitor(self, rhs: Self) -> Self::Output {
texture_usage_bit(self) | texture_usage_bit(rhs)
}
}
impl BitOr for ShaderStage {
type Output = ShaderStages;
fn bitor(self, rhs: Self) -> Self::Output {
ShaderStages(shader_stage_bit(self) | shader_stage_bit(rhs))
}
}
impl ShaderStages {
pub fn bits(self) -> u32 {
self.0
}
pub fn is_empty(self) -> bool {
self.0 == 0
}
pub fn contains(self, stage: ShaderStage) -> bool {
self.0 & shader_stage_bit(stage) == shader_stage_bit(stage)
}
}
impl From<ShaderStage> for ShaderStages {
fn from(value: ShaderStage) -> Self {
ShaderStages(shader_stage_bit(value))
}
}
impl BitOr<ShaderStage> for ShaderStages {
type Output = ShaderStages;
fn bitor(self, rhs: ShaderStage) -> Self::Output {
ShaderStages(self.0 | shader_stage_bit(rhs))
}
}
impl BitOr for ShaderStages {
type Output = ShaderStages;
fn bitor(self, rhs: Self) -> Self::Output {
ShaderStages(self.0 | rhs.0)
}
}
impl BufferUsage {
pub fn usage_bit(self) -> u32 {
buffer_usage_bit(self)
}
}
impl TextureUsage {
pub fn usage_bit(self) -> u32 {
texture_usage_bit(self)
}
}
impl ShaderStage {
pub fn stage_bit(self) -> u32 {
shader_stage_bit(self)
}
}