Move compositor module access from window to crate
This commit is contained in:
parent
5be1ac18fe
commit
984d1f375e
8 changed files with 27 additions and 22 deletions
|
|
@ -2,7 +2,7 @@ use crate::{Backend, Color, Error, Renderer, Settings, Viewport};
|
||||||
|
|
||||||
use core::ffi::c_void;
|
use core::ffi::c_void;
|
||||||
use glow::HasContext;
|
use glow::HasContext;
|
||||||
use iced_graphics::{Antialiasing, Size};
|
use iced_graphics::{compositor, Antialiasing, Size};
|
||||||
|
|
||||||
/// A window graphics backend for iced powered by `glow`.
|
/// A window graphics backend for iced powered by `glow`.
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
|
|
@ -67,10 +67,10 @@ impl iced_graphics::window::GLCompositor for Compositor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_information(&self) -> iced_graphics::window::Information {
|
fn get_information(&self) -> compositor::Information {
|
||||||
let adapter = unsafe { self.gl.get_parameter_string(glow::RENDERER) };
|
let adapter = unsafe { self.gl.get_parameter_string(glow::RENDERER) };
|
||||||
|
|
||||||
iced_graphics::window::Information {
|
compositor::Information {
|
||||||
backend: format!("{:?}", self.gl.version()),
|
backend: format!("{:?}", self.gl.version()),
|
||||||
adapter,
|
adapter,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ pub use primitive::Primitive;
|
||||||
pub use renderer::Renderer;
|
pub use renderer::Renderer;
|
||||||
pub use transformation::Transformation;
|
pub use transformation::Transformation;
|
||||||
pub use viewport::Viewport;
|
pub use viewport::Viewport;
|
||||||
|
pub use window::compositor;
|
||||||
|
|
||||||
pub use iced_native::alignment;
|
pub use iced_native::alignment;
|
||||||
pub use iced_native::{
|
pub use iced_native::{
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
//! Draw graphics to window surfaces.
|
//! Draw graphics to window surfaces.
|
||||||
mod compositor;
|
pub mod compositor;
|
||||||
|
|
||||||
#[cfg(feature = "opengl")]
|
#[cfg(feature = "opengl")]
|
||||||
mod gl_compositor;
|
pub mod gl_compositor;
|
||||||
|
|
||||||
pub use compositor::{Compositor, Information, SurfaceError};
|
pub use compositor::Compositor;
|
||||||
|
|
||||||
#[cfg(feature = "opengl")]
|
#[cfg(feature = "opengl")]
|
||||||
pub use gl_compositor::GLCompositor;
|
pub use gl_compositor::GLCompositor;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! A compositor is responsible for initializing a renderer and managing window
|
||||||
|
//! surfaces.
|
||||||
use crate::{Color, Error, Viewport};
|
use crate::{Color, Error, Viewport};
|
||||||
|
|
||||||
use raw_window_handle::HasRawWindowHandle;
|
use raw_window_handle::HasRawWindowHandle;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
use crate::window::Information;
|
//! A compositor is responsible for initializing a renderer and managing window
|
||||||
|
//! surfaces.
|
||||||
|
use crate::compositor::Information;
|
||||||
use crate::{Color, Error, Size, Viewport};
|
use crate::{Color, Error, Size, Viewport};
|
||||||
|
|
||||||
use core::ffi::c_void;
|
use core::ffi::c_void;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::{Backend, Color, Error, Renderer, Settings, Viewport};
|
use crate::{Backend, Color, Error, Renderer, Settings, Viewport};
|
||||||
|
|
||||||
use futures::task::SpawnExt;
|
use futures::task::SpawnExt;
|
||||||
|
use iced_graphics::compositor;
|
||||||
use iced_native::futures;
|
use iced_native::futures;
|
||||||
use raw_window_handle::HasRawWindowHandle;
|
use raw_window_handle::HasRawWindowHandle;
|
||||||
|
|
||||||
|
|
@ -157,10 +158,10 @@ impl iced_graphics::window::Compositor for Compositor {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_information(&self) -> iced_graphics::window::Information {
|
fn get_information(&self) -> compositor::Information {
|
||||||
let information = self.adapter.get_info();
|
let information = self.adapter.get_info();
|
||||||
|
|
||||||
iced_graphics::window::Information {
|
compositor::Information {
|
||||||
adapter: information.name,
|
adapter: information.name,
|
||||||
backend: format!("{:?}", information.backend),
|
backend: format!("{:?}", information.backend),
|
||||||
}
|
}
|
||||||
|
|
@ -173,7 +174,7 @@ impl iced_graphics::window::Compositor for Compositor {
|
||||||
viewport: &Viewport,
|
viewport: &Viewport,
|
||||||
background_color: Color,
|
background_color: Color,
|
||||||
overlay: &[T],
|
overlay: &[T],
|
||||||
) -> Result<(), iced_graphics::window::SurfaceError> {
|
) -> Result<(), compositor::SurfaceError> {
|
||||||
match surface.get_current_texture() {
|
match surface.get_current_texture() {
|
||||||
Ok(frame) => {
|
Ok(frame) => {
|
||||||
let mut encoder = self.device.create_command_encoder(
|
let mut encoder = self.device.create_command_encoder(
|
||||||
|
|
@ -241,16 +242,14 @@ impl iced_graphics::window::Compositor for Compositor {
|
||||||
}
|
}
|
||||||
Err(error) => match error {
|
Err(error) => match error {
|
||||||
wgpu::SurfaceError::Timeout => {
|
wgpu::SurfaceError::Timeout => {
|
||||||
Err(iced_graphics::window::SurfaceError::Timeout)
|
Err(compositor::SurfaceError::Timeout)
|
||||||
}
|
}
|
||||||
wgpu::SurfaceError::Outdated => {
|
wgpu::SurfaceError::Outdated => {
|
||||||
Err(iced_graphics::window::SurfaceError::Outdated)
|
Err(compositor::SurfaceError::Outdated)
|
||||||
}
|
|
||||||
wgpu::SurfaceError::Lost => {
|
|
||||||
Err(iced_graphics::window::SurfaceError::Lost)
|
|
||||||
}
|
}
|
||||||
|
wgpu::SurfaceError::Lost => Err(compositor::SurfaceError::Lost),
|
||||||
wgpu::SurfaceError::OutOfMemory => {
|
wgpu::SurfaceError::OutOfMemory => {
|
||||||
Err(iced_graphics::window::SurfaceError::OutOfMemory)
|
Err(compositor::SurfaceError::OutOfMemory)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ use crate::{
|
||||||
|
|
||||||
use iced_futures::futures;
|
use iced_futures::futures;
|
||||||
use iced_futures::futures::channel::mpsc;
|
use iced_futures::futures::channel::mpsc;
|
||||||
|
use iced_graphics::compositor;
|
||||||
use iced_graphics::window;
|
use iced_graphics::window;
|
||||||
use iced_native::program::Program;
|
use iced_native::program::Program;
|
||||||
use iced_native::user_interface::{self, UserInterface};
|
use iced_native::user_interface::{self, UserInterface};
|
||||||
|
|
@ -426,7 +427,7 @@ async fn run_instance<A, E, C>(
|
||||||
}
|
}
|
||||||
Err(error) => match error {
|
Err(error) => match error {
|
||||||
// This is an unrecoverable error.
|
// This is an unrecoverable error.
|
||||||
window::SurfaceError::OutOfMemory => {
|
compositor::SurfaceError::OutOfMemory => {
|
||||||
panic!("{:?}", error);
|
panic!("{:?}", error);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
@ -520,7 +521,7 @@ pub fn update<A: Application, E: Executor>(
|
||||||
debug: &mut Debug,
|
debug: &mut Debug,
|
||||||
messages: &mut Vec<A::Message>,
|
messages: &mut Vec<A::Message>,
|
||||||
window: &winit::window::Window,
|
window: &winit::window::Window,
|
||||||
graphics_info: &window::Information,
|
graphics_info: &compositor::Information,
|
||||||
) {
|
) {
|
||||||
for message in messages.drain(..) {
|
for message in messages.drain(..) {
|
||||||
debug.log_message(&message);
|
debug.log_message(&message);
|
||||||
|
|
@ -543,7 +544,7 @@ pub fn run_command<Message: 'static + std::fmt::Debug + Send, E: Executor>(
|
||||||
clipboard: &mut Clipboard,
|
clipboard: &mut Clipboard,
|
||||||
proxy: &mut winit::event_loop::EventLoopProxy<Message>,
|
proxy: &mut winit::event_loop::EventLoopProxy<Message>,
|
||||||
window: &winit::window::Window,
|
window: &winit::window::Window,
|
||||||
graphics_info: &window::Information,
|
graphics_info: &compositor::Information,
|
||||||
) {
|
) {
|
||||||
use iced_native::command;
|
use iced_native::command;
|
||||||
use iced_native::system;
|
use iced_native::system;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
use crate::command::{self, Command};
|
use crate::command::{self, Command};
|
||||||
pub use iced_native::system::*;
|
pub use iced_native::system::*;
|
||||||
|
|
||||||
use iced_graphics::window;
|
use iced_graphics::compositor;
|
||||||
|
|
||||||
/// Query for available system information.
|
/// Query for available system information.
|
||||||
///
|
///
|
||||||
|
|
@ -17,7 +17,7 @@ pub fn information<Message>(
|
||||||
|
|
||||||
#[cfg(feature = "sysinfo")]
|
#[cfg(feature = "sysinfo")]
|
||||||
pub(crate) fn get_information(
|
pub(crate) fn get_information(
|
||||||
graphics_info: &window::Information,
|
graphics_info: &compositor::Information,
|
||||||
) -> Option<Information> {
|
) -> Option<Information> {
|
||||||
use sysinfo::{ProcessExt, ProcessorExt, System, SystemExt};
|
use sysinfo::{ProcessExt, ProcessorExt, System, SystemExt};
|
||||||
let mut system = System::new_all();
|
let mut system = System::new_all();
|
||||||
|
|
@ -47,7 +47,7 @@ pub(crate) fn get_information(
|
||||||
|
|
||||||
#[cfg(not(feature = "sysinfo"))]
|
#[cfg(not(feature = "sysinfo"))]
|
||||||
pub(crate) fn get_information(
|
pub(crate) fn get_information(
|
||||||
_graphics_info: &window::Information,
|
_graphics_info: &compositor::Information,
|
||||||
) -> Option<Information> {
|
) -> Option<Information> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue