Write documentation for new iced_wgpu types

This commit is contained in:
Héctor Ramón Jiménez 2020-02-09 03:44:16 +01:00
parent 8f0b59a4b2
commit 9a73c3a88d
5 changed files with 16 additions and 1 deletions

View File

@ -19,7 +19,7 @@
//! [`wgpu`]: https://github.com/gfx-rs/wgpu-rs //! [`wgpu`]: https://github.com/gfx-rs/wgpu-rs
//! [WebGPU API]: https://gpuweb.github.io/gpuweb/ //! [WebGPU API]: https://gpuweb.github.io/gpuweb/
//! [`wgpu_glyph`]: https://github.com/hecrj/wgpu_glyph //! [`wgpu_glyph`]: https://github.com/hecrj/wgpu_glyph
//#![deny(missing_docs)] #![deny(missing_docs)]
#![deny(missing_debug_implementations)] #![deny(missing_debug_implementations)]
#![deny(unused_results)] #![deny(unused_results)]
#![forbid(unsafe_code)] #![forbid(unsafe_code)]

View File

@ -3,6 +3,12 @@ use crate::Viewport;
/// A rendering target. /// A rendering target.
#[derive(Debug)] #[derive(Debug)]
pub struct Target<'a> { pub struct Target<'a> {
/// The texture where graphics will be rendered.
pub texture: &'a wgpu::TextureView, pub texture: &'a wgpu::TextureView,
/// The viewport of the target.
///
/// Most of the time, you will want this to match the dimensions of the
/// texture.
pub viewport: &'a Viewport, pub viewport: &'a Viewport,
} }

View File

@ -1,3 +1,4 @@
//! Display rendering results on windows.
mod backend; mod backend;
mod swap_chain; mod swap_chain;

View File

@ -3,6 +3,7 @@ use crate::{window::SwapChain, Renderer, Settings, Target};
use iced_native::MouseCursor; use iced_native::MouseCursor;
use raw_window_handle::HasRawWindowHandle; use raw_window_handle::HasRawWindowHandle;
/// A window graphics backend for iced powered by `wgpu`.
#[derive(Debug)] #[derive(Debug)]
pub struct Backend { pub struct Backend {
device: wgpu::Device, device: wgpu::Device,

View File

@ -12,6 +12,9 @@ pub struct SwapChain {
impl SwapChain {} impl SwapChain {}
impl SwapChain { impl SwapChain {
/// Creates a new [`SwapChain`] for the given surface.
///
/// [`SwapChain`]: struct.SwapChain.html
pub fn new( pub fn new(
device: &wgpu::Device, device: &wgpu::Device,
surface: &wgpu::Surface, surface: &wgpu::Surface,
@ -24,6 +27,10 @@ impl SwapChain {
} }
} }
/// Returns the next frame of the [`SwapChain`] alongside its [`Viewport`].
///
/// [`SwapChain`]: struct.SwapChain.html
/// [`Viewport`]: ../struct.Viewport.html
pub fn next_frame(&mut self) -> (wgpu::SwapChainOutput<'_>, &Viewport) { pub fn next_frame(&mut self) -> (wgpu::SwapChainOutput<'_>, &Viewport) {
(self.raw.get_next_texture(), &self.viewport) (self.raw.get_next_texture(), &self.viewport)
} }