Rename SoftBufferError to SwBufError
This commit is contained in:
parent
33fe3ae3c7
commit
95e8d05902
8 changed files with 25 additions and 25 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{GraphicsContextImpl, SoftBufferError};
|
||||
use crate::{GraphicsContextImpl, SwBufError};
|
||||
use raw_window_handle::{HasRawWindowHandle, AppKitWindowHandle};
|
||||
use core_graphics::base::{kCGBitmapByteOrder32Little, kCGImageAlphaNoneSkipFirst, kCGRenderingIntentDefault};
|
||||
use core_graphics::color_space::CGColorSpace;
|
||||
|
|
@ -17,7 +17,7 @@ pub struct CGImpl {
|
|||
}
|
||||
|
||||
impl CGImpl {
|
||||
pub unsafe fn new<W: HasRawWindowHandle>(handle: AppKitWindowHandle) -> Result<Self, SoftBufferError<W>> {
|
||||
pub unsafe fn new<W: HasRawWindowHandle>(handle: AppKitWindowHandle) -> Result<Self, SwBufError<W>> {
|
||||
let view = handle.ns_view as id;
|
||||
let layer = CALayer::new();
|
||||
let subview: id = NSView::alloc(nil).initWithFrame_(view.frame());
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use raw_window_handle::{HasRawWindowHandle, RawDisplayHandle, RawWindowHandle};
|
|||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum SoftBufferError<W: HasRawWindowHandle> {
|
||||
pub enum SwBufError<W: HasRawWindowHandle> {
|
||||
#[error(
|
||||
"The provided window returned an unsupported platform: {human_readable_window_platform_name}, {human_readable_display_platform_name}."
|
||||
)]
|
||||
|
|
@ -19,9 +19,9 @@ pub enum SoftBufferError<W: HasRawWindowHandle> {
|
|||
}
|
||||
|
||||
#[allow(unused)] // This isn't used on all platforms
|
||||
pub(crate) fn unwrap<T, E: std::error::Error + 'static, W: HasRawWindowHandle>(res: Result<T, E>, str: &str) -> Result<T, SoftBufferError<W>>{
|
||||
pub(crate) fn unwrap<T, E: std::error::Error + 'static, W: HasRawWindowHandle>(res: Result<T, E>, str: &str) -> Result<T, SwBufError<W>>{
|
||||
match res{
|
||||
Ok(t) => Ok(t),
|
||||
Err(e) => Err(SoftBufferError::PlatformError(Some(str.into()), Some(Box::new(e))))
|
||||
Err(e) => Err(SwBufError::PlatformError(Some(str.into()), Some(Box::new(e))))
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ mod orbital;
|
|||
|
||||
mod error;
|
||||
|
||||
pub use error::SoftBufferError;
|
||||
pub use error::SwBufError;
|
||||
|
||||
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle, RawWindowHandle};
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ impl<W: HasRawWindowHandle + HasRawDisplayHandle> GraphicsContext<W> {
|
|||
/// # Safety
|
||||
///
|
||||
/// - Ensure that the passed object is valid to draw a 2D buffer to
|
||||
pub unsafe fn new(window: W) -> Result<Self, SoftBufferError<W>> {
|
||||
pub unsafe fn new(window: W) -> Result<Self, SwBufError<W>> {
|
||||
let raw_window_handle = window.raw_window_handle();
|
||||
let raw_display_handle = window.raw_display_handle();
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ impl<W: HasRawWindowHandle + HasRawDisplayHandle> GraphicsContext<W> {
|
|||
(RawWindowHandle::Web(web_handle), _) => Box::new(web::WebImpl::new(web_handle)?),
|
||||
#[cfg(target_os = "redox")]
|
||||
(RawWindowHandle::Orbital(orbital_handle), _) => Box::new(orbital::OrbitalImpl::new(orbital_handle)?),
|
||||
(unimplemented_window_handle, unimplemented_display_handle) => return Err(SoftBufferError::UnsupportedPlatform {
|
||||
(unimplemented_window_handle, unimplemented_display_handle) => return Err(SwBufError::UnsupportedPlatform {
|
||||
window,
|
||||
human_readable_window_platform_name: window_handle_type_name(&unimplemented_window_handle),
|
||||
human_readable_display_platform_name: display_handle_type_name(&unimplemented_display_handle),
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use std::{
|
|||
};
|
||||
|
||||
use crate::GraphicsContextImpl;
|
||||
use crate::SoftBufferError;
|
||||
use crate::SwBufError;
|
||||
|
||||
struct OrbitalMap {
|
||||
address: usize,
|
||||
|
|
@ -47,7 +47,7 @@ pub struct OrbitalImpl {
|
|||
}
|
||||
|
||||
impl OrbitalImpl {
|
||||
pub fn new<W: HasRawWindowHandle>(handle: OrbitalWindowHandle) -> Result<Self, SoftBufferError<W>> {
|
||||
pub fn new<W: HasRawWindowHandle>(handle: OrbitalWindowHandle) -> Result<Self, SwBufError<W>> {
|
||||
Ok(Self { handle })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{error::unwrap, GraphicsContextImpl, SoftBufferError};
|
||||
use crate::{error::unwrap, GraphicsContextImpl, SwBufError};
|
||||
use nix::sys::memfd::{memfd_create, MemFdCreateFlag};
|
||||
use raw_window_handle::{HasRawWindowHandle, WaylandDisplayHandle, WaylandWindowHandle};
|
||||
use std::{
|
||||
|
|
@ -43,7 +43,7 @@ impl WaylandImpl {
|
|||
pub unsafe fn new<W: HasRawWindowHandle>(
|
||||
window_handle: WaylandWindowHandle,
|
||||
display_handle: WaylandDisplayHandle,
|
||||
) -> Result<Self, SoftBufferError<W>> {
|
||||
) -> Result<Self, SwBufError<W>> {
|
||||
let conn = Connection::from_backend(Backend::from_foreign_display(
|
||||
display_handle.display as *mut _,
|
||||
));
|
||||
|
|
|
|||
14
src/web.rs
14
src/web.rs
|
|
@ -7,7 +7,7 @@ use web_sys::HtmlCanvasElement;
|
|||
use web_sys::ImageData;
|
||||
|
||||
use crate::GraphicsContextImpl;
|
||||
use crate::SoftBufferError;
|
||||
use crate::SwBufError;
|
||||
|
||||
pub struct WebImpl {
|
||||
canvas: HtmlCanvasElement,
|
||||
|
|
@ -15,17 +15,17 @@ pub struct WebImpl {
|
|||
}
|
||||
|
||||
impl WebImpl {
|
||||
pub fn new<W: HasRawWindowHandle>(handle: WebWindowHandle) -> Result<Self, SoftBufferError<W>> {
|
||||
pub fn new<W: HasRawWindowHandle>(handle: WebWindowHandle) -> Result<Self, SwBufError<W>> {
|
||||
let canvas: HtmlCanvasElement = web_sys::window()
|
||||
.ok_or_else(|| {
|
||||
SoftBufferError::PlatformError(
|
||||
SwBufError::PlatformError(
|
||||
Some("`window` is not present in this runtime".into()),
|
||||
None,
|
||||
)
|
||||
})?
|
||||
.document()
|
||||
.ok_or_else(|| {
|
||||
SoftBufferError::PlatformError(
|
||||
SwBufError::PlatformError(
|
||||
Some("`document` is not present in this runtime".into()),
|
||||
None,
|
||||
)
|
||||
|
|
@ -34,7 +34,7 @@ impl WebImpl {
|
|||
// `querySelector` only throws an error if the selector is invalid.
|
||||
.unwrap()
|
||||
.ok_or_else(|| {
|
||||
SoftBufferError::PlatformError(
|
||||
SwBufError::PlatformError(
|
||||
Some("No canvas found with the given id".into()),
|
||||
None,
|
||||
)
|
||||
|
|
@ -45,13 +45,13 @@ impl WebImpl {
|
|||
let ctx = canvas
|
||||
.get_context("2d")
|
||||
.map_err(|_| {
|
||||
SoftBufferError::PlatformError(
|
||||
SwBufError::PlatformError(
|
||||
Some("Canvas already controlled using `OffscreenCanvas`".into()),
|
||||
None,
|
||||
)
|
||||
})?
|
||||
.ok_or_else(|| {
|
||||
SoftBufferError::PlatformError(
|
||||
SwBufError::PlatformError(
|
||||
Some("A canvas context other than `CanvasRenderingContext2d` was already created".into()),
|
||||
None,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{GraphicsContextImpl, SoftBufferError};
|
||||
use crate::{GraphicsContextImpl, SwBufError};
|
||||
use raw_window_handle::{HasRawWindowHandle, Win32WindowHandle};
|
||||
use std::os::raw::c_int;
|
||||
use winapi::shared::windef::{HDC, HWND};
|
||||
|
|
@ -19,11 +19,11 @@ struct BitmapInfo {
|
|||
}
|
||||
|
||||
impl Win32Impl {
|
||||
pub unsafe fn new<W: HasRawWindowHandle>(handle: &Win32WindowHandle) -> Result<Self, crate::SoftBufferError<W>> {
|
||||
pub unsafe fn new<W: HasRawWindowHandle>(handle: &Win32WindowHandle) -> Result<Self, crate::SwBufError<W>> {
|
||||
let dc = GetDC(handle.hwnd as HWND);
|
||||
|
||||
if dc.is_null(){
|
||||
return Err(SoftBufferError::PlatformError(Some("Device Context is null".into()), None));
|
||||
return Err(SwBufError::PlatformError(Some("Device Context is null".into()), None));
|
||||
}
|
||||
|
||||
Ok(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{GraphicsContextImpl, SoftBufferError};
|
||||
use crate::{GraphicsContextImpl, SwBufError};
|
||||
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle, XlibDisplayHandle, XlibWindowHandle};
|
||||
use std::os::raw::{c_char, c_uint};
|
||||
use x11_dl::xlib::{Display, Visual, Xlib, ZPixmap, GC};
|
||||
|
|
@ -13,10 +13,10 @@ pub struct X11Impl {
|
|||
}
|
||||
|
||||
impl X11Impl {
|
||||
pub unsafe fn new<W: HasRawWindowHandle + HasRawDisplayHandle>(window_handle: XlibWindowHandle, display_handle: XlibDisplayHandle) -> Result<Self, SoftBufferError<W>> {
|
||||
pub unsafe fn new<W: HasRawWindowHandle + HasRawDisplayHandle>(window_handle: XlibWindowHandle, display_handle: XlibDisplayHandle) -> Result<Self, SwBufError<W>> {
|
||||
let lib = match Xlib::open() {
|
||||
Ok(lib) => lib,
|
||||
Err(e) => return Err(SoftBufferError::PlatformError(Some("Failed to open Xlib".into()), Some(Box::new(e))))
|
||||
Err(e) => return Err(SwBufError::PlatformError(Some("Failed to open Xlib".into()), Some(Box::new(e))))
|
||||
};
|
||||
let screen = (lib.XDefaultScreen)(display_handle.display as *mut Display);
|
||||
let gc = (lib.XDefaultGC)(display_handle.display as *mut Display, screen);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue