render: hide graphics API behind traits
This commit is contained in:
parent
d650b3375d
commit
24e410a5b5
40 changed files with 601 additions and 246 deletions
|
|
@ -2,7 +2,7 @@ use {
|
|||
crate::{
|
||||
fixed::Fixed,
|
||||
format::ARGB8888,
|
||||
gfx_apis::gl::{RenderContext, RenderError, Texture},
|
||||
gfx_api::{GfxContext, GfxError, GfxTexture},
|
||||
rect::Rect,
|
||||
renderer::Renderer,
|
||||
scale::Scale,
|
||||
|
|
@ -87,7 +87,7 @@ pub enum KnownCursor {
|
|||
}
|
||||
|
||||
impl ServerCursors {
|
||||
pub fn load(ctx: &Rc<RenderContext>, state: &State) -> Result<Option<Self>, CursorError> {
|
||||
pub fn load(ctx: &Rc<dyn GfxContext>, state: &State) -> Result<Option<Self>, CursorError> {
|
||||
let paths = find_cursor_paths();
|
||||
log::debug!("Trying to load cursors from paths {:?}", paths);
|
||||
let sizes = state.cursor_sizes.to_vec();
|
||||
|
|
@ -135,7 +135,7 @@ impl ServerCursorTemplate {
|
|||
scales: &[Scale],
|
||||
sizes: &[u32],
|
||||
paths: &[BString],
|
||||
ctx: &Rc<RenderContext>,
|
||||
ctx: &Rc<dyn GfxContext>,
|
||||
) -> Result<Self, CursorError> {
|
||||
match open_cursor(name, theme, scales, sizes, paths) {
|
||||
Ok(cs) => {
|
||||
|
|
@ -215,7 +215,7 @@ impl ServerCursorTemplate {
|
|||
|
||||
struct CursorImageScaled {
|
||||
extents: Rect,
|
||||
tex: Rc<Texture>,
|
||||
tex: Rc<dyn GfxTexture>,
|
||||
}
|
||||
|
||||
struct CursorImage {
|
||||
|
|
@ -230,7 +230,7 @@ struct InstantiatedCursorImage {
|
|||
|
||||
impl CursorImageScaled {
|
||||
fn from_bytes(
|
||||
ctx: &Rc<RenderContext>,
|
||||
ctx: &Rc<dyn GfxContext>,
|
||||
data: &[Cell<u8>],
|
||||
width: i32,
|
||||
height: i32,
|
||||
|
|
@ -239,7 +239,9 @@ impl CursorImageScaled {
|
|||
) -> Result<Rc<Self>, CursorError> {
|
||||
Ok(Rc::new(Self {
|
||||
extents: Rect::new_sized(-xhot, -yhot, width, height).unwrap(),
|
||||
tex: ctx.shmem_texture(data, ARGB8888, width, height, width * 4)?,
|
||||
tex: ctx
|
||||
.clone()
|
||||
.shmem_texture(data, ARGB8888, width, height, width * 4)?,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
@ -536,7 +538,7 @@ pub enum CursorError {
|
|||
#[error("The requested cursor could not be found")]
|
||||
NotFound,
|
||||
#[error("Could not import the cursor as a texture")]
|
||||
ImportError(#[from] RenderError),
|
||||
ImportError(#[from] GfxError),
|
||||
}
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue