Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ tracing = { version = "0.1.41", default-features = false }
bytemuck = "1.12.3"
ndk = "0.9.0"

[target.'cfg(all(unix, not(any(target_vendor = "apple", target_os = "android", target_os = "redox"))))'.dependencies]
[target.'cfg(not(any(target_os = "android", target_vendor = "apple", target_os = "redox", target_family = "wasm", target_os = "windows")))'.dependencies]
as-raw-xcb-connection = { version = "1.0.0", optional = true }
bytemuck = { version = "1.12.3", optional = true }
drm = { version = "0.14.1", default-features = false, optional = true }
Expand Down Expand Up @@ -130,9 +130,6 @@ features = [
[target.'cfg(target_os = "redox")'.dependencies]
redox_syscall = "0.5"

[build-dependencies]
cfg_aliases = "0.2.0"

[dev-dependencies]
colorous = "1.0.12"
criterion = { version = "0.4.0", default-features = false, features = [
Expand All @@ -158,7 +155,7 @@ rayon = "1.5.1"
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3"

[target.'cfg(all(unix, not(any(target_vendor = "apple", target_os = "android", target_os = "redox"))))'.dev-dependencies]
[target.'cfg(not(any(target_os = "android", target_vendor = "apple", target_os = "redox", target_family = "wasm", target_os = "windows")))'.dev-dependencies]
rustix = { version = "1.0.1", features = ["event"] }

[workspace]
Expand Down
13 changes: 0 additions & 13 deletions build.rs

This file was deleted.

22 changes: 20 additions & 2 deletions examples/drm.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
//! Example of using softbuffer with drm-rs.

#[cfg(kms_platform)]
#[cfg(all(
feature = "kms",
not(any(
target_os = "android",
target_vendor = "apple",
target_os = "redox",
target_family = "wasm",
target_os = "windows"
))
))]
mod imple {
use drm::control::{connector, Device as CtrlDevice, Event, ModeTypeFlags, PlaneType};
use drm::Device;
Expand Down Expand Up @@ -210,7 +219,16 @@ mod imple {
impl CtrlDevice for Card {}
}

#[cfg(not(kms_platform))]
#[cfg(not(all(
feature = "kms",
not(any(
target_os = "android",
target_vendor = "apple",
target_os = "redox",
target_family = "wasm",
target_os = "windows"
))
)))]
mod imple {
pub(super) fn entry() -> Result<(), Box<dyn std::error::Error>> {
eprintln!("This example requires the `kms` feature.");
Expand Down
33 changes: 30 additions & 3 deletions examples/libxcb.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
//! Example of using `softbuffer` with `libxcb`.

#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "freebsd")))]
#[cfg(all(
feature = "x11",
not(any(
target_os = "android",
target_vendor = "apple",
target_os = "redox",
target_family = "wasm",
target_os = "windows"
))
))]
mod example {
use raw_window_handle::{
DisplayHandle, RawDisplayHandle, RawWindowHandle, WindowHandle, XcbDisplayHandle,
Expand Down Expand Up @@ -135,12 +144,30 @@ mod example {
}
}

#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "freebsd")))]
#[cfg(all(
feature = "x11",
not(any(
target_os = "android",
target_vendor = "apple",
target_os = "redox",
target_family = "wasm",
target_os = "windows"
))
))]
fn main() {
example::run();
}

#[cfg(not(all(feature = "x11", any(target_os = "linux", target_os = "freebsd"))))]
#[cfg(not(all(
feature = "x11",
not(any(
target_os = "android",
target_vendor = "apple",
target_os = "redox",
target_family = "wasm",
target_os = "windows"
))
)))]
fn main() {
eprintln!("This example requires the `x11` feature to be enabled on a supported platform.");
}
41 changes: 33 additions & 8 deletions src/backend_dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use crate::{backend_interface::*, backends, InitError, Rect, SoftBufferError};

use raw_window_handle::{HasDisplayHandle, HasWindowHandle};
use std::num::NonZeroU32;
#[cfg(any(wayland_platform, x11_platform, kms_platform))]
use std::sync::Arc;

/// A macro for creating the enum used to statically dispatch to the platform-specific implementation.
macro_rules! make_dispatch {
Expand Down Expand Up @@ -201,12 +199,39 @@ make_dispatch! {
<D, W> =>
#[cfg(target_os = "android")]
Android(D, backends::android::AndroidImpl<D, W>, backends::android::BufferImpl<'a, D, W>),
#[cfg(x11_platform)]
X11(Arc<backends::x11::X11DisplayImpl<D>>, backends::x11::X11Impl<D, W>, backends::x11::BufferImpl<'a, D, W>),
#[cfg(wayland_platform)]
Wayland(Arc<backends::wayland::WaylandDisplayImpl<D>>, backends::wayland::WaylandImpl<D, W>, backends::wayland::BufferImpl<'a, D, W>),
#[cfg(kms_platform)]
Kms(Arc<backends::kms::KmsDisplayImpl<D>>, backends::kms::KmsImpl<D, W>, backends::kms::BufferImpl<'a, D, W>),
#[cfg(all(
feature = "x11",
not(any(
target_os = "android",
target_vendor = "apple",
target_os = "redox",
target_family = "wasm",
target_os = "windows"
))
))]
X11(std::sync::Arc<backends::x11::X11DisplayImpl<D>>, backends::x11::X11Impl<D, W>, backends::x11::BufferImpl<'a, D, W>),
#[cfg(all(
feature = "wayland",
not(any(
target_os = "android",
target_vendor = "apple",
target_os = "redox",
target_family = "wasm",
target_os = "windows"
))
))]
Wayland(std::sync::Arc<backends::wayland::WaylandDisplayImpl<D>>, backends::wayland::WaylandImpl<D, W>, backends::wayland::BufferImpl<'a, D, W>),
#[cfg(all(
feature = "kms",
not(any(
target_os = "android",
target_vendor = "apple",
target_os = "redox",
target_family = "wasm",
target_os = "windows"
))
))]
Kms(std::sync::Arc<backends::kms::KmsDisplayImpl<D>>, backends::kms::KmsImpl<D, W>, backends::kms::BufferImpl<'a, D, W>),
#[cfg(target_os = "windows")]
Win32(D, backends::win32::Win32Impl<D, W>, backends::win32::BufferImpl<'a, D, W>),
#[cfg(target_vendor = "apple")]
Expand Down
33 changes: 30 additions & 3 deletions src/backends/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,44 @@ use raw_window_handle::HasDisplayHandle;
pub(crate) mod android;
#[cfg(target_vendor = "apple")]
pub(crate) mod cg;
#[cfg(kms_platform)]
#[cfg(all(
feature = "kms",
not(any(
target_os = "android",
target_vendor = "apple",
target_os = "redox",
target_family = "wasm",
target_os = "windows"
))
))]
pub(crate) mod kms;
#[cfg(target_os = "redox")]
pub(crate) mod orbital;
#[cfg(wayland_platform)]
#[cfg(all(
feature = "wayland",
not(any(
target_os = "android",
target_vendor = "apple",
target_os = "redox",
target_family = "wasm",
target_os = "windows"
))
))]
pub(crate) mod wayland;
#[cfg(target_arch = "wasm32")]
pub(crate) mod web;
#[cfg(target_os = "windows")]
pub(crate) mod win32;
#[cfg(x11_platform)]
#[cfg(all(
feature = "x11",
not(any(
target_os = "android",
target_vendor = "apple",
target_os = "redox",
target_family = "wasm",
target_os = "windows"
))
))]
pub(crate) mod x11;

impl<D: HasDisplayHandle> ContextInterface<D> for D {
Expand Down