Skip to content

Commit

Permalink
Merge pull request #38 from hecrj/feature/performance-metrics
Browse files Browse the repository at this point in the history
Debug view
  • Loading branch information
hecrj authored Nov 5, 2019
2 parents da2717c + 0157121 commit ae6156f
Show file tree
Hide file tree
Showing 29 changed files with 550 additions and 296 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
rust: [stable, beta]
include:
- os: ubuntu-latest
rust: stable
targets: 'wasm32-unknown-unknown'
steps:
- uses: hecrj/setup-rust-action@v1
with:
Expand All @@ -23,4 +19,6 @@ jobs:
sudo apt-get install -y libasound2-dev libudev-dev
- uses: actions/checkout@master
- name: Run tests
run: cargo test --verbose --all --all-features
run: |
cargo test --verbose --all
cargo test --verbose --all --all-features
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ readme = "README.md"
keywords = ["gui", "ui", "graphics", "interface", "widgets"]
categories = ["gui"]

[features]
# Enables a debug view in native platforms (press F12)
debug = ["iced_winit/debug"]

[badges]
maintenance = { status = "actively-developed" }

Expand Down
202 changes: 0 additions & 202 deletions examples/resources/Roboto-LICENSE

This file was deleted.

Binary file removed examples/resources/Roboto-Regular.ttf
Binary file not shown.
Binary file removed examples/resources/ui.png
Binary file not shown.
2 changes: 1 addition & 1 deletion native/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mod debugger;
mod windowed;

pub use debugger::Debugger;
pub use windowed::Windowed;
pub use windowed::{Target, Windowed};

pub trait Renderer {
type Output;
Expand Down
24 changes: 18 additions & 6 deletions native/src/renderer/windowed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,28 @@ use crate::MouseCursor;

use raw_window_handle::HasRawWindowHandle;

pub trait Windowed: super::Renderer {
type Target;
pub trait Windowed: super::Renderer + Sized {
type Target: Target<Renderer = Self>;

fn new<W: HasRawWindowHandle>(window: &W) -> Self;
fn new() -> Self;

fn target(&self, width: u16, height: u16) -> Self::Target;

fn draw(
fn draw<T: AsRef<str>>(
&mut self,
output: &Self::Output,
overlay: &[T],
target: &mut Self::Target,
) -> MouseCursor;
}

pub trait Target {
type Renderer;

fn new<W: HasRawWindowHandle>(
window: &W,
width: u16,
height: u16,
renderer: &Self::Renderer,
) -> Self;

fn resize(&mut self, width: u16, height: u16, renderer: &Self::Renderer);
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod platform;
pub use platform::*;

pub trait Application {
type Message;
type Message: std::fmt::Debug;

fn update(&mut self, message: Self::Message);

Expand Down
1 change: 1 addition & 0 deletions wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ wgpu_glyph = { version = "0.4", git = "https://github.com/hecrj/wgpu_glyph", rev
raw-window-handle = "0.3"
image = "0.22"
glam = "0.8"
font-kit = "0.4"
log = "0.4"
36 changes: 36 additions & 0 deletions wgpu/src/font.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
pub use font_kit::error::SelectionError as LoadError;
pub use font_kit::family_name::FamilyName as Family;

pub struct Source {
raw: font_kit::source::SystemSource,
}

impl Source {
pub fn new() -> Self {
Source {
raw: font_kit::source::SystemSource::new(),
}
}

pub fn load(&self, families: &[Family]) -> Result<Vec<u8>, LoadError> {
let font = self.raw.select_best_match(
families,
&font_kit::properties::Properties::default(),
)?;

match font {
font_kit::handle::Handle::Path { path, .. } => {
use std::io::Read;

let mut buf = Vec::new();
let mut reader = std::fs::File::open(path).expect("Read font");
let _ = reader.read_to_end(&mut buf);

Ok(buf)
}
font_kit::handle::Handle::Memory { bytes, .. } => {
Ok(bytes.as_ref().clone())
}
}
}
}
1 change: 1 addition & 0 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod font;
mod image;
mod primitive;
mod quad;
Expand Down
Loading

0 comments on commit ae6156f

Please sign in to comment.