Merge branch 'feature/custom-runtime'

This commit is contained in:
Héctor Ramón Jiménez 2020-01-21 00:56:49 +01:00
commit 8957883a88
13 changed files with 43 additions and 25 deletions

View File

@ -12,10 +12,12 @@ keywords = ["gui", "ui", "graphics", "interface", "widgets"]
categories = ["gui"] categories = ["gui"]
[features] [features]
# Enables the Image widget
image = ["iced_wgpu/image"]
# Enables the Svg widget
svg = ["iced_wgpu/svg"]
# Enables a debug view in native platforms (press F12) # Enables a debug view in native platforms (press F12)
debug = ["iced_winit/debug"] debug = ["iced_winit/debug"]
# Enables support for SVG rendering
svg = ["iced_wgpu/svg"]
[badges] [badges]
maintenance = { status = "actively-developed" } maintenance = { status = "actively-developed" }

View File

@ -12,8 +12,8 @@
#![deny(missing_docs)] #![deny(missing_docs)]
#![deny(missing_debug_implementations)] #![deny(missing_debug_implementations)]
#![deny(unused_results)] #![deny(unused_results)]
#![deny(unsafe_code)] #![forbid(unsafe_code)]
#![deny(rust_2018_idioms)] #![forbid(rust_2018_idioms)]
mod align; mod align;
mod background; mod background;

View File

@ -6,7 +6,7 @@ edition = "2018"
publish = false publish = false
[dependencies] [dependencies]
iced = { path = "../.." } iced = { path = "../..", features = ["image"] }
iced_futures = { path = "../../futures", features = ["async-std"] } iced_futures = { path = "../../futures", features = ["async-std"] }
surf = "1.0" surf = "1.0"
rand = "0.7" rand = "0.7"

View File

@ -6,7 +6,7 @@ edition = "2018"
publish = false publish = false
[dependencies] [dependencies]
iced = { path = "../..", features = ["debug"] } iced = { path = "../..", features = ["image", "debug"] }
env_logger = "0.7" env_logger = "0.7"
[target.'cfg(target_arch = "wasm32")'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies]

View File

@ -2,8 +2,8 @@
#![deny(missing_docs)] #![deny(missing_docs)]
#![deny(missing_debug_implementations)] #![deny(missing_debug_implementations)]
#![deny(unused_results)] #![deny(unused_results)]
#![deny(unsafe_code)] #![forbid(unsafe_code)]
#![deny(rust_2018_idioms)] #![forbid(rust_2018_idioms)]
pub use futures; pub use futures;
mod command; mod command;

View File

@ -37,8 +37,8 @@
#![deny(missing_docs)] #![deny(missing_docs)]
#![deny(missing_debug_implementations)] #![deny(missing_debug_implementations)]
#![deny(unused_results)] #![deny(unused_results)]
#![deny(unsafe_code)] #![forbid(unsafe_code)]
#![deny(rust_2018_idioms)] #![forbid(rust_2018_idioms)]
pub mod input; pub mod input;
pub mod layout; pub mod layout;
pub mod renderer; pub mod renderer;

View File

@ -177,8 +177,8 @@
#![deny(missing_docs)] #![deny(missing_docs)]
#![deny(missing_debug_implementations)] #![deny(missing_debug_implementations)]
#![deny(unused_results)] #![deny(unused_results)]
#![deny(unsafe_code)] #![forbid(unsafe_code)]
#![deny(rust_2018_idioms)] #![forbid(rust_2018_idioms)]
mod application; mod application;
mod element; mod element;
mod sandbox; mod sandbox;

View File

@ -54,8 +54,8 @@
#![deny(missing_docs)] #![deny(missing_docs)]
#![deny(missing_debug_implementations)] #![deny(missing_debug_implementations)]
#![deny(unused_results)] #![deny(unused_results)]
#![deny(unsafe_code)] #![forbid(unsafe_code)]
#![deny(rust_2018_idioms)] #![forbid(rust_2018_idioms)]
use dodrio::bumpalo; use dodrio::bumpalo;
use std::{cell::RefCell, rc::Rc}; use std::{cell::RefCell, rc::Rc};

View File

@ -17,8 +17,8 @@ wgpu = "0.4"
glyph_brush = "0.6" glyph_brush = "0.6"
wgpu_glyph = { version = "0.7", git = "https://github.com/hecrj/wgpu_glyph", branch = "fix/font-load-panic" } wgpu_glyph = { version = "0.7", git = "https://github.com/hecrj/wgpu_glyph", branch = "fix/font-load-panic" }
raw-window-handle = "0.3" raw-window-handle = "0.3"
image = "0.22"
glam = "0.8" glam = "0.8"
font-kit = "0.4" font-kit = "0.4"
log = "0.4" log = "0.4"
resvg = { version = "0.8", features = ["raqote-backend"], optional = true } resvg = { version = "0.8", features = ["raqote-backend"], optional = true }
image = { version = "0.22", optional = true }

View File

@ -1,3 +1,4 @@
#[cfg(feature = "image")]
mod raster; mod raster;
#[cfg(feature = "svg")] #[cfg(feature = "svg")]
mod vector; mod vector;
@ -5,10 +6,14 @@ mod vector;
use crate::Transformation; use crate::Transformation;
use iced_native::{image, svg, Rectangle}; use iced_native::{image, svg, Rectangle};
use std::{cell::RefCell, mem}; use std::mem;
#[cfg(any(feature = "image", feature = "svg"))]
use std::cell::RefCell;
#[derive(Debug)] #[derive(Debug)]
pub struct Pipeline { pub struct Pipeline {
#[cfg(feature = "image")]
raster_cache: RefCell<raster::Cache>, raster_cache: RefCell<raster::Cache>,
#[cfg(feature = "svg")] #[cfg(feature = "svg")]
vector_cache: RefCell<vector::Cache>, vector_cache: RefCell<vector::Cache>,
@ -191,6 +196,7 @@ impl Pipeline {
}); });
Pipeline { Pipeline {
#[cfg(feature = "image")]
raster_cache: RefCell::new(raster::Cache::new()), raster_cache: RefCell::new(raster::Cache::new()),
#[cfg(feature = "svg")] #[cfg(feature = "svg")]
vector_cache: RefCell::new(vector::Cache::new()), vector_cache: RefCell::new(vector::Cache::new()),
@ -205,6 +211,7 @@ impl Pipeline {
} }
} }
#[cfg(feature = "image")]
pub fn dimensions(&self, handle: &image::Handle) -> (u32, u32) { pub fn dimensions(&self, handle: &image::Handle) -> (u32, u32) {
let mut cache = self.raster_cache.borrow_mut(); let mut cache = self.raster_cache.borrow_mut();
let memory = cache.load(&handle); let memory = cache.load(&handle);
@ -250,12 +257,18 @@ impl Pipeline {
// [1]: https://github.com/nical/guillotiere // [1]: https://github.com/nical/guillotiere
for image in instances { for image in instances {
let uploaded_texture = match &image.handle { let uploaded_texture = match &image.handle {
Handle::Raster(handle) => { Handle::Raster(_handle) => {
#[cfg(feature = "image")]
{
let mut cache = self.raster_cache.borrow_mut(); let mut cache = self.raster_cache.borrow_mut();
let memory = cache.load(&handle); let memory = cache.load(&_handle);
memory.upload(device, encoder, &self.texture_layout) memory.upload(device, encoder, &self.texture_layout)
} }
#[cfg(not(feature = "image"))]
None
}
Handle::Vector(_handle) => { Handle::Vector(_handle) => {
#[cfg(feature = "svg")] #[cfg(feature = "svg")]
{ {
@ -339,6 +352,7 @@ impl Pipeline {
} }
pub fn trim_cache(&mut self) { pub fn trim_cache(&mut self) {
#[cfg(feature = "image")]
self.raster_cache.borrow_mut().trim(); self.raster_cache.borrow_mut().trim();
#[cfg(feature = "svg")] #[cfg(feature = "svg")]

View File

@ -22,8 +22,8 @@
#![deny(missing_docs)] #![deny(missing_docs)]
#![deny(missing_debug_implementations)] #![deny(missing_debug_implementations)]
#![deny(unused_results)] #![deny(unused_results)]
#![deny(unsafe_code)] #![forbid(unsafe_code)]
#![deny(rust_2018_idioms)] #![forbid(rust_2018_idioms)]
pub mod defaults; pub mod defaults;
pub mod triangle; pub mod triangle;
pub mod widget; pub mod widget;

View File

@ -2,7 +2,6 @@ mod button;
mod checkbox; mod checkbox;
mod column; mod column;
mod container; mod container;
mod image;
mod progress_bar; mod progress_bar;
mod radio; mod radio;
mod row; mod row;
@ -14,3 +13,6 @@ mod text_input;
#[cfg(feature = "svg")] #[cfg(feature = "svg")]
mod svg; mod svg;
#[cfg(feature = "image")]
mod image;

View File

@ -18,8 +18,8 @@
#![deny(missing_docs)] #![deny(missing_docs)]
#![deny(missing_debug_implementations)] #![deny(missing_debug_implementations)]
#![deny(unused_results)] #![deny(unused_results)]
#![deny(unsafe_code)] #![forbid(unsafe_code)]
#![deny(rust_2018_idioms)] #![forbid(rust_2018_idioms)]
#[doc(no_inline)] #[doc(no_inline)]
pub use iced_native::*; pub use iced_native::*;