pub(crate) mod common;
pub mod shared_texture_handle;
pub use shared_texture_handle::SharedTextureHandle;
#[cfg(target_os = "linux")]
pub(crate) mod dmabuf;
#[cfg(target_os = "windows")]
pub(crate) mod d3d11;
#[cfg(target_os = "macos")]
pub(crate) mod iosurface;
pub type TextureImportResult = Result<wgpu::Texture, TextureImportError>;
#[derive(Debug, thiserror::Error)]
pub enum TextureImportError {
#[error("Invalid texture handle: {0}")]
InvalidHandle(String),
#[error("Unsupported texture format: {format:?}")]
UnsupportedFormat {
format: crate::sys::cef_color_type_t,
},
#[error("Hardware acceleration not available: {reason}")]
HardwareUnavailable { reason: String },
#[error("Vulkan operation failed: {operation}")]
VulkanError { operation: String },
#[error("Platform-specific error: {message}")]
PlatformError { message: String },
#[error("Unsupported platform for texture import")]
UnsupportedPlatform,
}
impl From<wgpu::hal::DeviceError> for TextureImportError {
fn from(e: wgpu::hal::DeviceError) -> Self {
TextureImportError::PlatformError {
message: format!("wgpu-hal DeviceError: {:?}", e),
}
}
}
pub trait TextureImporter {
fn new(info: &crate::AcceleratedPaintInfo) -> Self;
fn import_to_wgpu(&self, device: &wgpu::Device) -> TextureImportResult;
fn supports_hardware_acceleration(&self, device: &wgpu::Device) -> bool;
}