Skip to content

Commit

Permalink
Move backends into a backends module
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Feb 12, 2024
1 parent 4d62538 commit 2f8a5fb
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 38 deletions.
16 changes: 8 additions & 8 deletions src/backend_dispatch.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Implements `buffer_interface::*` traits for enums dispatching to backends
use crate::{backend_interface::*, Rect, SoftBufferError};
use crate::{backend_interface::*, backends, Rect, SoftBufferError};

use raw_window_handle::{HasDisplayHandle, HasWindowHandle};
use std::num::NonZeroU32;
Expand Down Expand Up @@ -146,17 +146,17 @@ macro_rules! make_dispatch {
make_dispatch! {
<D, W> =>
#[cfg(x11_platform)]
X11(Rc<crate::x11::X11DisplayImpl<D>>, crate::x11::X11Impl<D, W>, crate::x11::BufferImpl<'a, D, W>),
X11(Rc<backends::x11::X11DisplayImpl<D>>, backends::x11::X11Impl<D, W>, backends::x11::BufferImpl<'a, D, W>),
#[cfg(wayland_platform)]
Wayland(Rc<crate::wayland::WaylandDisplayImpl<D>>, crate::wayland::WaylandImpl<D, W>, crate::wayland::BufferImpl<'a, D, W>),
Wayland(Rc<backends::wayland::WaylandDisplayImpl<D>>, backends::wayland::WaylandImpl<D, W>, backends::wayland::BufferImpl<'a, D, W>),
#[cfg(kms_platform)]
Kms(Rc<crate::kms::KmsDisplayImpl<D>>, crate::kms::KmsImpl<D, W>, crate::kms::BufferImpl<'a, D, W>),
Kms(Rc<backends::kms::KmsDisplayImpl<D>>, backends::kms::KmsImpl<D, W>, backends::kms::BufferImpl<'a, D, W>),
#[cfg(target_os = "windows")]
Win32(D, crate::win32::Win32Impl<D, W>, crate::win32::BufferImpl<'a, D, W>),
Win32(D, backends::win32::Win32Impl<D, W>, backends::win32::BufferImpl<'a, D, W>),
#[cfg(target_os = "macos")]
CG(D, crate::cg::CGImpl<D, W>, crate::cg::BufferImpl<'a, D, W>),
CG(D, backends::cg::CGImpl<D, W>, backends::cg::BufferImpl<'a, D, W>),
#[cfg(target_arch = "wasm32")]
Web(crate::web::WebDisplayImpl<D>, crate::web::WebImpl<D, W>, crate::web::BufferImpl<'a, D, W>),
Web(backends::web::WebDisplayImpl<D>, backends::web::WebImpl<D, W>, backends::web::BufferImpl<'a, D, W>),
#[cfg(target_os = "redox")]
Orbital(D, crate::orbital::OrbitalImpl<D, W>, crate::orbital::BufferImpl<'a, D, W>),
Orbital(D, backends::orbital::OrbitalImpl<D, W>, backends::orbital::BufferImpl<'a, D, W>),
}
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions src/backends/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#[cfg(target_os = "macos")]
pub(crate) mod cg;
#[cfg(kms_platform)]
pub(crate) mod kms;
#[cfg(target_os = "redox")]
pub(crate) mod orbital;
#[cfg(wayland_platform)]
pub(crate) mod wayland;
#[cfg(target_arch = "wasm32")]
pub(crate) mod web;
#[cfg(target_os = "windows")]
pub(crate) mod win32;
#[cfg(x11_platform)]
pub(crate) mod x11;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
46 changes: 16 additions & 30 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,11 @@
extern crate objc;
extern crate core;

#[cfg(target_os = "macos")]
mod cg;
#[cfg(kms_platform)]
mod kms;
#[cfg(target_os = "redox")]
mod orbital;
#[cfg(wayland_platform)]
mod wayland;
#[cfg(target_arch = "wasm32")]
mod web;
#[cfg(target_os = "windows")]
mod win32;
#[cfg(x11_platform)]
mod x11;

mod backend_dispatch;
use backend_dispatch::*;
mod backend_interface;
use backend_interface::*;
mod backends;
mod error;
mod util;

Expand Down Expand Up @@ -73,17 +59,17 @@ impl<D: HasDisplayHandle> Context<D> {
}

#[cfg(x11_platform)]
try_init!(X11, display => x11::X11DisplayImpl::new(display).map(Rc::new));
try_init!(X11, display => backends::x11::X11DisplayImpl::new(display).map(Rc::new));
#[cfg(wayland_platform)]
try_init!(Wayland, display => wayland::WaylandDisplayImpl::new(display).map(Rc::new));
try_init!(Wayland, display => backends::wayland::WaylandDisplayImpl::new(display).map(Rc::new));
#[cfg(kms_platform)]
try_init!(Kms, display => kms::KmsDisplayImpl::new(display).map(Rc::new));
try_init!(Kms, display => backends::kms::KmsDisplayImpl::new(display).map(Rc::new));
#[cfg(target_os = "windows")]
try_init!(Win32, display => Ok(display));
#[cfg(target_os = "macos")]
try_init!(CG, display => Ok(display));
#[cfg(target_arch = "wasm32")]
try_init!(Web, display => web::WebDisplayImpl::new(display));
try_init!(Web, display => backends::web::WebDisplayImpl::new(display));

Check failure on line 72 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Tests (1.65.0, wasm32-unknown-unknown, ubuntu-latest)

associated function `new` is private

Check failure on line 72 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, wasm32-unknown-unknown, ubuntu-latest)

associated function `new` is private

Check failure on line 72 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, wasm32-unknown-unknown, ubuntu-latest)

associated function `new` is private

Check failure on line 72 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Tests (nightly, wasm32-unknown-unknown, ubuntu-latest, -Zbuild-std=panic_abort,std, -Ctarget-feat...

associated function `new` is private
#[cfg(target_os = "redox")]
try_init!(Orbital, display => Ok(display));

Expand Down Expand Up @@ -139,30 +125,30 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> Surface<D, W> {

let imple = match &context.context_impl {
#[cfg(x11_platform)]
ContextDispatch::X11(xcb_display_handle) => {
SurfaceDispatch::X11(leap!(x11::X11Impl::new(window, xcb_display_handle.clone())))
}
ContextDispatch::X11(xcb_display_handle) => SurfaceDispatch::X11(leap!(
backends::x11::X11Impl::new(window, xcb_display_handle.clone())
)),
#[cfg(wayland_platform)]
ContextDispatch::Wayland(wayland_display_impl) => SurfaceDispatch::Wayland(leap!(
wayland::WaylandImpl::new(window, wayland_display_impl.clone())
backends::wayland::WaylandImpl::new(window, wayland_display_impl.clone())
)),
#[cfg(kms_platform)]
ContextDispatch::Kms(kms_display_impl) => {
SurfaceDispatch::Kms(leap!(kms::KmsImpl::new(window, kms_display_impl.clone())))
}
ContextDispatch::Kms(kms_display_impl) => SurfaceDispatch::Kms(leap!(
backends::kms::KmsImpl::new(window, kms_display_impl.clone())
)),
#[cfg(target_os = "windows")]
ContextDispatch::Win32(_) => {
SurfaceDispatch::Win32(leap!(win32::Win32Impl::new(window)))
SurfaceDispatch::Win32(leap!(backends::win32::Win32Impl::new(window)))
}
#[cfg(target_os = "macos")]
ContextDispatch::CG(_) => SurfaceDispatch::CG(leap!(cg::CGImpl::new(window))),
ContextDispatch::CG(_) => SurfaceDispatch::CG(leap!(backends::cg::CGImpl::new(window))),
#[cfg(target_arch = "wasm32")]
ContextDispatch::Web(web_display_impl) => {
SurfaceDispatch::Web(leap!(web::WebImpl::new(web_display_impl, window)))
SurfaceDispatch::Web(leap!(backends::web::WebImpl::new(web_display_impl, window)))
}
#[cfg(target_os = "redox")]
ContextDispatch::Orbital(_) => {
SurfaceDispatch::Orbital(leap!(orbital::OrbitalImpl::new(window)))
SurfaceDispatch::Orbital(leap!(backends::orbital::OrbitalImpl::new(window)))
}
};

Expand Down

0 comments on commit 2f8a5fb

Please sign in to comment.